Merge branch 'master' into hqann2

This commit is contained in:
Andrew Kane
2024-10-09 22:06:29 -07:00
4 changed files with 15 additions and 14 deletions

View File

@@ -397,7 +397,7 @@ void HnswSetNeighborTuple(char *base, HnswNeighborTuple ntup, HnswElement e, in
void HnswAddHeapTid(HnswElement element, ItemPointer heaptid);
HnswNeighborArray *HnswInitNeighborArray(int lm, HnswAllocator * allocator);
void HnswInitNeighbors(char *base, HnswElement element, int m, HnswAllocator * alloc);
bool HnswInsertTupleOnDisk(Relation index, IndexTuple itup, ItemPointer heaptid, bool building);
bool HnswInsertTupleOnDisk(Relation index, FmgrInfo **procinfo, Oid *collation, IndexTuple itup, ItemPointer heaptid, bool building);
void HnswUpdateNeighborsOnDisk(Relation index, FmgrInfo **procinfo, Oid *collation, HnswElement e, int m, bool checkExisting, bool building);
void HnswLoadElementFromTuple(HnswElement element, HnswElementTuple etup, bool loadHeaptids, bool loadVec, Relation index);
void HnswLoadElement(HnswElement element, double *distance, bool *matches, Datum *q, IndexTuple qtup, ScanKeyData *keyData, Relation index, FmgrInfo **procinfo, Oid *collation, bool loadVec, double *maxDistance);

View File

@@ -476,6 +476,8 @@ InsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heaptid, Hn
HnswGraph *graph = buildstate->graph;
HnswElement element;
HnswAllocator *allocator = &buildstate->allocator;
FmgrInfo **procinfo = buildstate->procinfo;
Oid *collation = buildstate->collation;
LWLock *flushLock = &graph->flushLock;
char *base = buildstate->hnswarea;
TupleDesc tupdesc = buildstate->tupdesc;
@@ -485,7 +487,7 @@ InsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heaptid, Hn
bool unused;
/* Form index tuple */
if (!HnswFormIndexTuple(&itup, values, isnull, buildstate->typeInfo, buildstate->normprocinfo, buildstate->collation[0], tupdesc))
if (!HnswFormIndexTuple(&itup, values, isnull, buildstate->typeInfo, buildstate->normprocinfo, collation[0], tupdesc))
return false;
/* Get tuple size */
@@ -499,7 +501,7 @@ InsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heaptid, Hn
{
LWLockRelease(flushLock);
return HnswInsertTupleOnDisk(index, itup, heaptid, true);
return HnswInsertTupleOnDisk(index, procinfo, collation, itup, heaptid, true);
}
/*
@@ -531,7 +533,7 @@ InsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heaptid, Hn
LWLockRelease(flushLock);
return HnswInsertTupleOnDisk(index, itup, heaptid, true);
return HnswInsertTupleOnDisk(index, procinfo, collation, itup, heaptid, true);
}
/* Ok, we can proceed to allocate the element */

View File

@@ -692,21 +692,17 @@ UpdateGraphOnDisk(Relation index, FmgrInfo **procinfo, Oid *collation, HnswEleme
* Insert a tuple into the index
*/
bool
HnswInsertTupleOnDisk(Relation index, IndexTuple itup, ItemPointer heaptid, bool building)
HnswInsertTupleOnDisk(Relation index, FmgrInfo **procinfo, Oid *collation, IndexTuple itup, ItemPointer heaptid, bool building)
{
HnswElement entryPoint;
HnswElement element;
int m;
int efConstruction = HnswGetEfConstruction(index);
FmgrInfo *procinfo[2];
Oid *collation;
LOCKMODE lockmode = ShareLock;
char *base = NULL;
TupleDesc tupdesc = RelationGetDescr(index);
bool unused;
HnswSetProcinfo(index, procinfo, NULL, &collation);
/*
* Get a shared lock. This allows vacuum to ensure no in-flight inserts
* before repairing graph. Use a page lock so it does not interfere with
@@ -756,15 +752,18 @@ HnswInsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heaptid
{
IndexTuple itup;
const HnswTypeInfo *typeInfo = HnswGetTypeInfo(index);
FmgrInfo *normprocinfo = HnswOptionalProcInfo(index, HNSW_NORM_PROC);
Oid collation = index->rd_indcollation[0];
TupleDesc tupdesc = RelationGetDescr(index);
FmgrInfo *procinfo[2];
FmgrInfo *normprocinfo;
Oid *collation;
HnswSetProcinfo(index, procinfo, &normprocinfo, &collation);
/* Form index tuple */
if (!HnswFormIndexTuple(&itup, values, isnull, typeInfo, normprocinfo, collation, tupdesc))
if (!HnswFormIndexTuple(&itup, values, isnull, typeInfo, normprocinfo, collation[0], tupdesc))
return;
HnswInsertTupleOnDisk(index, itup, heaptid, false);
HnswInsertTupleOnDisk(index, procinfo, collation, itup, heaptid, false);
}
/*

View File

@@ -173,7 +173,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
ItemPointer heaptid;
/* Move to next element if no valid heap TIDs */
if (!hc->matches || element->heaptidsLength == 0)
if (!sc->matches || element->heaptidsLength == 0)
{
so->w = list_delete_last(so->w);
continue;