mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-12 15:46:54 +08:00
Copy index tuple
This commit is contained in:
@@ -248,6 +248,7 @@ typedef struct IvfflatScanOpaqueData
|
|||||||
bool first;
|
bool first;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
ItemPointerData heaptid;
|
ItemPointerData heaptid;
|
||||||
|
IndexTuple itup;
|
||||||
|
|
||||||
/* Sorting */
|
/* Sorting */
|
||||||
Tuplesortstate *sortstate;
|
Tuplesortstate *sortstate;
|
||||||
|
|||||||
@@ -266,6 +266,7 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
|
|||||||
so->buf = InvalidBuffer;
|
so->buf = InvalidBuffer;
|
||||||
so->first = true;
|
so->first = true;
|
||||||
ItemPointerSetInvalid(&so->heaptid);
|
ItemPointerSetInvalid(&so->heaptid);
|
||||||
|
so->itup = NULL;
|
||||||
so->probes = probes;
|
so->probes = probes;
|
||||||
so->dimensions = dimensions;
|
so->dimensions = dimensions;
|
||||||
|
|
||||||
@@ -410,12 +411,22 @@ ivfflatgettuple(IndexScanDesc scan, ScanDirection dir)
|
|||||||
if (scan->xs_want_itup)
|
if (scan->xs_want_itup)
|
||||||
{
|
{
|
||||||
Page page;
|
Page page;
|
||||||
|
OffsetNumber offno;
|
||||||
|
IndexTuple itup;
|
||||||
|
Size itupSize;
|
||||||
|
|
||||||
LockBuffer(so->buf, BUFFER_LOCK_SHARE);
|
LockBuffer(so->buf, BUFFER_LOCK_SHARE);
|
||||||
page = BufferGetPage(so->buf);
|
page = BufferGetPage(so->buf);
|
||||||
|
offno = ItemPointerGetOffsetNumber(indextid);
|
||||||
|
itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, offno));
|
||||||
|
itupSize = IndexTupleSize(itup);
|
||||||
|
|
||||||
/* TODO Copy tuple to IvfflatScanOpaque */
|
if (so->itup == NULL)
|
||||||
scan->xs_itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, ItemPointerGetOffsetNumber(indextid)));
|
so->itup = palloc(BLCKSZ);
|
||||||
|
|
||||||
|
memcpy(so->itup, itup, itupSize);
|
||||||
|
|
||||||
|
scan->xs_itup = so->itup;
|
||||||
|
|
||||||
LockBuffer(so->buf, BUFFER_LOCK_UNLOCK);
|
LockBuffer(so->buf, BUFFER_LOCK_UNLOCK);
|
||||||
}
|
}
|
||||||
@@ -439,6 +450,9 @@ ivfflatendscan(IndexScanDesc scan)
|
|||||||
if (BufferIsValid(so->buf))
|
if (BufferIsValid(so->buf))
|
||||||
ReleaseBuffer(so->buf);
|
ReleaseBuffer(so->buf);
|
||||||
|
|
||||||
|
if (so->itup != NULL)
|
||||||
|
pfree(so->itup);
|
||||||
|
|
||||||
pairingheap_free(so->listQueue);
|
pairingheap_free(so->listQueue);
|
||||||
tuplesort_end(so->sortstate);
|
tuplesort_end(so->sortstate);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user