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

Commit1a4070e

Browse files
committed
Add second pass (reversed) from gettuple if we did not found enough tuples
1 parentf48c31f commit1a4070e

File tree

3 files changed

+42
-16
lines changed

3 files changed

+42
-16
lines changed

‎rum.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ typedef struct RumScanOpaqueData
695695
TIDBitmap*tbm;
696696

697697
ScanDirectionnaturalOrder;
698+
boolsecondPass;
698699
}RumScanOpaqueData;
699700

700701
typedefRumScanOpaqueData*RumScanOpaque;
@@ -706,6 +707,7 @@ extern void rumrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
706707
externDatumrummarkpos(PG_FUNCTION_ARGS);
707708
externDatumrumrestrpos(PG_FUNCTION_ARGS);
708709
externvoidrumNewScanKey(IndexScanDescscan);
710+
externvoidfreeScanKeys(RumScanOpaqueso);
709711

710712
/* rumget.c */
711713
externint64rumgetbitmap(IndexScanDescscan,TIDBitmap*tbm);

‎rumget.c

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@
2525
/* GUC parameter */
2626
intRumFuzzySearchLimit=0;
2727

28-
typedefstructpendingPosition
29-
{
30-
BufferpendingBuffer;
31-
OffsetNumberfirstOffset;
32-
OffsetNumberlastOffset;
33-
ItemPointerDataitem;
34-
bool*hasMatchKey;
35-
}pendingPosition;
36-
3728
staticboolscanPage(RumState*rumstate,RumScanEntryentry,RumKey*item,
3829
Pagepage,boolequalOk);
3930
staticvoidinsertScanItem(RumScanOpaqueso,boolrecheck);
@@ -2331,6 +2322,34 @@ insertScanItem(RumScanOpaque so, bool recheck)
23312322
rum_tuplesort_putrum(so->sortstate,item);
23322323
}
23332324

2325+
staticvoid
2326+
reverseScan(IndexScanDescscan)
2327+
{
2328+
RumScanOpaqueso= (RumScanOpaque)scan->opaque;
2329+
inti,j;
2330+
2331+
freeScanKeys(so);
2332+
rumNewScanKey(scan);
2333+
2334+
for(i=0;i<so->nkeys;i++)
2335+
{
2336+
RumScanKeykey=so->keys[i];
2337+
2338+
key->isFinished= false;
2339+
key->scanDirection=-key->scanDirection;
2340+
2341+
for(j=0;j<key->nentries;j++)
2342+
{
2343+
RumScanEntryentry=key->scanEntry[j];
2344+
2345+
entry->isFinished= false;
2346+
entry->scanDirection=-entry->scanDirection;
2347+
}
2348+
}
2349+
2350+
startScan(scan);
2351+
}
2352+
23342353
bool
23352354
rumgettuple(IndexScanDescscan,ScanDirectiondirection)
23362355
{
@@ -2341,8 +2360,6 @@ rumgettuple(IndexScanDesc scan, ScanDirection direction)
23412360

23422361
if (so->firstCall)
23432362
{
2344-
so->norderbys=scan->numberOfOrderBys;
2345-
23462363
/*
23472364
* Set up the scan keys, and check for unsatisfiable query.
23482365
*/
@@ -2352,10 +2369,6 @@ rumgettuple(IndexScanDesc scan, ScanDirection direction)
23522369
if (RumIsVoidRes(scan))
23532370
PG_RETURN_INT64(0);
23542371

2355-
so->tbm=NULL;
2356-
so->entriesIncrIndex=-1;
2357-
so->firstCall= false;
2358-
23592372
startScan(scan);
23602373
if (so->naturalOrder==NoMovementScanDirection)
23612374
{
@@ -2384,6 +2397,12 @@ rumgettuple(IndexScanDesc scan, ScanDirection direction)
23842397

23852398
return true;
23862399
}
2400+
elseif (so->secondPass== false)
2401+
{
2402+
reverseScan(scan);
2403+
so->secondPass= true;
2404+
returnrumgettuple(scan,direction);
2405+
}
23872406

23882407
return false;
23892408
}

‎rumscan.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ freeScanEntries(RumScanEntry *entries, uint32 nentries)
285285
}
286286
}
287287

288-
staticvoid
288+
void
289289
freeScanKeys(RumScanOpaqueso)
290290
{
291291
freeScanEntries(so->entries,so->totalentries);
@@ -513,6 +513,11 @@ rumNewScanKey(IndexScanDesc scan)
513513
}hasAddOnFilter=haofNone;
514514

515515
so->naturalOrder=NoMovementScanDirection;
516+
so->secondPass= false;
517+
so->tbm=NULL;
518+
so->entriesIncrIndex=-1;
519+
so->firstCall= false;
520+
so->norderbys=scan->numberOfOrderBys;
516521

517522
/*
518523
* Allocate all the scan key information in the key context. (If

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp