Skip to content

Commit

Permalink
Move runtime fields classes into common packages (elastic#70965)
Browse files Browse the repository at this point in the history
Runtime fields currently live in their own java package. This is really
a leftover from when they were in their own module; now that they are
in core they should instead live in the common packages for classes of
their kind.

This commit makes the following moves:
org.elasticsearch.runtimefields.mapper => org.elasticsearch.index.mapper
org.elasticsearch.runtimefields.fielddata => org.elasticsearch.index.fielddata
org.elasticsearch.runtimefields.query => org.elasticsearch.search.runtime

The XFieldScript fields are moved out of the `mapper` package into
org.elasticsearch.scripts, and the `PARSE_FROM_SOURCE` default scripts
are moved from these Script classes directly into the field type classes that
use them.
  • Loading branch information
romseygeek committed Mar 29, 2021
1 parent 3c27dc1 commit 7f08b3b
Show file tree
Hide file tree
Showing 133 changed files with 493 additions and 560 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.runtimefields.mapper.BooleanFieldScript;
import org.elasticsearch.runtimefields.mapper.DateFieldScript;
import org.elasticsearch.runtimefields.mapper.DoubleFieldScript;
import org.elasticsearch.runtimefields.mapper.GeoPointFieldScript;
import org.elasticsearch.runtimefields.mapper.IpFieldScript;
import org.elasticsearch.runtimefields.mapper.LongFieldScript;
import org.elasticsearch.runtimefields.mapper.StringFieldScript;
import org.elasticsearch.script.BooleanFieldScript;
import org.elasticsearch.script.DateFieldScript;
import org.elasticsearch.script.DoubleFieldScript;
import org.elasticsearch.script.GeoPointFieldScript;
import org.elasticsearch.script.IpFieldScript;
import org.elasticsearch.script.LongFieldScript;
import org.elasticsearch.script.StringFieldScript;
import org.elasticsearch.script.IngestScript;
import org.elasticsearch.script.ScoreScript;
import org.elasticsearch.script.ScriptContext;
Expand Down Expand Up @@ -118,7 +118,7 @@ public final class PainlessPlugin extends Plugin implements ScriptPlugin, Extens
private static List<Whitelist> getRuntimeFieldWhitelist(String fieldType) {
List<Whitelist> scriptField = new ArrayList<>(Whitelist.BASE_WHITELISTS);
Whitelist whitelist = WhitelistLoader.loadFromResourceFiles(Whitelist.class,
"org.elasticsearch.runtimefields." + fieldType + ".txt");
"org.elasticsearch.script." + fieldType + ".txt");
scriptField.add(whitelist);
return scriptField;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
# The whitelist for boolean-valued runtime fields

# These two whitelists are required for painless to find the classes
class org.elasticsearch.runtimefields.mapper.BooleanFieldScript @no_import {
class org.elasticsearch.script.BooleanFieldScript @no_import {
}
class org.elasticsearch.runtimefields.mapper.BooleanFieldScript$Factory @no_import {
class org.elasticsearch.script.BooleanFieldScript$Factory @no_import {
}

static_import {
# The `emit` callback to collect values for the field
void emit(org.elasticsearch.runtimefields.mapper.BooleanFieldScript, boolean) bound_to org.elasticsearch.runtimefields.mapper.BooleanFieldScript$Emit
void emit(org.elasticsearch.script.BooleanFieldScript, boolean) bound_to org.elasticsearch.script.BooleanFieldScript$Emit
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
# The whitelist for date-valued runtime fields

# These two whitelists are required for painless to find the classes
class org.elasticsearch.runtimefields.mapper.DateFieldScript @no_import {
class org.elasticsearch.script.DateFieldScript @no_import {
}
class org.elasticsearch.runtimefields.mapper.DateFieldScript$Factory @no_import {
class org.elasticsearch.script.DateFieldScript$Factory @no_import {
}

static_import {
# The `emit` callback to collect values for the field
void emit(org.elasticsearch.runtimefields.mapper.DateFieldScript, long) bound_to org.elasticsearch.runtimefields.mapper.DateFieldScript$Emit
void emit(org.elasticsearch.script.DateFieldScript, long) bound_to org.elasticsearch.script.DateFieldScript$Emit
# Parse a value from the source to millis since epoch
long parse(org.elasticsearch.runtimefields.mapper.DateFieldScript, def) bound_to org.elasticsearch.runtimefields.mapper.DateFieldScript$Parse
long parse(org.elasticsearch.script.DateFieldScript, def) bound_to org.elasticsearch.script.DateFieldScript$Parse
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
# The whitelist for double-valued runtime fields

# These two whitelists are required for painless to find the classes
class org.elasticsearch.runtimefields.mapper.DoubleFieldScript @no_import {
class org.elasticsearch.script.DoubleFieldScript @no_import {
}
class org.elasticsearch.runtimefields.mapper.DoubleFieldScript$Factory @no_import {
class org.elasticsearch.script.DoubleFieldScript$Factory @no_import {
}

static_import {
# The `emit` callback to collect values for the field
void emit(org.elasticsearch.runtimefields.mapper.DoubleFieldScript, double) bound_to org.elasticsearch.runtimefields.mapper.DoubleFieldScript$Emit
void emit(org.elasticsearch.script.DoubleFieldScript, double) bound_to org.elasticsearch.script.DoubleFieldScript$Emit
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
# The whitelist for ip-valued runtime fields

# These two whitelists are required for painless to find the classes
class org.elasticsearch.runtimefields.mapper.IpFieldScript @no_import {
class org.elasticsearch.script.GeoPointFieldScript @no_import {
}
class org.elasticsearch.runtimefields.mapper.IpFieldScript$Factory @no_import {
class org.elasticsearch.script.GeoPointFieldScript$Factory @no_import {
}

static_import {
# The `emit` callback to collect values for the field
void emit(org.elasticsearch.runtimefields.mapper.IpFieldScript, String) bound_to org.elasticsearch.runtimefields.mapper.IpFieldScript$Emit
void emit(org.elasticsearch.script.GeoPointFieldScript, double, double) bound_to org.elasticsearch.script.GeoPointFieldScript$Emit
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
# The whitelist for ip-valued runtime fields

# These two whitelists are required for painless to find the classes
class org.elasticsearch.runtimefields.mapper.GeoPointFieldScript @no_import {
class org.elasticsearch.script.IpFieldScript @no_import {
}
class org.elasticsearch.runtimefields.mapper.GeoPointFieldScript$Factory @no_import {
class org.elasticsearch.script.IpFieldScript$Factory @no_import {
}

static_import {
# The `emit` callback to collect values for the field
void emit(org.elasticsearch.runtimefields.mapper.GeoPointFieldScript, double, double) bound_to org.elasticsearch.runtimefields.mapper.GeoPointFieldScript$Emit
void emit(org.elasticsearch.script.IpFieldScript, String) bound_to org.elasticsearch.script.IpFieldScript$Emit
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
# The whitelist for long-valued runtime fields

# These two whitelists are required for painless to find the classes
class org.elasticsearch.runtimefields.mapper.LongFieldScript @no_import {
class org.elasticsearch.script.LongFieldScript @no_import {
}
class org.elasticsearch.runtimefields.mapper.LongFieldScript$Factory @no_import {
class org.elasticsearch.script.LongFieldScript$Factory @no_import {
}

static_import {
# The `emit` callback to collect values for the field
void emit(org.elasticsearch.runtimefields.mapper.LongFieldScript, long) bound_to org.elasticsearch.runtimefields.mapper.LongFieldScript$Emit
void emit(org.elasticsearch.script.LongFieldScript, long) bound_to org.elasticsearch.script.LongFieldScript$Emit
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
# The whitelist for string-valued runtime fields

# These two whitelists are required for painless to find the classes
class org.elasticsearch.runtimefields.mapper.StringFieldScript @no_import {
class org.elasticsearch.script.StringFieldScript @no_import {
}
class org.elasticsearch.runtimefields.mapper.StringFieldScript$Factory @no_import {
class org.elasticsearch.script.StringFieldScript$Factory @no_import {
}

static_import {
# The `emit` callback to collect values for the field
void emit(org.elasticsearch.runtimefields.mapper.StringFieldScript, String) bound_to org.elasticsearch.runtimefields.mapper.StringFieldScript$Emit
void emit(org.elasticsearch.script.StringFieldScript, String) bound_to org.elasticsearch.script.StringFieldScript$Emit
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
import org.elasticsearch.painless.spi.WhitelistInstanceBinding;
import org.elasticsearch.painless.spi.WhitelistLoader;
import org.elasticsearch.painless.spi.annotation.CompileTimeOnlyAnnotation;
import org.elasticsearch.runtimefields.mapper.AbstractFieldScript;
import org.elasticsearch.runtimefields.mapper.BooleanFieldScript;
import org.elasticsearch.runtimefields.mapper.DateFieldScript;
import org.elasticsearch.runtimefields.mapper.DoubleFieldScript;
import org.elasticsearch.runtimefields.mapper.GeoPointFieldScript;
import org.elasticsearch.runtimefields.mapper.IpFieldScript;
import org.elasticsearch.runtimefields.mapper.LongFieldScript;
import org.elasticsearch.runtimefields.mapper.StringFieldScript;
import org.elasticsearch.script.AbstractFieldScript;
import org.elasticsearch.script.BooleanFieldScript;
import org.elasticsearch.script.DateFieldScript;
import org.elasticsearch.script.DoubleFieldScript;
import org.elasticsearch.script.GeoPointFieldScript;
import org.elasticsearch.script.IpFieldScript;
import org.elasticsearch.script.LongFieldScript;
import org.elasticsearch.script.StringFieldScript;
import org.elasticsearch.script.ScriptContext;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
* Side Public License, v 1.
*/

package org.elasticsearch.runtimefields.fielddata;
package org.elasticsearch.index.fielddata;

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.SortField;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.LeafFieldData;
import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource;
import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.search.MultiValueMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
* Side Public License, v 1.
*/

package org.elasticsearch.runtimefields.fielddata;
package org.elasticsearch.index.fielddata;

import org.elasticsearch.index.fielddata.AbstractSortedNumericDocValues;
import org.elasticsearch.runtimefields.mapper.BooleanFieldScript;
import org.elasticsearch.script.BooleanFieldScript;

public final class BooleanScriptDocValues extends AbstractSortedNumericDocValues {
private final BooleanFieldScript script;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@
* Side Public License, v 1.
*/

package org.elasticsearch.runtimefields.fielddata;
package org.elasticsearch.index.fielddata;

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.SortedNumericDocValues;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
import org.elasticsearch.index.fielddata.plain.LeafLongFieldData;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.runtimefields.mapper.BooleanFieldScript;
import org.elasticsearch.script.BooleanFieldScript;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@
* Side Public License, v 1.
*/

package org.elasticsearch.runtimefields.fielddata;
package org.elasticsearch.index.fielddata;

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.SortedNumericDocValues;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
import org.elasticsearch.index.fielddata.plain.LeafLongFieldData;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.runtimefields.mapper.DateFieldScript;
import org.elasticsearch.script.DateFieldScript;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
* Side Public License, v 1.
*/

package org.elasticsearch.runtimefields.fielddata;
package org.elasticsearch.index.fielddata;

import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
import org.elasticsearch.runtimefields.mapper.DoubleFieldScript;
import org.elasticsearch.script.DoubleFieldScript;

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
* Side Public License, v 1.
*/

package org.elasticsearch.runtimefields.fielddata;
package org.elasticsearch.index.fielddata;

import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
import org.elasticsearch.index.fielddata.plain.LeafDoubleFieldData;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.runtimefields.mapper.DoubleFieldScript;
import org.elasticsearch.script.DoubleFieldScript;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
* Side Public License, v 1.
*/

package org.elasticsearch.runtimefields.fielddata;
package org.elasticsearch.index.fielddata;

import org.apache.lucene.geo.GeoEncodingUtils;
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.runtimefields.mapper.GeoPointFieldScript;
import org.elasticsearch.script.GeoPointFieldScript;

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@
* Side Public License, v 1.
*/

package org.elasticsearch.runtimefields.fielddata;
package org.elasticsearch.index.fielddata;

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.SortField;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
import org.elasticsearch.index.fielddata.IndexGeoPointFieldData;
import org.elasticsearch.index.fielddata.LeafGeoPointFieldData;
import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.plain.AbstractLeafGeoPointFieldData;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.runtimefields.mapper.GeoPointFieldScript;
import org.elasticsearch.script.GeoPointFieldScript;
import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.search.MultiValueMode;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
* Side Public License, v 1.
*/

package org.elasticsearch.runtimefields.fielddata;
package org.elasticsearch.index.fielddata;

import org.apache.lucene.util.BytesRef;
import org.elasticsearch.index.fielddata.SortedBinaryDocValues;
import org.elasticsearch.runtimefields.mapper.IpFieldScript;
import org.elasticsearch.script.IpFieldScript;

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@
* Side Public License, v 1.
*/

package org.elasticsearch.runtimefields.fielddata;
package org.elasticsearch.index.fielddata;

import org.apache.lucene.document.InetAddressPoint;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.network.InetAddresses;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
import org.elasticsearch.index.fielddata.ScriptDocValues;
import org.elasticsearch.index.fielddata.SortedBinaryDocValues;
import org.elasticsearch.index.mapper.IpFieldMapper;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.runtimefields.mapper.IpFieldScript;
import org.elasticsearch.script.IpFieldScript;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;

Expand Down Expand Up @@ -60,7 +56,7 @@ public ScriptDocValues<String> getScriptValues() {

@Override
public SortedBinaryDocValues getBytesValues() {
return new org.elasticsearch.runtimefields.fielddata.IpScriptDocValues(script);
return new org.elasticsearch.index.fielddata.IpScriptDocValues(script);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
* Side Public License, v 1.
*/

package org.elasticsearch.runtimefields.fielddata;
package org.elasticsearch.index.fielddata;

import org.elasticsearch.index.fielddata.AbstractSortedNumericDocValues;
import org.elasticsearch.runtimefields.mapper.AbstractLongFieldScript;
import org.elasticsearch.script.AbstractLongFieldScript;

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@
* Side Public License, v 1.
*/

package org.elasticsearch.runtimefields.fielddata;
package org.elasticsearch.index.fielddata;

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.SortedNumericDocValues;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
import org.elasticsearch.index.fielddata.plain.LeafLongFieldData;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.runtimefields.mapper.LongFieldScript;
import org.elasticsearch.script.LongFieldScript;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;

Expand Down
Loading

0 comments on commit 7f08b3b

Please sign in to comment.