some cleanups suggested by @uschindler and break some long lines

This commit is contained in:
Robert Muir 2016-05-10 12:31:02 -04:00
parent eb1b2cf111
commit 1c2d3b10ef
4 changed files with 12 additions and 9 deletions

View File

@ -29,8 +29,9 @@ import java.lang.invoke.MutableCallSite;
/** /**
* Painless invokedynamic call site. * Painless invokedynamic call site.
* <p> * <p>
* Has 3 flavors (passed as static bootstrap parameters): dynamic method call, * Has 5 flavors (passed as static bootstrap parameters): dynamic method call,
* dynamic field load (getter), and dynamic field store (setter). * dynamic field load (getter), and dynamic field store (setter), dynamic array load,
* and dynamic array store.
* <p> * <p>
* When a new type is encountered at the call site, we lookup from the appropriate * When a new type is encountered at the call site, we lookup from the appropriate
* whitelist, and cache with a guard. If we encounter too many types, we stop caching. * whitelist, and cache with a guard. If we encounter too many types, we stop caching.

View File

@ -84,7 +84,6 @@ import static org.elasticsearch.painless.WriterConstants.MAP_GET;
import static org.elasticsearch.painless.WriterConstants.MAP_TYPE; import static org.elasticsearch.painless.WriterConstants.MAP_TYPE;
import static org.elasticsearch.painless.WriterConstants.SCORE_ACCESSOR_FLOAT; import static org.elasticsearch.painless.WriterConstants.SCORE_ACCESSOR_FLOAT;
import static org.elasticsearch.painless.WriterConstants.SCORE_ACCESSOR_TYPE; import static org.elasticsearch.painless.WriterConstants.SCORE_ACCESSOR_TYPE;
import static org.elasticsearch.painless.WriterConstants.SIGNATURE;
class Writer extends PainlessParserBaseVisitor<Void> { class Writer extends PainlessParserBaseVisitor<Void> {
static byte[] write(Metadata metadata) { static byte[] write(Metadata metadata) {
@ -116,7 +115,7 @@ class Writer extends PainlessParserBaseVisitor<Void> {
writeBegin(); writeBegin();
writeConstructor(); writeConstructor();
execute = new GeneratorAdapter(Opcodes.ACC_PUBLIC, EXECUTE, SIGNATURE, null, writer); execute = new GeneratorAdapter(Opcodes.ACC_PUBLIC, EXECUTE, null, null, writer);
final WriterUtility utility = new WriterUtility(metadata, execute); final WriterUtility utility = new WriterUtility(metadata, execute);
final WriterCaster caster = new WriterCaster(execute); final WriterCaster caster = new WriterCaster(execute);

View File

@ -38,7 +38,6 @@ class WriterConstants {
final static Method CONSTRUCTOR = getAsmMethod(void.class, "<init>", Definition.class, String.class, String.class); final static Method CONSTRUCTOR = getAsmMethod(void.class, "<init>", Definition.class, String.class, String.class);
final static Method EXECUTE = getAsmMethod(Object.class, "execute", Map.class); final static Method EXECUTE = getAsmMethod(Object.class, "execute", Map.class);
final static String SIGNATURE = "(Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;)Ljava/lang/Object;";
final static Type PAINLESS_ERROR_TYPE = Type.getType(PainlessError.class); final static Type PAINLESS_ERROR_TYPE = Type.getType(PainlessError.class);

View File

@ -42,19 +42,23 @@ public class NeedsScoreTests extends ESSingleNodeTestCase {
SearchLookup lookup = new SearchLookup(index.mapperService(), index.fieldData(), null); SearchLookup lookup = new SearchLookup(index.mapperService(), index.fieldData(), null);
Object compiled = service.compile("1.2", Collections.emptyMap()); Object compiled = service.compile("1.2", Collections.emptyMap());
SearchScript ss = service.search(new CompiledScript(ScriptType.INLINE, "randomName", "painless", compiled), lookup, Collections.<String, Object>emptyMap()); SearchScript ss = service.search(new CompiledScript(ScriptType.INLINE, "randomName", "painless", compiled),
lookup, Collections.<String, Object>emptyMap());
assertFalse(ss.needsScores()); assertFalse(ss.needsScores());
compiled = service.compile("input.doc['d'].value", Collections.emptyMap()); compiled = service.compile("input.doc['d'].value", Collections.emptyMap());
ss = service.search(new CompiledScript(ScriptType.INLINE, "randomName", "painless", compiled), lookup, Collections.<String, Object>emptyMap()); ss = service.search(new CompiledScript(ScriptType.INLINE, "randomName", "painless", compiled),
lookup, Collections.<String, Object>emptyMap());
assertFalse(ss.needsScores()); assertFalse(ss.needsScores());
compiled = service.compile("1/_score", Collections.emptyMap()); compiled = service.compile("1/_score", Collections.emptyMap());
ss = service.search(new CompiledScript(ScriptType.INLINE, "randomName", "painless", compiled), lookup, Collections.<String, Object>emptyMap()); ss = service.search(new CompiledScript(ScriptType.INLINE, "randomName", "painless", compiled),
lookup, Collections.<String, Object>emptyMap());
assertTrue(ss.needsScores()); assertTrue(ss.needsScores());
compiled = service.compile("input.doc['d'].value * _score", Collections.emptyMap()); compiled = service.compile("input.doc['d'].value * _score", Collections.emptyMap());
ss = service.search(new CompiledScript(ScriptType.INLINE, "randomName", "painless", compiled), lookup, Collections.<String, Object>emptyMap()); ss = service.search(new CompiledScript(ScriptType.INLINE, "randomName", "painless", compiled),
lookup, Collections.<String, Object>emptyMap());
assertTrue(ss.needsScores()); assertTrue(ss.needsScores());
} }