Skip to content

Commit

Permalink
Spotless fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Rishabh Maurya <[email protected]>
  • Loading branch information
rishabhmaurya committed Apr 1, 2024
1 parent c6278cb commit 6b2d222
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public Map<String, ScriptDocValues<?>> getDoc() {
/**
* Return the emitted values from the script execution.
*/
public List<Object> getEmittedValues() { return emittedValues; }
public List<Object> getEmittedValues() {
return emittedValues;
}

/**
* Set the current document to run the script on next.
Expand All @@ -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() {}

Expand Down
12 changes: 6 additions & 6 deletions server/src/main/java/org/opensearch/script/ScriptEmitValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 6b2d222

Please sign in to comment.