1616
1717package org .bson ;
1818
19+ import org .bson .annotations .Beta ;
20+ import org .bson .annotations .Reason ;
21+
1922import static org .bson .assertions .Assertions .isTrueArgument ;
2023import static org .bson .assertions .Assertions .notNull ;
2124
2225/**
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.
26+ * Binary Vectors are densely packed arrays of numbers, all the same type, which are stored and retrieved efficiently using the BSON Binary
27+ * Subtype 9 format. This class supports multiple vector {@link DataType}'s and provides static methods to create vectors.
2928 * <p>
3029 * <b>NOTE:</b> This class should be treated as <b>sealed</b>: it must not be extended or implemented by consumers of the library.
3130 *
3231 * @mongodb.server.release 6.0
3332 * @see BsonBinary
3433 * @since 5.3
3534 */
36- public abstract class Vector {
35+ public abstract class BinaryVector {
3736 private final DataType dataType ;
3837
39- Vector (final DataType dataType ) {
38+ BinaryVector (final DataType dataType ) {
4039 this .dataType = dataType ;
4140 }
4241
@@ -56,18 +55,19 @@ public abstract class Vector {
5655 * </pre>
5756 * <p>
5857 * NOTE: The byte array `data` is not copied; changes to the provided array will be reflected
59- * in the created {@link PackedBitVector } instance.
58+ * in the created {@link PackedBitBinaryVector } instance.
6059 *
6160 * @param data The byte array representing the packed bit vector data. Each byte can store 8 bits.
6261 * @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.
62+ * @return A {@link PackedBitBinaryVector } instance with the {@link DataType#PACKED_BIT} data type.
6463 * @throws IllegalArgumentException If the padding value is greater than 7.
6564 */
66- public static PackedBitVector packedBitVector (final byte [] data , final byte padding ) {
65+ @ Beta (Reason .SERVER )
66+ public static PackedBitBinaryVector packedBitVector (final byte [] data , final byte padding ) {
6767 notNull ("data" , data );
6868 isTrueArgument ("Padding must be between 0 and 7 bits. Provided padding: " + padding , padding >= 0 && padding <= 7 );
6969 isTrueArgument ("Padding must be 0 if vector is empty. Provided padding: " + padding , padding == 0 || data .length > 0 );
70- return new PackedBitVector (data , padding );
70+ return new PackedBitBinaryVector (data , padding );
7171 }
7272
7373 /**
@@ -77,14 +77,14 @@ public static PackedBitVector packedBitVector(final byte[] data, final byte padd
7777 * with values in the range [-128, 127].</p>
7878 * <p>
7979 * NOTE: The byte array `data` is not copied; changes to the provided array will be reflected
80- * in the created {@link Int8Vector } instance.
80+ * in the created {@link Int8BinaryVector } instance.
8181 *
8282 * @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.
83+ * @return A {@link Int8BinaryVector } instance with the {@link DataType#INT8} data type.
8484 */
85- public static Int8Vector int8Vector (final byte [] data ) {
85+ public static Int8BinaryVector int8Vector (final byte [] data ) {
8686 notNull ("data" , data );
87- return new Int8Vector (data );
87+ return new Int8BinaryVector (data );
8888 }
8989
9090 /**
@@ -93,50 +93,50 @@ public static Int8Vector int8Vector(final byte[] data) {
9393 * A {@link DataType#FLOAT32} vector is a vector of floating-point numbers, where each element in the vector is a float.</p>
9494 * <p>
9595 * NOTE: The float array `data` is not copied; changes to the provided array will be reflected
96- * in the created {@link Float32Vector } instance.
96+ * in the created {@link Float32BinaryVector } instance.
9797 *
9898 * @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.
99+ * @return A {@link Float32BinaryVector } instance with the {@link DataType#FLOAT32} data type.
100100 */
101- public static Float32Vector floatVector (final float [] data ) {
101+ public static Float32BinaryVector floatVector (final float [] data ) {
102102 notNull ("data" , data );
103- return new Float32Vector (data );
103+ return new Float32BinaryVector (data );
104104 }
105105
106106 /**
107- * Returns the {@link PackedBitVector }.
107+ * Returns the {@link PackedBitBinaryVector }.
108108 *
109- * @return {@link PackedBitVector }.
109+ * @return {@link PackedBitBinaryVector }.
110110 * @throws IllegalStateException if this vector is not of type {@link DataType#PACKED_BIT}. Use {@link #getDataType()} to check the vector
111111 * type before calling this method.
112112 */
113- public PackedBitVector asPackedBitVector () {
113+ public PackedBitBinaryVector asPackedBitVector () {
114114 ensureType (DataType .PACKED_BIT );
115- return (PackedBitVector ) this ;
115+ return (PackedBitBinaryVector ) this ;
116116 }
117117
118118 /**
119- * Returns the {@link Int8Vector }.
119+ * Returns the {@link Int8BinaryVector }.
120120 *
121- * @return {@link Int8Vector }.
121+ * @return {@link Int8BinaryVector }.
122122 * @throws IllegalStateException if this vector is not of type {@link DataType#INT8}. Use {@link #getDataType()} to check the vector
123123 * type before calling this method.
124124 */
125- public Int8Vector asInt8Vector () {
125+ public Int8BinaryVector asInt8Vector () {
126126 ensureType (DataType .INT8 );
127- return (Int8Vector ) this ;
127+ return (Int8BinaryVector ) this ;
128128 }
129129
130130 /**
131- * Returns the {@link Float32Vector }.
131+ * Returns the {@link Float32BinaryVector }.
132132 *
133- * @return {@link Float32Vector }.
133+ * @return {@link Float32BinaryVector }.
134134 * @throws IllegalStateException if this vector is not of type {@link DataType#FLOAT32}. Use {@link #getDataType()} to check the vector
135135 * type before calling this method.
136136 */
137- public Float32Vector asFloat32Vector () {
137+ public Float32BinaryVector asFloat32Vector () {
138138 ensureType (DataType .FLOAT32 );
139- return (Float32Vector ) this ;
139+ return (Float32BinaryVector ) this ;
140140 }
141141
142142 /**
0 commit comments