Record Class SparseFloatVector
java.lang.Object
java.lang.Record
io.micronaut.data.model.vector.SparseFloatVector
- Record Components:
length- The dense vector length.indices- Sorted non-zero positions.values- Non-zero values aligned withindices.
- All Implemented Interfaces:
SparseVector, Vector
@TypeDef(type=OBJECT,
converter=SparseFloatVectorAttributeConverter.class)
public record SparseFloatVector(int length, int[] indices, float[] values)
extends Record
implements SparseVector
Sparse
FloatVector representation.- Since:
- 5.0.0
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSparseFloatVector(int length, int[] indices, float[] values) Creates a sparse float vector. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether some other object is "equal to" this one.static SparseFloatVectorfromDense(float[] denseValues) Creates a sparse vector from dense float values.static SparseFloatVectorfromDense(FloatVector denseVector) Creates a sparse vector from a denseFloatVector.getType()Return the primitive number type the vector is backed by.inthashCode()Returns a hash code value for this object.int[]indices()intlength()Returns the value of thelengthrecord component.byte[]Convert this vector to a new byte array copy.Converts this sparse vector into denseFloatVectorform.double[]Convert this vector to a new double array copy.float[]Convert this vector to a new float array copy.toString()Returns a string representation of this record class.float[]values()Returns the value of thevaluesrecord component.Methods inherited from interface SparseVector
sizeMethods inherited from interface Vector
toSparseByteVector, toSparseDoubleVector, toSparseFloatVector
-
Constructor Details
-
SparseFloatVector
public SparseFloatVector(int length, int[] indices, float[] values) Creates a sparse float vector.- Parameters:
length- dense vector lengthindices- sorted non-zero indicesvalues- non-zero values aligned with indices
-
-
Method Details
-
fromDense
Creates a sparse vector from dense float values.- Parameters:
denseValues- dense values- Returns:
- sparse vector representation
-
fromDense
Creates a sparse vector from a denseFloatVector.- Parameters:
denseVector- dense vector- Returns:
- sparse vector representation
-
indices
public int[] indices()- Specified by:
indicesin interfaceSparseVector- Returns:
- sorted non-zero indices
-
values
-
getType
-
toFloatArray
public float[] toFloatArray()Convert this vector to a new float array copy.- Specified by:
toFloatArrayin interfaceVector- Returns:
- a new float[] with the vector content
-
toDoubleArray
public double[] toDoubleArray()Convert this vector to a new double array copy.- Specified by:
toDoubleArrayin interfaceVector- Returns:
- a new double[] with the vector content
-
toByteArray
public byte[] toByteArray()Convert this vector to a new byte array copy.- Specified by:
toByteArrayin interfaceVector- Returns:
- a new byte[] with the vector content
-
toDenseVector
Converts this sparse vector into denseFloatVectorform.- Returns:
- dense float vector
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
length
public int length()Returns the value of thelengthrecord component.- Specified by:
lengthin interfaceSparseVector- Returns:
- the value of the
lengthrecord component
-