Record Class SparseByteVector
java.lang.Object
java.lang.Record
io.micronaut.data.model.vector.SparseByteVector
- 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=SparseByteVectorAttributeConverter.class)
public record SparseByteVector(int length, int[] indices, byte[] values)
extends Record
implements SparseVector
Sparse
ByteVector representation.- Since:
- 5.0.0
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSparseByteVector(int length, int[] indices, byte[] values) Creates a sparse byte vector. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether some other object is "equal to" this one.static SparseByteVectorfromDense(byte[] denseValues) Creates a sparse vector from dense byte values.static SparseByteVectorfromDense(ByteVector denseVector) Creates a sparse vector from a denseByteVector.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 denseByteVectorform.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.byte[]values()Returns the value of thevaluesrecord component.Methods inherited from interface SparseVector
sizeMethods inherited from interface Vector
toSparseByteVector, toSparseDoubleVector, toSparseFloatVector
-
Constructor Details
-
SparseByteVector
public SparseByteVector(int length, int[] indices, byte[] values) Creates a sparse byte 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 byte values.- Parameters:
denseValues- dense values- Returns:
- sparse vector representation
-
fromDense
Creates a sparse vector from a denseByteVector.- 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 denseByteVectorform.- Returns:
- dense byte 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
-