mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-10 22:56:55 +08:00
Added SetIndexTuple function
This commit is contained in:
@@ -238,6 +238,34 @@ MarkPriorTupleDead(IndexScanDesc scan)
|
|||||||
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
|
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set tuple for index-only scan
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
SetIndexTuple(IndexScanDesc scan, ItemPointer indextid)
|
||||||
|
{
|
||||||
|
IvfflatScanOpaque so = (IvfflatScanOpaque) scan->opaque;
|
||||||
|
Buffer buf = so->buf;
|
||||||
|
Page page;
|
||||||
|
OffsetNumber offno = ItemPointerGetOffsetNumber(indextid);
|
||||||
|
IndexTuple itup;
|
||||||
|
Size itupSize;
|
||||||
|
|
||||||
|
LockBuffer(buf, BUFFER_LOCK_SHARE);
|
||||||
|
page = BufferGetPage(buf);
|
||||||
|
itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, offno));
|
||||||
|
itupSize = IndexTupleSize(itup);
|
||||||
|
|
||||||
|
if (so->itup == NULL)
|
||||||
|
so->itup = palloc(BLCKSZ);
|
||||||
|
|
||||||
|
memcpy(so->itup, itup, itupSize);
|
||||||
|
|
||||||
|
scan->xs_itup = so->itup;
|
||||||
|
|
||||||
|
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare for an index scan
|
* Prepare for an index scan
|
||||||
*/
|
*/
|
||||||
@@ -409,27 +437,7 @@ ivfflatgettuple(IndexScanDesc scan, ScanDirection dir)
|
|||||||
so->buf = ReadBuffer(scan->indexRelation, ItemPointerGetBlockNumber(indextid));
|
so->buf = ReadBuffer(scan->indexRelation, ItemPointerGetBlockNumber(indextid));
|
||||||
|
|
||||||
if (scan->xs_want_itup)
|
if (scan->xs_want_itup)
|
||||||
{
|
SetIndexTuple(scan, indextid);
|
||||||
Page page;
|
|
||||||
OffsetNumber offno;
|
|
||||||
IndexTuple itup;
|
|
||||||
Size itupSize;
|
|
||||||
|
|
||||||
LockBuffer(so->buf, BUFFER_LOCK_SHARE);
|
|
||||||
page = BufferGetPage(so->buf);
|
|
||||||
offno = ItemPointerGetOffsetNumber(indextid);
|
|
||||||
itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, offno));
|
|
||||||
itupSize = IndexTupleSize(itup);
|
|
||||||
|
|
||||||
if (so->itup == NULL)
|
|
||||||
so->itup = palloc(BLCKSZ);
|
|
||||||
|
|
||||||
memcpy(so->itup, itup, itupSize);
|
|
||||||
|
|
||||||
scan->xs_itup = so->itup;
|
|
||||||
|
|
||||||
LockBuffer(so->buf, BUFFER_LOCK_UNLOCK);
|
|
||||||
}
|
|
||||||
|
|
||||||
scan->xs_recheckorderby = false;
|
scan->xs_recheckorderby = false;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user