Skip to content

Commit e5b6513

Browse files
committed
remove some safe methods because of the new makeSafe method usage
1 parent f189a83 commit e5b6513

File tree

5 files changed

+3
-580
lines changed

5 files changed

+3
-580
lines changed

src/main/java/org/elasticsearch/index/fielddata/BytesValues.java

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ public interface BytesValues {
5555
*/
5656
BytesRef getValueScratch(int docId, BytesRef ret);
5757

58-
/**
59-
* Returns a bytes value for a docId. The content is guaranteed not to be shared.
60-
*/
61-
BytesRef getValueSafe(int docId);
62-
6358
/**
6459
* Returns an array wrapping all the bytes values for a doc. The content is guaranteed not to be shared.
6560
*/
@@ -70,21 +65,11 @@ public interface BytesValues {
7065
*/
7166
Iter getIter(int docId);
7267

73-
/**
74-
* Returns a bytes value iterator for a docId. The content is guaranteed not to be shared.
75-
*/
76-
Iter getIterSafe(int docId);
77-
7868
/**
7969
* Go over all the possible values in their BytesRef format for a specific doc.
8070
*/
8171
void forEachValueInDoc(int docId, ValueInDocProc proc);
8272

83-
/**
84-
* Go over all the possible values in their BytesRef format for a specific doc.
85-
*/
86-
void forEachSafeValueInDoc(int docId, ValueInDocProc proc);
87-
8873
public static interface ValueInDocProc {
8974
void onValue(int docId, BytesRef value);
9075

@@ -144,9 +129,7 @@ public static class StringBased implements BytesValues {
144129
protected final BytesRef scratch = new BytesRef();
145130
private final BytesRefArrayRef arrayScratch = new BytesRefArrayRef(new BytesRef[1], 1);
146131
private final ValueIter valueIter = new ValueIter();
147-
private final SafeValueIter safeValueIter = new SafeValueIter();
148132
private final Proc proc = new Proc();
149-
private final SafeProc safeProc = new SafeProc();
150133

151134
public StringBased(StringValues values) {
152135
this.values = values;
@@ -187,13 +170,6 @@ public BytesRef getValueScratch(int docId, BytesRef ret) {
187170
return ret;
188171
}
189172

190-
@Override
191-
public BytesRef getValueSafe(int docId) {
192-
String value = values.getValue(docId);
193-
if (value == null) return null;
194-
return new BytesRef(value);
195-
}
196-
197173
@Override
198174
public BytesRefArrayRef getValues(int docId) {
199175
StringArrayRef arrayRef = values.getValues(docId);
@@ -214,21 +190,11 @@ public Iter getIter(int docId) {
214190
return valueIter.reset(values.getIter(docId));
215191
}
216192

217-
@Override
218-
public Iter getIterSafe(int docId) {
219-
return safeValueIter.reset(values.getIter(docId));
220-
}
221-
222193
@Override
223194
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
224195
values.forEachValueInDoc(docId, this.proc.reset(proc));
225196
}
226197

227-
@Override
228-
public void forEachSafeValueInDoc(int docId, ValueInDocProc proc) {
229-
values.forEachValueInDoc(docId, this.safeProc.reset(proc));
230-
}
231-
232198
static class ValueIter implements Iter {
233199

234200
private final BytesRef scratch = new BytesRef();
@@ -251,26 +217,6 @@ public BytesRef next() {
251217
}
252218
}
253219

254-
static class SafeValueIter implements Iter {
255-
256-
private StringValues.Iter iter;
257-
258-
public SafeValueIter reset(StringValues.Iter iter) {
259-
this.iter = iter;
260-
return this;
261-
}
262-
263-
@Override
264-
public boolean hasNext() {
265-
return iter.hasNext();
266-
}
267-
268-
@Override
269-
public BytesRef next() {
270-
return new BytesRef(iter.next());
271-
}
272-
}
273-
274220
static class Proc implements StringValues.ValueInDocProc {
275221

276222
private final BytesRef scratch = new BytesRef();
@@ -292,25 +238,5 @@ public void onMissing(int docId) {
292238
proc.onMissing(docId);
293239
}
294240
}
295-
296-
static class SafeProc implements StringValues.ValueInDocProc {
297-
298-
private BytesValues.ValueInDocProc proc;
299-
300-
public SafeProc reset(BytesValues.ValueInDocProc proc) {
301-
this.proc = proc;
302-
return this;
303-
}
304-
305-
@Override
306-
public void onValue(int docId, String value) {
307-
proc.onValue(docId, new BytesRef(value));
308-
}
309-
310-
@Override
311-
public void onMissing(int docId) {
312-
proc.onMissing(docId);
313-
}
314-
}
315241
}
316242
}

src/main/java/org/elasticsearch/index/fielddata/HashedBytesValues.java

Lines changed: 3 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -43,35 +43,22 @@ public interface HashedBytesValues {
4343
HashedBytesRef makeSafe(HashedBytesRef bytes);
4444

4545
/**
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).
4749
*/
4850
HashedBytesRef getValue(int docId);
4951

50-
/**
51-
* Returns a bytes value for a docId. The content is guaranteed not to be shared.
52-
*/
53-
HashedBytesRef getValueSafe(int docId);
54-
5552
/**
5653
* Returns a bytes value iterator for a docId. Note, the content of it might be shared across invocation.
5754
*/
5855
Iter getIter(int docId);
5956

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-
6557
/**
6658
* Go over all the possible values in their BytesRef format for a specific doc.
6759
*/
6860
void forEachValueInDoc(int docId, ValueInDocProc proc);
6961

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-
7562
public static interface ValueInDocProc {
7663
void onValue(int docId, HashedBytesRef value);
7764

@@ -133,9 +120,7 @@ static class BytesBased implements HashedBytesValues {
133120

134121
protected final HashedBytesRef scratch = new HashedBytesRef(new BytesRef());
135122
private final ValueIter valueIter = new ValueIter();
136-
private final SafeValueIter safeValueIter = new SafeValueIter();
137123
private final Proc proc = new Proc();
138-
private final SafeProc safeProc = new SafeProc();
139124

140125
public BytesBased(BytesValues values) {
141126
this.values = values;
@@ -164,31 +149,16 @@ public HashedBytesRef getValue(int docId) {
164149
return scratch.resetHashCode();
165150
}
166151

167-
@Override
168-
public HashedBytesRef getValueSafe(int docId) {
169-
return new HashedBytesRef(values.getValueSafe(docId));
170-
}
171-
172152
@Override
173153
public Iter getIter(int docId) {
174154
return valueIter.reset(values.getIter(docId));
175155
}
176156

177-
@Override
178-
public Iter getIterSafe(int docId) {
179-
return safeValueIter.reset(values.getIterSafe(docId));
180-
}
181-
182157
@Override
183158
public void forEachValueInDoc(int docId, final ValueInDocProc proc) {
184159
values.forEachValueInDoc(docId, this.proc.reset(proc));
185160
}
186161

187-
@Override
188-
public void forEachSafeValueInDoc(int docId, final ValueInDocProc proc) {
189-
values.forEachValueInDoc(docId, this.safeProc.reset(proc));
190-
}
191-
192162
static class ValueIter implements Iter {
193163

194164
private final HashedBytesRef scratch = new HashedBytesRef(new BytesRef());
@@ -211,26 +181,6 @@ public HashedBytesRef next() {
211181
}
212182
}
213183

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-
234184
static class Proc implements BytesValues.ValueInDocProc {
235185

236186
private final HashedBytesRef scratch = new HashedBytesRef();
@@ -252,27 +202,6 @@ public void onMissing(int docId) {
252202
proc.onMissing(docId);
253203
}
254204
}
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-
276205
}
277206

278207
static class StringBased implements HashedBytesValues {
@@ -281,9 +210,7 @@ static class StringBased implements HashedBytesValues {
281210

282211
protected final HashedBytesRef scratch = new HashedBytesRef(new BytesRef());
283212
private final ValueIter valueIter = new ValueIter();
284-
private final SafeValueIter safeValueIter = new SafeValueIter();
285213
private final Proc proc = new Proc();
286-
private final SafeProc safeProc = new SafeProc();
287214

288215
public StringBased(StringValues values) {
289216
this.values = values;
@@ -313,33 +240,16 @@ public HashedBytesRef getValue(int docId) {
313240
return scratch.resetHashCode();
314241
}
315242

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-
323243
@Override
324244
public Iter getIter(int docId) {
325245
return valueIter.reset(values.getIter(docId));
326246
}
327247

328-
@Override
329-
public Iter getIterSafe(int docId) {
330-
return safeValueIter.reset(values.getIter(docId));
331-
}
332-
333248
@Override
334249
public void forEachValueInDoc(int docId, final ValueInDocProc proc) {
335250
values.forEachValueInDoc(docId, this.proc.reset(proc));
336251
}
337252

338-
@Override
339-
public void forEachSafeValueInDoc(int docId, final ValueInDocProc proc) {
340-
values.forEachValueInDoc(docId, this.safeProc.reset(proc));
341-
}
342-
343253
static class ValueIter implements Iter {
344254

345255
private final HashedBytesRef scratch = new HashedBytesRef(new BytesRef());
@@ -362,26 +272,6 @@ public HashedBytesRef next() {
362272
}
363273
}
364274

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-
385275
static class Proc implements StringValues.ValueInDocProc {
386276

387277
private final HashedBytesRef scratch = new HashedBytesRef(new BytesRef());
@@ -403,25 +293,5 @@ public void onMissing(int docId) {
403293
proc.onMissing(docId);
404294
}
405295
}
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-
}
426296
}
427297
}

0 commit comments

Comments
 (0)