32
32
import jakarta .json .stream .JsonGenerator ;
33
33
import java .lang .Float ;
34
34
import java .lang .Integer ;
35
+ import java .lang .String ;
35
36
import java .util .Objects ;
36
37
import java .util .function .Function ;
37
38
import javax .annotation .Nullable ;
61
62
*/
62
63
@ JsonpDeserializable
63
64
public class DenseVectorIndexOptions implements JsonpSerializable {
65
+ private final String type ;
66
+
64
67
@ Nullable
65
- private final Float confidenceInterval ;
68
+ private final Integer m ;
66
69
67
70
@ Nullable
68
71
private final Integer efConstruction ;
69
72
70
73
@ Nullable
71
- private final Integer m ;
72
-
73
- private final DenseVectorIndexOptionsType type ;
74
+ private final Float confidenceInterval ;
74
75
75
76
// ---------------------------------------------------------------------------------------------
76
77
77
78
private DenseVectorIndexOptions (Builder builder ) {
78
79
79
- this .confidenceInterval = builder .confidenceInterval ;
80
- this .efConstruction = builder .efConstruction ;
81
- this .m = builder .m ;
82
80
this .type = ApiTypeHelper .requireNonNull (builder .type , this , "type" );
81
+ this .m = builder .m ;
82
+ this .efConstruction = builder .efConstruction ;
83
+ this .confidenceInterval = builder .confidenceInterval ;
83
84
84
85
}
85
86
@@ -88,64 +89,34 @@ public static DenseVectorIndexOptions of(Function<Builder, ObjectBuilder<DenseVe
88
89
}
89
90
90
91
/**
91
- * The confidence interval to use when quantizing the vectors. Can be any value
92
- * between and including <code>0.90</code> and <code>1.0</code> or exactly
93
- * <code>0</code>. When the value is <code>0</code>, this indicates that dynamic
94
- * quantiles should be calculated for optimized quantization. When between
95
- * <code>0.90</code> and <code>1.0</code>, this value restricts the values used
96
- * when calculating the quantization thresholds.
97
- * <p>
98
- * For example, a value of <code>0.95</code> will only use the middle
99
- * <code>95%</code> of the values when calculating the quantization thresholds
100
- * (e.g. the highest and lowest <code>2.5%</code> of values will be ignored).
101
- * <p>
102
- * Defaults to <code>1/(dims + 1)</code> for <code>int8</code> quantized vectors
103
- * and <code>0</code> for <code>int4</code> for dynamic quantile calculation.
104
- * <p>
105
- * Only applicable to <code>int8_hnsw</code>, <code>int4_hnsw</code>,
106
- * <code>int8_flat</code>, and <code>int4_flat</code> index types.
107
- * <p>
108
- * API name: {@code confidence_interval}
92
+ * Required - API name: {@code type}
109
93
*/
110
- @ Nullable
111
- public final Float confidenceInterval () {
112
- return this .confidenceInterval ;
94
+ public final String type () {
95
+ return this .type ;
113
96
}
114
97
115
98
/**
116
- * The number of candidates to track while assembling the list of nearest
117
- * neighbors for each new node.
118
- * <p>
119
- * Only applicable to <code>hnsw</code>, <code>int8_hnsw</code>, and
120
- * <code>int4_hnsw</code> index types.
121
- * <p>
122
- * API name: {@code ef_construction}
99
+ * API name: {@code m}
123
100
*/
124
101
@ Nullable
125
- public final Integer efConstruction () {
126
- return this .efConstruction ;
102
+ public final Integer m () {
103
+ return this .m ;
127
104
}
128
105
129
106
/**
130
- * The number of neighbors each node will be connected to in the HNSW graph.
131
- * <p>
132
- * Only applicable to <code>hnsw</code>, <code>int8_hnsw</code>, and
133
- * <code>int4_hnsw</code> index types.
134
- * <p>
135
- * API name: {@code m}
107
+ * API name: {@code ef_construction}
136
108
*/
137
109
@ Nullable
138
- public final Integer m () {
139
- return this .m ;
110
+ public final Integer efConstruction () {
111
+ return this .efConstruction ;
140
112
}
141
113
142
114
/**
143
- * Required - The type of kNN algorithm to use.
144
- * <p>
145
- * API name: {@code type}
115
+ * API name: {@code confidence_interval}
146
116
*/
147
- public final DenseVectorIndexOptionsType type () {
148
- return this .type ;
117
+ @ Nullable
118
+ public final Float confidenceInterval () {
119
+ return this .confidenceInterval ;
149
120
}
150
121
151
122
/**
@@ -159,23 +130,24 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
159
130
160
131
protected void serializeInternal (JsonGenerator generator , JsonpMapper mapper ) {
161
132
162
- if (this .confidenceInterval != null ) {
163
- generator .writeKey ("confidence_interval" );
164
- generator .write (this .confidenceInterval );
133
+ generator .writeKey ("type" );
134
+ generator .write (this .type );
135
+
136
+ if (this .m != null ) {
137
+ generator .writeKey ("m" );
138
+ generator .write (this .m );
165
139
166
140
}
167
141
if (this .efConstruction != null ) {
168
142
generator .writeKey ("ef_construction" );
169
143
generator .write (this .efConstruction );
170
144
171
145
}
172
- if (this .m != null ) {
173
- generator .writeKey ("m " );
174
- generator .write (this .m );
146
+ if (this .confidenceInterval != null ) {
147
+ generator .writeKey ("confidence_interval " );
148
+ generator .write (this .confidenceInterval );
175
149
176
150
}
177
- generator .writeKey ("type" );
178
- this .type .serialize (generator , mapper );
179
151
180
152
}
181
153
@@ -193,76 +165,46 @@ public String toString() {
193
165
public static class Builder extends WithJsonObjectBuilderBase <Builder >
194
166
implements
195
167
ObjectBuilder <DenseVectorIndexOptions > {
168
+ private String type ;
169
+
196
170
@ Nullable
197
- private Float confidenceInterval ;
171
+ private Integer m ;
198
172
199
173
@ Nullable
200
174
private Integer efConstruction ;
201
175
202
176
@ Nullable
203
- private Integer m ;
204
-
205
- private DenseVectorIndexOptionsType type ;
177
+ private Float confidenceInterval ;
206
178
207
179
/**
208
- * The confidence interval to use when quantizing the vectors. Can be any value
209
- * between and including <code>0.90</code> and <code>1.0</code> or exactly
210
- * <code>0</code>. When the value is <code>0</code>, this indicates that dynamic
211
- * quantiles should be calculated for optimized quantization. When between
212
- * <code>0.90</code> and <code>1.0</code>, this value restricts the values used
213
- * when calculating the quantization thresholds.
214
- * <p>
215
- * For example, a value of <code>0.95</code> will only use the middle
216
- * <code>95%</code> of the values when calculating the quantization thresholds
217
- * (e.g. the highest and lowest <code>2.5%</code> of values will be ignored).
218
- * <p>
219
- * Defaults to <code>1/(dims + 1)</code> for <code>int8</code> quantized vectors
220
- * and <code>0</code> for <code>int4</code> for dynamic quantile calculation.
221
- * <p>
222
- * Only applicable to <code>int8_hnsw</code>, <code>int4_hnsw</code>,
223
- * <code>int8_flat</code>, and <code>int4_flat</code> index types.
224
- * <p>
225
- * API name: {@code confidence_interval}
180
+ * Required - API name: {@code type}
226
181
*/
227
- public final Builder confidenceInterval ( @ Nullable Float value ) {
228
- this .confidenceInterval = value ;
182
+ public final Builder type ( String value ) {
183
+ this .type = value ;
229
184
return this ;
230
185
}
231
186
232
187
/**
233
- * The number of candidates to track while assembling the list of nearest
234
- * neighbors for each new node.
235
- * <p>
236
- * Only applicable to <code>hnsw</code>, <code>int8_hnsw</code>, and
237
- * <code>int4_hnsw</code> index types.
238
- * <p>
239
- * API name: {@code ef_construction}
188
+ * API name: {@code m}
240
189
*/
241
- public final Builder efConstruction (@ Nullable Integer value ) {
242
- this .efConstruction = value ;
190
+ public final Builder m (@ Nullable Integer value ) {
191
+ this .m = value ;
243
192
return this ;
244
193
}
245
194
246
195
/**
247
- * The number of neighbors each node will be connected to in the HNSW graph.
248
- * <p>
249
- * Only applicable to <code>hnsw</code>, <code>int8_hnsw</code>, and
250
- * <code>int4_hnsw</code> index types.
251
- * <p>
252
- * API name: {@code m}
196
+ * API name: {@code ef_construction}
253
197
*/
254
- public final Builder m (@ Nullable Integer value ) {
255
- this .m = value ;
198
+ public final Builder efConstruction (@ Nullable Integer value ) {
199
+ this .efConstruction = value ;
256
200
return this ;
257
201
}
258
202
259
203
/**
260
- * Required - The type of kNN algorithm to use.
261
- * <p>
262
- * API name: {@code type}
204
+ * API name: {@code confidence_interval}
263
205
*/
264
- public final Builder type ( DenseVectorIndexOptionsType value ) {
265
- this .type = value ;
206
+ public final Builder confidenceInterval ( @ Nullable Float value ) {
207
+ this .confidenceInterval = value ;
266
208
return this ;
267
209
}
268
210
@@ -295,10 +237,10 @@ public DenseVectorIndexOptions build() {
295
237
protected static void setupDenseVectorIndexOptionsDeserializer (
296
238
ObjectDeserializer <DenseVectorIndexOptions .Builder > op ) {
297
239
298
- op .add (Builder ::confidenceInterval , JsonpDeserializer .floatDeserializer (), "confidence_interval" );
299
- op .add (Builder ::efConstruction , JsonpDeserializer .integerDeserializer (), "ef_construction" );
240
+ op .add (Builder ::type , JsonpDeserializer .stringDeserializer (), "type" );
300
241
op .add (Builder ::m , JsonpDeserializer .integerDeserializer (), "m" );
301
- op .add (Builder ::type , DenseVectorIndexOptionsType ._DESERIALIZER , "type" );
242
+ op .add (Builder ::efConstruction , JsonpDeserializer .integerDeserializer (), "ef_construction" );
243
+ op .add (Builder ::confidenceInterval , JsonpDeserializer .floatDeserializer (), "confidence_interval" );
302
244
303
245
}
304
246
0 commit comments