Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8b0295d

Browse files
author
Artur Zakirov
committed
Improve speed
1 parentfd321b6 commit8b0295d

File tree

1 file changed

+30
-38
lines changed

1 file changed

+30
-38
lines changed

‎rum_ts_utils.c

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ typedef struct
4949
{
5050
QueryItem**item;
5151
int16nitem;
52+
int32keyn;
5253
uint8wclass;
5354
int32pos;
5455
}DocRepresentation;
@@ -608,9 +609,10 @@ checkcondition_QueryOperand(void *checkval, QueryOperand *val,
608609

609610
staticbool
610611
Cover(DocRepresentation*doc,uint32len,QueryRepresentation*qr,
611-
Extention*ext)
612+
int*map_item_operand,Extention*ext)
612613
{
613614
DocRepresentation*ptr;
615+
QueryItem*item=GETQUERY(qr->query);
614616
intlastpos=ext->pos;
615617
inti;
616618
boolfound= false;
@@ -630,11 +632,17 @@ Cover(DocRepresentation *doc, uint32 len, QueryRepresentation *qr,
630632
/* find upper bound of cover from current position, move up */
631633
while (ptr-doc<len)
632634
{
633-
for (i=0;i<ptr->nitem;i++)
635+
if (ptr->item!=NULL)
634636
{
635-
if (ptr->item[i]->type==QI_VAL)
637+
for (i=0;i<ptr->nitem;i++)
636638
QR_SET_OPERAND_EXISTS(qr,ptr->item[i]);
637639
}
640+
else
641+
{
642+
for (i=0;i<qr->query->size;i++)
643+
if (ptr->keyn==map_item_operand[i])
644+
QR_SET_OPERAND_EXISTS(qr,item+i);
645+
}
638646
if (TS_execute(GETQUERY(qr->query), (void*)qr, false,
639647
checkcondition_QueryOperand))
640648
{
@@ -660,9 +668,17 @@ Cover(DocRepresentation *doc, uint32 len, QueryRepresentation *qr,
660668
/* find lower bound of cover from found upper bound, move down */
661669
while (ptr >=doc+ext->pos)
662670
{
663-
for (i=0;i<ptr->nitem;i++)
664-
if (ptr->item[i]->type==QI_VAL)
671+
if (ptr->item!=NULL)
672+
{
673+
for (i=0;i<ptr->nitem;i++)
665674
QR_SET_OPERAND_EXISTS(qr,ptr->item[i]);
675+
}
676+
else
677+
{
678+
for (i=0;i<qr->query->size;i++)
679+
if (ptr->keyn==map_item_operand[i])
680+
QR_SET_OPERAND_EXISTS(qr,item+i);
681+
}
666682
if (TS_execute(GETQUERY(qr->query), (void*)qr, true,
667683
checkcondition_QueryOperand))
668684
{
@@ -687,7 +703,7 @@ Cover(DocRepresentation *doc, uint32 len, QueryRepresentation *qr,
687703
}
688704

689705
ext->pos++;
690-
returnCover(doc,len,qr,ext);
706+
returnCover(doc,len,qr,map_item_operand,ext);
691707
}
692708

693709
staticDocRepresentation*
@@ -745,34 +761,8 @@ get_docrep_addinfo(bool *check, QueryRepresentation *qr, int *map_item_operand,
745761
else
746762
ptrt=decompress_pos(ptrt,&post);
747763

748-
if (j==0)
749-
{
750-
intk;
751-
752-
doc[cur].nitem=0;
753-
doc[cur].item= (QueryItem**)palloc(sizeof(QueryItem*)*
754-
qr->query->size);
755-
756-
for (k=0;k<qr->query->size;k++)
757-
{
758-
if (k==i||
759-
(item[k].type==QI_VAL&&map_item_operand[i]==
760-
map_item_operand[k]))
761-
{
762-
/*
763-
* if k == i, we've already checked above that
764-
* it's type == Q_VAL
765-
*/
766-
doc[cur].item[doc[cur].nitem]=item+k;
767-
doc[cur].nitem++;
768-
}
769-
}
770-
}
771-
else
772-
{
773-
doc[cur].nitem=doc[cur-1].nitem;
774-
doc[cur].item=doc[cur-1].item;
775-
}
764+
doc[cur].item=NULL;
765+
doc[cur].keyn=keyN;
776766
doc[cur].pos=WEP_GETPOS(post);
777767
doc[cur].wclass=WEP_GETWEIGHT(post);
778768
cur++;
@@ -932,6 +922,7 @@ get_docrep(TSVector txt, QueryRepresentation *qr, uint32 *doclen)
932922
doc[cur].nitem=doc[cur-1].nitem;
933923
doc[cur].item=doc[cur-1].item;
934924
}
925+
doc[cur].keyn=-1;
935926
doc[cur].pos=WEP_GETPOS(post[j]);
936927
doc[cur].wclass=WEP_GETWEIGHT(post[j]);
937928
cur++;
@@ -955,7 +946,7 @@ get_docrep(TSVector txt, QueryRepresentation *qr, uint32 *doclen)
955946

956947
staticdouble
957948
calc_score_docr(float4*arrdata,DocRepresentation*doc,uint32doclen,
958-
QueryRepresentation*qr,intmethod)
949+
QueryRepresentation*qr,int*map_item_operand,intmethod)
959950
{
960951
int32i;
961952
Extentionext;
@@ -972,7 +963,7 @@ calc_score_docr(float4 *arrdata, DocRepresentation *doc, uint32 doclen,
972963
intncovers=0;
973964

974965
MemSet(&ext,0,sizeof(Extention));
975-
while (Cover(doc,doclen,qr,&ext))
966+
while (Cover(doc,doclen,qr,map_item_operand,&ext))
976967
{
977968
doubleCpos=0.0;
978969
doubleInvSum=0.0;
@@ -1091,7 +1082,8 @@ calc_score_addinfo(float4 *arrdata, bool *check, TSQuery query,
10911082
return0.0;
10921083
}
10931084

1094-
Wdoc=calc_score_docr(arrdata,doc,doclen,&qr,DEF_NORM_METHOD);
1085+
Wdoc=calc_score_docr(arrdata,doc,doclen,&qr,map_item_operand,
1086+
DEF_NORM_METHOD);
10951087

10961088
pfree(doc);
10971089
pfree(qr.operandexist);
@@ -1118,7 +1110,7 @@ calc_score(float4 *arrdata, TSVector txt, TSQuery query, int method)
11181110
return0.0;
11191111
}
11201112

1121-
Wdoc=calc_score_docr(arrdata,doc,doclen,&qr,method);
1113+
Wdoc=calc_score_docr(arrdata,doc,doclen,&qr,NULL,method);
11221114

11231115
if ((method&RANK_NORM_LOGLENGTH)&&txt->size>0)
11241116
Wdoc /=log((double) (count_length(txt)+1));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp