- All Implemented Interfaces:
Vector
Vector based on Mongo's BinaryVector. Note that only float32
and int8 variants can be represented as floating-point numbers. int1 throws
UnsupportedOperationException when calling toFloatArray() and toDoubleArray().- Since:
- 4.5
- Author:
- Mark Paluch
-
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic MongoVectorCreates a new binaryMongoVectorfrom the givenVector.org.bson.BinaryVectorgetType()inthashCode()static MongoVectorof(org.bson.BinaryVector v) Creates a new binaryMongoVectorusing the givenBinaryVector.static MongoVectorofFloat(float... data) Creates a new binaryMongoVectorusing the givendata.static MongoVectorofInt8(byte[] data) Creates a new binaryMongoVectorusing the givendata.intsize()double[]float[]toString()
-
Method Details
-
of
Creates a new binaryMongoVectorusing the givenBinaryVector.- Parameters:
v- binary vector representation.- Returns:
- the
MongoVectorwrappingBinaryVector.
-
ofInt8
Creates a new binaryMongoVectorusing the givendata.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 is not copied; changes to the provided array will be referenced in the created
MongoVectorinstance.- Parameters:
data- the byte array representing theBinaryVector.DataType.INT8vector data.- Returns:
- the
MongoVectorcontaining the given vector values to be represented as binaryint8.
-
ofFloat
Creates a new binaryMongoVectorusing the givendata.A
BinaryVector.DataType.FLOAT32vector is a vector of floating-point numbers, where each element in the vector is afloat.NOTE: The float array is not copied; changes to the provided array will be referenced in the created
MongoVectorinstance.- Parameters:
data- the float array representing theBinaryVector.DataType.FLOAT32vector data.- Returns:
- the
MongoVectorcontaining the given vector values to be represented as binaryfloat32.
-
fromFloat
Creates a new binaryMongoVectorfrom the givenVector.A
BinaryVector.DataType.FLOAT32vector is a vector of floating-point numbers, where each element in the vector is afloat. The givenVectormust be able to return afloatarray.NOTE: The float array is not copied; changes to the provided array will be referenced in the created
MongoVectorinstance.- Parameters:
v- the- Returns:
- the
MongoVectorusing vector values from the givenVectorto be represented as binary float32.
-
getType
-
getSource
public org.bson.BinaryVector getSource() -
size
public int size() -
toFloatArray
public float[] toFloatArray()- Specified by:
toFloatArrayin interfaceVector- Throws:
UnsupportedOperationException- if the underlying data type isint1PackedBitBinaryVector.
-
toDoubleArray
public double[] toDoubleArray()- Specified by:
toDoubleArrayin interfaceVector- Throws:
UnsupportedOperationException- if the underlying data type isint1PackedBitBinaryVector.
-
equals
-
hashCode
public int hashCode() -
toString
-