From 6b2d2224cc0ca40accde4b521e3141f8347c33bc Mon Sep 17 00:00:00 2001 From: Rishabh Maurya Date: Mon, 1 Apr 2024 16:01:28 -0700 Subject: [PATCH] Spotless fixes Signed-off-by: Rishabh Maurya --- .../opensearch/painless/DerivedFieldScriptTests.java | 6 ++---- .../org/opensearch/script/DerivedFieldScript.java | 8 ++++++-- .../java/org/opensearch/script/ScriptEmitValues.java | 12 ++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/DerivedFieldScriptTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/DerivedFieldScriptTests.java index 0a5226d4eaeb2..e394b2c7d2968 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/DerivedFieldScriptTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/DerivedFieldScriptTests.java @@ -139,10 +139,8 @@ public void testEmittingGeoPoint() throws IOException { LeafReaderContext leafReaderContext = index.createSearcher().getIndexReader().leaves().get(0); // Execute the script - DerivedFieldScript script = compile( - "emit(doc['test_geo_field'].value.getLat(), doc['test_geo_field'].value.getLon())", - lookup - ).newInstance(leafReaderContext); + DerivedFieldScript script = compile("emit(doc['test_geo_field'].value.getLat(), doc['test_geo_field'].value.getLon())", lookup) + .newInstance(leafReaderContext); script.setDocument(1); script.execute(); diff --git a/server/src/main/java/org/opensearch/script/DerivedFieldScript.java b/server/src/main/java/org/opensearch/script/DerivedFieldScript.java index 9c7f90b5d58cd..f56c9ad1cd101 100644 --- a/server/src/main/java/org/opensearch/script/DerivedFieldScript.java +++ b/server/src/main/java/org/opensearch/script/DerivedFieldScript.java @@ -85,7 +85,9 @@ public Map> getDoc() { /** * Return the emitted values from the script execution. */ - public List getEmittedValues() { return emittedValues; } + public List getEmittedValues() { + return emittedValues; + } /** * Set the current document to run the script on next. @@ -96,7 +98,9 @@ public void setDocument(int docid) { leafLookup.setDocument(docid); } - public void addEmittedValue(Object o) { emittedValues.add(o); } + public void addEmittedValue(Object o) { + emittedValues.add(o); + } public void execute() {} diff --git a/server/src/main/java/org/opensearch/script/ScriptEmitValues.java b/server/src/main/java/org/opensearch/script/ScriptEmitValues.java index 0e444bbc239a4..9d3fb98bb3172 100644 --- a/server/src/main/java/org/opensearch/script/ScriptEmitValues.java +++ b/server/src/main/java/org/opensearch/script/ScriptEmitValues.java @@ -29,12 +29,12 @@ public EmitSingle(DerivedFieldScript derivedFieldScript) { } // TODO: Keeping this generic for the time being due to limitations with - // binding methods with the same name and arity. - // Ideally, we should have an emit signature per derived field type and try to scope - // that to the respective script execution so the other emits aren't allowed. - // One way to do this could be to create implementations of the DerivedFieldScript.LeafFactory - // per field type where they each define their own emit() method and then the engine that executes - // it can have custom compilation logic to perform class bindings on that emit implementation. + // binding methods with the same name and arity. + // Ideally, we should have an emit signature per derived field type and try to scope + // that to the respective script execution so the other emits aren't allowed. + // One way to do this could be to create implementations of the DerivedFieldScript.LeafFactory + // per field type where they each define their own emit() method and then the engine that executes + // it can have custom compilation logic to perform class bindings on that emit implementation. public void emit(Object val) { derivedFieldScript.addEmittedValue(val); }