@@ -43,35 +43,22 @@ public interface HashedBytesValues {
43
43
HashedBytesRef makeSafe (HashedBytesRef bytes );
44
44
45
45
/**
46
- * Returns a bytes value for a docId. Note, the content of it might be shared across invocation.
46
+ * Returns a bytes value for a docId. Note, the content of it might be shared across invocation,
47
+ * call {@link #makeSafe(org.elasticsearch.common.lucene.HashedBytesRef)} to converts it to a "safe"
48
+ * option (if needed).
47
49
*/
48
50
HashedBytesRef getValue (int docId );
49
51
50
- /**
51
- * Returns a bytes value for a docId. The content is guaranteed not to be shared.
52
- */
53
- HashedBytesRef getValueSafe (int docId );
54
-
55
52
/**
56
53
* Returns a bytes value iterator for a docId. Note, the content of it might be shared across invocation.
57
54
*/
58
55
Iter getIter (int docId );
59
56
60
- /**
61
- * Returns a bytes value iterator for a docId. The content is guaranteed not to be shared.
62
- */
63
- Iter getIterSafe (int docId );
64
-
65
57
/**
66
58
* Go over all the possible values in their BytesRef format for a specific doc.
67
59
*/
68
60
void forEachValueInDoc (int docId , ValueInDocProc proc );
69
61
70
- /**
71
- * Go over all the possible values in their BytesRef format for a specific doc.
72
- */
73
- void forEachSafeValueInDoc (int docId , ValueInDocProc proc );
74
-
75
62
public static interface ValueInDocProc {
76
63
void onValue (int docId , HashedBytesRef value );
77
64
@@ -133,9 +120,7 @@ static class BytesBased implements HashedBytesValues {
133
120
134
121
protected final HashedBytesRef scratch = new HashedBytesRef (new BytesRef ());
135
122
private final ValueIter valueIter = new ValueIter ();
136
- private final SafeValueIter safeValueIter = new SafeValueIter ();
137
123
private final Proc proc = new Proc ();
138
- private final SafeProc safeProc = new SafeProc ();
139
124
140
125
public BytesBased (BytesValues values ) {
141
126
this .values = values ;
@@ -164,31 +149,16 @@ public HashedBytesRef getValue(int docId) {
164
149
return scratch .resetHashCode ();
165
150
}
166
151
167
- @ Override
168
- public HashedBytesRef getValueSafe (int docId ) {
169
- return new HashedBytesRef (values .getValueSafe (docId ));
170
- }
171
-
172
152
@ Override
173
153
public Iter getIter (int docId ) {
174
154
return valueIter .reset (values .getIter (docId ));
175
155
}
176
156
177
- @ Override
178
- public Iter getIterSafe (int docId ) {
179
- return safeValueIter .reset (values .getIterSafe (docId ));
180
- }
181
-
182
157
@ Override
183
158
public void forEachValueInDoc (int docId , final ValueInDocProc proc ) {
184
159
values .forEachValueInDoc (docId , this .proc .reset (proc ));
185
160
}
186
161
187
- @ Override
188
- public void forEachSafeValueInDoc (int docId , final ValueInDocProc proc ) {
189
- values .forEachValueInDoc (docId , this .safeProc .reset (proc ));
190
- }
191
-
192
162
static class ValueIter implements Iter {
193
163
194
164
private final HashedBytesRef scratch = new HashedBytesRef (new BytesRef ());
@@ -211,26 +181,6 @@ public HashedBytesRef next() {
211
181
}
212
182
}
213
183
214
- static class SafeValueIter implements Iter {
215
-
216
- private BytesValues .Iter iter ;
217
-
218
- public SafeValueIter reset (BytesValues .Iter iter ) {
219
- this .iter = iter ;
220
- return this ;
221
- }
222
-
223
- @ Override
224
- public boolean hasNext () {
225
- return iter .hasNext ();
226
- }
227
-
228
- @ Override
229
- public HashedBytesRef next () {
230
- return new HashedBytesRef (iter .next ());
231
- }
232
- }
233
-
234
184
static class Proc implements BytesValues .ValueInDocProc {
235
185
236
186
private final HashedBytesRef scratch = new HashedBytesRef ();
@@ -252,27 +202,6 @@ public void onMissing(int docId) {
252
202
proc .onMissing (docId );
253
203
}
254
204
}
255
-
256
- static class SafeProc implements BytesValues .ValueInDocProc {
257
-
258
- private ValueInDocProc proc ;
259
-
260
- public SafeProc reset (ValueInDocProc proc ) {
261
- this .proc = proc ;
262
- return this ;
263
- }
264
-
265
- @ Override
266
- public void onValue (int docId , BytesRef value ) {
267
- proc .onValue (docId , new HashedBytesRef (value ));
268
- }
269
-
270
- @ Override
271
- public void onMissing (int docId ) {
272
- proc .onMissing (docId );
273
- }
274
- }
275
-
276
205
}
277
206
278
207
static class StringBased implements HashedBytesValues {
@@ -281,9 +210,7 @@ static class StringBased implements HashedBytesValues {
281
210
282
211
protected final HashedBytesRef scratch = new HashedBytesRef (new BytesRef ());
283
212
private final ValueIter valueIter = new ValueIter ();
284
- private final SafeValueIter safeValueIter = new SafeValueIter ();
285
213
private final Proc proc = new Proc ();
286
- private final SafeProc safeProc = new SafeProc ();
287
214
288
215
public StringBased (StringValues values ) {
289
216
this .values = values ;
@@ -313,33 +240,16 @@ public HashedBytesRef getValue(int docId) {
313
240
return scratch .resetHashCode ();
314
241
}
315
242
316
- @ Override
317
- public HashedBytesRef getValueSafe (int docId ) {
318
- String value = values .getValue (docId );
319
- if (value == null ) return null ;
320
- return new HashedBytesRef (new BytesRef (values .getValue (docId )));
321
- }
322
-
323
243
@ Override
324
244
public Iter getIter (int docId ) {
325
245
return valueIter .reset (values .getIter (docId ));
326
246
}
327
247
328
- @ Override
329
- public Iter getIterSafe (int docId ) {
330
- return safeValueIter .reset (values .getIter (docId ));
331
- }
332
-
333
248
@ Override
334
249
public void forEachValueInDoc (int docId , final ValueInDocProc proc ) {
335
250
values .forEachValueInDoc (docId , this .proc .reset (proc ));
336
251
}
337
252
338
- @ Override
339
- public void forEachSafeValueInDoc (int docId , final ValueInDocProc proc ) {
340
- values .forEachValueInDoc (docId , this .safeProc .reset (proc ));
341
- }
342
-
343
253
static class ValueIter implements Iter {
344
254
345
255
private final HashedBytesRef scratch = new HashedBytesRef (new BytesRef ());
@@ -362,26 +272,6 @@ public HashedBytesRef next() {
362
272
}
363
273
}
364
274
365
- static class SafeValueIter implements Iter {
366
-
367
- private StringValues .Iter iter ;
368
-
369
- public SafeValueIter reset (StringValues .Iter iter ) {
370
- this .iter = iter ;
371
- return this ;
372
- }
373
-
374
- @ Override
375
- public boolean hasNext () {
376
- return iter .hasNext ();
377
- }
378
-
379
- @ Override
380
- public HashedBytesRef next () {
381
- return new HashedBytesRef (new BytesRef (iter .next ()));
382
- }
383
- }
384
-
385
275
static class Proc implements StringValues .ValueInDocProc {
386
276
387
277
private final HashedBytesRef scratch = new HashedBytesRef (new BytesRef ());
@@ -403,25 +293,5 @@ public void onMissing(int docId) {
403
293
proc .onMissing (docId );
404
294
}
405
295
}
406
-
407
- static class SafeProc implements StringValues .ValueInDocProc {
408
-
409
- private ValueInDocProc proc ;
410
-
411
- public SafeProc reset (ValueInDocProc proc ) {
412
- this .proc = proc ;
413
- return this ;
414
- }
415
-
416
- @ Override
417
- public void onValue (int docId , String value ) {
418
- proc .onValue (docId , new HashedBytesRef (new BytesRef (value )));
419
- }
420
-
421
- @ Override
422
- public void onMissing (int docId ) {
423
- proc .onMissing (docId );
424
- }
425
- }
426
296
}
427
297
}
0 commit comments