Class BinaryVector
- Direct Known Subclasses:
Float32BinaryVector,Int8BinaryVector,PackedBitBinaryVector
BinaryVector.DataType's and provides static methods to create vectors.
NOTE: This class should be treated as sealed: it must not be extended or implemented by consumers of the library.
- Since:
- 5.3
- See Also:
- Since server release
- 6.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents the data type (dtype) of a vector. -
Method Summary
Modifier and TypeMethodDescriptionReturns theFloat32BinaryVector.Returns theInt8BinaryVector.Returns thePackedBitBinaryVector.static Float32BinaryVectorfloatVector(float[] data) Creates a vector with theBinaryVector.DataType.FLOAT32data type.ReturnsBinaryVector.DataTypeof the vector.static Int8BinaryVectorint8Vector(byte[] data) Creates a vector with theBinaryVector.DataType.INT8data type.static PackedBitBinaryVectorpackedBitVector(byte[] data, byte padding) Creates a vector with theBinaryVector.DataType.PACKED_BITdata type.
-
Method Details
-
packedBitVector
Creates a vector with theBinaryVector.DataType.PACKED_BITdata type.A
BinaryVector.DataType.PACKED_BITvector is a binary quantized vector where each element of a vector is represented by a single bit (0 or 1). Each byte can hold up to 8 bits (vector elements). The padding parameter is used to specify how many least-significant bits in the final byte should be ignored.For example, a vector with two bytes and a padding of 4 would have the following structure:
Byte 1: 238 (binary: 11101110) Byte 2: 224 (binary: 11100000) Padding: 4 (ignore the last 4 bits in Byte 2) Resulting vector: 12 bits: 111011101110
NOTE: The byte array `data` is not copied; changes to the provided array will be reflected in the created
PackedBitBinaryVectorinstance.- Parameters:
data- The byte array representing the packed bit vector data. Each byte can store 8 bits.padding- The number of least-significant bits (0 to 7) to ignore in the final byte of the vector data.- Returns:
- A
PackedBitBinaryVectorinstance with theBinaryVector.DataType.PACKED_BITdata type. - Throws:
IllegalArgumentException- If the padding value is greater than 7.
-
int8Vector
Creates a vector with theBinaryVector.DataType.INT8data type.A
BinaryVector.DataType.INT8vector is a vector of 8-bit signed integers where each byte in the vector represents an element of a vector, with values in the range [-128, 127].NOTE: The byte array `data` is not copied; changes to the provided array will be reflected in the created
Int8BinaryVectorinstance.- Parameters:
data- The byte array representing theBinaryVector.DataType.INT8vector data.- Returns:
- A
Int8BinaryVectorinstance with theBinaryVector.DataType.INT8data type.
-
floatVector
Creates a vector with theBinaryVector.DataType.FLOAT32data type.A
BinaryVector.DataType.FLOAT32vector is a vector of floating-point numbers, where each element in the vector is a float.NOTE: The float array `data` is not copied; changes to the provided array will be reflected in the created
Float32BinaryVectorinstance.- Parameters:
data- The float array representing theBinaryVector.DataType.FLOAT32vector data.- Returns:
- A
Float32BinaryVectorinstance with theBinaryVector.DataType.FLOAT32data type.
-
asPackedBitVector
Returns thePackedBitBinaryVector.- Returns:
PackedBitBinaryVector.- Throws:
IllegalStateException- if this vector is not of typeBinaryVector.DataType.PACKED_BIT. UsegetDataType()to check the vector type before calling this method.
-
asInt8Vector
Returns theInt8BinaryVector.- Returns:
Int8BinaryVector.- Throws:
IllegalStateException- if this vector is not of typeBinaryVector.DataType.INT8. UsegetDataType()to check the vector type before calling this method.
-
asFloat32Vector
Returns theFloat32BinaryVector.- Returns:
Float32BinaryVector.- Throws:
IllegalStateException- if this vector is not of typeBinaryVector.DataType.FLOAT32. UsegetDataType()to check the vector type before calling this method.
-
getDataType
ReturnsBinaryVector.DataTypeof the vector.- Returns:
- the data type of the vector.
-