Package io.objectbox.model
Class HnswParams
- java.lang.Object
-
- io.objectbox.flatbuffers.Table
-
- io.objectbox.model.HnswParams
-
public final class HnswParams extends Table
Parameters to configure HNSW-based approximate nearest neighbor (ANN) search. Some of the parameters can influence index construction and searching. Changing these values causes re-indexing, which can take a while due to the complex nature of HNSW.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHnswParams.Vector
-
Constructor Summary
Constructors Constructor Description HnswParams()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HnswParams__assign(int _i, java.nio.ByteBuffer _bb)void__init(int _i, java.nio.ByteBuffer _bb)static voidaddDimensions(FlatBufferBuilder builder, long dimensions)static voidaddDistanceType(FlatBufferBuilder builder, int distanceType)static voidaddFlags(FlatBufferBuilder builder, long flags)static voidaddIndexingSearchCount(FlatBufferBuilder builder, long indexingSearchCount)static voidaddNeighborsPerNode(FlatBufferBuilder builder, long neighborsPerNode)static voidaddReparationBacklinkProbability(FlatBufferBuilder builder, float reparationBacklinkProbability)static voidaddVectorCacheHintSizeKb(FlatBufferBuilder builder, long vectorCacheHintSizeKb)static intcreateHnswParams(FlatBufferBuilder builder, long dimensions, long neighborsPerNode, long indexingSearchCount, long flags, int distanceType, float reparationBacklinkProbability, long vectorCacheHintSizeKb)longdimensions()Dimensions of vectors; vector data with less dimensions are ignored.intdistanceType()The distance type used for the HNSW index; if none is given, the default Euclidean is used.static intendHnswParams(FlatBufferBuilder builder)longflags()static HnswParamsgetRootAsHnswParams(java.nio.ByteBuffer _bb)static HnswParamsgetRootAsHnswParams(java.nio.ByteBuffer _bb, HnswParams obj)longindexingSearchCount()Aka "efConstruction": the number of neighbor searched for while indexing (default: 100).longneighborsPerNode()Aka "M": the max number of connections per node (default: 30).floatreparationBacklinkProbability()When repairing the graph after a node was removed, this gives the probability of adding backlinks to the repaired neighbors.static voidstartHnswParams(FlatBufferBuilder builder)static voidValidateVersion()longvectorCacheHintSizeKb()A non-binding hint at the maximum size of the vector cache in KB (default: 2097152 or 2 GB/GiB).-
Methods inherited from class io.objectbox.flatbuffers.Table
__has_identifier, __indirect, __indirect, __offset, __offset, __reset, __reset, __string, __string, __union, __union, __vector, __vector_as_bytebuffer, __vector_in_bytebuffer, __vector_len, compareStrings, compareStrings, getByteBuffer, keysCompare, sortTables
-
-
-
-
Method Detail
-
ValidateVersion
public static void ValidateVersion()
-
getRootAsHnswParams
public static HnswParams getRootAsHnswParams(java.nio.ByteBuffer _bb)
-
getRootAsHnswParams
public static HnswParams getRootAsHnswParams(java.nio.ByteBuffer _bb, HnswParams obj)
-
__init
public void __init(int _i, java.nio.ByteBuffer _bb)
-
__assign
public HnswParams __assign(int _i, java.nio.ByteBuffer _bb)
-
dimensions
public long dimensions()
Dimensions of vectors; vector data with less dimensions are ignored. Vectors with more dimensions than specified here are only evaluated up to the given dimension value. Changing this value causes re-indexing.
-
neighborsPerNode
public long neighborsPerNode()
Aka "M": the max number of connections per node (default: 30). Higher numbers increase the graph connectivity, which can lead to more accurate search results. However, higher numbers also increase the indexing time and resource usage. Try e.g. 16 for faster but less accurate results, or 64 for more accurate results. Changing this value causes re-indexing.
-
indexingSearchCount
public long indexingSearchCount()
Aka "efConstruction": the number of neighbor searched for while indexing (default: 100). The higher the value, the more accurate the search, but the longer the indexing. If indexing time is not a major concern, a value of at least 200 is recommended to improve search quality. Changing this value causes re-indexing.
-
flags
public long flags()
-
distanceType
public int distanceType()
The distance type used for the HNSW index; if none is given, the default Euclidean is used. Changing this value causes re-indexing.
-
reparationBacklinkProbability
public float reparationBacklinkProbability()
When repairing the graph after a node was removed, this gives the probability of adding backlinks to the repaired neighbors. The default is 1.0 (aka "always") as this should be worth a bit of extra costs as it improves the graph's quality.
-
vectorCacheHintSizeKb
public long vectorCacheHintSizeKb()
A non-binding hint at the maximum size of the vector cache in KB (default: 2097152 or 2 GB/GiB). The actual size max cache size may be altered according to device and/or runtime settings. The vector cache is used to store vectors in memory to speed up search and indexing. Note 1: cache chunks are allocated only on demand, when they are actually used. Thus, smaller datasets will use less memory. Note 2: the cache is for one specific HNSW index; e.g. each index has its own cache. Note 3: the memory consumption can temporarily exceed the cache size, e.g. for large changes, it can double due to multi-version transactions.
-
createHnswParams
public static int createHnswParams(FlatBufferBuilder builder, long dimensions, long neighborsPerNode, long indexingSearchCount, long flags, int distanceType, float reparationBacklinkProbability, long vectorCacheHintSizeKb)
-
startHnswParams
public static void startHnswParams(FlatBufferBuilder builder)
-
addDimensions
public static void addDimensions(FlatBufferBuilder builder, long dimensions)
-
addNeighborsPerNode
public static void addNeighborsPerNode(FlatBufferBuilder builder, long neighborsPerNode)
-
addIndexingSearchCount
public static void addIndexingSearchCount(FlatBufferBuilder builder, long indexingSearchCount)
-
addFlags
public static void addFlags(FlatBufferBuilder builder, long flags)
-
addDistanceType
public static void addDistanceType(FlatBufferBuilder builder, int distanceType)
-
addReparationBacklinkProbability
public static void addReparationBacklinkProbability(FlatBufferBuilder builder, float reparationBacklinkProbability)
-
addVectorCacheHintSizeKb
public static void addVectorCacheHintSizeKb(FlatBufferBuilder builder, long vectorCacheHintSizeKb)
-
endHnswParams
public static int endHnswParams(FlatBufferBuilder builder)
-
-