more line length fixes
This commit is contained in:
parent
92d958c46e
commit
19d9c588e1
|
@ -132,27 +132,28 @@ public abstract class BaseAggregationTestCase<AF extends AggregatorFactory> exte
|
|||
ScriptModule scriptModule = new ScriptModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
Settings settings = Settings.builder()
|
||||
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
|
||||
// no file watching, so we don't need a ResourceWatcherService
|
||||
.put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING.getKey(), false)
|
||||
.build();
|
||||
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
|
||||
// no file watching, so we don't need a
|
||||
// ResourceWatcherService
|
||||
.put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING.getKey(), false).build();
|
||||
MockScriptEngine mockScriptEngine = new MockScriptEngine();
|
||||
Multibinder<ScriptEngineService> multibinder = Multibinder.newSetBinder(binder(), ScriptEngineService.class);
|
||||
multibinder.addBinding().toInstance(mockScriptEngine);
|
||||
Set<ScriptEngineService> engines = new HashSet<>();
|
||||
engines.add(mockScriptEngine);
|
||||
List<ScriptContext.Plugin> customContexts = new ArrayList<>();
|
||||
ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Collections.singletonList(new ScriptEngineRegistry.ScriptEngineRegistration(MockScriptEngine.class, MockScriptEngine.TYPES)));
|
||||
ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Collections
|
||||
.singletonList(new ScriptEngineRegistry.ScriptEngineRegistration(MockScriptEngine.class, MockScriptEngine.TYPES)));
|
||||
bind(ScriptEngineRegistry.class).toInstance(scriptEngineRegistry);
|
||||
ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(customContexts);
|
||||
bind(ScriptContextRegistry.class).toInstance(scriptContextRegistry);
|
||||
ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry);
|
||||
bind(ScriptSettings.class).toInstance(scriptSettings);
|
||||
try {
|
||||
ScriptService scriptService = new ScriptService(settings, new Environment(settings), engines, null, scriptEngineRegistry, scriptContextRegistry, scriptSettings);
|
||||
ScriptService scriptService = new ScriptService(settings, new Environment(settings), engines, null,
|
||||
scriptEngineRegistry, scriptContextRegistry, scriptSettings);
|
||||
bind(ScriptService.class).toInstance(scriptService);
|
||||
} catch(IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("error while binding ScriptService", e);
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +266,8 @@ public abstract class BaseAggregationTestCase<AF extends AggregatorFactory> exte
|
|||
try (BytesStreamOutput output = new BytesStreamOutput()) {
|
||||
testAgg.writeTo(output);
|
||||
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
|
||||
AggregatorFactory prototype = (AggregatorFactory) namedWriteableRegistry.getPrototype(AggregatorFactory.class, testAgg.getWriteableName());
|
||||
AggregatorFactory prototype = (AggregatorFactory) namedWriteableRegistry.getPrototype(AggregatorFactory.class,
|
||||
testAgg.getWriteableName());
|
||||
AggregatorFactory deserializedQuery = prototype.readFrom(in);
|
||||
assertEquals(deserializedQuery, testAgg);
|
||||
assertEquals(deserializedQuery.hashCode(), testAgg.hashCode());
|
||||
|
@ -306,7 +308,8 @@ public abstract class BaseAggregationTestCase<AF extends AggregatorFactory> exte
|
|||
try (BytesStreamOutput output = new BytesStreamOutput()) {
|
||||
agg.writeTo(output);
|
||||
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
|
||||
AggregatorFactory prototype = (AggregatorFactory) namedWriteableRegistry.getPrototype(AggregatorFactory.class, agg.getWriteableName());
|
||||
AggregatorFactory prototype = (AggregatorFactory) namedWriteableRegistry.getPrototype(AggregatorFactory.class,
|
||||
agg.getWriteableName());
|
||||
@SuppressWarnings("unchecked")
|
||||
AF secondAgg = (AF) prototype.readFrom(in);
|
||||
return secondAgg;
|
||||
|
|
|
@ -133,27 +133,28 @@ public abstract class BasePipelineAggregationTestCase<AF extends PipelineAggrega
|
|||
ScriptModule scriptModule = new ScriptModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
Settings settings = Settings.builder()
|
||||
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
|
||||
// no file watching, so we don't need a ResourceWatcherService
|
||||
.put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING.getKey(), false)
|
||||
.build();
|
||||
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
|
||||
// no file watching, so we don't need a
|
||||
// ResourceWatcherService
|
||||
.put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING.getKey(), false).build();
|
||||
MockScriptEngine mockScriptEngine = new MockScriptEngine();
|
||||
Multibinder<ScriptEngineService> multibinder = Multibinder.newSetBinder(binder(), ScriptEngineService.class);
|
||||
multibinder.addBinding().toInstance(mockScriptEngine);
|
||||
Set<ScriptEngineService> engines = new HashSet<>();
|
||||
engines.add(mockScriptEngine);
|
||||
List<ScriptContext.Plugin> customContexts = new ArrayList<>();
|
||||
ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Collections.singletonList(new ScriptEngineRegistry.ScriptEngineRegistration(MockScriptEngine.class, MockScriptEngine.TYPES)));
|
||||
ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Collections
|
||||
.singletonList(new ScriptEngineRegistry.ScriptEngineRegistration(MockScriptEngine.class, MockScriptEngine.TYPES)));
|
||||
bind(ScriptEngineRegistry.class).toInstance(scriptEngineRegistry);
|
||||
ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(customContexts);
|
||||
bind(ScriptContextRegistry.class).toInstance(scriptContextRegistry);
|
||||
ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry);
|
||||
bind(ScriptSettings.class).toInstance(scriptSettings);
|
||||
try {
|
||||
ScriptService scriptService = new ScriptService(settings, new Environment(settings), engines, null, scriptEngineRegistry, scriptContextRegistry, scriptSettings);
|
||||
ScriptService scriptService = new ScriptService(settings, new Environment(settings), engines, null,
|
||||
scriptEngineRegistry, scriptContextRegistry, scriptSettings);
|
||||
bind(ScriptService.class).toInstance(scriptService);
|
||||
} catch(IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("error while binding ScriptService", e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,8 @@ public class DiversifiedSamplerIT extends ESIntegTestCase {
|
|||
createIndex("idx_unmapped");
|
||||
// idx_unmapped_author is same as main index but missing author field
|
||||
assertAcked(prepareCreate("idx_unmapped_author").setSettings(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS, SETTING_NUMBER_OF_REPLICAS, 0)
|
||||
.addMapping("book", "name", "type=string,index=analyzed", "genre", "type=string,index=not_analyzed", "price", "type=float"));
|
||||
.addMapping("book", "name", "type=string,index=analyzed", "genre", "type=string,index=not_analyzed", "price",
|
||||
"type=float"));
|
||||
|
||||
ensureGreen();
|
||||
String data[] = {
|
||||
|
@ -86,8 +87,10 @@ public class DiversifiedSamplerIT extends ESIntegTestCase {
|
|||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
String[] parts = data[i].split(",");
|
||||
client().prepareIndex("test", "book", "" + i).setSource("author", parts[5], "name", parts[2], "genre", parts[8], "price",Float.parseFloat(parts[3])).get();
|
||||
client().prepareIndex("idx_unmapped_author", "book", "" + i).setSource("name", parts[2], "genre", parts[8],"price",Float.parseFloat(parts[3])).get();
|
||||
client().prepareIndex("test", "book", "" + i)
|
||||
.setSource("author", parts[5], "name", parts[2], "genre", parts[8], "price", Float.parseFloat(parts[3])).get();
|
||||
client().prepareIndex("idx_unmapped_author", "book", "" + i)
|
||||
.setSource("name", parts[2], "genre", parts[8], "price", Float.parseFloat(parts[3])).get();
|
||||
}
|
||||
client().admin().indices().refresh(new RefreshRequest("test")).get();
|
||||
}
|
||||
|
|
|
@ -78,8 +78,9 @@ public class MovAvgTests extends BasePipelineAggregationTestCase<MovAvgPipelineA
|
|||
factory.window(randomIntBetween(2, 100));
|
||||
} else {
|
||||
int period = randomIntBetween(1, 100);
|
||||
factory.modelBuilder(new HoltWintersModel.HoltWintersModelBuilder().alpha(randomDouble()).beta(randomDouble())
|
||||
.gamma(randomDouble()).period(period).seasonalityType(randomFrom(SeasonalityType.values())).pad(randomBoolean()));
|
||||
factory.modelBuilder(
|
||||
new HoltWintersModel.HoltWintersModelBuilder().alpha(randomDouble()).beta(randomDouble()).gamma(randomDouble())
|
||||
.period(period).seasonalityType(randomFrom(SeasonalityType.values())).pad(randomBoolean()));
|
||||
factory.window(randomIntBetween(2 * period, 200 * period));
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -117,18 +117,13 @@ public class BucketSelectorTests extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
public void testInlineScript() {
|
||||
SearchResponse response = client()
|
||||
.prepareSearch("idx")
|
||||
.addAggregation(
|
||||
histogram("histo")
|
||||
.field(FIELD_1_NAME)
|
||||
.interval(interval)
|
||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||
.subAggregation(
|
||||
bucketSelector("bucketSelector", new Script("Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)",
|
||||
ScriptType.INLINE, null, null), "field2Sum", "field3Sum"))).execute()
|
||||
.actionGet();
|
||||
SearchResponse response = client().prepareSearch("idx")
|
||||
.addAggregation(histogram("histo").field(FIELD_1_NAME).interval(interval)
|
||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME)).subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||
.subAggregation(bucketSelector("bucketSelector",
|
||||
new Script("Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)", ScriptType.INLINE, null, null),
|
||||
"field2Sum", "field3Sum")))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
||||
|
@ -159,7 +154,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
|
|||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||
.subAggregation(
|
||||
bucketSelector("bucketSelector", new Script("Double.isNaN(_value0) ? true : (_value0 < 10000)",
|
||||
bucketSelector("bucketSelector", new Script("Double.isNaN(_value0) ? true : (_value0 < 10000)",
|
||||
ScriptType.INLINE, null, null), "field2Sum", "field3Sum"))).execute()
|
||||
.actionGet();
|
||||
|
||||
|
@ -192,7 +187,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
|
|||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||
.subAggregation(
|
||||
bucketSelector("bucketSelector", new Script("Double.isNaN(_value0) ? false : (_value0 > 10000)",
|
||||
bucketSelector("bucketSelector", new Script("Double.isNaN(_value0) ? false : (_value0 > 10000)",
|
||||
ScriptType.INLINE, null, null), "field2Sum", "field3Sum"))).execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
@ -245,7 +240,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
|
|||
.interval(interval)
|
||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||
.subAggregation(
|
||||
bucketSelector("bucketSelector", new Script("Double.isNaN(_value0) ? false : (_value0 > 100)",
|
||||
bucketSelector("bucketSelector", new Script("Double.isNaN(_value0) ? false : (_value0 > 100)",
|
||||
ScriptType.INLINE,null, null), "field2Sum"))).execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
@ -269,18 +264,12 @@ public class BucketSelectorTests extends ESIntegTestCase {
|
|||
bucketPathsMap.put("my_value1", "field2Sum");
|
||||
bucketPathsMap.put("my_value2", "field3Sum");
|
||||
|
||||
SearchResponse response = client()
|
||||
.prepareSearch("idx")
|
||||
.addAggregation(
|
||||
histogram("histo")
|
||||
.field(FIELD_1_NAME)
|
||||
.interval(interval)
|
||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||
.subAggregation(
|
||||
bucketSelector("bucketSelector", bucketPathsMap, new Script("Double.isNaN(my_value1) ? false : (my_value1 + my_value2 > 100)",
|
||||
ScriptType.INLINE, null, null)))).execute()
|
||||
.actionGet();
|
||||
SearchResponse response = client().prepareSearch("idx")
|
||||
.addAggregation(histogram("histo").field(FIELD_1_NAME).interval(interval)
|
||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME)).subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||
.subAggregation(bucketSelector("bucketSelector", bucketPathsMap, new Script(
|
||||
"Double.isNaN(my_value1) ? false : (my_value1 + my_value2 > 100)", ScriptType.INLINE, null, null))))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
||||
|
@ -304,18 +293,12 @@ public class BucketSelectorTests extends ESIntegTestCase {
|
|||
public void testInlineScriptWithParams() {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("threshold", 100);
|
||||
SearchResponse response = client()
|
||||
.prepareSearch("idx")
|
||||
.addAggregation(
|
||||
histogram("histo")
|
||||
.field(FIELD_1_NAME)
|
||||
.interval(interval)
|
||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||
.subAggregation(
|
||||
bucketSelector("bucketSelector", new Script("Double.isNaN(_value0) ? false : (_value0 + _value1 > threshold)",
|
||||
ScriptType.INLINE, null, params), "field2Sum", "field3Sum"))).execute()
|
||||
.actionGet();
|
||||
SearchResponse response = client().prepareSearch("idx").addAggregation(histogram("histo").field(FIELD_1_NAME).interval(interval)
|
||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME)).subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||
.subAggregation(bucketSelector("bucketSelector",
|
||||
new Script("Double.isNaN(_value0) ? false : (_value0 + _value1 > threshold)", ScriptType.INLINE, null, params),
|
||||
"field2Sum", "field3Sum")))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
||||
|
@ -337,17 +320,13 @@ public class BucketSelectorTests extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
public void testInlineScriptInsertZeros() {
|
||||
SearchResponse response = client()
|
||||
.prepareSearch("idx")
|
||||
SearchResponse response = client().prepareSearch("idx")
|
||||
.addAggregation(
|
||||
histogram("histo")
|
||||
.field(FIELD_1_NAME)
|
||||
.interval(interval)
|
||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||
histogram("histo").field(FIELD_1_NAME).interval(interval).subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||
.subAggregation(
|
||||
bucketSelector("bucketSelector", new Script("_value0 + _value1 > 100", ScriptType.INLINE, null, null),
|
||||
"field2Sum", "field3Sum").gapPolicy(GapPolicy.INSERT_ZEROS)))
|
||||
.subAggregation(bucketSelector("bucketSelector",
|
||||
new Script("_value0 + _value1 > 100", ScriptType.INLINE, null, null), "field2Sum", "field3Sum")
|
||||
.gapPolicy(GapPolicy.INSERT_ZEROS)))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
@ -402,18 +381,13 @@ public class BucketSelectorTests extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
public void testUnmapped() throws Exception {
|
||||
SearchResponse response = client()
|
||||
.prepareSearch("idx_unmapped")
|
||||
.addAggregation(
|
||||
histogram("histo")
|
||||
.field(FIELD_1_NAME)
|
||||
.interval(interval)
|
||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||
.subAggregation(
|
||||
bucketSelector("bucketSelector", new Script("Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)",
|
||||
ScriptType.INLINE, null, null), "field2Sum", "field3Sum"))).execute()
|
||||
.actionGet();
|
||||
SearchResponse response = client().prepareSearch("idx_unmapped")
|
||||
.addAggregation(histogram("histo").field(FIELD_1_NAME).interval(interval)
|
||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME)).subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||
.subAggregation(bucketSelector("bucketSelector",
|
||||
new Script("Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)", ScriptType.INLINE, null, null),
|
||||
"field2Sum", "field3Sum")))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
||||
|
@ -424,18 +398,13 @@ public class BucketSelectorTests extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPartiallyUnmapped() throws Exception {
|
||||
SearchResponse response = client()
|
||||
.prepareSearch("idx", "idx_unmapped")
|
||||
.addAggregation(
|
||||
histogram("histo")
|
||||
.field(FIELD_1_NAME)
|
||||
.interval(interval)
|
||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||
.subAggregation(
|
||||
bucketSelector("bucketSelector", new Script("Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)",
|
||||
ScriptType.INLINE, null, null), "field2Sum", "field3Sum"))).execute()
|
||||
.actionGet();
|
||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
||||
.addAggregation(histogram("histo").field(FIELD_1_NAME).interval(interval)
|
||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME)).subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||
.subAggregation(bucketSelector("bucketSelector",
|
||||
new Script("Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)", ScriptType.INLINE, null, null),
|
||||
"field2Sum", "field3Sum")))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
||||
|
|
Loading…
Reference in New Issue