20
20
import static org .bson .assertions .Assertions .notNull ;
21
21
22
22
/**
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.
29
25
* <p>
30
26
* <b>NOTE:</b> This class should be treated as <b>sealed</b>: it must not be extended or implemented by consumers of the library.
31
27
*
32
28
* @mongodb.server.release 6.0
33
29
* @see BsonBinary
34
30
* @since 5.3
35
31
*/
36
- public abstract class Vector {
32
+ public abstract class BinaryVector {
37
33
private final DataType dataType ;
38
34
39
- Vector (final DataType dataType ) {
35
+ BinaryVector (final DataType dataType ) {
40
36
this .dataType = dataType ;
41
37
}
42
38
@@ -56,18 +52,18 @@ public abstract class Vector {
56
52
* </pre>
57
53
* <p>
58
54
* 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.
60
56
*
61
57
* @param data The byte array representing the packed bit vector data. Each byte can store 8 bits.
62
58
* @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.
64
60
* @throws IllegalArgumentException If the padding value is greater than 7.
65
61
*/
66
- public static PackedBitVector packedBitVector (final byte [] data , final byte padding ) {
62
+ public static PackedBitBinaryVector packedBitVector (final byte [] data , final byte padding ) {
67
63
notNull ("data" , data );
68
64
isTrueArgument ("Padding must be between 0 and 7 bits. Provided padding: " + padding , padding >= 0 && padding <= 7 );
69
65
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 );
71
67
}
72
68
73
69
/**
@@ -77,14 +73,14 @@ public static PackedBitVector packedBitVector(final byte[] data, final byte padd
77
73
* with values in the range [-128, 127].</p>
78
74
* <p>
79
75
* 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.
81
77
*
82
78
* @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.
84
80
*/
85
- public static Int8Vector int8Vector (final byte [] data ) {
81
+ public static Int8BinaryVector int8Vector (final byte [] data ) {
86
82
notNull ("data" , data );
87
- return new Int8Vector (data );
83
+ return new Int8BinaryVector (data );
88
84
}
89
85
90
86
/**
@@ -93,50 +89,50 @@ public static Int8Vector int8Vector(final byte[] data) {
93
89
* A {@link DataType#FLOAT32} vector is a vector of floating-point numbers, where each element in the vector is a float.</p>
94
90
* <p>
95
91
* 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.
97
93
*
98
94
* @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.
100
96
*/
101
- public static Float32Vector floatVector (final float [] data ) {
97
+ public static Float32BinaryVector floatVector (final float [] data ) {
102
98
notNull ("data" , data );
103
- return new Float32Vector (data );
99
+ return new Float32BinaryVector (data );
104
100
}
105
101
106
102
/**
107
- * Returns the {@link PackedBitVector }.
103
+ * Returns the {@link PackedBitBinaryVector }.
108
104
*
109
- * @return {@link PackedBitVector }.
105
+ * @return {@link PackedBitBinaryVector }.
110
106
* @throws IllegalStateException if this vector is not of type {@link DataType#PACKED_BIT}. Use {@link #getDataType()} to check the vector
111
107
* type before calling this method.
112
108
*/
113
- public PackedBitVector asPackedBitVector () {
109
+ public PackedBitBinaryVector asPackedBitVector () {
114
110
ensureType (DataType .PACKED_BIT );
115
- return (PackedBitVector ) this ;
111
+ return (PackedBitBinaryVector ) this ;
116
112
}
117
113
118
114
/**
119
- * Returns the {@link Int8Vector }.
115
+ * Returns the {@link Int8BinaryVector }.
120
116
*
121
- * @return {@link Int8Vector }.
117
+ * @return {@link Int8BinaryVector }.
122
118
* @throws IllegalStateException if this vector is not of type {@link DataType#INT8}. Use {@link #getDataType()} to check the vector
123
119
* type before calling this method.
124
120
*/
125
- public Int8Vector asInt8Vector () {
121
+ public Int8BinaryVector asInt8Vector () {
126
122
ensureType (DataType .INT8 );
127
- return (Int8Vector ) this ;
123
+ return (Int8BinaryVector ) this ;
128
124
}
129
125
130
126
/**
131
- * Returns the {@link Float32Vector }.
127
+ * Returns the {@link Float32BinaryVector }.
132
128
*
133
- * @return {@link Float32Vector }.
129
+ * @return {@link Float32BinaryVector }.
134
130
* @throws IllegalStateException if this vector is not of type {@link DataType#FLOAT32}. Use {@link #getDataType()} to check the vector
135
131
* type before calling this method.
136
132
*/
137
- public Float32Vector asFloat32Vector () {
133
+ public Float32BinaryVector asFloat32Vector () {
138
134
ensureType (DataType .FLOAT32 );
139
- return (Float32Vector ) this ;
135
+ return (Float32BinaryVector ) this ;
140
136
}
141
137
142
138
/**
0 commit comments