Package io.github.jbellis.jvector.graph
Class ListRandomAccessVectorValues
java.lang.Object
io.github.jbellis.jvector.graph.ListRandomAccessVectorValues
- All Implemented Interfaces:
RandomAccessVectorValues<float[]>
public class ListRandomAccessVectorValues
extends Object
implements RandomAccessVectorValues<float[]>
A List-backed implementation of the
RandomAccessVectorValues interface.
It is acceptable to provide this class to a GraphBuilder, and then continue to add vectors to it as you add to the graph.
This will be as threadsafe as the provided List.
-
Constructor Summary
ConstructorsConstructorDescriptionListRandomAccessVectorValues(List<float[]> vectors, int dimension) Construct a new instance ofListRandomAccessVectorValues. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a new copy of thisRandomAccessVectorValues.intReturn the dimension of the returned vector valuesbooleanintsize()Return the number of vector values.float[]vectorValue(int targetOrd) Return the vector value indexed at the given ordinal.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.jbellis.jvector.graph.RandomAccessVectorValues
threadLocalSupplier
-
Constructor Details
-
ListRandomAccessVectorValues
Construct a new instance ofListRandomAccessVectorValues.- Parameters:
vectors- a (potentially mutable) list of float vectors.dimension- the dimension of the vectors.
-
-
Method Details
-
size
public int size()Description copied from interface:RandomAccessVectorValuesReturn the number of vector values.All copies of a given RAVV should have the same size. Typically this is achieved by either (1) implementing a threadsafe, un-shared RAVV, where `copy` returns `this`, or (2) implementing a fixed-size RAVV.
- Specified by:
sizein interfaceRandomAccessVectorValues<float[]>
-
dimension
public int dimension()Description copied from interface:RandomAccessVectorValuesReturn the dimension of the returned vector values- Specified by:
dimensionin interfaceRandomAccessVectorValues<float[]>
-
vectorValue
public float[] vectorValue(int targetOrd) Description copied from interface:RandomAccessVectorValuesReturn the vector value indexed at the given ordinal.For performance, implementations are free to re-use the same object across invocations. That is, you will get back the same float[] reference (for instance) for every requested ordinal. If you want to use those values across calls, you should make a copy.
- Specified by:
vectorValuein interfaceRandomAccessVectorValues<float[]>- Parameters:
targetOrd- a valid ordinal, ≥ 0 and <RandomAccessVectorValues.size().
-
copy
Description copied from interface:RandomAccessVectorValuesCreates a new copy of thisRandomAccessVectorValues. This is helpful when you need to access different values at once, to avoid overwriting the underlying float vector returned by a sharedRandomAccessVectorValues.vectorValue(int).Un-shared implementations may simply return `this`.
- Specified by:
copyin interfaceRandomAccessVectorValues<float[]>
-