2020import static org .bson .assertions .Assertions .notNull ;
2121
2222/**
23- * Represents a vector that is stored and retrieved using the BSON Binary Subtype 9 format.
24- * This class supports multiple vector {@link DataType}'s and provides static methods to create
25- * vectors.
26- * <p>
27- * Vectors are densely packed arrays of numbers, all the same type, which are stored efficiently
28- * in BSON using a binary format.
23+ * Binary Vectors are densely packed arrays of numbers, all the same type, which are stored and retrieved efficiently using the BSON Binary
24+ * Subtype 9 format. This class supports multiple vector {@link DataType}'s and provides static methods to create vectors.
2925 * <p>
3026 * <b>NOTE:</b> This class should be treated as <b>sealed</b>: it must not be extended or implemented by consumers of the library.
3127 *
3228 * @mongodb.server.release 6.0
3329 * @see BsonBinary
3430 * @since 5.3
3531 */
36- public abstract class Vector {
32+ public abstract class BinaryVector {
3733 private final DataType dataType ;
3834
39- Vector (final DataType dataType ) {
35+ BinaryVector (final DataType dataType ) {
4036 this .dataType = dataType ;
4137 }
4238
@@ -56,18 +52,18 @@ public abstract class Vector {
5652 * </pre>
5753 * <p>
5854 * NOTE: The byte array `data` is not copied; changes to the provided array will be reflected
59- * in the created {@link PackedBitVector } instance.
55+ * in the created {@link PackedBitBinaryVector } instance.
6056 *
6157 * @param data The byte array representing the packed bit vector data. Each byte can store 8 bits.
6258 * @param padding The number of least-significant bits (0 to 7) to ignore in the final byte of the vector data.
63- * @return A {@link PackedBitVector } instance with the {@link DataType#PACKED_BIT} data type.
59+ * @return A {@link PackedBitBinaryVector } instance with the {@link DataType#PACKED_BIT} data type.
6460 * @throws IllegalArgumentException If the padding value is greater than 7.
6561 */
66- public static PackedBitVector packedBitVector (final byte [] data , final byte padding ) {
62+ public static PackedBitBinaryVector packedBitVector (final byte [] data , final byte padding ) {
6763 notNull ("data" , data );
6864 isTrueArgument ("Padding must be between 0 and 7 bits. Provided padding: " + padding , padding >= 0 && padding <= 7 );
6965 isTrueArgument ("Padding must be 0 if vector is empty. Provided padding: " + padding , padding == 0 || data .length > 0 );
70- return new PackedBitVector (data , padding );
66+ return new PackedBitBinaryVector (data , padding );
7167 }
7268
7369 /**
@@ -77,14 +73,14 @@ public static PackedBitVector packedBitVector(final byte[] data, final byte padd
7773 * with values in the range [-128, 127].</p>
7874 * <p>
7975 * NOTE: The byte array `data` is not copied; changes to the provided array will be reflected
80- * in the created {@link Int8Vector } instance.
76+ * in the created {@link Int8BinaryVector } instance.
8177 *
8278 * @param data The byte array representing the {@link DataType#INT8} vector data.
83- * @return A {@link Int8Vector } instance with the {@link DataType#INT8} data type.
79+ * @return A {@link Int8BinaryVector } instance with the {@link DataType#INT8} data type.
8480 */
85- public static Int8Vector int8Vector (final byte [] data ) {
81+ public static Int8BinaryVector int8Vector (final byte [] data ) {
8682 notNull ("data" , data );
87- return new Int8Vector (data );
83+ return new Int8BinaryVector (data );
8884 }
8985
9086 /**
@@ -93,50 +89,50 @@ public static Int8Vector int8Vector(final byte[] data) {
9389 * A {@link DataType#FLOAT32} vector is a vector of floating-point numbers, where each element in the vector is a float.</p>
9490 * <p>
9591 * NOTE: The float array `data` is not copied; changes to the provided array will be reflected
96- * in the created {@link Float32Vector } instance.
92+ * in the created {@link Float32BinaryVector } instance.
9793 *
9894 * @param data The float array representing the {@link DataType#FLOAT32} vector data.
99- * @return A {@link Float32Vector } instance with the {@link DataType#FLOAT32} data type.
95+ * @return A {@link Float32BinaryVector } instance with the {@link DataType#FLOAT32} data type.
10096 */
101- public static Float32Vector floatVector (final float [] data ) {
97+ public static Float32BinaryVector floatVector (final float [] data ) {
10298 notNull ("data" , data );
103- return new Float32Vector (data );
99+ return new Float32BinaryVector (data );
104100 }
105101
106102 /**
107- * Returns the {@link PackedBitVector }.
103+ * Returns the {@link PackedBitBinaryVector }.
108104 *
109- * @return {@link PackedBitVector }.
105+ * @return {@link PackedBitBinaryVector }.
110106 * @throws IllegalStateException if this vector is not of type {@link DataType#PACKED_BIT}. Use {@link #getDataType()} to check the vector
111107 * type before calling this method.
112108 */
113- public PackedBitVector asPackedBitVector () {
109+ public PackedBitBinaryVector asPackedBitVector () {
114110 ensureType (DataType .PACKED_BIT );
115- return (PackedBitVector ) this ;
111+ return (PackedBitBinaryVector ) this ;
116112 }
117113
118114 /**
119- * Returns the {@link Int8Vector }.
115+ * Returns the {@link Int8BinaryVector }.
120116 *
121- * @return {@link Int8Vector }.
117+ * @return {@link Int8BinaryVector }.
122118 * @throws IllegalStateException if this vector is not of type {@link DataType#INT8}. Use {@link #getDataType()} to check the vector
123119 * type before calling this method.
124120 */
125- public Int8Vector asInt8Vector () {
121+ public Int8BinaryVector asInt8Vector () {
126122 ensureType (DataType .INT8 );
127- return (Int8Vector ) this ;
123+ return (Int8BinaryVector ) this ;
128124 }
129125
130126 /**
131- * Returns the {@link Float32Vector }.
127+ * Returns the {@link Float32BinaryVector }.
132128 *
133- * @return {@link Float32Vector }.
129+ * @return {@link Float32BinaryVector }.
134130 * @throws IllegalStateException if this vector is not of type {@link DataType#FLOAT32}. Use {@link #getDataType()} to check the vector
135131 * type before calling this method.
136132 */
137- public Float32Vector asFloat32Vector () {
133+ public Float32BinaryVector asFloat32Vector () {
138134 ensureType (DataType .FLOAT32 );
139- return (Float32Vector ) this ;
135+ return (Float32BinaryVector ) this ;
140136 }
141137
142138 /**
0 commit comments