Skip to content

Commit e1882cd

Browse files
authored
Runtime fields: rename fielddata and mapped field type classes (#62483)
With this commit we rename all of the fielddata, doc_values and mapped field type classes for runtime fields to not start with the Script prefix but rather their runtime type (e.g. Boolean) and only then Script
1 parent ecf370c commit e1882cd

26 files changed

+183
-185
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
import org.elasticsearch.search.sort.BucketedSort;
1919
import org.elasticsearch.search.sort.SortOrder;
2020

21-
public abstract class ScriptBinaryFieldData implements IndexFieldData<ScriptBinaryFieldData.ScriptBinaryLeafFieldData> {
21+
public abstract class BinaryScriptFieldData implements IndexFieldData<BinaryScriptFieldData.BinaryScriptLeafFieldData> {
2222
private final String fieldName;
2323

24-
protected ScriptBinaryFieldData(String fieldName) {
24+
protected BinaryScriptFieldData(String fieldName) {
2525
this.fieldName = fieldName;
2626
}
2727

@@ -31,7 +31,7 @@ public String getFieldName() {
3131
}
3232

3333
@Override
34-
public ScriptBinaryLeafFieldData load(LeafReaderContext context) {
34+
public BinaryScriptLeafFieldData load(LeafReaderContext context) {
3535
try {
3636
return loadDirect(context);
3737
} catch (Exception e) {
@@ -59,7 +59,7 @@ public BucketedSort newBucketedSort(
5959
throw new IllegalArgumentException("only supported on numeric fields");
6060
}
6161

62-
public abstract class ScriptBinaryLeafFieldData implements LeafFieldData {
62+
public abstract class BinaryScriptLeafFieldData implements LeafFieldData {
6363
@Override
6464
public long ramBytesUsed() {
6565
return 0;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
import java.io.IOException;
1313

14-
public final class ScriptBooleanDocValues extends AbstractSortedNumericDocValues {
14+
public final class BooleanScriptDocValues extends AbstractSortedNumericDocValues {
1515
private final BooleanFieldScript script;
1616
private int cursor;
1717

18-
ScriptBooleanDocValues(BooleanFieldScript script) {
18+
BooleanScriptDocValues(BooleanFieldScript script) {
1919
this.script = script;
2020
}
2121

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import java.io.IOException;
2323

24-
public final class ScriptBooleanFieldData extends IndexNumericFieldData {
24+
public final class BooleanScriptFieldData extends IndexNumericFieldData {
2525

2626
public static class Builder implements IndexFieldData.Builder {
2727
private final String name;
@@ -33,15 +33,15 @@ public Builder(String name, BooleanFieldScript.LeafFactory leafFactory) {
3333
}
3434

3535
@Override
36-
public ScriptBooleanFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
37-
return new ScriptBooleanFieldData(name, leafFactory);
36+
public BooleanScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
37+
return new BooleanScriptFieldData(name, leafFactory);
3838
}
3939
}
4040

4141
private final String fieldName;
4242
private final BooleanFieldScript.LeafFactory leafFactory;
4343

44-
private ScriptBooleanFieldData(String fieldName, BooleanFieldScript.LeafFactory leafFactory) {
44+
private BooleanScriptFieldData(String fieldName, BooleanFieldScript.LeafFactory leafFactory) {
4545
this.fieldName = fieldName;
4646
this.leafFactory = leafFactory;
4747
}
@@ -57,7 +57,7 @@ public ValuesSourceType getValuesSourceType() {
5757
}
5858

5959
@Override
60-
public ScriptBooleanLeafFieldData load(LeafReaderContext context) {
60+
public BooleanScriptLeafFieldData load(LeafReaderContext context) {
6161
try {
6262
return loadDirect(context);
6363
} catch (Exception e) {
@@ -66,8 +66,8 @@ public ScriptBooleanLeafFieldData load(LeafReaderContext context) {
6666
}
6767

6868
@Override
69-
public ScriptBooleanLeafFieldData loadDirect(LeafReaderContext context) throws IOException {
70-
return new ScriptBooleanLeafFieldData(new ScriptBooleanDocValues(leafFactory.newInstance(context)));
69+
public BooleanScriptLeafFieldData loadDirect(LeafReaderContext context) throws IOException {
70+
return new BooleanScriptLeafFieldData(new BooleanScriptDocValues(leafFactory.newInstance(context)));
7171
}
7272

7373
@Override
@@ -80,17 +80,17 @@ protected boolean sortRequiresCustomComparator() {
8080
return true;
8181
}
8282

83-
public static class ScriptBooleanLeafFieldData extends LeafLongFieldData {
84-
private final ScriptBooleanDocValues scriptBooleanDocValues;
83+
public static class BooleanScriptLeafFieldData extends LeafLongFieldData {
84+
private final BooleanScriptDocValues booleanScriptDocValues;
8585

86-
ScriptBooleanLeafFieldData(ScriptBooleanDocValues scriptBooleanDocValues) {
86+
BooleanScriptLeafFieldData(BooleanScriptDocValues booleanScriptDocValues) {
8787
super(0, NumericType.BOOLEAN);
88-
this.scriptBooleanDocValues = scriptBooleanDocValues;
88+
this.booleanScriptDocValues = booleanScriptDocValues;
8989
}
9090

9191
@Override
9292
public SortedNumericDocValues getLongValues() {
93-
return scriptBooleanDocValues;
93+
return booleanScriptDocValues;
9494
}
9595

9696
@Override
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import java.io.IOException;
2323

24-
public final class ScriptDateFieldData extends IndexNumericFieldData {
24+
public final class DateScriptFieldData extends IndexNumericFieldData {
2525

2626
public static class Builder implements IndexFieldData.Builder {
2727
private final String name;
@@ -33,15 +33,15 @@ public Builder(String name, DateFieldScript.LeafFactory leafFactory) {
3333
}
3434

3535
@Override
36-
public ScriptDateFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
37-
return new ScriptDateFieldData(name, leafFactory);
36+
public DateScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
37+
return new DateScriptFieldData(name, leafFactory);
3838
}
3939
}
4040

4141
private final String fieldName;
4242
private final DateFieldScript.LeafFactory leafFactory;
4343

44-
private ScriptDateFieldData(String fieldName, DateFieldScript.LeafFactory leafFactory) {
44+
private DateScriptFieldData(String fieldName, DateFieldScript.LeafFactory leafFactory) {
4545
this.fieldName = fieldName;
4646
this.leafFactory = leafFactory;
4747
}
@@ -57,7 +57,7 @@ public ValuesSourceType getValuesSourceType() {
5757
}
5858

5959
@Override
60-
public ScriptDateLeafFieldData load(LeafReaderContext context) {
60+
public DateScriptLeafFieldData load(LeafReaderContext context) {
6161
try {
6262
return loadDirect(context);
6363
} catch (Exception e) {
@@ -66,8 +66,8 @@ public ScriptDateLeafFieldData load(LeafReaderContext context) {
6666
}
6767

6868
@Override
69-
public ScriptDateLeafFieldData loadDirect(LeafReaderContext context) throws IOException {
70-
return new ScriptDateLeafFieldData(new ScriptLongDocValues(leafFactory.newInstance(context)));
69+
public DateScriptLeafFieldData loadDirect(LeafReaderContext context) throws IOException {
70+
return new DateScriptLeafFieldData(new LongScriptDocValues(leafFactory.newInstance(context)));
7171
}
7272

7373
@Override
@@ -80,17 +80,17 @@ protected boolean sortRequiresCustomComparator() {
8080
return true;
8181
}
8282

83-
public static class ScriptDateLeafFieldData extends LeafLongFieldData {
84-
private final ScriptLongDocValues scriptLongDocValues;
83+
public static class DateScriptLeafFieldData extends LeafLongFieldData {
84+
private final LongScriptDocValues longScriptDocValues;
8585

86-
ScriptDateLeafFieldData(ScriptLongDocValues scriptLongDocValues) {
86+
DateScriptLeafFieldData(LongScriptDocValues longScriptDocValues) {
8787
super(0, NumericType.DATE);
88-
this.scriptLongDocValues = scriptLongDocValues;
88+
this.longScriptDocValues = longScriptDocValues;
8989
}
9090

9191
@Override
9292
public SortedNumericDocValues getLongValues() {
93-
return scriptLongDocValues;
93+
return longScriptDocValues;
9494
}
9595
}
9696
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
import java.io.IOException;
1313
import java.util.Arrays;
1414

15-
public final class ScriptDoubleDocValues extends SortedNumericDoubleValues {
15+
public final class DoubleScriptDocValues extends SortedNumericDoubleValues {
1616
private final DoubleFieldScript script;
1717
private int cursor;
1818

19-
ScriptDoubleDocValues(DoubleFieldScript script) {
19+
DoubleScriptDocValues(DoubleFieldScript script) {
2020
this.script = script;
2121
}
2222

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import java.io.IOException;
2323

24-
public final class ScriptDoubleFieldData extends IndexNumericFieldData {
24+
public final class DoubleScriptFieldData extends IndexNumericFieldData {
2525

2626
public static class Builder implements IndexFieldData.Builder {
2727
private final String name;
@@ -33,15 +33,15 @@ public Builder(String name, DoubleFieldScript.LeafFactory leafFactory) {
3333
}
3434

3535
@Override
36-
public ScriptDoubleFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
37-
return new ScriptDoubleFieldData(name, leafFactory);
36+
public DoubleScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
37+
return new DoubleScriptFieldData(name, leafFactory);
3838
}
3939
}
4040

4141
private final String fieldName;
4242
DoubleFieldScript.LeafFactory leafFactory;
4343

44-
private ScriptDoubleFieldData(String fieldName, DoubleFieldScript.LeafFactory leafFactory) {
44+
private DoubleScriptFieldData(String fieldName, DoubleFieldScript.LeafFactory leafFactory) {
4545
this.fieldName = fieldName;
4646
this.leafFactory = leafFactory;
4747
}
@@ -57,7 +57,7 @@ public ValuesSourceType getValuesSourceType() {
5757
}
5858

5959
@Override
60-
public ScriptDoubleLeafFieldData load(LeafReaderContext context) {
60+
public DoubleScriptLeafFieldData load(LeafReaderContext context) {
6161
try {
6262
return loadDirect(context);
6363
} catch (Exception e) {
@@ -66,8 +66,8 @@ public ScriptDoubleLeafFieldData load(LeafReaderContext context) {
6666
}
6767

6868
@Override
69-
public ScriptDoubleLeafFieldData loadDirect(LeafReaderContext context) throws IOException {
70-
return new ScriptDoubleLeafFieldData(new ScriptDoubleDocValues(leafFactory.newInstance(context)));
69+
public DoubleScriptLeafFieldData loadDirect(LeafReaderContext context) throws IOException {
70+
return new DoubleScriptLeafFieldData(new DoubleScriptDocValues(leafFactory.newInstance(context)));
7171
}
7272

7373
@Override
@@ -80,17 +80,17 @@ protected boolean sortRequiresCustomComparator() {
8080
return true;
8181
}
8282

83-
public static class ScriptDoubleLeafFieldData extends LeafDoubleFieldData {
84-
private final ScriptDoubleDocValues scriptDoubleDocValues;
83+
public static class DoubleScriptLeafFieldData extends LeafDoubleFieldData {
84+
private final DoubleScriptDocValues doubleScriptDocValues;
8585

86-
ScriptDoubleLeafFieldData(ScriptDoubleDocValues scriptDoubleDocValues) {
86+
DoubleScriptLeafFieldData(DoubleScriptDocValues doubleScriptDocValues) {
8787
super(0);
88-
this.scriptDoubleDocValues = scriptDoubleDocValues;
88+
this.doubleScriptDocValues = doubleScriptDocValues;
8989
}
9090

9191
@Override
9292
public SortedNumericDoubleValues getDoubleValues() {
93-
return scriptDoubleDocValues;
93+
return doubleScriptDocValues;
9494
}
9595

9696
@Override
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
import org.elasticsearch.index.fielddata.SortedBinaryDocValues;
1111
import org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript;
1212

13-
import java.io.IOException;
1413
import java.util.Arrays;
1514

16-
public final class ScriptIpDocValues extends SortedBinaryDocValues {
15+
public final class IpScriptDocValues extends SortedBinaryDocValues {
1716
private final IpFieldScript script;
1817
private int cursor;
1918

20-
ScriptIpDocValues(IpFieldScript script) {
19+
IpScriptDocValues(IpFieldScript script) {
2120
this.script = script;
2221
}
2322

@@ -33,7 +32,7 @@ public boolean advanceExact(int docId) {
3332
}
3433

3534
@Override
36-
public BytesRef nextValue() throws IOException {
35+
public BytesRef nextValue() {
3736
return script.values()[cursor++];
3837
}
3938

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import java.net.InetAddress;
2727

28-
public class ScriptIpFieldData extends ScriptBinaryFieldData {
28+
public class IpScriptFieldData extends BinaryScriptFieldData {
2929
public static class Builder implements IndexFieldData.Builder {
3030
private final String name;
3131
private final IpFieldScript.LeafFactory leafFactory;
@@ -36,30 +36,30 @@ public Builder(String name, IpFieldScript.LeafFactory leafFactory) {
3636
}
3737

3838
@Override
39-
public ScriptIpFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
40-
return new ScriptIpFieldData(name, leafFactory);
39+
public IpScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
40+
return new IpScriptFieldData(name, leafFactory);
4141
}
4242
}
4343

4444
private final IpFieldScript.LeafFactory leafFactory;
4545

46-
private ScriptIpFieldData(String fieldName, IpFieldScript.LeafFactory leafFactory) {
46+
private IpScriptFieldData(String fieldName, IpFieldScript.LeafFactory leafFactory) {
4747
super(fieldName);
4848
this.leafFactory = leafFactory;
4949
}
5050

5151
@Override
52-
public ScriptBinaryLeafFieldData loadDirect(LeafReaderContext context) throws Exception {
52+
public BinaryScriptLeafFieldData loadDirect(LeafReaderContext context) throws Exception {
5353
IpFieldScript script = leafFactory.newInstance(context);
54-
return new ScriptBinaryLeafFieldData() {
54+
return new BinaryScriptLeafFieldData() {
5555
@Override
5656
public ScriptDocValues<String> getScriptValues() {
5757
return new IpScriptDocValues(getBytesValues());
5858
}
5959

6060
@Override
6161
public SortedBinaryDocValues getBytesValues() {
62-
return new ScriptIpDocValues(script);
62+
return new org.elasticsearch.xpack.runtimefields.fielddata.IpScriptDocValues(script);
6363
}
6464
};
6565
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
import org.elasticsearch.index.fielddata.AbstractSortedNumericDocValues;
1010
import org.elasticsearch.xpack.runtimefields.mapper.AbstractLongFieldScript;
1111

12-
import java.io.IOException;
1312
import java.util.Arrays;
1413

15-
public final class ScriptLongDocValues extends AbstractSortedNumericDocValues {
14+
public final class LongScriptDocValues extends AbstractSortedNumericDocValues {
1615
private final AbstractLongFieldScript script;
1716
private int cursor;
1817

19-
ScriptLongDocValues(AbstractLongFieldScript script) {
18+
LongScriptDocValues(AbstractLongFieldScript script) {
2019
this.script = script;
2120
}
2221

@@ -32,7 +31,7 @@ public boolean advanceExact(int docId) {
3231
}
3332

3433
@Override
35-
public long nextValue() throws IOException {
34+
public long nextValue() {
3635
return script.values()[cursor++];
3736
}
3837

0 commit comments

Comments
 (0)