@@ -49,6 +49,7 @@ typedef struct
4949{
5050QueryItem * * item ;
5151int16 nitem ;
52+ int32 keyn ;
5253uint8 wclass ;
5354int32 pos ;
5455}DocRepresentation ;
@@ -608,9 +609,10 @@ checkcondition_QueryOperand(void *checkval, QueryOperand *val,
608609
609610static bool
610611Cover (DocRepresentation * doc ,uint32 len ,QueryRepresentation * qr ,
611- Extention * ext )
612+ int * map_item_operand , Extention * ext )
612613{
613614DocRepresentation * ptr ;
615+ QueryItem * item = GETQUERY (qr -> query );
614616int lastpos = ext -> pos ;
615617int i ;
616618bool found = false;
@@ -630,11 +632,17 @@ Cover(DocRepresentation *doc, uint32 len, QueryRepresentation *qr,
630632/* find upper bound of cover from current position, move up */
631633while (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 ++ )
636638QR_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+ }
638646if (TS_execute (GETQUERY (qr -> query ), (void * )qr , false,
639647checkcondition_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 */
661669while (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 ++ )
665674QR_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+ }
666682if (TS_execute (GETQUERY (qr -> query ), (void * )qr , true,
667683checkcondition_QueryOperand ))
668684{
@@ -687,7 +703,7 @@ Cover(DocRepresentation *doc, uint32 len, QueryRepresentation *qr,
687703}
688704
689705ext -> pos ++ ;
690- return Cover (doc ,len ,qr ,ext );
706+ return Cover (doc ,len ,qr ,map_item_operand , ext );
691707}
692708
693709static DocRepresentation *
@@ -745,34 +761,8 @@ get_docrep_addinfo(bool *check, QueryRepresentation *qr, int *map_item_operand,
745761else
746762ptrt = decompress_pos (ptrt ,& post );
747763
748- if (j == 0 )
749- {
750- int k ;
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 ;
776766doc [cur ].pos = WEP_GETPOS (post );
777767doc [cur ].wclass = WEP_GETWEIGHT (post );
778768cur ++ ;
@@ -932,6 +922,7 @@ get_docrep(TSVector txt, QueryRepresentation *qr, uint32 *doclen)
932922doc [cur ].nitem = doc [cur - 1 ].nitem ;
933923doc [cur ].item = doc [cur - 1 ].item ;
934924}
925+ doc [cur ].keyn = -1 ;
935926doc [cur ].pos = WEP_GETPOS (post [j ]);
936927doc [cur ].wclass = WEP_GETWEIGHT (post [j ]);
937928cur ++ ;
@@ -955,7 +946,7 @@ get_docrep(TSVector txt, QueryRepresentation *qr, uint32 *doclen)
955946
956947static double
957948calc_score_docr (float4 * arrdata ,DocRepresentation * doc ,uint32 doclen ,
958- QueryRepresentation * qr ,int method )
949+ QueryRepresentation * qr ,int * map_item_operand , int method )
959950{
960951int32 i ;
961952Extention ext ;
@@ -972,7 +963,7 @@ calc_score_docr(float4 *arrdata, DocRepresentation *doc, uint32 doclen,
972963int ncovers = 0 ;
973964
974965MemSet (& ext ,0 ,sizeof (Extention ));
975- while (Cover (doc ,doclen ,qr ,& ext ))
966+ while (Cover (doc ,doclen ,qr ,map_item_operand , & ext ))
976967{
977968double Cpos = 0.0 ;
978969double InvSum = 0.0 ;
@@ -1091,7 +1082,8 @@ calc_score_addinfo(float4 *arrdata, bool *check, TSQuery query,
10911082return 0.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
10961088pfree (doc );
10971089pfree (qr .operandexist );
@@ -1118,7 +1110,7 @@ calc_score(float4 *arrdata, TSVector txt, TSQuery query, int method)
11181110return 0.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
11231115if ((method & RANK_NORM_LOGLENGTH )&& txt -> size > 0 )
11241116Wdoc /=log ((double ) (count_length (txt )+ 1 ));