method %OnNew(ClassName, IndexName, Distance, IndexProperty, DIM, IndexData) as %Status
Inherited description: This callback method is invoked by the %New() method to
provide notification that a new instance of an object is being created.
If this method returns an error then the object will not be created.
It is passed the arguments provided in the %New call.
When customizing this method, override the arguments with whatever variables and types you expect to receive from %New().
For example, if you're going to call %New, passing 2 arguments, %OnNew's signature could be:
Method %OnNew(dob as %Date = "", name as %Name = "") as %Status
If instead of returning a %Status code this returns an oref and this oref is a subclass of the current
class then this oref will be the one returned to the caller of %New method.
method Delete(pID, ByRef pArg, lock=1)
Removes row with id pID from the HNSW index
lock indicates if locking is in effect (lock=1) or not (lock =0). Default value is 1.
classmethod HNSWrandomLevel(mL)
Return a random positive integer based on the probability distribution described in the HNSW paper (https://arxiv.org/abs/1603.09320).
Parameter:
mL: controls the shape of the distribution. A larger mL results in more layers in the graph
method HNSWsearchLayer(ByRef results, q, epIdx, ef, lc, lock=0, ByRef rerun)
Search for the top ef neighbors in layer lc for query point q, given the entry point epIdx.
Stores the result in "results" local array that has most ef nodes.
Each node in results is a list that contains the ID of the neighbor point and the distance between the neighbor point and q, subscripted by the ranking: results(ranking)=$lb(ID, distance)
method Insert(pID, ByRef pArg, lock=1)
Inserts row with id pID into the HNSW index
lock indicates if locking is in effect (lock=1) or not (lock =0). Default value is 1.
method TopK(point, k, efSearch="")
Find the top k nearest neighbor of point and store the results as a local array in i%TopK. Each node in i%TopK is a list that contains the ID of the neighbor point and the distance between the neighbor point and q, subscripted by the ranking: i%TopK(ranking)=$lb(ID, distance)
Parameter:
efSearch: The size of the candidate vectors when finding nearest neighbors for point
method Update(pID, ByRef pArg, lock=1)
Update a point by first deleting the old point, and then inserting the new point
lock indicates if locking is in effect (lock=1) or not (lock =0). Default value is 1.
method buildResults(ByRef data, ByRef results)
Given a resultArray in HNSWsearchLayer,returns the same data in an array of lists: results(ranking)=$lb(idx, distance)
method getNext(ByRef distance, ByRef id) as %Boolean
Returns by reference the next nearest neighbor to i%Point and the distance between this neighbor to i%Point