Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 14840f3

Browse files
author
Nikita Glukhov
committed
Add ginPostingListDecodeOneSegment()
1 parent 00d3822 commit 14840f3

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/backend/access/gin/ginpostinglist.c

+27
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,33 @@ ginPostingListDecode(GinPostingList *plist, int *ndecoded)
288288
ndecoded);
289289
}
290290

291+
int
292+
ginPostingListDecodeOneSegment(GinPostingList *segment, ItemPointer result)
293+
{
294+
unsigned char *ptr;
295+
unsigned char *endptr;
296+
uint64 val;
297+
int ndecoded = 0;
298+
299+
/* copy the first item */
300+
Assert(OffsetNumberIsValid(ItemPointerGetOffsetNumber(&segment->first)));
301+
result[ndecoded] = segment->first;
302+
ndecoded++;
303+
304+
val = itemptr_to_uint64(&segment->first);
305+
ptr = segment->bytes;
306+
endptr = segment->bytes + segment->nbytes;
307+
308+
while (ptr < endptr)
309+
{
310+
val += decode_varbyte(&ptr);
311+
uint64_to_itemptr(val, &result[ndecoded]);
312+
ndecoded++;
313+
}
314+
315+
return ndecoded;
316+
}
317+
291318
/*
292319
* Decode multiple posting list segments into an array of item pointers.
293320
* The number of items is returned in *ndecoded_out. The segments are stored

src/include/access/gin_private.h

+1
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ extern GinPostingList *ginCompressPostingList(const ItemPointer ipd, int nipd,
472472
extern int ginPostingListDecodeAllSegmentsToTbm(GinPostingList *ptr, int totalsize, TIDBitmap *tbm);
473473

474474
extern ItemPointer ginPostingListDecodeAllSegments(GinPostingList *ptr, int len, int *ndecoded);
475+
extern int ginPostingListDecodeOneSegment(GinPostingList *segment, ItemPointer result);
475476
extern ItemPointer ginPostingListDecode(GinPostingList *ptr, int *ndecoded);
476477
extern ItemPointer ginMergeItemPointers(ItemPointerData *a, uint32 na,
477478
ItemPointerData *b, uint32 nb,

0 commit comments

Comments
 (0)