Moved Painless from a plugin to a module.

Closes #16755
This commit is contained in:
Jack Conradson 2016-02-21 16:50:33 -08:00
parent 5451763935
commit 7986770e5f
67 changed files with 24 additions and 21 deletions

View File

@ -1572,13 +1572,6 @@
<suppress files="plugins[/\\]lang-javascript[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]javascript[/\\]JavaScriptScriptMultiThreadedTests.java" checks="LineLength" />
<suppress files="plugins[/\\]lang-javascript[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]javascript[/\\]JavaScriptSecurityTests.java" checks="LineLength" />
<suppress files="plugins[/\\]lang-javascript[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]javascript[/\\]SimpleBench.java" checks="LineLength" />
<suppress files="plugins[/\\]lang-painless[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]Definition.java" checks="LineLength" />
<suppress files="plugins[/\\]lang-painless[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]PainlessPlugin.java" checks="LineLength" />
<suppress files="plugins[/\\]lang-painless[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]ConditionalTests.java" checks="LineLength" />
<suppress files="plugins[/\\]lang-painless[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]FieldTests.java" checks="LineLength" />
<suppress files="plugins[/\\]lang-painless[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]FloatOverflowEnabledTests.java" checks="LineLength" />
<suppress files="plugins[/\\]lang-painless[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]IntegerOverflowEnabledTests.java" checks="LineLength" />
<suppress files="plugins[/\\]lang-painless[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]ScriptEngineTests.java" checks="LineLength" />
<suppress files="plugins[/\\]lang-python[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]plugin[/\\]python[/\\]PythonPlugin.java" checks="LineLength" />
<suppress files="plugins[/\\]lang-python[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]python[/\\]PythonScriptEngineTests.java" checks="LineLength" />
<suppress files="plugins[/\\]lang-python[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]python[/\\]PythonScriptMultiThreadedTests.java" checks="LineLength" />

View File

@ -956,7 +956,8 @@ class Definition {
addConstructor("ArrayList<Object>", "new", new Type[] {}, null);
addMethod("List<String>", "set", null, false, objectType, new Type[] {intType, objectType}, stringType, new Type[] {intType, stringType});
addMethod("List<String>", "set", null, false, objectType, new Type[] {intType, objectType}, stringType,
new Type[] {intType, stringType});
addMethod("List<String>", "get", null, false, objectType, new Type[] {intType}, stringType, null);
addMethod("List<String>", "remove", null, false, objectType, new Type[] {intType}, stringType, null);
@ -992,7 +993,8 @@ class Definition {
addConstructor("HashMap<Object,Object>", "new", new Type[] {}, null);
addMethod("Map<String,def>", "put", null, false, objectType, new Type[] {objectType, objectType}, defType, new Type[] {stringType, defType});
addMethod("Map<String,def>", "put", null, false, objectType, new Type[] {objectType, objectType}, defType,
new Type[] {stringType, defType});
addMethod("Map<String,def>", "get", null, false, objectType, new Type[] {objectType}, defType, new Type[] {stringType});
addMethod("Map<String,def>", "remove", null, false, objectType, new Type[] {objectType}, defType, new Type[] {stringType});
addMethod("Map<String,def>", "isEmpty", null, false, booleanType, new Type[] {}, null, null);
@ -1004,7 +1006,8 @@ class Definition {
addConstructor("HashMap<String,def>", "new", new Type[] {}, null);
addMethod("Map<String,Object>", "put", null, false, objectType, new Type[] {objectType, objectType}, null, new Type[] {stringType, objectType});
addMethod("Map<String,Object>", "put", null, false, objectType, new Type[] {objectType, objectType}, null,
new Type[] {stringType, objectType});
addMethod("Map<String,Object>", "get", null, false, objectType, new Type[] {objectType}, null, new Type[] {stringType});
addMethod("Map<String,Object>", "remove", null, false, objectType, new Type[] {objectType}, null, new Type[] {stringType});
addMethod("Map<String,Object>", "isEmpty", null, false, booleanType, new Type[] {}, null, null);

View File

@ -36,6 +36,7 @@ public final class PainlessPlugin extends Plugin {
}
public void onModule(final ScriptModule module) {
module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(PainlessScriptEngineService.class, PainlessScriptEngineService.TYPES));
module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(
PainlessScriptEngineService.class, PainlessScriptEngineService.TYPES));
}
}

View File

@ -59,13 +59,15 @@ public class ConditionalTests extends ScriptTestCase {
public void testNullArguments() {
assertEquals(null, exec("boolean b = false, c = true; Object x; Map y; return b && c ? x : y;"));
assertEquals(HashMap.class, exec("boolean b = false, c = true; Object x; Map y = new HashMap(); return b && c ? x : y;").getClass());
assertEquals(HashMap.class,
exec("boolean b = false, c = true; Object x; Map y = new HashMap(); return b && c ? x : y;").getClass());
}
public void testPromotion() {
assertEquals(false, exec("boolean x = false; boolean y = true; return (x ? 2 : 4.0F) == (y ? 2 : 4.0F);"));
assertEquals(false, exec("boolean x = false; boolean y = true; return (x ? 2 : 4.0F) == (y ? new Long(2) : new Float(4.0F));"));
assertEquals(false, exec("boolean x = false; boolean y = true; return (x ? new HashMap() : new ArrayList()) == (y ? new Long(2) : new Float(4.0F));"));
assertEquals(false, exec("boolean x = false; boolean y = true; " +
"return (x ? new HashMap() : new ArrayList()) == (y ? new Long(2) : new Float(4.0F));"));
assertEquals(false, exec("boolean x = false; boolean y = true; return (x ? 2 : 4.0F) == (y ? new HashMap() : new ArrayList());"));
}

View File

@ -80,7 +80,8 @@ public class FieldTests extends ScriptTestCase {
assertEquals("s5t42", exec("def fc = new FieldClass() return fc.t += 2 + fc.j + \"t\" + 4 + (3 - 1)"));
assertEquals(2.0f, exec("def fc = new FieldClass(); def l = new Double(3) Byte b = new Byte((byte)2) return fc.test(l, b)"));
assertEquals(4, exec("def fc = new FieldClass() fc.i = 4 return fc.i"));
assertEquals(5, exec("FieldClass fc0 = new FieldClass() FieldClass fc1 = new FieldClass() fc0.i = 7 - fc0.i fc1.i = fc0.i return fc1.i"));
assertEquals(5,
exec("FieldClass fc0 = new FieldClass() FieldClass fc1 = new FieldClass() fc0.i = 7 - fc0.i fc1.i = fc0.i return fc1.i"));
assertEquals(8, exec("def fc0 = new FieldClass() def fc1 = new FieldClass() fc0.i += fc1.i fc0.i += fc0.i return fc0.i"));
}

View File

@ -85,7 +85,8 @@ public class FloatOverflowEnabledTests extends ScriptTestCase {
public void testSubtraction() throws Exception {
assertEquals(Float.NEGATIVE_INFINITY, exec("float x = -3.4028234663852886E38f; float y = 3.4028234663852886E38f; return x - y;"));
assertEquals(Double.NEGATIVE_INFINITY, exec("double x = -1.7976931348623157E308; double y = 1.7976931348623157E308; return x - y;"));
assertEquals(Double.NEGATIVE_INFINITY,
exec("double x = -1.7976931348623157E308; double y = 1.7976931348623157E308; return x - y;"));
}
public void testSubtractionConst() throws Exception {

View File

@ -143,7 +143,8 @@ public class IntegerOverflowEnabledTests extends ScriptTestCase {
public void testAddition() throws Exception {
assertEquals(2147483647 + 2147483647, exec("int x = 2147483647; int y = 2147483647; return x + y;"));
assertEquals(9223372036854775807L + 9223372036854775807L, exec("long x = 9223372036854775807L; long y = 9223372036854775807L; return x + y;"));
assertEquals(9223372036854775807L + 9223372036854775807L,
exec("long x = 9223372036854775807L; long y = 9223372036854775807L; return x + y;"));
}
public void testAdditionConst() throws Exception {
@ -163,7 +164,8 @@ public class IntegerOverflowEnabledTests extends ScriptTestCase {
public void testMultiplication() throws Exception {
assertEquals(2147483647 * 2147483647, exec("int x = 2147483647; int y = 2147483647; return x * y;"));
assertEquals(9223372036854775807L * 9223372036854775807L, exec("long x = 9223372036854775807L; long y = 9223372036854775807L; return x * y;"));
assertEquals(9223372036854775807L * 9223372036854775807L,
exec("long x = 9223372036854775807L; long y = 9223372036854775807L; return x * y;"));
}
public void testMultiplicationConst() throws Exception {

View File

@ -81,7 +81,8 @@ public class ScriptEngineTests extends ScriptTestCase {
Map<String, Object> ctx = new HashMap<>();
vars.put("ctx", ctx);
Object compiledScript = scriptEngine.compile("return ((Map<String, Object>)input.get(\"ctx\")).get(\"value\");", Collections.emptyMap());
Object compiledScript = scriptEngine.compile(
"return ((Map<String, Object>)input.get(\"ctx\")).get(\"value\");", Collections.emptyMap());
ExecutableScript script = scriptEngine.executable(new CompiledScript(ScriptService.ScriptType.INLINE,
"testChangingVarsCrossExecution1", "painless", compiledScript), vars);

View File

@ -10,4 +10,4 @@
- do:
nodes.info: {}
- match: { nodes.$master.plugins.0.name: lang-painless }
- match: { nodes.$master.modules.0.name: lang-painless }

View File

@ -94,4 +94,3 @@
- match: { hits.hits.0.fields.sNum1.0: 1.0 }
- match: { hits.hits.1.fields.sNum1.0: 2.0 }
- match: { hits.hits.2.fields.sNum1.0: 3.0 }

View File

@ -15,6 +15,7 @@ List projects = [
'modules:lang-expression',
'modules:lang-groovy',
'modules:lang-mustache',
'modules:lang-painless',
'plugins:analysis-icu',
'plugins:analysis-kuromoji',
'plugins:analysis-phonetic',
@ -27,7 +28,6 @@ List projects = [
'plugins:ingest-geoip',
'plugins:ingest-attachment',
'plugins:lang-javascript',
'plugins:lang-painless',
'plugins:lang-python',
'plugins:mapper-attachments',
'plugins:mapper-murmur3',