@@ -532,13 +532,11 @@ typedef struct RestoreWordEntry
532
532
* reconstruct partial tsvector from set of index entries
533
533
*/
534
534
static TSVector
535
- rum_reconstruct_tsvector (bool * check , TSQuery query , int32 nkeys ,
536
- int * map_item_operand ,
535
+ rum_reconstruct_tsvector (bool * check , TSQuery query , int * map_item_operand ,
537
536
Datum * addInfo , bool * addInfoIsNull )
538
537
{
539
538
TSVector tsv ;
540
- int cntwords = 0 ,
541
- totalwords = query -> size * 4 ;/* 4 positions per word, estimation */
539
+ int cntwords = 0 ;
542
540
int i = 0 ;
543
541
QueryItem * item = GETQUERY (query );
544
542
char * operandData = GETOPERAND (query );
@@ -550,8 +548,8 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int32 nkeys,
550
548
int stroff ;
551
549
552
550
553
- rwe = palloc (sizeof (* rwe ) * totalwords );
554
- visited = palloc0 (sizeof (* visited ) * nkeys );
551
+ rwe = palloc (sizeof (* rwe ) * query -> size );
552
+ visited = palloc0 (sizeof (* visited ) * query -> size );
555
553
556
554
/*
557
555
* go through query to collect lexemes and add to them
@@ -562,7 +560,7 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int32 nkeys,
562
560
{
563
561
if (item -> type == QI_VAL )
564
562
{
565
- int keyN = map_item_operand [i ];
563
+ int keyN = map_item_operand [i ];
566
564
567
565
if (check [keyN ] == true && visited [keyN ] == false)
568
566
{
@@ -572,12 +570,6 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int32 nkeys,
572
570
*/
573
571
visited [keyN ] = true;
574
572
575
- while (cntwords + 1 >= totalwords )
576
- {
577
- totalwords *= 2 ;
578
- rwe = repalloc (rwe , sizeof (* rwe ) * totalwords );
579
- }
580
-
581
573
rwe [cntwords ].word = operandData + item -> qoperand .distance ;
582
574
rwe [cntwords ].wordlen = item -> qoperand .length ;
583
575
@@ -662,15 +654,15 @@ rum_tsquery_distance(PG_FUNCTION_ARGS)
662
654
663
655
/* StrategyNumber strategy = PG_GETARG_UINT16(1); */
664
656
TSQuery query = PG_GETARG_TSQUERY (2 );
665
- int32 nkeys = PG_GETARG_INT32 (3 );
657
+ /* int32 nkeys = PG_GETARG_INT32(3); */
666
658
Pointer * extra_data = (Pointer * ) PG_GETARG_POINTER (4 );
667
659
Datum * addInfo = (Datum * ) PG_GETARG_POINTER (8 );
668
660
bool * addInfoIsNull = (bool * ) PG_GETARG_POINTER (9 );
669
661
float8 res ;
670
662
int * map_item_operand = (int * ) (extra_data [0 ]);
671
663
TSVector tsv ;
672
664
673
- tsv = rum_reconstruct_tsvector (check , query , nkeys , map_item_operand ,
665
+ tsv = rum_reconstruct_tsvector (check , query , map_item_operand ,
674
666
addInfo , addInfoIsNull );
675
667
676
668
res = DatumGetFloat4 (DirectFunctionCall2Coll (ts_rank_tt ,
0 commit comments