Skip to content

Commit 9a127ad

Browse files
authored
Implement fields fetch for runtime fields (#61995)
This implements the `fields` API in `_search` for runtime fields using doc values. Most of that implementation is stolen from the `docvalue_fields` fetch sub-phase, just moved into the same API that the `fields` API uses. At this point the `docvalue_fields` fetch phase looks like a special case of the `fields` API. While I was at it I moved the "which doc values sub-implementation should I use for fetching?" question from a bunch of `instanceof`s to a method on `LeafFieldData` so we can be much more flexible with what is returned and we're not forced to extend certain classes just to make the fetch phase happy. Relates to #59332
1 parent 5075e83 commit 9a127ad

File tree

107 files changed

+640
-341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+640
-341
lines changed

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeatureFieldMapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private Float objectToFloat(Object value) {
183183
}
184184

185185
@Override
186-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
186+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
187187
if (format != null) {
188188
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
189189
}

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeaturesFieldMapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
162162
}
163163

164164
@Override
165-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
165+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
166166
if (format != null) {
167167
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
168168
}

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ private static double objectToDouble(Object value) {
397397
}
398398

399399
@Override
400-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
400+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
401401
if (format != null) {
402402
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
403403
}

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/SearchAsYouTypeFieldMapper.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.elasticsearch.index.query.QueryShardContext;
5555
import org.elasticsearch.index.similarity.SimilarityProvider;
5656
import org.elasticsearch.index.similarity.SimilarityService;
57+
import org.elasticsearch.search.lookup.SearchLookup;
5758

5859
import java.io.IOException;
5960
import java.util.ArrayList;
@@ -419,7 +420,7 @@ protected void parseCreateField(ParseContext context) {
419420
}
420421

421422
@Override
422-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
423+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
423424
throw new UnsupportedOperationException();
424425
}
425426

@@ -465,7 +466,7 @@ protected void mergeOptions(FieldMapper other, List<String> conflicts) {
465466
}
466467

467468
@Override
468-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
469+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
469470
throw new UnsupportedOperationException();
470471
}
471472

@@ -588,7 +589,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
588589
}
589590

590591
@Override
591-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
592+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
592593
throw new UnsupportedOperationException();
593594
}
594595

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/TokenCountFieldMapper.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.lucene.document.FieldType;
2626
import org.elasticsearch.common.xcontent.XContentBuilder;
2727
import org.elasticsearch.index.analysis.NamedAnalyzer;
28+
import org.elasticsearch.search.lookup.SearchLookup;
2829

2930
import java.io.IOException;
3031
import java.util.Iterator;
@@ -159,7 +160,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
159160
}
160161

161162
@Override
162-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
163+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
163164
if (format != null) {
164165
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
165166
}

modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RankFeatureFieldMapperTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public void testRejectMultiValuedFields() throws MapperParsingException, IOExcep
147147
e.getCause().getMessage());
148148
}
149149

150-
public void testFetchSourceValue() {
150+
public void testFetchSourceValue() throws IOException {
151151
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id).build();
152152
Mapper.BuilderContext context = new Mapper.BuilderContext(settings, new ContentPath());
153153
RankFeatureFieldMapper mapper = new RankFeatureFieldMapper.Builder("field").build(context);

modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapperTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public void testRejectIndexOptions() {
259259
containsString("Failed to parse mapping: unknown parameter [index_options] on mapper [field] of type [scaled_float]"));
260260
}
261261

262-
public void testFetchSourceValue() {
262+
public void testFetchSourceValue() throws IOException {
263263
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id).build();
264264
Mapper.BuilderContext context = new Mapper.BuilderContext(settings, new ContentPath());
265265

modules/parent-join/src/main/java/org/elasticsearch/join/mapper/MetaJoinFieldMapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
140140
}
141141

142142
@Override
143-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
143+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
144144
throw new UnsupportedOperationException("Cannot fetch values for metadata field [" + typeName() + "].");
145145
}
146146

modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentIdFieldMapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
190190
}
191191

192192
@Override
193-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
193+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
194194
throw new UnsupportedOperationException("Cannot fetch values for internal field [" + typeName() + "].");
195195
}
196196

modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentJoinFieldMapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
352352
}
353353

354354
@Override
355-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
355+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
356356
if (format != null) {
357357
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
358358
}

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
import org.elasticsearch.index.query.QueryShardException;
8080
import org.elasticsearch.index.query.Rewriteable;
8181
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
82+
import org.elasticsearch.search.lookup.SearchLookup;
8283

8384
import java.io.ByteArrayOutputStream;
8485
import java.io.IOException;
@@ -366,7 +367,7 @@ public void parse(ParseContext context) throws IOException {
366367
}
367368

368369
@Override
369-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
370+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
370371
if (format != null) {
371372
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
372373
}

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorHighlightSubFetchPhase.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import org.elasticsearch.search.fetch.subphase.highlight.Highlighter;
3535
import org.elasticsearch.search.fetch.subphase.highlight.SearchHighlightContext;
3636
import org.elasticsearch.search.internal.SearchContext;
37+
import org.elasticsearch.search.lookup.SearchLookup;
38+
import org.elasticsearch.search.lookup.SourceLookup;
3739

3840
import java.io.IOException;
3941
import java.util.ArrayList;
@@ -54,7 +56,7 @@ final class PercolatorHighlightSubFetchPhase implements FetchSubPhase {
5456
}
5557

5658
@Override
57-
public FetchSubPhaseProcessor getProcessor(SearchContext searchContext) throws IOException {
59+
public FetchSubPhaseProcessor getProcessor(SearchContext searchContext, SearchLookup lookup) throws IOException {
5860
if (searchContext.highlight() == null) {
5961
return null;
6062
}
@@ -95,7 +97,7 @@ public void process(HitContext hit) throws IOException {
9597
BytesReference document = percolateQuery.getDocuments().get(slot);
9698
HitContext subContext = new HitContext(
9799
new SearchHit(slot, "unknown", Collections.emptyMap(), Collections.emptyMap()),
98-
percolatorLeafReaderContext, slot, new HashMap<>()
100+
percolatorLeafReaderContext, slot, new SourceLookup(), new HashMap<>()
99101
);
100102
subContext.sourceLookup().setSource(document);
101103
// force source because MemoryIndex does not store fields

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorMatchedSlotSubFetchPhase.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.elasticsearch.search.fetch.FetchSubPhase;
3737
import org.elasticsearch.search.fetch.FetchSubPhaseProcessor;
3838
import org.elasticsearch.search.internal.SearchContext;
39+
import org.elasticsearch.search.lookup.SearchLookup;
3940

4041
import java.io.IOException;
4142
import java.util.ArrayList;
@@ -56,7 +57,7 @@ final class PercolatorMatchedSlotSubFetchPhase implements FetchSubPhase {
5657
static final String FIELD_NAME_PREFIX = "_percolator_document_slot";
5758

5859
@Override
59-
public FetchSubPhaseProcessor getProcessor(SearchContext searchContext) throws IOException {
60+
public FetchSubPhaseProcessor getProcessor(SearchContext searchContext, SearchLookup lookup) throws IOException {
6061

6162
List<PercolateContext> percolateContexts = new ArrayList<>();
6263
List<PercolateQuery> percolateQueries = locatePercolatorQuery(searchContext.query());

modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorHighlightSubFetchPhaseTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public void testHitsExecutionNeeded() throws IOException {
5252
Mockito.when(searchContext.highlight()).thenReturn(new SearchHighlightContext(Collections.emptyList()));
5353
Mockito.when(searchContext.query()).thenReturn(new MatchAllDocsQuery());
5454

55-
assertNull(subFetchPhase.getProcessor(searchContext));
55+
assertNull(subFetchPhase.getProcessor(searchContext, null));
5656
Mockito.when(searchContext.query()).thenReturn(percolateQuery);
57-
assertNotNull(subFetchPhase.getProcessor(searchContext));
57+
assertNotNull(subFetchPhase.getProcessor(searchContext, null));
5858
}
5959

6060
public void testLocatePercolatorQuery() {

modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorMatchedSlotSubFetchPhaseTests.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.elasticsearch.search.fetch.FetchSubPhase.HitContext;
4141
import org.elasticsearch.search.fetch.FetchSubPhaseProcessor;
4242
import org.elasticsearch.search.internal.SearchContext;
43+
import org.elasticsearch.search.lookup.SourceLookup;
4344
import org.elasticsearch.test.ESTestCase;
4445

4546
import java.util.Collections;
@@ -66,7 +67,7 @@ public void testHitsExecute() throws Exception {
6667
LeafReaderContext context = reader.leaves().get(0);
6768
// A match:
6869
{
69-
HitContext hit = new HitContext(new SearchHit(0), context, 0, new HashMap<>());
70+
HitContext hit = new HitContext(new SearchHit(0), context, 0, new SourceLookup(), new HashMap<>());
7071
PercolateQuery.QueryStore queryStore = ctx -> docId -> new TermQuery(new Term("field", "value"));
7172
MemoryIndex memoryIndex = new MemoryIndex();
7273
memoryIndex.addField("field", "value", new WhitespaceAnalyzer());
@@ -77,7 +78,7 @@ public void testHitsExecute() throws Exception {
7778
SearchContext sc = mock(SearchContext.class);
7879
when(sc.query()).thenReturn(percolateQuery);
7980

80-
FetchSubPhaseProcessor processor = phase.getProcessor(sc);
81+
FetchSubPhaseProcessor processor = phase.getProcessor(sc, null);
8182
assertNotNull(processor);
8283
processor.process(hit);
8384

@@ -87,7 +88,7 @@ public void testHitsExecute() throws Exception {
8788

8889
// No match:
8990
{
90-
HitContext hit = new HitContext(new SearchHit(0), context, 0, new HashMap<>());
91+
HitContext hit = new HitContext(new SearchHit(0), context, 0, new SourceLookup(), new HashMap<>());
9192
PercolateQuery.QueryStore queryStore = ctx -> docId -> new TermQuery(new Term("field", "value"));
9293
MemoryIndex memoryIndex = new MemoryIndex();
9394
memoryIndex.addField("field", "value1", new WhitespaceAnalyzer());
@@ -98,7 +99,7 @@ public void testHitsExecute() throws Exception {
9899
SearchContext sc = mock(SearchContext.class);
99100
when(sc.query()).thenReturn(percolateQuery);
100101

101-
FetchSubPhaseProcessor processor = phase.getProcessor(sc);
102+
FetchSubPhaseProcessor processor = phase.getProcessor(sc, null);
102103
assertNotNull(processor);
103104
processor.process(hit);
104105

@@ -107,7 +108,7 @@ public void testHitsExecute() throws Exception {
107108

108109
// No query:
109110
{
110-
HitContext hit = new HitContext(new SearchHit(0), context, 0, new HashMap<>());
111+
HitContext hit = new HitContext(new SearchHit(0), context, 0, new SourceLookup(), new HashMap<>());
111112
PercolateQuery.QueryStore queryStore = ctx -> docId -> null;
112113
MemoryIndex memoryIndex = new MemoryIndex();
113114
memoryIndex.addField("field", "value", new WhitespaceAnalyzer());
@@ -118,7 +119,7 @@ public void testHitsExecute() throws Exception {
118119
SearchContext sc = mock(SearchContext.class);
119120
when(sc.query()).thenReturn(percolateQuery);
120121

121-
FetchSubPhaseProcessor processor = phase.getProcessor(sc);
122+
FetchSubPhaseProcessor processor = phase.getProcessor(sc, null);
122123
assertNotNull(processor);
123124
processor.process(hit);
124125

plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
735735
}
736736

737737
@Override
738-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
738+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
739739
if (format != null) {
740740
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
741741
}

plugins/analysis-icu/src/test/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapperTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public void testUpdateIgnoreAbove() throws IOException {
317317
assertEquals(0, fields.length);
318318
}
319319

320-
public void testFetchSourceValue() {
320+
public void testFetchSourceValue() throws IOException {
321321
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id).build();
322322
Mapper.BuilderContext context = new Mapper.BuilderContext(settings, new ContentPath());
323323

plugins/mapper-annotated-text/src/internalClusterTest/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapperTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ public void testEmptyName() throws IOException {
678678
assertThat(e.getMessage(), containsString("name cannot be empty string"));
679679
}
680680

681-
public void testFetchSourceValue() {
681+
public void testFetchSourceValue() throws IOException {
682682
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id).build();
683683
Mapper.BuilderContext context = new Mapper.BuilderContext(settings, new ContentPath());
684684

plugins/mapper-annotated-text/src/main/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapper.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.elasticsearch.index.mapper.ValueFetcher;
4747
import org.elasticsearch.index.mapper.annotatedtext.AnnotatedTextFieldMapper.AnnotatedText.AnnotationToken;
4848
import org.elasticsearch.index.similarity.SimilarityProvider;
49+
import org.elasticsearch.search.lookup.SearchLookup;
4950

5051
import java.io.IOException;
5152
import java.io.Reader;
@@ -589,7 +590,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
589590
}
590591

591592
@Override
592-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
593+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
593594
if (format != null) {
594595
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
595596
}

plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ protected void parseCreateField(ParseContext context)
153153
}
154154

155155
@Override
156-
public ValueFetcher valueFetcher(MapperService mapperService, String format) {
156+
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
157157
if (format != null) {
158158
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
159159
}

rest-api-spec/src/main/resources/rest-api-spec/test/search/240_date_nanos.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,15 @@ setup:
110110
rest_total_hits_as_int: true
111111
index: date*
112112
body:
113-
docvalue_fields: [ { "field": "date", "format" : "strict_date_optional_time" }, { "field": "date", "format": "epoch_millis" }, { "field" : "date", "format": "uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSSX" } ]
114-
sort: [ { "date": "desc" } ]
113+
docvalue_fields:
114+
- field: date
115+
format: strict_date_optional_time
116+
- field: date
117+
format: epoch_millis
118+
- field: date
119+
format: uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSSX
120+
sort:
121+
- date: desc
115122

116123
- match: { hits.total: 2 }
117124
- length: { hits.hits: 2 }

server/src/internalClusterTest/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.elasticsearch.search.SearchExtBuilder;
4040
import org.elasticsearch.search.builder.SearchSourceBuilder;
4141
import org.elasticsearch.search.internal.SearchContext;
42+
import org.elasticsearch.search.lookup.SearchLookup;
4243
import org.elasticsearch.test.ESIntegTestCase;
4344
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
4445
import org.elasticsearch.test.ESIntegTestCase.Scope;
@@ -114,7 +115,7 @@ private static final class TermVectorsFetchSubPhase implements FetchSubPhase {
114115
private static final String NAME = "term_vectors_fetch";
115116

116117
@Override
117-
public FetchSubPhaseProcessor getProcessor(SearchContext searchContext) {
118+
public FetchSubPhaseProcessor getProcessor(SearchContext searchContext, SearchLookup lookup) {
118119
return new FetchSubPhaseProcessor() {
119120
@Override
120121
public void setNextReader(LeafReaderContext readerContext) {

server/src/main/java/org/elasticsearch/index/fielddata/IndexNumericFieldData.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
import org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource;
3333
import org.elasticsearch.search.DocValueFormat;
3434
import org.elasticsearch.search.MultiValueMode;
35-
import org.elasticsearch.search.sort.BucketedSort;
36-
import org.elasticsearch.search.sort.SortOrder;
3735
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
3836
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
37+
import org.elasticsearch.search.sort.BucketedSort;
38+
import org.elasticsearch.search.sort.SortOrder;
3939

4040
import java.io.IOException;
4141
import java.util.function.LongUnaryOperator;

server/src/main/java/org/elasticsearch/index/fielddata/LeafFieldData.java

+26
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222
import org.apache.lucene.util.Accountable;
2323
import org.elasticsearch.common.lease.Releasable;
24+
import org.elasticsearch.index.mapper.DocValueFetcher;
25+
import org.elasticsearch.search.DocValueFormat;
26+
27+
import java.io.IOException;
2428

2529
/**
2630
* The thread safe {@link org.apache.lucene.index.LeafReader} level cache of the data.
@@ -37,4 +41,26 @@ public interface LeafFieldData extends Accountable, Releasable {
3741
*/
3842
SortedBinaryDocValues getBytesValues();
3943

44+
/**
45+
* Return a value fetcher for this leaf implementation.
46+
*/
47+
default DocValueFetcher.Leaf getLeafValueFetcher(DocValueFormat format) {
48+
SortedBinaryDocValues values = getBytesValues();
49+
return new DocValueFetcher.Leaf() {
50+
@Override
51+
public boolean advanceExact(int docId) throws IOException {
52+
return values.advanceExact(docId);
53+
}
54+
55+
@Override
56+
public int docValueCount() throws IOException {
57+
return values.docValueCount();
58+
}
59+
60+
@Override
61+
public Object nextValue() throws IOException {
62+
return format.format(values.nextValue());
63+
}
64+
};
65+
}
4066
}

0 commit comments

Comments
 (0)