diff --git a/bson/src/main/org/bson/Vector.java b/bson/src/main/org/bson/BinaryVector.java
similarity index 77%
rename from bson/src/main/org/bson/Vector.java
rename to bson/src/main/org/bson/BinaryVector.java
index d267387d727..630f54ea4f5 100644
--- a/bson/src/main/org/bson/Vector.java
+++ b/bson/src/main/org/bson/BinaryVector.java
@@ -20,12 +20,8 @@
import static org.bson.assertions.Assertions.notNull;
/**
- * Represents a vector that is stored and retrieved using the BSON Binary Subtype 9 format.
- * This class supports multiple vector {@link DataType}'s and provides static methods to create
- * vectors.
- *
- * Vectors are densely packed arrays of numbers, all the same type, which are stored efficiently
- * in BSON using a binary format.
+ * Binary Vectors are densely packed arrays of numbers, all the same type, which are stored and retrieved efficiently using the BSON Binary
+ * Subtype 9 format. This class supports multiple vector {@link 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.
*
@@ -33,10 +29,10 @@
* @see BsonBinary
* @since 5.3
*/
-public abstract class Vector {
+public abstract class BinaryVector {
private final DataType dataType;
- Vector(final DataType dataType) {
+ BinaryVector(final DataType dataType) {
this.dataType = dataType;
}
@@ -56,18 +52,18 @@ public abstract class Vector {
*
*
* NOTE: The byte array `data` is not copied; changes to the provided array will be reflected
- * in the created {@link PackedBitVector} instance.
+ * in the created {@link PackedBitBinaryVector} instance.
*
* @param data The byte array representing the packed bit vector data. Each byte can store 8 bits.
* @param padding The number of least-significant bits (0 to 7) to ignore in the final byte of the vector data.
- * @return A {@link PackedBitVector} instance with the {@link DataType#PACKED_BIT} data type.
+ * @return A {@link PackedBitBinaryVector} instance with the {@link DataType#PACKED_BIT} data type.
* @throws IllegalArgumentException If the padding value is greater than 7.
*/
- public static PackedBitVector packedBitVector(final byte[] data, final byte padding) {
+ public static PackedBitBinaryVector packedBitVector(final byte[] data, final byte padding) {
notNull("data", data);
isTrueArgument("Padding must be between 0 and 7 bits. Provided padding: " + padding, padding >= 0 && padding <= 7);
isTrueArgument("Padding must be 0 if vector is empty. Provided padding: " + padding, padding == 0 || data.length > 0);
- return new PackedBitVector(data, padding);
+ return new PackedBitBinaryVector(data, padding);
}
/**
@@ -77,14 +73,14 @@ public static PackedBitVector packedBitVector(final byte[] data, final byte padd
* 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 {@link Int8Vector} instance.
+ * in the created {@link Int8BinaryVector} instance.
*
* @param data The byte array representing the {@link DataType#INT8} vector data.
- * @return A {@link Int8Vector} instance with the {@link DataType#INT8} data type.
+ * @return A {@link Int8BinaryVector} instance with the {@link DataType#INT8} data type.
*/
- public static Int8Vector int8Vector(final byte[] data) {
+ public static Int8BinaryVector int8Vector(final byte[] data) {
notNull("data", data);
- return new Int8Vector(data);
+ return new Int8BinaryVector(data);
}
/**
@@ -93,50 +89,50 @@ public static Int8Vector int8Vector(final byte[] data) {
* A {@link DataType#FLOAT32} vector 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 {@link Float32Vector} instance.
+ * in the created {@link Float32BinaryVector} instance.
*
* @param data The float array representing the {@link DataType#FLOAT32} vector data.
- * @return A {@link Float32Vector} instance with the {@link DataType#FLOAT32} data type.
+ * @return A {@link Float32BinaryVector} instance with the {@link DataType#FLOAT32} data type.
*/
- public static Float32Vector floatVector(final float[] data) {
+ public static Float32BinaryVector floatVector(final float[] data) {
notNull("data", data);
- return new Float32Vector(data);
+ return new Float32BinaryVector(data);
}
/**
- * Returns the {@link PackedBitVector}.
+ * Returns the {@link PackedBitBinaryVector}.
*
- * @return {@link PackedBitVector}.
+ * @return {@link PackedBitBinaryVector}.
* @throws IllegalStateException if this vector is not of type {@link DataType#PACKED_BIT}. Use {@link #getDataType()} to check the vector
* type before calling this method.
*/
- public PackedBitVector asPackedBitVector() {
+ public PackedBitBinaryVector asPackedBitVector() {
ensureType(DataType.PACKED_BIT);
- return (PackedBitVector) this;
+ return (PackedBitBinaryVector) this;
}
/**
- * Returns the {@link Int8Vector}.
+ * Returns the {@link Int8BinaryVector}.
*
- * @return {@link Int8Vector}.
+ * @return {@link Int8BinaryVector}.
* @throws IllegalStateException if this vector is not of type {@link DataType#INT8}. Use {@link #getDataType()} to check the vector
* type before calling this method.
*/
- public Int8Vector asInt8Vector() {
+ public Int8BinaryVector asInt8Vector() {
ensureType(DataType.INT8);
- return (Int8Vector) this;
+ return (Int8BinaryVector) this;
}
/**
- * Returns the {@link Float32Vector}.
+ * Returns the {@link Float32BinaryVector}.
*
- * @return {@link Float32Vector}.
+ * @return {@link Float32BinaryVector}.
* @throws IllegalStateException if this vector is not of type {@link DataType#FLOAT32}. Use {@link #getDataType()} to check the vector
* type before calling this method.
*/
- public Float32Vector asFloat32Vector() {
+ public Float32BinaryVector asFloat32Vector() {
ensureType(DataType.FLOAT32);
- return (Float32Vector) this;
+ return (Float32BinaryVector) this;
}
/**
diff --git a/bson/src/main/org/bson/BsonBinary.java b/bson/src/main/org/bson/BsonBinary.java
index 8590c2920be..833a1b5ad29 100644
--- a/bson/src/main/org/bson/BsonBinary.java
+++ b/bson/src/main/org/bson/BsonBinary.java
@@ -18,12 +18,12 @@
import org.bson.assertions.Assertions;
import org.bson.internal.UuidHelper;
-import org.bson.internal.vector.VectorHelper;
+import org.bson.internal.vector.BinaryVectorHelper;
import java.util.Arrays;
import java.util.UUID;
-import static org.bson.internal.vector.VectorHelper.encodeVectorToBinary;
+import static org.bson.internal.vector.BinaryVectorHelper.encodeVectorToBinary;
/**
* A representation of the BSON Binary type. Note that for performance reasons instances of this class are not immutable,
@@ -93,12 +93,12 @@ public BsonBinary(final UUID uuid) {
}
/**
- * Constructs a {@linkplain BsonBinarySubType#VECTOR subtype 9} {@link BsonBinary} from the given {@link Vector}.
+ * Constructs a {@linkplain BsonBinarySubType#VECTOR subtype 9} {@link BsonBinary} from the given {@link BinaryVector}.
*
- * @param vector the {@link Vector}
+ * @param vector the {@link BinaryVector}
* @since 5.3
*/
- public BsonBinary(final Vector vector) {
+ public BsonBinary(final BinaryVector vector) {
if (vector == null) {
throw new IllegalArgumentException("Vector must not be null");
}
@@ -145,18 +145,18 @@ public UUID asUuid() {
}
/**
- * Returns the binary as a {@link Vector}. The {@linkplain #getType() subtype} must be {@linkplain BsonBinarySubType#VECTOR 9}.
+ * Returns the binary as a {@link BinaryVector}. The {@linkplain #getType() subtype} must be {@linkplain BsonBinarySubType#VECTOR 9}.
*
* @return the vector
* @throws BsonInvalidOperationException if the binary subtype is not {@link BsonBinarySubType#VECTOR}.
* @since 5.3
*/
- public Vector asVector() {
+ public BinaryVector asVector() {
if (type != BsonBinarySubType.VECTOR.getValue()) {
throw new BsonInvalidOperationException("type must be a Vector subtype.");
}
- return VectorHelper.decodeBinaryToVector(this.data);
+ return BinaryVectorHelper.decodeBinaryToVector(this.data);
}
/**
diff --git a/bson/src/main/org/bson/BsonBinarySubType.java b/bson/src/main/org/bson/BsonBinarySubType.java
index 7b5948b4efc..08c29e2ef09 100644
--- a/bson/src/main/org/bson/BsonBinarySubType.java
+++ b/bson/src/main/org/bson/BsonBinarySubType.java
@@ -78,7 +78,7 @@ public enum BsonBinarySubType {
*
* @mongodb.server.release 6.0
* @since 5.3
- * @see Vector
+ * @see BinaryVector
*/
VECTOR((byte) 0x09),
diff --git a/bson/src/main/org/bson/Float32Vector.java b/bson/src/main/org/bson/Float32BinaryVector.java
similarity index 81%
rename from bson/src/main/org/bson/Float32Vector.java
rename to bson/src/main/org/bson/Float32BinaryVector.java
index 9678003b72f..37d1b8abb6e 100644
--- a/bson/src/main/org/bson/Float32Vector.java
+++ b/bson/src/main/org/bson/Float32BinaryVector.java
@@ -23,30 +23,30 @@
/**
* Represents a vector of 32-bit floating-point numbers, where each element in the vector is a float.
*
- * The {@link Float32Vector} is used to store and retrieve data efficiently using the BSON Binary Subtype 9 format.
+ * The {@link Float32BinaryVector} is used to store and retrieve data efficiently using the BSON Binary Subtype 9 format.
*
* @mongodb.server.release 6.0
- * @see Vector#floatVector(float[])
- * @see BsonBinary#BsonBinary(Vector)
+ * @see BinaryVector#floatVector(float[])
+ * @see BsonBinary#BsonBinary(BinaryVector)
* @see BsonBinary#asVector()
* @since 5.3
*/
-public final class Float32Vector extends Vector {
+public final class Float32BinaryVector extends BinaryVector {
private final float[] data;
- Float32Vector(final float[] vectorData) {
+ Float32BinaryVector(final float[] vectorData) {
super(DataType.FLOAT32);
this.data = assertNotNull(vectorData);
}
/**
- * Retrieve the underlying float array representing this {@link Float32Vector}, where each float
+ * Retrieve the underlying float array representing this {@link Float32BinaryVector}, where each float
* represents an element of a vector.
*
* NOTE: The underlying float array is not copied; changes to the returned array will be reflected in this instance.
*
- * @return the underlying float array representing this {@link Float32Vector} vector.
+ * @return the underlying float array representing this {@link Float32BinaryVector} vector.
*/
public float[] getData() {
return assertNotNull(data);
@@ -60,7 +60,7 @@ public boolean equals(final Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
- Float32Vector that = (Float32Vector) o;
+ Float32BinaryVector that = (Float32BinaryVector) o;
return Arrays.equals(data, that.data);
}
diff --git a/bson/src/main/org/bson/Int8Vector.java b/bson/src/main/org/bson/Int8BinaryVector.java
similarity index 81%
rename from bson/src/main/org/bson/Int8Vector.java
rename to bson/src/main/org/bson/Int8BinaryVector.java
index b61e6bfee55..a851aff94ff 100644
--- a/bson/src/main/org/bson/Int8Vector.java
+++ b/bson/src/main/org/bson/Int8BinaryVector.java
@@ -24,30 +24,30 @@
/**
* Represents a vector of 8-bit signed integers, where each element in the vector is a byte.
*
- * The {@link Int8Vector} is used to store and retrieve data efficiently using the BSON Binary Subtype 9 format.
+ * The {@link Int8BinaryVector} is used to store and retrieve data efficiently using the BSON Binary Subtype 9 format.
*
* @mongodb.server.release 6.0
- * @see Vector#int8Vector(byte[])
- * @see BsonBinary#BsonBinary(Vector)
+ * @see BinaryVector#int8Vector(byte[])
+ * @see BsonBinary#BsonBinary(BinaryVector)
* @see BsonBinary#asVector()
* @since 5.3
*/
-public final class Int8Vector extends Vector {
+public final class Int8BinaryVector extends BinaryVector {
private byte[] data;
- Int8Vector(final byte[] data) {
+ Int8BinaryVector(final byte[] data) {
super(DataType.INT8);
this.data = assertNotNull(data);
}
/**
- * Retrieve the underlying byte array representing this {@link Int8Vector} vector, where each byte represents
+ * Retrieve the underlying byte array representing this {@link Int8BinaryVector} vector, where each byte represents
* an element of a vector.
*
* NOTE: The underlying byte array is not copied; changes to the returned array will be reflected in this instance.
*
- * @return the underlying byte array representing this {@link Int8Vector} vector.
+ * @return the underlying byte array representing this {@link Int8BinaryVector} vector.
*/
public byte[] getData() {
return assertNotNull(data);
@@ -61,7 +61,7 @@ public boolean equals(final Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
- Int8Vector that = (Int8Vector) o;
+ Int8BinaryVector that = (Int8BinaryVector) o;
return Objects.deepEquals(data, that.data);
}
diff --git a/bson/src/main/org/bson/PackedBitVector.java b/bson/src/main/org/bson/PackedBitBinaryVector.java
similarity index 86%
rename from bson/src/main/org/bson/PackedBitVector.java
rename to bson/src/main/org/bson/PackedBitBinaryVector.java
index a5dd8f4dcdf..28d00174036 100644
--- a/bson/src/main/org/bson/PackedBitVector.java
+++ b/bson/src/main/org/bson/PackedBitBinaryVector.java
@@ -24,33 +24,33 @@
/**
* Represents a packed bit vector, where each element of the vector is represented by a single bit (0 or 1).
*
- * The {@link PackedBitVector} is used to store data efficiently using the BSON Binary Subtype 9 format.
+ * The {@link PackedBitBinaryVector} is used to store data efficiently using the BSON Binary Subtype 9 format.
*
* @mongodb.server.release 6.0
- * @see Vector#packedBitVector(byte[], byte)
- * @see BsonBinary#BsonBinary(Vector)
+ * @see BinaryVector#packedBitVector(byte[], byte)
+ * @see BsonBinary#BsonBinary(BinaryVector)
* @see BsonBinary#asVector()
* @since 5.3
*/
-public final class PackedBitVector extends Vector {
+public final class PackedBitBinaryVector extends BinaryVector {
private final byte padding;
private final byte[] data;
- PackedBitVector(final byte[] data, final byte padding) {
+ PackedBitBinaryVector(final byte[] data, final byte padding) {
super(DataType.PACKED_BIT);
this.data = assertNotNull(data);
this.padding = padding;
}
/**
- * Retrieve the underlying byte array representing this {@link PackedBitVector} vector, where
+ * Retrieve the underlying byte array representing this {@link PackedBitBinaryVector} vector, where
* each bit represents an element of the vector (either 0 or 1).
*
* Note that the {@linkplain #getPadding() padding value} should be considered when interpreting the final byte of the array,
* as it indicates how many least-significant bits are to be ignored.
*
- * @return the underlying byte array representing this {@link PackedBitVector} vector.
+ * @return the underlying byte array representing this {@link PackedBitBinaryVector} vector.
* @see #getPadding()
*/
public byte[] getData() {
@@ -81,7 +81,7 @@ public boolean equals(final Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
- PackedBitVector that = (PackedBitVector) o;
+ PackedBitBinaryVector that = (PackedBitBinaryVector) o;
return padding == that.padding && Arrays.equals(data, that.data);
}
diff --git a/bson/src/main/org/bson/codecs/VectorCodec.java b/bson/src/main/org/bson/codecs/BinaryVectorCodec.java
similarity index 74%
rename from bson/src/main/org/bson/codecs/VectorCodec.java
rename to bson/src/main/org/bson/codecs/BinaryVectorCodec.java
index 87d847664dc..4d23557ad49 100644
--- a/bson/src/main/org/bson/codecs/VectorCodec.java
+++ b/bson/src/main/org/bson/codecs/BinaryVectorCodec.java
@@ -21,21 +21,21 @@
import org.bson.BsonInvalidOperationException;
import org.bson.BsonReader;
import org.bson.BsonWriter;
-import org.bson.Vector;
+import org.bson.BinaryVector;
/**
- * Encodes and decodes {@link Vector} objects.
+ * Encodes and decodes {@link BinaryVector} objects.
*
*/
- final class VectorCodec implements Codec {
+ final class BinaryVectorCodec implements Codec {
@Override
- public void encode(final BsonWriter writer, final Vector vectorToEncode, final EncoderContext encoderContext) {
+ public void encode(final BsonWriter writer, final BinaryVector vectorToEncode, final EncoderContext encoderContext) {
writer.writeBinaryData(new BsonBinary(vectorToEncode));
}
@Override
- public Vector decode(final BsonReader reader, final DecoderContext decoderContext) {
+ public BinaryVector decode(final BsonReader reader, final DecoderContext decoderContext) {
byte subType = reader.peekBinarySubType();
if (subType != BsonBinarySubType.VECTOR.getValue()) {
@@ -48,8 +48,8 @@ public Vector decode(final BsonReader reader, final DecoderContext decoderContex
}
@Override
- public Class getEncoderClass() {
- return Vector.class;
+ public Class getEncoderClass() {
+ return BinaryVector.class;
}
}
diff --git a/bson/src/main/org/bson/codecs/ContainerCodecHelper.java b/bson/src/main/org/bson/codecs/ContainerCodecHelper.java
index b454206d5e8..2243f209528 100644
--- a/bson/src/main/org/bson/codecs/ContainerCodecHelper.java
+++ b/bson/src/main/org/bson/codecs/ContainerCodecHelper.java
@@ -21,7 +21,7 @@
import org.bson.BsonType;
import org.bson.Transformer;
import org.bson.UuidRepresentation;
-import org.bson.Vector;
+import org.bson.BinaryVector;
import org.bson.codecs.configuration.CodecConfigurationException;
import org.bson.codecs.configuration.CodecRegistry;
@@ -68,7 +68,7 @@ private static Codec> getBinarySubTypeCodec(final BsonReader reader,
final Codec> binaryTypeCodec) {
if (binarySubType == BsonBinarySubType.VECTOR.getValue()) {
- Codec vectorCodec = registry.get(Vector.class, registry);
+ Codec vectorCodec = registry.get(BinaryVector.class, registry);
if (vectorCodec != null) {
return vectorCodec;
}
diff --git a/bson/src/main/org/bson/codecs/Float32VectorCodec.java b/bson/src/main/org/bson/codecs/Float32BinaryVectorCodec.java
similarity index 72%
rename from bson/src/main/org/bson/codecs/Float32VectorCodec.java
rename to bson/src/main/org/bson/codecs/Float32BinaryVectorCodec.java
index a6df27e3f87..99f740a6873 100644
--- a/bson/src/main/org/bson/codecs/Float32VectorCodec.java
+++ b/bson/src/main/org/bson/codecs/Float32BinaryVectorCodec.java
@@ -21,21 +21,21 @@
import org.bson.BsonInvalidOperationException;
import org.bson.BsonReader;
import org.bson.BsonWriter;
-import org.bson.Float32Vector;
+import org.bson.Float32BinaryVector;
/**
- * Encodes and decodes {@link Float32Vector} objects.
+ * Encodes and decodes {@link Float32BinaryVector} objects.
*
*/
-final class Float32VectorCodec implements Codec {
+final class Float32BinaryVectorCodec implements Codec {
@Override
- public void encode(final BsonWriter writer, final Float32Vector vectorToEncode, final EncoderContext encoderContext) {
+ public void encode(final BsonWriter writer, final Float32BinaryVector vectorToEncode, final EncoderContext encoderContext) {
writer.writeBinaryData(new BsonBinary(vectorToEncode));
}
@Override
- public Float32Vector decode(final BsonReader reader, final DecoderContext decoderContext) {
+ public Float32BinaryVector decode(final BsonReader reader, final DecoderContext decoderContext) {
byte subType = reader.peekBinarySubType();
if (subType != BsonBinarySubType.VECTOR.getValue()) {
@@ -49,8 +49,8 @@ public Float32Vector decode(final BsonReader reader, final DecoderContext decode
}
@Override
- public Class getEncoderClass() {
- return Float32Vector.class;
+ public Class getEncoderClass() {
+ return Float32BinaryVector.class;
}
}
diff --git a/bson/src/main/org/bson/codecs/Int8VectorCodec.java b/bson/src/main/org/bson/codecs/Int8VectorCodec.java
index a9a70f53746..963da625d7f 100644
--- a/bson/src/main/org/bson/codecs/Int8VectorCodec.java
+++ b/bson/src/main/org/bson/codecs/Int8VectorCodec.java
@@ -21,22 +21,22 @@
import org.bson.BsonInvalidOperationException;
import org.bson.BsonReader;
import org.bson.BsonWriter;
-import org.bson.Int8Vector;
+import org.bson.Int8BinaryVector;
/**
- * Encodes and decodes {@link Int8Vector} objects.
+ * Encodes and decodes {@link Int8BinaryVector} objects.
*
* @since 5.3
*/
-final class Int8VectorCodec implements Codec {
+final class Int8VectorCodec implements Codec {
@Override
- public void encode(final BsonWriter writer, final Int8Vector vectorToEncode, final EncoderContext encoderContext) {
+ public void encode(final BsonWriter writer, final Int8BinaryVector vectorToEncode, final EncoderContext encoderContext) {
writer.writeBinaryData(new BsonBinary(vectorToEncode));
}
@Override
- public Int8Vector decode(final BsonReader reader, final DecoderContext decoderContext) {
+ public Int8BinaryVector decode(final BsonReader reader, final DecoderContext decoderContext) {
byte subType = reader.peekBinarySubType();
if (subType != BsonBinarySubType.VECTOR.getValue()) {
@@ -51,8 +51,8 @@ public Int8Vector decode(final BsonReader reader, final DecoderContext decoderCo
@Override
- public Class getEncoderClass() {
- return Int8Vector.class;
+ public Class getEncoderClass() {
+ return Int8BinaryVector.class;
}
}
diff --git a/bson/src/main/org/bson/codecs/PackedBitVectorCodec.java b/bson/src/main/org/bson/codecs/PackedBitBinaryVectorCodec.java
similarity index 72%
rename from bson/src/main/org/bson/codecs/PackedBitVectorCodec.java
rename to bson/src/main/org/bson/codecs/PackedBitBinaryVectorCodec.java
index 6fcb9552955..c8d0410a4c6 100644
--- a/bson/src/main/org/bson/codecs/PackedBitVectorCodec.java
+++ b/bson/src/main/org/bson/codecs/PackedBitBinaryVectorCodec.java
@@ -21,21 +21,21 @@
import org.bson.BsonInvalidOperationException;
import org.bson.BsonReader;
import org.bson.BsonWriter;
-import org.bson.PackedBitVector;
+import org.bson.PackedBitBinaryVector;
/**
- * Encodes and decodes {@link PackedBitVector} objects.
+ * Encodes and decodes {@link PackedBitBinaryVector} objects.
*
*/
-final class PackedBitVectorCodec implements Codec {
+final class PackedBitBinaryVectorCodec implements Codec {
@Override
- public void encode(final BsonWriter writer, final PackedBitVector vectorToEncode, final EncoderContext encoderContext) {
+ public void encode(final BsonWriter writer, final PackedBitBinaryVector vectorToEncode, final EncoderContext encoderContext) {
writer.writeBinaryData(new BsonBinary(vectorToEncode));
}
@Override
- public PackedBitVector decode(final BsonReader reader, final DecoderContext decoderContext) {
+ public PackedBitBinaryVector decode(final BsonReader reader, final DecoderContext decoderContext) {
byte subType = reader.peekBinarySubType();
if (subType != BsonBinarySubType.VECTOR.getValue()) {
@@ -51,8 +51,8 @@ public PackedBitVector decode(final BsonReader reader, final DecoderContext deco
@Override
- public Class getEncoderClass() {
- return PackedBitVector.class;
+ public Class getEncoderClass() {
+ return PackedBitBinaryVector.class;
}
}
diff --git a/bson/src/main/org/bson/codecs/ValueCodecProvider.java b/bson/src/main/org/bson/codecs/ValueCodecProvider.java
index 3a921c1b08a..5c21e048529 100644
--- a/bson/src/main/org/bson/codecs/ValueCodecProvider.java
+++ b/bson/src/main/org/bson/codecs/ValueCodecProvider.java
@@ -42,10 +42,10 @@
* {@link org.bson.codecs.StringCodec}
* {@link org.bson.codecs.SymbolCodec}
* {@link org.bson.codecs.UuidCodec}
- * {@link VectorCodec}
- * {@link Float32VectorCodec}
+ * {@link BinaryVectorCodec}
+ * {@link Float32BinaryVectorCodec}
* {@link Int8VectorCodec}
- * {@link PackedBitVectorCodec}
+ * {@link PackedBitBinaryVectorCodec}
* {@link org.bson.codecs.ByteCodec}
* {@link org.bson.codecs.ShortCodec}
* {@link org.bson.codecs.ByteArrayCodec}
@@ -90,10 +90,10 @@ private void addCodecs() {
addCodec(new StringCodec());
addCodec(new SymbolCodec());
addCodec(new OverridableUuidRepresentationUuidCodec());
- addCodec(new VectorCodec());
- addCodec(new Float32VectorCodec());
+ addCodec(new BinaryVectorCodec());
+ addCodec(new Float32BinaryVectorCodec());
addCodec(new Int8VectorCodec());
- addCodec(new PackedBitVectorCodec());
+ addCodec(new PackedBitBinaryVectorCodec());
addCodec(new ByteCodec());
addCodec(new PatternCodec());
diff --git a/bson/src/main/org/bson/internal/vector/VectorHelper.java b/bson/src/main/org/bson/internal/vector/BinaryVectorHelper.java
similarity index 81%
rename from bson/src/main/org/bson/internal/vector/VectorHelper.java
rename to bson/src/main/org/bson/internal/vector/BinaryVectorHelper.java
index 9dbf583d2b0..74d50d334fc 100644
--- a/bson/src/main/org/bson/internal/vector/VectorHelper.java
+++ b/bson/src/main/org/bson/internal/vector/BinaryVectorHelper.java
@@ -18,10 +18,10 @@
import org.bson.BsonBinary;
import org.bson.BsonInvalidOperationException;
-import org.bson.Float32Vector;
-import org.bson.Int8Vector;
-import org.bson.PackedBitVector;
-import org.bson.Vector;
+import org.bson.Float32BinaryVector;
+import org.bson.Int8BinaryVector;
+import org.bson.PackedBitBinaryVector;
+import org.bson.BinaryVector;
import org.bson.assertions.Assertions;
import org.bson.types.Binary;
@@ -35,29 +35,29 @@
*
* This class is not part of the public API and may be removed or changed at any time.
*
- * @see Vector
+ * @see BinaryVector
* @see BsonBinary#asVector()
- * @see BsonBinary#BsonBinary(Vector)
+ * @see BsonBinary#BsonBinary(BinaryVector)
*/
-public final class VectorHelper {
+public final class BinaryVectorHelper {
private static final ByteOrder STORED_BYTE_ORDER = ByteOrder.LITTLE_ENDIAN;
private static final String ERROR_MESSAGE_UNKNOWN_VECTOR_DATA_TYPE = "Unknown vector data type: ";
private static final byte ZERO_PADDING = 0;
- private VectorHelper() {
+ private BinaryVectorHelper() {
//NOP
}
private static final int METADATA_SIZE = 2;
- public static byte[] encodeVectorToBinary(final Vector vector) {
- Vector.DataType dataType = vector.getDataType();
+ public static byte[] encodeVectorToBinary(final BinaryVector vector) {
+ BinaryVector.DataType dataType = vector.getDataType();
switch (dataType) {
case INT8:
return encodeVector(dataType.getValue(), ZERO_PADDING, vector.asInt8Vector().getData());
case PACKED_BIT:
- PackedBitVector packedBitVector = vector.asPackedBitVector();
+ PackedBitBinaryVector packedBitVector = vector.asPackedBitVector();
return encodeVector(dataType.getValue(), packedBitVector.getPadding(), packedBitVector.getData());
case FLOAT32:
return encodeVector(dataType.getValue(), vector.asFloat32Vector().getData());
@@ -69,11 +69,11 @@ public static byte[] encodeVectorToBinary(final Vector vector) {
/**
* Decodes a vector from a binary representation.
*
- * encodedVector is not mutated nor stored in the returned {@link Vector}.
+ * encodedVector is not mutated nor stored in the returned {@link BinaryVector}.
*/
- public static Vector decodeBinaryToVector(final byte[] encodedVector) {
+ public static BinaryVector decodeBinaryToVector(final byte[] encodedVector) {
isTrue("Vector encoded array length must be at least 2, but found: " + encodedVector.length, encodedVector.length >= METADATA_SIZE);
- Vector.DataType dataType = determineVectorDType(encodedVector[0]);
+ BinaryVector.DataType dataType = determineVectorDType(encodedVector[0]);
byte padding = encodedVector[1];
switch (dataType) {
case INT8:
@@ -87,22 +87,22 @@ public static Vector decodeBinaryToVector(final byte[] encodedVector) {
}
}
- private static Float32Vector decodeFloat32Vector(final byte[] encodedVector, final byte padding) {
+ private static Float32BinaryVector decodeFloat32Vector(final byte[] encodedVector, final byte padding) {
isTrue("Padding must be 0 for FLOAT32 data type, but found: " + padding, padding == 0);
- return Vector.floatVector(decodeLittleEndianFloats(encodedVector));
+ return BinaryVector.floatVector(decodeLittleEndianFloats(encodedVector));
}
- private static PackedBitVector decodePackedBitVector(final byte[] encodedVector, final byte padding) {
+ private static PackedBitBinaryVector decodePackedBitVector(final byte[] encodedVector, final byte padding) {
byte[] packedBitVector = extractVectorData(encodedVector);
isTrue("Padding must be 0 if vector is empty, but found: " + padding, padding == 0 || packedBitVector.length > 0);
isTrue("Padding must be between 0 and 7 bits, but found: " + padding, padding >= 0 && padding <= 7);
- return Vector.packedBitVector(packedBitVector, padding);
+ return BinaryVector.packedBitVector(packedBitVector, padding);
}
- private static Int8Vector decodeInt8Vector(final byte[] encodedVector, final byte padding) {
+ private static Int8BinaryVector decodeInt8Vector(final byte[] encodedVector, final byte padding) {
isTrue("Padding must be 0 for INT8 data type, but found: " + padding, padding == 0);
byte[] int8Vector = extractVectorData(encodedVector);
- return Vector.int8Vector(int8Vector);
+ return BinaryVector.int8Vector(int8Vector);
}
private static byte[] extractVectorData(final byte[] encodedVector) {
@@ -159,9 +159,9 @@ private static float[] decodeLittleEndianFloats(final byte[] encodedVector) {
return floatArray;
}
- public static Vector.DataType determineVectorDType(final byte dType) {
- Vector.DataType[] values = Vector.DataType.values();
- for (Vector.DataType value : values) {
+ public static BinaryVector.DataType determineVectorDType(final byte dType) {
+ BinaryVector.DataType[] values = BinaryVector.DataType.values();
+ for (BinaryVector.DataType value : values) {
if (value.getValue() == dType) {
return value;
}
diff --git a/bson/src/test/unit/org/bson/VectorTest.java b/bson/src/test/unit/org/bson/BinaryVectorTest.java
similarity index 82%
rename from bson/src/test/unit/org/bson/VectorTest.java
rename to bson/src/test/unit/org/bson/BinaryVectorTest.java
index 36cc7156db6..57e8b294019 100644
--- a/bson/src/test/unit/org/bson/VectorTest.java
+++ b/bson/src/test/unit/org/bson/BinaryVectorTest.java
@@ -25,7 +25,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
-class VectorTest {
+class BinaryVectorTest {
@Test
void shouldCreateInt8Vector() {
@@ -33,11 +33,11 @@ void shouldCreateInt8Vector() {
byte[] data = {1, 2, 3, 4, 5};
// when
- Int8Vector vector = Vector.int8Vector(data);
+ Int8BinaryVector vector = BinaryVector.int8Vector(data);
// then
assertNotNull(vector);
- assertEquals(Vector.DataType.INT8, vector.getDataType());
+ assertEquals(BinaryVector.DataType.INT8, vector.getDataType());
assertArrayEquals(data, vector.getData());
}
@@ -47,7 +47,7 @@ void shouldThrowExceptionWhenCreatingInt8VectorWithNullData() {
byte[] data = null;
// when & Then
- IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> Vector.int8Vector(data));
+ IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> BinaryVector.int8Vector(data));
assertEquals("data can not be null", exception.getMessage());
}
@@ -57,11 +57,11 @@ void shouldCreateFloat32Vector() {
float[] data = {1.0f, 2.0f, 3.0f};
// when
- Float32Vector vector = Vector.floatVector(data);
+ Float32BinaryVector vector = BinaryVector.floatVector(data);
// then
assertNotNull(vector);
- assertEquals(Vector.DataType.FLOAT32, vector.getDataType());
+ assertEquals(BinaryVector.DataType.FLOAT32, vector.getDataType());
assertArrayEquals(data, vector.getData());
}
@@ -71,7 +71,7 @@ void shouldThrowExceptionWhenCreatingFloat32VectorWithNullData() {
float[] data = null;
// when & Then
- IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> Vector.floatVector(data));
+ IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> BinaryVector.floatVector(data));
assertEquals("data can not be null", exception.getMessage());
}
@@ -83,11 +83,11 @@ void shouldCreatePackedBitVector(final byte validPadding) {
byte[] data = {(byte) 0b10101010, (byte) 0b01010101};
// when
- PackedBitVector vector = Vector.packedBitVector(data, validPadding);
+ PackedBitBinaryVector vector = BinaryVector.packedBitVector(data, validPadding);
// then
assertNotNull(vector);
- assertEquals(Vector.DataType.PACKED_BIT, vector.getDataType());
+ assertEquals(BinaryVector.DataType.PACKED_BIT, vector.getDataType());
assertArrayEquals(data, vector.getData());
assertEquals(validPadding, vector.getPadding());
}
@@ -100,7 +100,7 @@ void shouldThrowExceptionWhenPackedBitVectorHasInvalidPadding(final byte invalid
// when & Then
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () ->
- Vector.packedBitVector(data, invalidPadding));
+ BinaryVector.packedBitVector(data, invalidPadding));
assertEquals("state should be: Padding must be between 0 and 7 bits. Provided padding: " + invalidPadding, exception.getMessage());
}
@@ -112,7 +112,7 @@ void shouldThrowExceptionWhenPackedBitVectorIsCreatedWithNullData() {
// when & Then
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () ->
- Vector.packedBitVector(data, padding));
+ BinaryVector.packedBitVector(data, padding));
assertEquals("data can not be null", exception.getMessage());
}
@@ -123,11 +123,11 @@ void shouldCreatePackedBitVectorWithZeroPaddingAndEmptyData() {
byte padding = 0;
// when
- PackedBitVector vector = Vector.packedBitVector(data, padding);
+ PackedBitBinaryVector vector = BinaryVector.packedBitVector(data, padding);
// then
assertNotNull(vector);
- assertEquals(Vector.DataType.PACKED_BIT, vector.getDataType());
+ assertEquals(BinaryVector.DataType.PACKED_BIT, vector.getDataType());
assertArrayEquals(data, vector.getData());
assertEquals(padding, vector.getPadding());
}
@@ -140,7 +140,7 @@ void shouldThrowExceptionWhenPackedBitVectorWithNonZeroPaddingAndEmptyData() {
// when & Then
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () ->
- Vector.packedBitVector(data, padding));
+ BinaryVector.packedBitVector(data, padding));
assertEquals("state should be: Padding must be 0 if vector is empty. Provided padding: " + padding, exception.getMessage());
}
@@ -148,7 +148,7 @@ void shouldThrowExceptionWhenPackedBitVectorWithNonZeroPaddingAndEmptyData() {
void shouldThrowExceptionWhenRetrievingInt8DataFromNonInt8Vector() {
// given
float[] data = {1.0f, 2.0f};
- Vector vector = Vector.floatVector(data);
+ BinaryVector vector = BinaryVector.floatVector(data);
// when & Then
IllegalStateException exception = assertThrows(IllegalStateException.class, vector::asInt8Vector);
@@ -159,7 +159,7 @@ void shouldThrowExceptionWhenRetrievingInt8DataFromNonInt8Vector() {
void shouldThrowExceptionWhenRetrievingFloat32DataFromNonFloat32Vector() {
// given
byte[] data = {1, 2, 3};
- Vector vector = Vector.int8Vector(data);
+ BinaryVector vector = BinaryVector.int8Vector(data);
// when & Then
IllegalStateException exception = assertThrows(IllegalStateException.class, vector::asFloat32Vector);
@@ -170,7 +170,7 @@ void shouldThrowExceptionWhenRetrievingFloat32DataFromNonFloat32Vector() {
void shouldThrowExceptionWhenRetrievingPackedBitDataFromNonPackedBitVector() {
// given
float[] data = {1.0f, 2.0f};
- Vector vector = Vector.floatVector(data);
+ BinaryVector vector = BinaryVector.floatVector(data);
// when & Then
IllegalStateException exception = assertThrows(IllegalStateException.class, vector::asPackedBitVector);
diff --git a/bson/src/test/unit/org/bson/BsonBinaryTest.java b/bson/src/test/unit/org/bson/BsonBinaryTest.java
index 029c611c594..b47bcbf8a79 100644
--- a/bson/src/test/unit/org/bson/BsonBinaryTest.java
+++ b/bson/src/test/unit/org/bson/BsonBinaryTest.java
@@ -32,15 +32,15 @@
class BsonBinaryTest {
- private static final byte FLOAT32_DTYPE = Vector.DataType.FLOAT32.getValue();
- private static final byte INT8_DTYPE = Vector.DataType.INT8.getValue();
- private static final byte PACKED_BIT_DTYPE = Vector.DataType.PACKED_BIT.getValue();
+ private static final byte FLOAT32_DTYPE = BinaryVector.DataType.FLOAT32.getValue();
+ private static final byte INT8_DTYPE = BinaryVector.DataType.INT8.getValue();
+ private static final byte PACKED_BIT_DTYPE = BinaryVector.DataType.PACKED_BIT.getValue();
public static final int ZERO_PADDING = 0;
@Test
void shouldThrowExceptionWhenCreatingBsonBinaryWithNullVector() {
// given
- Vector vector = null;
+ BinaryVector vector = null;
// when & then
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> new BsonBinary(vector));
@@ -61,7 +61,7 @@ void shouldThrowExceptionWhenBsonBinarySubTypeIsNotVector(final BsonBinarySubTyp
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("provideFloatVectors")
- void shouldEncodeFloatVector(final Vector actualFloat32Vector, final byte[] expectedBsonEncodedVector) {
+ void shouldEncodeFloatVector(final BinaryVector actualFloat32Vector, final byte[] expectedBsonEncodedVector) {
// when
BsonBinary actualBsonBinary = new BsonBinary(actualFloat32Vector);
byte[] actualBsonEncodedVector = actualBsonBinary.getData();
@@ -73,9 +73,9 @@ void shouldEncodeFloatVector(final Vector actualFloat32Vector, final byte[] expe
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("provideFloatVectors")
- void shouldDecodeFloatVector(final Float32Vector expectedFloatVector, final byte[] bsonEncodedVector) {
+ void shouldDecodeFloatVector(final Float32BinaryVector expectedFloatVector, final byte[] bsonEncodedVector) {
// when
- Float32Vector decodedVector = (Float32Vector) new BsonBinary(BsonBinarySubType.VECTOR, bsonEncodedVector).asVector();
+ Float32BinaryVector decodedVector = (Float32BinaryVector) new BsonBinary(BsonBinarySubType.VECTOR, bsonEncodedVector).asVector();
// then
assertEquals(expectedFloatVector, decodedVector);
@@ -84,7 +84,7 @@ void shouldDecodeFloatVector(final Float32Vector expectedFloatVector, final byte
private static Stream provideFloatVectors() {
return Stream.of(
arguments(
- Vector.floatVector(new float[]{1.1f, 2.2f, 3.3f, -1.0f, Float.MAX_VALUE, Float.MIN_VALUE, Float.POSITIVE_INFINITY,
+ BinaryVector.floatVector(new float[]{1.1f, 2.2f, 3.3f, -1.0f, Float.MAX_VALUE, Float.MIN_VALUE, Float.POSITIVE_INFINITY,
Float.NEGATIVE_INFINITY}),
new byte[]{FLOAT32_DTYPE, ZERO_PADDING,
(byte) 205, (byte) 204, (byte) 140, (byte) 63, // 1.1f in little-endian
@@ -98,13 +98,13 @@ private static Stream provideFloatVectors() {
}
),
arguments(
- Vector.floatVector(new float[]{0.0f}),
+ BinaryVector.floatVector(new float[]{0.0f}),
new byte[]{FLOAT32_DTYPE, ZERO_PADDING,
(byte) 0, (byte) 0, (byte) 0, (byte) 0 // 0.0f in little-endian
}
),
arguments(
- Vector.floatVector(new float[]{}),
+ BinaryVector.floatVector(new float[]{}),
new byte[]{FLOAT32_DTYPE, ZERO_PADDING}
)
);
@@ -112,7 +112,7 @@ private static Stream provideFloatVectors() {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("provideInt8Vectors")
- void shouldEncodeInt8Vector(final Vector actualInt8Vector, final byte[] expectedBsonEncodedVector) {
+ void shouldEncodeInt8Vector(final BinaryVector actualInt8Vector, final byte[] expectedBsonEncodedVector) {
// when
BsonBinary actualBsonBinary = new BsonBinary(actualInt8Vector);
byte[] actualBsonEncodedVector = actualBsonBinary.getData();
@@ -124,9 +124,9 @@ void shouldEncodeInt8Vector(final Vector actualInt8Vector, final byte[] expected
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("provideInt8Vectors")
- void shouldDecodeInt8Vector(final Int8Vector expectedInt8Vector, final byte[] bsonEncodedVector) {
+ void shouldDecodeInt8Vector(final Int8BinaryVector expectedInt8Vector, final byte[] bsonEncodedVector) {
// when
- Int8Vector decodedVector = (Int8Vector) new BsonBinary(BsonBinarySubType.VECTOR, bsonEncodedVector).asVector();
+ Int8BinaryVector decodedVector = (Int8BinaryVector) new BsonBinary(BsonBinarySubType.VECTOR, bsonEncodedVector).asVector();
// then
assertEquals(expectedInt8Vector, decodedVector);
@@ -135,10 +135,10 @@ void shouldDecodeInt8Vector(final Int8Vector expectedInt8Vector, final byte[] bs
private static Stream provideInt8Vectors() {
return Stream.of(
arguments(
- Vector.int8Vector(new byte[]{Byte.MAX_VALUE, 1, 2, 3, 4, Byte.MIN_VALUE}),
+ BinaryVector.int8Vector(new byte[]{Byte.MAX_VALUE, 1, 2, 3, 4, Byte.MIN_VALUE}),
new byte[]{INT8_DTYPE, ZERO_PADDING, Byte.MAX_VALUE, 1, 2, 3, 4, Byte.MIN_VALUE
}),
- arguments(Vector.int8Vector(new byte[]{}),
+ arguments(BinaryVector.int8Vector(new byte[]{}),
new byte[]{INT8_DTYPE, ZERO_PADDING}
)
);
@@ -146,7 +146,7 @@ private static Stream provideInt8Vectors() {
@ParameterizedTest
@MethodSource("providePackedBitVectors")
- void shouldEncodePackedBitVector(final Vector actualPackedBitVector, final byte[] expectedBsonEncodedVector) {
+ void shouldEncodePackedBitVector(final BinaryVector actualPackedBitVector, final byte[] expectedBsonEncodedVector) {
// when
BsonBinary actualBsonBinary = new BsonBinary(actualPackedBitVector);
byte[] actualBsonEncodedVector = actualBsonBinary.getData();
@@ -158,9 +158,9 @@ void shouldEncodePackedBitVector(final Vector actualPackedBitVector, final byte[
@ParameterizedTest
@MethodSource("providePackedBitVectors")
- void shouldDecodePackedBitVector(final PackedBitVector expectedPackedBitVector, final byte[] bsonEncodedVector) {
+ void shouldDecodePackedBitVector(final PackedBitBinaryVector expectedPackedBitVector, final byte[] bsonEncodedVector) {
// when
- PackedBitVector decodedVector = (PackedBitVector) new BsonBinary(BsonBinarySubType.VECTOR, bsonEncodedVector).asVector();
+ PackedBitBinaryVector decodedVector = (PackedBitBinaryVector) new BsonBinary(BsonBinarySubType.VECTOR, bsonEncodedVector).asVector();
// then
assertEquals(expectedPackedBitVector, decodedVector);
@@ -169,11 +169,11 @@ void shouldDecodePackedBitVector(final PackedBitVector expectedPackedBitVector,
private static Stream providePackedBitVectors() {
return Stream.of(
arguments(
- Vector.packedBitVector(new byte[]{(byte) 0, (byte) 255, (byte) 10}, (byte) 2),
+ BinaryVector.packedBitVector(new byte[]{(byte) 0, (byte) 255, (byte) 10}, (byte) 2),
new byte[]{PACKED_BIT_DTYPE, 2, (byte) 0, (byte) 255, (byte) 10}
),
arguments(
- Vector.packedBitVector(new byte[0], (byte) 0),
+ BinaryVector.packedBitVector(new byte[0], (byte) 0),
new byte[]{PACKED_BIT_DTYPE, 0}
));
}
diff --git a/bson/src/test/unit/org/bson/BsonBinaryWriterTest.java b/bson/src/test/unit/org/bson/BsonBinaryWriterTest.java
index c9e22fcce7a..8e0f7c23c28 100644
--- a/bson/src/test/unit/org/bson/BsonBinaryWriterTest.java
+++ b/bson/src/test/unit/org/bson/BsonBinaryWriterTest.java
@@ -40,7 +40,7 @@
public class BsonBinaryWriterTest {
- private static final byte FLOAT32_DTYPE = Vector.DataType.FLOAT32.getValue();
+ private static final byte FLOAT32_DTYPE = BinaryVector.DataType.FLOAT32.getValue();
private static final int ZERO_PADDING = 0;
private BsonBinaryWriter writer;
diff --git a/bson/src/test/unit/org/bson/codecs/VectorCodecTest.java b/bson/src/test/unit/org/bson/codecs/BinaryBinaryVectorCodecTest.java
similarity index 73%
rename from bson/src/test/unit/org/bson/codecs/VectorCodecTest.java
rename to bson/src/test/unit/org/bson/codecs/BinaryBinaryVectorCodecTest.java
index bf33af90cae..fadddb7a635 100644
--- a/bson/src/test/unit/org/bson/codecs/VectorCodecTest.java
+++ b/bson/src/test/unit/org/bson/codecs/BinaryBinaryVectorCodecTest.java
@@ -25,10 +25,10 @@
import org.bson.BsonType;
import org.bson.BsonWriter;
import org.bson.ByteBufNIO;
-import org.bson.Float32Vector;
-import org.bson.Int8Vector;
-import org.bson.PackedBitVector;
-import org.bson.Vector;
+import org.bson.Float32BinaryVector;
+import org.bson.Int8BinaryVector;
+import org.bson.PackedBitBinaryVector;
+import org.bson.BinaryVector;
import org.bson.io.BasicOutputBuffer;
import org.bson.io.ByteBufferBsonInput;
import org.bson.io.OutputBuffer;
@@ -50,22 +50,22 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.params.provider.Arguments.arguments;
-class VectorCodecTest extends CodecTestCase {
+class BinaryBinaryVectorCodecTest extends CodecTestCase {
private static Stream provideVectorsAndCodecs() {
return Stream.of(
- arguments(Vector.floatVector(new float[]{1.1f, 2.2f, 3.3f}), new Float32VectorCodec(), Float32Vector.class),
- arguments(Vector.int8Vector(new byte[]{10, 20, 30, 40}), new Int8VectorCodec(), Int8Vector.class),
- arguments(Vector.packedBitVector(new byte[]{(byte) 0b10101010, (byte) 0b01010101}, (byte) 3), new PackedBitVectorCodec(), PackedBitVector.class),
- arguments(Vector.packedBitVector(new byte[]{(byte) 0b10101010, (byte) 0b01010101}, (byte) 3), new VectorCodec(), Vector.class),
- arguments(Vector.int8Vector(new byte[]{10, 20, 30, 40}), new VectorCodec(), Vector.class),
- arguments(Vector.packedBitVector(new byte[]{(byte) 0b10101010, (byte) 0b01010101}, (byte) 3), new VectorCodec(), Vector.class)
+ arguments(BinaryVector.floatVector(new float[]{1.1f, 2.2f, 3.3f}), new Float32BinaryVectorCodec(), Float32BinaryVector.class),
+ arguments(BinaryVector.int8Vector(new byte[]{10, 20, 30, 40}), new Int8VectorCodec(), Int8BinaryVector.class),
+ arguments(BinaryVector.packedBitVector(new byte[]{(byte) 0b10101010, (byte) 0b01010101}, (byte) 3), new PackedBitBinaryVectorCodec(), PackedBitBinaryVector.class),
+ arguments(BinaryVector.packedBitVector(new byte[]{(byte) 0b10101010, (byte) 0b01010101}, (byte) 3), new BinaryVectorCodec(), BinaryVector.class),
+ arguments(BinaryVector.int8Vector(new byte[]{10, 20, 30, 40}), new BinaryVectorCodec(), BinaryVector.class),
+ arguments(BinaryVector.packedBitVector(new byte[]{(byte) 0b10101010, (byte) 0b01010101}, (byte) 3), new BinaryVectorCodec(), BinaryVector.class)
);
}
@ParameterizedTest
@MethodSource("provideVectorsAndCodecs")
- void shouldEncodeVector(final Vector vectorToEncode, final Codec vectorCodec) throws IOException {
+ void shouldEncodeVector(final BinaryVector vectorToEncode, final Codec vectorCodec) throws IOException {
// given
BsonBinary bsonBinary = new BsonBinary(vectorToEncode);
byte[] encodedVector = bsonBinary.getData();
@@ -98,7 +98,7 @@ void shouldEncodeVector(final Vector vectorToEncode, final Codec vectorC
@ParameterizedTest
@MethodSource("provideVectorsAndCodecs")
- void shouldDecodeVector(final Vector vectorToDecode, final Codec vectorCodec) {
+ void shouldDecodeVector(final BinaryVector vectorToDecode, final Codec vectorCodec) {
// given
OutputBuffer buffer = new BasicOutputBuffer();
BsonWriter writer = new BsonBinaryWriter(buffer);
@@ -111,7 +111,7 @@ void shouldDecodeVector(final Vector vectorToDecode, final Codec vectorC
reader.readStartDocument();
// when
- Vector decodedVector = vectorCodec.decode(reader, DecoderContext.builder().build());
+ BinaryVector decodedVector = vectorCodec.decode(reader, DecoderContext.builder().build());
// then
assertDoesNotThrow(reader::readEndDocument);
@@ -129,7 +129,7 @@ void shouldThrowExceptionForInvalidSubType(final BsonBinarySubType subType) {
reader.readStartDocument();
// when & then
- Stream.of(new Float32VectorCodec(), new Int8VectorCodec(), new PackedBitVectorCodec())
+ Stream.of(new Float32BinaryVectorCodec(), new Int8VectorCodec(), new PackedBitBinaryVectorCodec())
.forEach(codec -> {
BsonInvalidOperationException exception = assertThrows(BsonInvalidOperationException.class, () ->
codec.decode(reader, DecoderContext.builder().build()));
@@ -140,11 +140,11 @@ void shouldThrowExceptionForInvalidSubType(final BsonBinarySubType subType) {
@ParameterizedTest
@MethodSource("provideVectorsAndCodecs")
- void shouldReturnCorrectEncoderClass(final Vector vector,
- final Codec extends Vector> codec,
- final Class extends Vector> expectedEncoderClass) {
+ void shouldReturnCorrectEncoderClass(final BinaryVector vector,
+ final Codec extends BinaryVector> codec,
+ final Class extends BinaryVector> expectedEncoderClass) {
// when
- Class extends Vector> encoderClass = codec.getEncoderClass();
+ Class extends BinaryVector> encoderClass = codec.getEncoderClass();
// then
assertEquals(expectedEncoderClass, encoderClass);
diff --git a/bson/src/test/unit/org/bson/codecs/DocumentCodecTest.java b/bson/src/test/unit/org/bson/codecs/DocumentCodecTest.java
index 67c6b561aa5..7343707d5a7 100644
--- a/bson/src/test/unit/org/bson/codecs/DocumentCodecTest.java
+++ b/bson/src/test/unit/org/bson/codecs/DocumentCodecTest.java
@@ -23,7 +23,7 @@
import org.bson.BsonObjectId;
import org.bson.ByteBufNIO;
import org.bson.Document;
-import org.bson.Vector;
+import org.bson.BinaryVector;
import org.bson.io.BasicOutputBuffer;
import org.bson.io.BsonInput;
import org.bson.io.ByteBufferBsonInput;
@@ -81,9 +81,9 @@ public void testPrimitiveBSONTypeCodecs() throws IOException {
doc.put("code", new Code("var i = 0"));
doc.put("minkey", new MinKey());
doc.put("maxkey", new MaxKey());
- doc.put("vectorFloat", Vector.floatVector(new float[]{1.1f, 2.2f, 3.3f}));
- doc.put("vectorInt8", Vector.int8Vector(new byte[]{10, 20, 30, 40}));
- doc.put("vectorPackedBit", Vector.packedBitVector(new byte[]{(byte) 0b10101010, (byte) 0b01010101}, (byte) 3));
+ doc.put("vectorFloat", BinaryVector.floatVector(new float[]{1.1f, 2.2f, 3.3f}));
+ doc.put("vectorInt8", BinaryVector.int8Vector(new byte[]{10, 20, 30, 40}));
+ doc.put("vectorPackedBit", BinaryVector.packedBitVector(new byte[]{(byte) 0b10101010, (byte) 0b01010101}, (byte) 3));
// doc.put("pattern", Pattern.compile("^hello")); // TODO: Pattern doesn't override equals method!
doc.put("null", null);
diff --git a/bson/src/test/unit/org/bson/codecs/ValueCodecProviderSpecification.groovy b/bson/src/test/unit/org/bson/codecs/ValueCodecProviderSpecification.groovy
index 23c46fb7b0b..1fd738b5c5c 100644
--- a/bson/src/test/unit/org/bson/codecs/ValueCodecProviderSpecification.groovy
+++ b/bson/src/test/unit/org/bson/codecs/ValueCodecProviderSpecification.groovy
@@ -17,10 +17,10 @@
package org.bson.codecs
import org.bson.Document
-import org.bson.Float32Vector
-import org.bson.Int8Vector
-import org.bson.PackedBitVector
-import org.bson.Vector
+import org.bson.Float32BinaryVector
+import org.bson.Int8BinaryVector
+import org.bson.PackedBitBinaryVector
+import org.bson.BinaryVector
import org.bson.codecs.configuration.CodecRegistries
import org.bson.types.Binary
import org.bson.types.Code
@@ -62,10 +62,10 @@ class ValueCodecProviderSpecification extends Specification {
provider.get(Short, registry) instanceof ShortCodec
provider.get(byte[], registry) instanceof ByteArrayCodec
provider.get(Float, registry) instanceof FloatCodec
- provider.get(Vector, registry) instanceof VectorCodec
- provider.get(Float32Vector, registry) instanceof Float32VectorCodec
- provider.get(Int8Vector, registry) instanceof Int8VectorCodec
- provider.get(PackedBitVector, registry) instanceof PackedBitVectorCodec
+ provider.get(BinaryVector, registry) instanceof BinaryVectorCodec
+ provider.get(Float32BinaryVector, registry) instanceof Float32BinaryVectorCodec
+ provider.get(Int8BinaryVector, registry) instanceof Int8VectorCodec
+ provider.get(PackedBitBinaryVector, registry) instanceof PackedBitBinaryVectorCodec
provider.get(Binary, registry) instanceof BinaryCodec
provider.get(MinKey, registry) instanceof MinKeyCodec
diff --git a/bson/src/test/unit/org/bson/vector/VectorGenericBsonTest.java b/bson/src/test/unit/org/bson/vector/BinaryVectorGenericBsonTest.java
similarity index 87%
rename from bson/src/test/unit/org/bson/vector/VectorGenericBsonTest.java
rename to bson/src/test/unit/org/bson/vector/BinaryVectorGenericBsonTest.java
index 64e84f6afc8..858174d7cd9 100644
--- a/bson/src/test/unit/org/bson/vector/VectorGenericBsonTest.java
+++ b/bson/src/test/unit/org/bson/vector/BinaryVectorGenericBsonTest.java
@@ -21,9 +21,9 @@
import org.bson.BsonDocument;
import org.bson.BsonString;
import org.bson.BsonValue;
-import org.bson.Float32Vector;
-import org.bson.PackedBitVector;
-import org.bson.Vector;
+import org.bson.Float32BinaryVector;
+import org.bson.PackedBitBinaryVector;
+import org.bson.BinaryVector;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@@ -41,7 +41,7 @@
import static java.lang.String.format;
import static org.bson.BsonHelper.decodeToDocument;
import static org.bson.BsonHelper.encodeToHex;
-import static org.bson.internal.vector.VectorHelper.determineVectorDType;
+import static org.bson.internal.vector.BinaryVectorHelper.determineVectorDType;
import static org.junit.Assert.assertThrows;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -51,7 +51,7 @@
* See
* JSON-based tests that included in test resources.
*/
-class VectorGenericBsonTest {
+class BinaryVectorGenericBsonTest {
private static final List TEST_NAMES_TO_IGNORE = Arrays.asList(
//NO API to set padding for floats available.
@@ -91,22 +91,22 @@ private static void runInvalidTestCase(final BsonDocument testCase) {
BsonArray arrayVector = testCase.getArray("vector");
byte expectedPadding = (byte) testCase.getInt32("padding").getValue();
byte dtypeByte = Byte.decode(testCase.getString("dtype_hex").getValue());
- Vector.DataType expectedDType = determineVectorDType(dtypeByte);
+ BinaryVector.DataType expectedDType = determineVectorDType(dtypeByte);
switch (expectedDType) {
case INT8:
byte[] expectedVectorData = toByteArray(arrayVector);
assertValidationException(assertThrows(RuntimeException.class,
- () -> Vector.int8Vector(expectedVectorData)));
+ () -> BinaryVector.int8Vector(expectedVectorData)));
break;
case PACKED_BIT:
byte[] expectedVectorPackedBitData = toByteArray(arrayVector);
assertValidationException(assertThrows(RuntimeException.class,
- () -> Vector.packedBitVector(expectedVectorPackedBitData, expectedPadding)));
+ () -> BinaryVector.packedBitVector(expectedVectorPackedBitData, expectedPadding)));
break;
case FLOAT32:
float[] expectedFloatVector = toFloatArray(arrayVector);
- assertValidationException(assertThrows(RuntimeException.class, () -> Vector.floatVector(expectedFloatVector)));
+ assertValidationException(assertThrows(RuntimeException.class, () -> BinaryVector.floatVector(expectedFloatVector)));
break;
default:
throw new IllegalArgumentException("Unsupported vector data type: " + expectedDType);
@@ -118,12 +118,12 @@ private static void runValidTestCase(final String testKey, final BsonDocument te
byte dtypeByte = Byte.decode(testCase.getString("dtype_hex").getValue());
byte expectedPadding = (byte) testCase.getInt32("padding").getValue();
- Vector.DataType expectedDType = determineVectorDType(dtypeByte);
+ BinaryVector.DataType expectedDType = determineVectorDType(dtypeByte);
String expectedCanonicalBsonHex = testCase.getString("canonical_bson").getValue().toUpperCase();
BsonArray arrayVector = testCase.getArray("vector");
BsonDocument actualDecodedDocument = decodeToDocument(expectedCanonicalBsonHex, description);
- Vector actualVector = actualDecodedDocument.getBinary("vector").asVector();
+ BinaryVector actualVector = actualDecodedDocument.getBinary("vector").asVector();
switch (expectedDType) {
case INT8:
@@ -135,14 +135,14 @@ private static void runValidTestCase(final String testKey, final BsonDocument te
actualVectorData,
actualVector);
- assertThatVectorCreationResultsInCorrectBinary(Vector.int8Vector(expectedVectorData),
+ assertThatVectorCreationResultsInCorrectBinary(BinaryVector.int8Vector(expectedVectorData),
testKey,
actualDecodedDocument,
expectedCanonicalBsonHex,
description);
break;
case PACKED_BIT:
- PackedBitVector actualPackedBitVector = actualVector.asPackedBitVector();
+ PackedBitBinaryVector actualPackedBitVector = actualVector.asPackedBitVector();
byte[] expectedVectorPackedBitData = toByteArray(arrayVector);
assertVectorDecoding(
expectedVectorPackedBitData,
@@ -150,21 +150,21 @@ private static void runValidTestCase(final String testKey, final BsonDocument te
actualPackedBitVector);
assertThatVectorCreationResultsInCorrectBinary(
- Vector.packedBitVector(expectedVectorPackedBitData, expectedPadding),
+ BinaryVector.packedBitVector(expectedVectorPackedBitData, expectedPadding),
testKey,
actualDecodedDocument,
expectedCanonicalBsonHex,
description);
break;
case FLOAT32:
- Float32Vector actualFloat32Vector = actualVector.asFloat32Vector();
+ Float32BinaryVector actualFloat32Vector = actualVector.asFloat32Vector();
float[] expectedFloatVector = toFloatArray(arrayVector);
assertVectorDecoding(
expectedFloatVector,
expectedDType,
actualFloat32Vector);
assertThatVectorCreationResultsInCorrectBinary(
- Vector.floatVector(expectedFloatVector),
+ BinaryVector.floatVector(expectedFloatVector),
testKey,
actualDecodedDocument,
expectedCanonicalBsonHex,
@@ -179,7 +179,7 @@ private static void assertValidationException(final RuntimeException runtimeExce
assertTrue(runtimeException instanceof IllegalArgumentException || runtimeException instanceof IllegalStateException);
}
- private static void assertThatVectorCreationResultsInCorrectBinary(final Vector expectedVectorData,
+ private static void assertThatVectorCreationResultsInCorrectBinary(final BinaryVector expectedVectorData,
final String testKey,
final BsonDocument actualDecodedDocument,
final String expectedCanonicalBsonHex,
@@ -191,18 +191,18 @@ private static void assertThatVectorCreationResultsInCorrectBinary(final Vector
}
private static void assertVectorDecoding(final byte[] expectedVectorData,
- final Vector.DataType expectedDType,
+ final BinaryVector.DataType expectedDType,
final byte[] actualVectorData,
- final Vector actualVector) {
+ final BinaryVector actualVector) {
Assertions.assertArrayEquals(actualVectorData, expectedVectorData,
() -> "Actual: " + Arrays.toString(actualVectorData) + " != Expected:" + Arrays.toString(expectedVectorData));
assertEquals(expectedDType, actualVector.getDataType());
}
private static void assertVectorDecoding(final byte[] expectedVectorData,
- final Vector.DataType expectedDType,
+ final BinaryVector.DataType expectedDType,
final byte expectedPadding,
- final PackedBitVector actualVector) {
+ final PackedBitBinaryVector actualVector) {
byte[] actualVectorData = actualVector.getData();
assertVectorDecoding(
expectedVectorData,
@@ -213,8 +213,8 @@ private static void assertVectorDecoding(final byte[] expectedVectorData,
}
private static void assertVectorDecoding(final float[] expectedVectorData,
- final Vector.DataType expectedDType,
- final Float32Vector actualVector) {
+ final BinaryVector.DataType expectedDType,
+ final Float32BinaryVector actualVector) {
float[] actualVectorArray = actualVector.getData();
Assertions.assertArrayEquals(actualVectorArray, expectedVectorData,
() -> "Actual: " + Arrays.toString(actualVectorArray) + " != Expected:" + Arrays.toString(expectedVectorData));
diff --git a/driver-core/src/main/com/mongodb/client/model/Aggregates.java b/driver-core/src/main/com/mongodb/client/model/Aggregates.java
index 7d6306cdd23..44283ccba04 100644
--- a/driver-core/src/main/com/mongodb/client/model/Aggregates.java
+++ b/driver-core/src/main/com/mongodb/client/model/Aggregates.java
@@ -37,7 +37,7 @@
import org.bson.BsonType;
import org.bson.BsonValue;
import org.bson.Document;
-import org.bson.Vector;
+import org.bson.BinaryVector;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.conversions.Bson;
@@ -972,7 +972,7 @@ public static Bson vectorSearch(
* You may use the {@code $meta: "vectorSearchScore"} expression, e.g., via {@link Projections#metaVectorSearchScore(String)},
* to extract the relevance score assigned to each found document.
*
- * @param queryVector The {@linkplain Vector query vector}. The number of dimensions must match that of the {@code index}.
+ * @param queryVector The {@linkplain BinaryVector query vector}. The number of dimensions must match that of the {@code index}.
* @param path The field to be searched.
* @param index The name of the index to use.
* @param limit The limit on the number of documents produced by the pipeline stage.
@@ -981,12 +981,12 @@ public static Bson vectorSearch(
* @mongodb.atlas.manual atlas-vector-search/vector-search-stage/ $vectorSearch
* @mongodb.atlas.manual atlas-search/scoring/ Scoring
* @mongodb.server.release 6.0
- * @see Vector
+ * @see BinaryVector
* @since 5.3
*/
public static Bson vectorSearch(
final FieldSearchPath path,
- final Vector queryVector,
+ final BinaryVector queryVector,
final String index,
final long limit,
final VectorSearchOptions options) {
diff --git a/driver-core/src/test/functional/com/mongodb/client/model/search/AggregatesVectorSearchIntegrationTest.java b/driver-core/src/test/functional/com/mongodb/client/model/search/AggregatesBinaryVectorSearchIntegrationTest.java
similarity index 78%
rename from driver-core/src/test/functional/com/mongodb/client/model/search/AggregatesVectorSearchIntegrationTest.java
rename to driver-core/src/test/functional/com/mongodb/client/model/search/AggregatesBinaryVectorSearchIntegrationTest.java
index 15def0f5d71..0d5aad1085a 100644
--- a/driver-core/src/test/functional/com/mongodb/client/model/search/AggregatesVectorSearchIntegrationTest.java
+++ b/driver-core/src/test/functional/com/mongodb/client/model/search/AggregatesBinaryVectorSearchIntegrationTest.java
@@ -24,7 +24,7 @@
import com.mongodb.internal.operation.SearchIndexRequest;
import org.bson.BsonDocument;
import org.bson.Document;
-import org.bson.Vector;
+import org.bson.BinaryVector;
import org.bson.codecs.DocumentCodec;
import org.bson.conversions.Bson;
import org.junit.jupiter.api.AfterAll;
@@ -67,7 +67,7 @@
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.junit.jupiter.params.provider.Arguments.arguments;
-class AggregatesVectorSearchIntegrationTest {
+class AggregatesBinaryVectorSearchIntegrationTest {
private static final String EXCEED_WAIT_ATTEMPTS_ERROR_MESSAGE =
"Exceeded maximum attempts waiting for Search Index creation in Atlas cluster. Index document: %s";
@@ -112,67 +112,67 @@ static void beforeAll() {
assumeTrue(serverVersionAtLeast(6, 0));
collectionHelper =
- new CollectionHelper<>(new DocumentCodec(), new MongoNamespace("javaVectorSearchTest", AggregatesVectorSearchIntegrationTest.class.getSimpleName()));
+ new CollectionHelper<>(new DocumentCodec(), new MongoNamespace("javaVectorSearchTest", AggregatesBinaryVectorSearchIntegrationTest.class.getSimpleName()));
collectionHelper.drop();
collectionHelper.insertDocuments(
new Document()
.append("_id", 0)
- .append(VECTOR_FIELD_INT_8, Vector.int8Vector(new byte[]{0, 1, 2, 3, 4}))
- .append(VECTOR_FIELD_FLOAT_32, Vector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}))
+ .append(VECTOR_FIELD_INT_8, BinaryVector.int8Vector(new byte[]{0, 1, 2, 3, 4}))
+ .append(VECTOR_FIELD_FLOAT_32, BinaryVector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}))
.append(VECTOR_FIELD_LEGACY_DOUBLE_LIST, new double[]{0.0001, 1.12345, 2.23456, 3.34567, 4.45678})
.append(FIELD_YEAR, 2016),
new Document()
.append("_id", 1)
- .append(VECTOR_FIELD_INT_8, Vector.int8Vector(new byte[]{1, 2, 3, 4, 5}))
- .append(VECTOR_FIELD_FLOAT_32, Vector.floatVector(new float[]{1.0001f, 2.12345f, 3.23456f, 4.34567f, 5.45678f}))
+ .append(VECTOR_FIELD_INT_8, BinaryVector.int8Vector(new byte[]{1, 2, 3, 4, 5}))
+ .append(VECTOR_FIELD_FLOAT_32, BinaryVector.floatVector(new float[]{1.0001f, 2.12345f, 3.23456f, 4.34567f, 5.45678f}))
.append(VECTOR_FIELD_LEGACY_DOUBLE_LIST, new double[]{1.0001, 2.12345, 3.23456, 4.34567, 5.45678})
.append(FIELD_YEAR, 2017),
new Document()
.append("_id", 2)
- .append(VECTOR_FIELD_INT_8, Vector.int8Vector(new byte[]{2, 3, 4, 5, 6}))
- .append(VECTOR_FIELD_FLOAT_32, Vector.floatVector(new float[]{2.0002f, 3.12345f, 4.23456f, 5.34567f, 6.45678f}))
+ .append(VECTOR_FIELD_INT_8, BinaryVector.int8Vector(new byte[]{2, 3, 4, 5, 6}))
+ .append(VECTOR_FIELD_FLOAT_32, BinaryVector.floatVector(new float[]{2.0002f, 3.12345f, 4.23456f, 5.34567f, 6.45678f}))
.append(VECTOR_FIELD_LEGACY_DOUBLE_LIST, new double[]{2.0002, 3.12345, 4.23456, 5.34567, 6.45678})
.append(FIELD_YEAR, 2018),
new Document()
.append("_id", 3)
- .append(VECTOR_FIELD_INT_8, Vector.int8Vector(new byte[]{3, 4, 5, 6, 7}))
- .append(VECTOR_FIELD_FLOAT_32, Vector.floatVector(new float[]{3.0003f, 4.12345f, 5.23456f, 6.34567f, 7.45678f}))
+ .append(VECTOR_FIELD_INT_8, BinaryVector.int8Vector(new byte[]{3, 4, 5, 6, 7}))
+ .append(VECTOR_FIELD_FLOAT_32, BinaryVector.floatVector(new float[]{3.0003f, 4.12345f, 5.23456f, 6.34567f, 7.45678f}))
.append(VECTOR_FIELD_LEGACY_DOUBLE_LIST, new double[]{3.0003, 4.12345, 5.23456, 6.34567, 7.45678})
.append(FIELD_YEAR, 2019),
new Document()
.append("_id", 4)
- .append(VECTOR_FIELD_INT_8, Vector.int8Vector(new byte[]{4, 5, 6, 7, 8}))
- .append(VECTOR_FIELD_FLOAT_32, Vector.floatVector(new float[]{4.0004f, 5.12345f, 6.23456f, 7.34567f, 8.45678f}))
+ .append(VECTOR_FIELD_INT_8, BinaryVector.int8Vector(new byte[]{4, 5, 6, 7, 8}))
+ .append(VECTOR_FIELD_FLOAT_32, BinaryVector.floatVector(new float[]{4.0004f, 5.12345f, 6.23456f, 7.34567f, 8.45678f}))
.append(VECTOR_FIELD_LEGACY_DOUBLE_LIST, new double[]{4.0004, 5.12345, 6.23456, 7.34567, 8.45678})
.append(FIELD_YEAR, 2020),
new Document()
.append("_id", 5)
- .append(VECTOR_FIELD_INT_8, Vector.int8Vector(new byte[]{5, 6, 7, 8, 9}))
- .append(VECTOR_FIELD_FLOAT_32, Vector.floatVector(new float[]{5.0005f, 6.12345f, 7.23456f, 8.34567f, 9.45678f}))
+ .append(VECTOR_FIELD_INT_8, BinaryVector.int8Vector(new byte[]{5, 6, 7, 8, 9}))
+ .append(VECTOR_FIELD_FLOAT_32, BinaryVector.floatVector(new float[]{5.0005f, 6.12345f, 7.23456f, 8.34567f, 9.45678f}))
.append(VECTOR_FIELD_LEGACY_DOUBLE_LIST, new double[]{5.0005, 6.12345, 7.23456, 8.34567, 9.45678})
.append(FIELD_YEAR, 2021),
new Document()
.append("_id", 6)
- .append(VECTOR_FIELD_INT_8, Vector.int8Vector(new byte[]{6, 7, 8, 9, 10}))
- .append(VECTOR_FIELD_FLOAT_32, Vector.floatVector(new float[]{6.0006f, 7.12345f, 8.23456f, 9.34567f, 10.45678f}))
+ .append(VECTOR_FIELD_INT_8, BinaryVector.int8Vector(new byte[]{6, 7, 8, 9, 10}))
+ .append(VECTOR_FIELD_FLOAT_32, BinaryVector.floatVector(new float[]{6.0006f, 7.12345f, 8.23456f, 9.34567f, 10.45678f}))
.append(VECTOR_FIELD_LEGACY_DOUBLE_LIST, new double[]{6.0006, 7.12345, 8.23456, 9.34567, 10.45678})
.append(FIELD_YEAR, 2022),
new Document()
.append("_id", 7)
- .append(VECTOR_FIELD_INT_8, Vector.int8Vector(new byte[]{7, 8, 9, 10, 11}))
- .append(VECTOR_FIELD_FLOAT_32, Vector.floatVector(new float[]{7.0007f, 8.12345f, 9.23456f, 10.34567f, 11.45678f}))
+ .append(VECTOR_FIELD_INT_8, BinaryVector.int8Vector(new byte[]{7, 8, 9, 10, 11}))
+ .append(VECTOR_FIELD_FLOAT_32, BinaryVector.floatVector(new float[]{7.0007f, 8.12345f, 9.23456f, 10.34567f, 11.45678f}))
.append(VECTOR_FIELD_LEGACY_DOUBLE_LIST, new double[]{7.0007, 8.12345, 9.23456, 10.34567, 11.45678})
.append(FIELD_YEAR, 2023),
new Document()
.append("_id", 8)
- .append(VECTOR_FIELD_INT_8, Vector.int8Vector(new byte[]{8, 9, 10, 11, 12}))
- .append(VECTOR_FIELD_FLOAT_32, Vector.floatVector(new float[]{8.0008f, 9.12345f, 10.23456f, 11.34567f, 12.45678f}))
+ .append(VECTOR_FIELD_INT_8, BinaryVector.int8Vector(new byte[]{8, 9, 10, 11, 12}))
+ .append(VECTOR_FIELD_FLOAT_32, BinaryVector.floatVector(new float[]{8.0008f, 9.12345f, 10.23456f, 11.34567f, 12.45678f}))
.append(VECTOR_FIELD_LEGACY_DOUBLE_LIST, new double[]{8.0008, 9.12345, 10.23456, 11.34567, 12.45678})
.append(FIELD_YEAR, 2024),
new Document()
.append("_id", 9)
- .append(VECTOR_FIELD_INT_8, Vector.int8Vector(new byte[]{9, 10, 11, 12, 13}))
- .append(VECTOR_FIELD_FLOAT_32, Vector.floatVector(new float[]{9.0009f, 10.12345f, 11.23456f, 12.34567f, 13.45678f}))
+ .append(VECTOR_FIELD_INT_8, BinaryVector.int8Vector(new byte[]{9, 10, 11, 12, 13}))
+ .append(VECTOR_FIELD_FLOAT_32, BinaryVector.floatVector(new float[]{9.0009f, 10.12345f, 11.23456f, 12.34567f, 13.45678f}))
.append(VECTOR_FIELD_LEGACY_DOUBLE_LIST, new double[]{9.0009, 10.12345, 11.23456, 12.34567, 13.45678})
.append(FIELD_YEAR, 2025)
);
@@ -192,43 +192,43 @@ static void afterAll() {
private static Stream provideSupportedVectors() {
return Stream.of(
- arguments(Vector.int8Vector(new byte[]{0, 1, 2, 3, 4}),
+ arguments(BinaryVector.int8Vector(new byte[]{0, 1, 2, 3, 4}),
// `multi` is used here only to verify that it is tolerated
fieldPath(VECTOR_FIELD_INT_8).multi("ignored"),
approximateVectorSearchOptions(LIMIT * 2)),
- arguments(Vector.int8Vector(new byte[]{0, 1, 2, 3, 4}),
+ arguments(BinaryVector.int8Vector(new byte[]{0, 1, 2, 3, 4}),
fieldPath(VECTOR_FIELD_INT_8),
approximateVectorSearchOptions(LIMIT * 2)),
- arguments(Vector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
+ arguments(BinaryVector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
// `multi` is used here only to verify that it is tolerated
fieldPath(VECTOR_FIELD_FLOAT_32).multi("ignored"),
approximateVectorSearchOptions(LIMIT * 2)),
- arguments(Vector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
+ arguments(BinaryVector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
fieldPath(VECTOR_FIELD_FLOAT_32),
approximateVectorSearchOptions(LIMIT * 2)),
- arguments(Vector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
+ arguments(BinaryVector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
// `multi` is used here only to verify that it is tolerated
fieldPath(VECTOR_FIELD_FLOAT_32).multi("ignored"),
exactVectorSearchOptions()),
- arguments(Vector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
+ arguments(BinaryVector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
fieldPath(VECTOR_FIELD_FLOAT_32),
exactVectorSearchOptions()),
- arguments(Vector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
+ arguments(BinaryVector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
// `multi` is used here only to verify that it is tolerated
fieldPath(VECTOR_FIELD_LEGACY_DOUBLE_LIST).multi("ignored"),
exactVectorSearchOptions()),
- arguments(Vector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
+ arguments(BinaryVector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
fieldPath(VECTOR_FIELD_LEGACY_DOUBLE_LIST),
exactVectorSearchOptions()),
- arguments(Vector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
+ arguments(BinaryVector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
// `multi` is used here only to verify that it is tolerated
fieldPath(VECTOR_FIELD_LEGACY_DOUBLE_LIST).multi("ignored"),
approximateVectorSearchOptions(LIMIT * 2)),
- arguments(Vector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
+ arguments(BinaryVector.floatVector(new float[]{0.0001f, 1.12345f, 2.23456f, 3.34567f, 4.45678f}),
fieldPath(VECTOR_FIELD_LEGACY_DOUBLE_LIST),
approximateVectorSearchOptions(LIMIT * 2))
);
@@ -236,7 +236,7 @@ private static Stream provideSupportedVectors() {
@ParameterizedTest
@MethodSource("provideSupportedVectors")
- void shouldSearchByVectorWithSearchScore(final Vector vector,
+ void shouldSearchByVectorWithSearchScore(final BinaryVector vector,
final FieldSearchPath fieldSearchPath,
final VectorSearchOptions vectorSearchOptions) {
//given
@@ -264,7 +264,7 @@ void shouldSearchByVectorWithSearchScore(final Vector vector,
@ParameterizedTest
@MethodSource("provideSupportedVectors")
- void shouldSearchByVector(final Vector vector,
+ void shouldSearchByVector(final BinaryVector vector,
final FieldSearchPath fieldSearchPath,
final VectorSearchOptions vectorSearchOptions) {
//given
@@ -289,7 +289,7 @@ void shouldSearchByVector(final Vector vector,
@ParameterizedTest
@MethodSource("provideSupportedVectors")
- void shouldSearchByVectorWithFilter(final Vector vector,
+ void shouldSearchByVectorWithFilter(final BinaryVector vector,
final FieldSearchPath fieldSearchPath,
final VectorSearchOptions vectorSearchOptions) {
Consumer asserter = filter -> {
diff --git a/driver-core/src/test/unit/com/mongodb/client/model/AggregatesSpecification.groovy b/driver-core/src/test/unit/com/mongodb/client/model/AggregatesSpecification.groovy
index 1370a9ef25a..f78aefd51b4 100644
--- a/driver-core/src/test/unit/com/mongodb/client/model/AggregatesSpecification.groovy
+++ b/driver-core/src/test/unit/com/mongodb/client/model/AggregatesSpecification.groovy
@@ -23,7 +23,7 @@ import com.mongodb.client.model.search.SearchOperator
import org.bson.BsonDocument
import org.bson.BsonInt32
import org.bson.Document
-import org.bson.Vector
+import org.bson.BinaryVector
import org.bson.conversions.Bson
import spock.lang.IgnoreIf
import spock.lang.Specification
@@ -879,9 +879,9 @@ class AggregatesSpecification extends Specification {
where:
vector | queryVector
- Vector.int8Vector([127, 7] as byte[]) | '{"$binary": {"base64": "AwB/Bw==", "subType": "09"}}'
- Vector.floatVector([127.0f, 7.0f] as float[]) | '{"$binary": {"base64": "JwAAAP5CAADgQA==", "subType": "09"}}'
- Vector.packedBitVector([127, 7] as byte[], (byte) 0) | '{"$binary": {"base64": "EAB/Bw==", "subType": "09"}}'
+ BinaryVector.int8Vector([127, 7] as byte[]) | '{"$binary": {"base64": "AwB/Bw==", "subType": "09"}}'
+ BinaryVector.floatVector([127.0f, 7.0f] as float[]) | '{"$binary": {"base64": "JwAAAP5CAADgQA==", "subType": "09"}}'
+ BinaryVector.packedBitVector([127, 7] as byte[], (byte) 0) | '{"$binary": {"base64": "EAB/Bw==", "subType": "09"}}'
[1.0d, 2.0d] | "[1.0, 2.0]"
}
@@ -913,8 +913,8 @@ class AggregatesSpecification extends Specification {
where:
vector | queryVector
- Vector.int8Vector([127, 7] as byte[]) | '{"$binary": {"base64": "AwB/Bw==", "subType": "09"}}'
- Vector.floatVector([127.0f, 7.0f] as float[]) | '{"$binary": {"base64": "JwAAAP5CAADgQA==", "subType": "09"}}'
+ BinaryVector.int8Vector([127, 7] as byte[]) | '{"$binary": {"base64": "AwB/Bw==", "subType": "09"}}'
+ BinaryVector.floatVector([127.0f, 7.0f] as float[]) | '{"$binary": {"base64": "JwAAAP5CAADgQA==", "subType": "09"}}'
[1.0d, 2.0d] | "[1.0, 2.0]"
}
diff --git a/driver-core/src/test/unit/com/mongodb/client/model/search/VectorSearchOptionsTest.java b/driver-core/src/test/unit/com/mongodb/client/model/search/BinaryVectorSearchOptionsTest.java
similarity index 99%
rename from driver-core/src/test/unit/com/mongodb/client/model/search/VectorSearchOptionsTest.java
rename to driver-core/src/test/unit/com/mongodb/client/model/search/BinaryVectorSearchOptionsTest.java
index 190347dc1fe..1fde037dbef 100644
--- a/driver-core/src/test/unit/com/mongodb/client/model/search/VectorSearchOptionsTest.java
+++ b/driver-core/src/test/unit/com/mongodb/client/model/search/BinaryVectorSearchOptionsTest.java
@@ -24,7 +24,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
-final class VectorSearchOptionsTest {
+final class BinaryVectorSearchOptionsTest {
@Test
void approximateVectorSearchOptions() {
assertEquals(
diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/vector/VectorFunctionalTest.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/vector/BinaryVectorFunctionalTest.java
similarity index 87%
rename from driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/vector/VectorFunctionalTest.java
rename to driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/vector/BinaryVectorFunctionalTest.java
index f5b8e63f8c3..ef8d8d1d817 100644
--- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/vector/VectorFunctionalTest.java
+++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/vector/BinaryVectorFunctionalTest.java
@@ -18,11 +18,11 @@
import com.mongodb.MongoClientSettings;
import com.mongodb.client.MongoClient;
-import com.mongodb.client.vector.AbstractVectorFunctionalTest;
+import com.mongodb.client.vector.AbstractBinaryVectorFunctionalTest;
import com.mongodb.reactivestreams.client.MongoClients;
import com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient;
-public class VectorFunctionalTest extends AbstractVectorFunctionalTest {
+public class BinaryVectorFunctionalTest extends AbstractBinaryVectorFunctionalTest {
@Override
protected MongoClient getMongoClient(final MongoClientSettings settings) {
return new SyncMongoClient(MongoClients.create(settings));
diff --git a/driver-sync/src/test/functional/com/mongodb/client/vector/AbstractVectorFunctionalTest.java b/driver-sync/src/test/functional/com/mongodb/client/vector/AbstractBinaryVectorFunctionalTest.java
similarity index 69%
rename from driver-sync/src/test/functional/com/mongodb/client/vector/AbstractVectorFunctionalTest.java
rename to driver-sync/src/test/functional/com/mongodb/client/vector/AbstractBinaryVectorFunctionalTest.java
index c3edf6983da..5d61051a997 100644
--- a/driver-sync/src/test/functional/com/mongodb/client/vector/AbstractVectorFunctionalTest.java
+++ b/driver-sync/src/test/functional/com/mongodb/client/vector/AbstractBinaryVectorFunctionalTest.java
@@ -28,10 +28,10 @@
import org.bson.BsonBinarySubType;
import org.bson.BsonInvalidOperationException;
import org.bson.Document;
-import org.bson.Float32Vector;
-import org.bson.Int8Vector;
-import org.bson.PackedBitVector;
-import org.bson.Vector;
+import org.bson.Float32BinaryVector;
+import org.bson.Int8BinaryVector;
+import org.bson.PackedBitBinaryVector;
+import org.bson.BinaryVector;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.codecs.pojo.PojoCodecProvider;
import org.bson.types.Binary;
@@ -48,14 +48,14 @@
import java.util.stream.Stream;
import static com.mongodb.MongoClientSettings.getDefaultCodecRegistry;
-import static org.bson.Vector.DataType.FLOAT32;
-import static org.bson.Vector.DataType.INT8;
-import static org.bson.Vector.DataType.PACKED_BIT;
+import static org.bson.BinaryVector.DataType.FLOAT32;
+import static org.bson.BinaryVector.DataType.INT8;
+import static org.bson.BinaryVector.DataType.PACKED_BIT;
import static org.bson.codecs.configuration.CodecRegistries.fromProviders;
import static org.bson.codecs.configuration.CodecRegistries.fromRegistries;
import static org.junit.jupiter.api.Assertions.assertEquals;
-public abstract class AbstractVectorFunctionalTest extends OperationTest {
+public abstract class AbstractBinaryVectorFunctionalTest extends OperationTest {
private static final byte VECTOR_SUBTYPE = BsonBinarySubType.VECTOR.getValue();
private static final String FIELD_VECTOR = "vector";
@@ -105,7 +105,7 @@ void shouldThrowExceptionForInvalidPackedBitArrayPaddingWhenDecodeEmptyVector(fi
// when & then
BsonInvalidOperationException exception = Assertions.assertThrows(BsonInvalidOperationException.class, ()-> {
findExactlyOne(documentCollection)
- .get(FIELD_VECTOR, Vector.class);
+ .get(FIELD_VECTOR, BinaryVector.class);
});
assertEquals("Padding must be 0 if vector is empty, but found: " + invalidPadding, exception.getMessage());
}
@@ -120,7 +120,7 @@ void shouldThrowExceptionForInvalidFloat32Padding(final byte invalidPadding) {
// when & then
BsonInvalidOperationException exception = Assertions.assertThrows(BsonInvalidOperationException.class, ()-> {
findExactlyOne(documentCollection)
- .get(FIELD_VECTOR, Vector.class);
+ .get(FIELD_VECTOR, BinaryVector.class);
});
assertEquals("Padding must be 0 for FLOAT32 data type, but found: " + invalidPadding, exception.getMessage());
}
@@ -135,7 +135,7 @@ void shouldThrowExceptionForInvalidInt8Padding(final byte invalidPadding) {
// when & then
BsonInvalidOperationException exception = Assertions.assertThrows(BsonInvalidOperationException.class, ()-> {
findExactlyOne(documentCollection)
- .get(FIELD_VECTOR, Vector.class);
+ .get(FIELD_VECTOR, BinaryVector.class);
});
assertEquals("Padding must be 0 for INT8 data type, but found: " + invalidPadding, exception.getMessage());
}
@@ -150,44 +150,44 @@ void shouldThrowExceptionForInvalidPackedBitPadding(final byte invalidPadding) {
// when & then
BsonInvalidOperationException exception = Assertions.assertThrows(BsonInvalidOperationException.class, ()-> {
findExactlyOne(documentCollection)
- .get(FIELD_VECTOR, Vector.class);
+ .get(FIELD_VECTOR, BinaryVector.class);
});
assertEquals("Padding must be between 0 and 7 bits, but found: " + invalidPadding, exception.getMessage());
}
- private static Stream provideValidVectors() {
+ private static Stream provideValidVectors() {
return Stream.of(
- Vector.floatVector(new float[]{1.1f, 2.2f, 3.3f}),
- Vector.int8Vector(new byte[]{10, 20, 30, 40}),
- Vector.packedBitVector(new byte[]{(byte) 0b10101010, (byte) 0b01010101}, (byte) 3)
+ BinaryVector.floatVector(new float[]{1.1f, 2.2f, 3.3f}),
+ BinaryVector.int8Vector(new byte[]{10, 20, 30, 40}),
+ BinaryVector.packedBitVector(new byte[]{(byte) 0b10101010, (byte) 0b01010101}, (byte) 3)
);
}
@ParameterizedTest
@MethodSource("provideValidVectors")
- void shouldStoreAndRetrieveValidVector(final Vector expectedVector) {
+ void shouldStoreAndRetrieveValidVector(final BinaryVector expectedVector) {
// Given
Document documentToInsert = new Document(FIELD_VECTOR, expectedVector)
.append("otherField", 1); // to test that the next field is not affected
documentCollection.insertOne(documentToInsert);
// when & then
- Vector actualVector = findExactlyOne(documentCollection)
- .get(FIELD_VECTOR, Vector.class);
+ BinaryVector actualVector = findExactlyOne(documentCollection)
+ .get(FIELD_VECTOR, BinaryVector.class);
assertEquals(expectedVector, actualVector);
}
@ParameterizedTest
@MethodSource("provideValidVectors")
- void shouldStoreAndRetrieveValidVectorWithBsonBinary(final Vector expectedVector) {
+ void shouldStoreAndRetrieveValidVectorWithBsonBinary(final BinaryVector expectedVector) {
// Given
Document documentToInsert = new Document(FIELD_VECTOR, new BsonBinary(expectedVector));
documentCollection.insertOne(documentToInsert);
// when & then
- Vector actualVector = findExactlyOne(documentCollection)
- .get(FIELD_VECTOR, Vector.class);
+ BinaryVector actualVector = findExactlyOne(documentCollection)
+ .get(FIELD_VECTOR, BinaryVector.class);
assertEquals(actualVector, actualVector);
}
@@ -195,14 +195,14 @@ void shouldStoreAndRetrieveValidVectorWithBsonBinary(final Vector expectedVector
@Test
void shouldStoreAndRetrieveValidVectorWithFloatVectorPojo() {
// given
- MongoCollection floatVectorPojoMongoCollection = mongoClient
+ MongoCollection floatVectorPojoMongoCollection = mongoClient
.getDatabase(getDatabaseName())
- .getCollection(getCollectionName()).withDocumentClass(FloatVectorPojo.class);
- Float32Vector vector = Vector.floatVector(new float[]{1.1f, 2.2f, 3.3f});
+ .getCollection(getCollectionName()).withDocumentClass(Float32BinaryVectorPojo.class);
+ Float32BinaryVector vector = BinaryVector.floatVector(new float[]{1.1f, 2.2f, 3.3f});
// whe
- floatVectorPojoMongoCollection.insertOne(new FloatVectorPojo(vector));
- FloatVectorPojo floatVectorPojo = floatVectorPojoMongoCollection.find().first();
+ floatVectorPojoMongoCollection.insertOne(new Float32BinaryVectorPojo(vector));
+ Float32BinaryVectorPojo floatVectorPojo = floatVectorPojoMongoCollection.find().first();
// then
Assertions.assertNotNull(floatVectorPojo);
@@ -212,14 +212,14 @@ void shouldStoreAndRetrieveValidVectorWithFloatVectorPojo() {
@Test
void shouldStoreAndRetrieveValidVectorWithInt8VectorPojo() {
// given
- MongoCollection floatVectorPojoMongoCollection = mongoClient
+ MongoCollection floatVectorPojoMongoCollection = mongoClient
.getDatabase(getDatabaseName())
- .getCollection(getCollectionName()).withDocumentClass(Int8VectorPojo.class);
- Int8Vector vector = Vector.int8Vector(new byte[]{10, 20, 30, 40});
+ .getCollection(getCollectionName()).withDocumentClass(Int8BinaryVectorPojo.class);
+ Int8BinaryVector vector = BinaryVector.int8Vector(new byte[]{10, 20, 30, 40});
// when
- floatVectorPojoMongoCollection.insertOne(new Int8VectorPojo(vector));
- Int8VectorPojo int8VectorPojo = floatVectorPojoMongoCollection.find().first();
+ floatVectorPojoMongoCollection.insertOne(new Int8BinaryVectorPojo(vector));
+ Int8BinaryVectorPojo int8VectorPojo = floatVectorPojoMongoCollection.find().first();
// then
Assertions.assertNotNull(int8VectorPojo);
@@ -229,15 +229,15 @@ void shouldStoreAndRetrieveValidVectorWithInt8VectorPojo() {
@Test
void shouldStoreAndRetrieveValidVectorWithPackedBitVectorPojo() {
// given
- MongoCollection floatVectorPojoMongoCollection = mongoClient
+ MongoCollection floatVectorPojoMongoCollection = mongoClient
.getDatabase(getDatabaseName())
- .getCollection(getCollectionName()).withDocumentClass(PackedBitVectorPojo.class);
+ .getCollection(getCollectionName()).withDocumentClass(PackedBitBinaryVectorPojo.class);
- PackedBitVector vector = Vector.packedBitVector(new byte[]{(byte) 0b10101010, (byte) 0b01010101}, (byte) 3);
+ PackedBitBinaryVector vector = BinaryVector.packedBitVector(new byte[]{(byte) 0b10101010, (byte) 0b01010101}, (byte) 3);
// when
- floatVectorPojoMongoCollection.insertOne(new PackedBitVectorPojo(vector));
- PackedBitVectorPojo packedBitVectorPojo = floatVectorPojoMongoCollection.find().first();
+ floatVectorPojoMongoCollection.insertOne(new PackedBitBinaryVectorPojo(vector));
+ PackedBitBinaryVectorPojo packedBitVectorPojo = floatVectorPojoMongoCollection.find().first();
// then
Assertions.assertNotNull(packedBitVectorPojo);
@@ -246,15 +246,15 @@ void shouldStoreAndRetrieveValidVectorWithPackedBitVectorPojo() {
@ParameterizedTest
@MethodSource("provideValidVectors")
- void shouldStoreAndRetrieveValidVectorWithGenericVectorPojo(final Vector actualVector) {
+ void shouldStoreAndRetrieveValidVectorWithGenericVectorPojo(final BinaryVector actualVector) {
// given
- MongoCollection floatVectorPojoMongoCollection = mongoClient
+ MongoCollection floatVectorPojoMongoCollection = mongoClient
.getDatabase(getDatabaseName())
- .getCollection(getCollectionName()).withDocumentClass(VectorPojo.class);
+ .getCollection(getCollectionName()).withDocumentClass(BinaryVectorPojo.class);
// when
- floatVectorPojoMongoCollection.insertOne(new VectorPojo(actualVector));
- VectorPojo vectorPojo = floatVectorPojoMongoCollection.find().first();
+ floatVectorPojoMongoCollection.insertOne(new BinaryVectorPojo(actualVector));
+ BinaryVectorPojo vectorPojo = floatVectorPojoMongoCollection.find().first();
//then
Assertions.assertNotNull(vectorPojo);
@@ -268,78 +268,78 @@ private Document findExactlyOne(final MongoCollection collection) {
return documents.get(0);
}
- public static class VectorPojo {
- private Vector vector;
+ public static class BinaryVectorPojo {
+ private BinaryVector vector;
- public VectorPojo() {
+ public BinaryVectorPojo() {
}
- public VectorPojo(final Vector vector) {
+ public BinaryVectorPojo(final BinaryVector vector) {
this.vector = vector;
}
- public Vector getVector() {
+ public BinaryVector getVector() {
return vector;
}
- public void setVector(final Vector vector) {
+ public void setVector(final BinaryVector vector) {
this.vector = vector;
}
}
- public static class Int8VectorPojo {
- private Int8Vector vector;
+ public static class Int8BinaryVectorPojo {
+ private Int8BinaryVector vector;
- public Int8VectorPojo() {
+ public Int8BinaryVectorPojo() {
}
- public Int8VectorPojo(final Int8Vector vector) {
+ public Int8BinaryVectorPojo(final Int8BinaryVector vector) {
this.vector = vector;
}
- public Vector getVector() {
+ public BinaryVector getVector() {
return vector;
}
- public void setVector(final Int8Vector vector) {
+ public void setVector(final Int8BinaryVector vector) {
this.vector = vector;
}
}
- public static class PackedBitVectorPojo {
- private PackedBitVector vector;
+ public static class PackedBitBinaryVectorPojo {
+ private PackedBitBinaryVector vector;
- public PackedBitVectorPojo() {
+ public PackedBitBinaryVectorPojo() {
}
- public PackedBitVectorPojo(final PackedBitVector vector) {
+ public PackedBitBinaryVectorPojo(final PackedBitBinaryVector vector) {
this.vector = vector;
}
- public Vector getVector() {
+ public BinaryVector getVector() {
return vector;
}
- public void setVector(final PackedBitVector vector) {
+ public void setVector(final PackedBitBinaryVector vector) {
this.vector = vector;
}
}
- public static class FloatVectorPojo {
- private Float32Vector vector;
+ public static class Float32BinaryVectorPojo {
+ private Float32BinaryVector vector;
- public FloatVectorPojo() {
+ public Float32BinaryVectorPojo() {
}
- public FloatVectorPojo(final Float32Vector vector) {
+ public Float32BinaryVectorPojo(final Float32BinaryVector vector) {
this.vector = vector;
}
- public Vector getVector() {
+ public BinaryVector getVector() {
return vector;
}
- public void setVector(final Float32Vector vector) {
+ public void setVector(final Float32BinaryVector vector) {
this.vector = vector;
}
}
diff --git a/driver-sync/src/test/functional/com/mongodb/client/vector/VectorFunctionalTest.java b/driver-sync/src/test/functional/com/mongodb/client/vector/BinaryVectorFunctionalTest.java
similarity index 91%
rename from driver-sync/src/test/functional/com/mongodb/client/vector/VectorFunctionalTest.java
rename to driver-sync/src/test/functional/com/mongodb/client/vector/BinaryVectorFunctionalTest.java
index 63d756a8f35..05bf084dc84 100644
--- a/driver-sync/src/test/functional/com/mongodb/client/vector/VectorFunctionalTest.java
+++ b/driver-sync/src/test/functional/com/mongodb/client/vector/BinaryVectorFunctionalTest.java
@@ -20,7 +20,7 @@
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
-public class VectorFunctionalTest extends AbstractVectorFunctionalTest {
+public class BinaryVectorFunctionalTest extends AbstractBinaryVectorFunctionalTest {
@Override
protected MongoClient getMongoClient(final MongoClientSettings settings) {
return MongoClients.create(settings);