Skip to content

Commit

Permalink
update spotless style issues
Browse files Browse the repository at this point in the history
Signed-off-by: YANGDB <[email protected]>
  • Loading branch information
YANG-DB committed Oct 26, 2023
1 parent 29dd64b commit e3f13c5
Show file tree
Hide file tree
Showing 5 changed files with 364 additions and 246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

package org.opensearch.sql.data.model;

import java.util.List;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.opensearch.sql.data.type.ExprCoreType;
import org.opensearch.sql.data.type.ExprType;

import java.util.List;
import java.util.Objects;

/** Expression array Value. */
@RequiredArgsConstructor
public class ExprArrayValue extends AbstractExprValue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ default boolean isArray() {
return false;

Check warning on line 70 in core/src/main/java/org/opensearch/sql/data/model/ExprValue.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/opensearch/sql/data/model/ExprValue.java#L70

Added line #L70 was not covered by tests
}


/** Get the {@link BindingTuple}. */
default BindingTuple bindingTuples() {
return BindingTuple.EMPTY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@

package org.opensearch.sql.spark.functions.response;

import static java.util.Spliterators.spliteratorUnknownSize;
import static java.util.stream.StreamSupport.stream;
import static org.opensearch.sql.data.model.ExprValueUtils.fromObjectValue;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Spliterator;
import java.util.stream.Collectors;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONArray;
Expand All @@ -32,14 +35,7 @@
import org.opensearch.sql.data.type.ExprType;
import org.opensearch.sql.executor.ExecutionEngine;

import static java.util.Spliterators.spliteratorUnknownSize;
import static java.util.stream.StreamSupport.stream;
import static org.opensearch.sql.data.model.ExprValueUtils.fromObjectValue;

/**
* Default implementation of SparkSqlFunctionResponseHandle.
*
*/
/** Default implementation of SparkSqlFunctionResponseHandle. */
public class DefaultSparkSqlFunctionResponseHandle implements SparkSqlFunctionResponseHandle {
public static final String DATA = "data";
public static final String APPLICATION_ID = "applicationId";
Expand All @@ -51,7 +47,7 @@ public class DefaultSparkSqlFunctionResponseHandle implements SparkSqlFunctionRe
private ExecutionEngine.Schema schema;
private static final Logger logger =
LogManager.getLogger(DefaultSparkSqlFunctionResponseHandle.class);

/**
* Constructor.
*
Expand All @@ -76,6 +72,7 @@ private void constructIteratorAndSchema(JSONObject responseObject) {
this.schema = new ExecutionEngine.Schema(columnList);
this.responseIterator = result.iterator();
}

private static LinkedHashMap<String, ExprValue> extractRow(
JSONObject row, List<ExecutionEngine.Schema.Column> columnList) {
LinkedHashMap<String, ExprValue> linkedHashMap = new LinkedHashMap<>();
Expand Down Expand Up @@ -188,9 +185,7 @@ public ExecutionEngine.Schema schema() {
return schema;
}

/**
* visitor implementation for traversing the json object
*/
/** visitor implementation for traversing the json object */
public static class JsonVisitorImpl implements JsonVisitor<ExprValue> {
public ExprValue visit(Object obj) {
if (obj instanceof JSONObject) {
Expand All @@ -204,15 +199,15 @@ public ExprValue visit(Object obj) {

@Override
public ExprValue visitObject(JSONObject jsonObject) {
return fromObjectValue(jsonObject.keySet().stream().collect(Collectors.toMap(
key -> key,
key -> visit(jsonObject.get(key))
)));
return fromObjectValue(
jsonObject.keySet().stream()
.collect(Collectors.toMap(key -> key, key -> visit(jsonObject.get(key)))));
}

@Override
public ExprValue visitArray(JSONArray jsonArray) {
return new ExprArrayValue(stream(spliteratorUnknownSize(jsonArray.iterator(), Spliterator.ORDERED), false)
return new ExprArrayValue(
stream(spliteratorUnknownSize(jsonArray.iterator(), Spliterator.ORDERED), false)
.map(this::visit)
.collect(Collectors.toList()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
import org.json.JSONArray;
import org.json.JSONObject;

/**
* visitor for the generic Json Object arriving from the flint's result payload
*/
/** visitor for the generic Json Object arriving from the flint's result payload */
public interface JsonVisitor<T> {

T visitObject(JSONObject jsonObject);
T visitObject(JSONObject jsonObject);

T visitArray(JSONArray jsonArray);
T visitArray(JSONArray jsonArray);

T visitPrimitive(Object primitive);
T visitPrimitive(Object primitive);
}
Loading

0 comments on commit e3f13c5

Please sign in to comment.