Skip to content

Commit b89660a

Browse files
committed
iter
1 parent 5487cf8 commit b89660a

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

server/src/main/java/org/elasticsearch/index/mapper/Mapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,14 @@ public static FieldType freezeAndDeduplicateFieldType(FieldType fieldType) {
214214
public abstract int getTotalFieldsCount();
215215

216216
/**
217-
* @return whether this mapper support storing leaf array elements natively when synthetic source is enabled.
217+
* @return whether this mapper supports storing leaf array elements natively when synthetic source is enabled.
218218
*/
219219
public boolean supportStoringArrayOffsets(DocumentParserContext context) {
220220
return false;
221221
}
222222

223223
/**
224-
* @return the offset field name use the store offsets iff {@link #supportStoringArrayOffsets(DocumentParserContext)} returns
224+
* @return the offset field name used the store offsets iff {@link #supportStoringArrayOffsets(DocumentParserContext)} returns
225225
* <code>true</code>.
226226
*/
227227
public String getOffsetFieldName() {

server/src/main/java/org/elasticsearch/index/mapper/SortedSetWithOffsetsDocValuesSyntheticFieldLoaderLayer.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class SortedSetWithOffsetsDocValuesSyntheticFieldLoaderLayer implements Co
3131

3232
private final String name;
3333
private final String offsetsFieldName;
34-
private ImmediateDocValuesLoader docValues;
34+
private DocValuesWithOffsetsLoader docValues;
3535

3636
SortedSetWithOffsetsDocValuesSyntheticFieldLoaderLayer(String name, String offsetsFieldName) {
3737
this.name = Objects.requireNonNull(name);
@@ -48,9 +48,7 @@ public DocValuesLoader docValuesLoader(LeafReader leafReader, int[] docIdsInLeaf
4848
SortedSetDocValues valueDocValues = DocValues.getSortedSet(leafReader, name);
4949
BinaryDocValues offsetDocValues = DocValues.getBinary(leafReader, offsetsFieldName);
5050

51-
ImmediateDocValuesLoader loader = new ImmediateDocValuesLoader(valueDocValues, offsetDocValues);
52-
docValues = loader;
53-
return loader;
51+
return docValues = new DocValuesWithOffsetsLoader(valueDocValues, offsetDocValues);
5452
}
5553

5654
@Override
@@ -78,7 +76,7 @@ public void write(XContentBuilder b) throws IOException {
7876
}
7977
}
8078

81-
static final class ImmediateDocValuesLoader implements DocValuesLoader {
79+
static final class DocValuesWithOffsetsLoader implements DocValuesLoader {
8280
private final BinaryDocValues offsetDocValues;
8381
private final SortedSetDocValues valueDocValues;
8482
private final ByteArrayStreamInput scratch = new ByteArrayStreamInput();
@@ -87,7 +85,7 @@ static final class ImmediateDocValuesLoader implements DocValuesLoader {
8785
private boolean hasOffset;
8886
private int[] offsetToOrd;
8987

90-
ImmediateDocValuesLoader(SortedSetDocValues valueDocValues, BinaryDocValues offsetDocValues) {
88+
DocValuesWithOffsetsLoader(SortedSetDocValues valueDocValues, BinaryDocValues offsetDocValues) {
9189
this.valueDocValues = valueDocValues;
9290
this.offsetDocValues = offsetDocValues;
9391
}
@@ -148,6 +146,7 @@ public void write(XContentBuilder b) throws IOException {
148146

149147
long ord = ords[offset];
150148
BytesRef c = valueDocValues.lookupOrd(ord);
149+
// This is keyword specific and needs to be updated once support is added for other field types:
151150
b.utf8Value(c.bytes, c.offset, c.length);
152151
}
153152
} else if (offsetToOrd != null) {

server/src/test/java/org/elasticsearch/index/mapper/OffsetDocValuesLoaderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.elasticsearch.common.Strings;
1414
import org.elasticsearch.common.bytes.BytesArray;
1515
import org.elasticsearch.common.settings.Settings;
16-
import org.elasticsearch.index.mapper.SortedSetWithOffsetsDocValuesSyntheticFieldLoaderLayer.ImmediateDocValuesLoader;
16+
import org.elasticsearch.index.mapper.SortedSetWithOffsetsDocValuesSyntheticFieldLoaderLayer.DocValuesWithOffsetsLoader;
1717
import org.elasticsearch.xcontent.XContentBuilder;
1818
import org.elasticsearch.xcontent.XContentType;
1919

@@ -203,7 +203,7 @@ private void verifyOffsets(String mapping, String source, String expectedSource)
203203
try (var indexReader = wrapInMockESDirectoryReader(DirectoryReader.open(directory))) {
204204
var layer = new SortedSetWithOffsetsDocValuesSyntheticFieldLoaderLayer("field", "field.offsets");
205205
var leafReader = indexReader.leaves().getFirst().reader();
206-
var loader = (ImmediateDocValuesLoader) layer.docValuesLoader(leafReader, new int[] { 0 });
206+
var loader = (DocValuesWithOffsetsLoader) layer.docValuesLoader(leafReader, new int[] { 0 });
207207
assertTrue(loader.advanceToDoc(0));
208208
assertTrue(loader.count() > 0);
209209
XContentBuilder builder = jsonBuilder().startObject();

0 commit comments

Comments
 (0)