Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address issues flagged by checkstyle build step #229

Merged
merged 4 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@

package org.opensearch.sql.executor;

import java.util.concurrent.atomic.AtomicBoolean;
import org.opensearch.sql.ast.AbstractNodeVisitor;
import org.opensearch.sql.ast.Node;
import org.opensearch.sql.ast.expression.AllFields;
import org.opensearch.sql.ast.tree.Filter;
import org.opensearch.sql.ast.tree.Limit;
import org.opensearch.sql.ast.tree.Project;
import org.opensearch.sql.ast.tree.Relation;
import org.opensearch.sql.ast.tree.Sort;
import org.opensearch.sql.ast.tree.Values;

import java.util.concurrent.atomic.AtomicBoolean;

/**
* Use this unresolved plan visitor to check if a plan can be serialized by PaginatedPlanCache.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,15 @@ public Cursor convertToCursor(PhysicalPlan plan) {
}
}

/**
* Compress serialized query plan.
* @param str string representing a query plan
* @return str compressed with gzip.
*/
@SneakyThrows
public static String compress(String str) {
if (str == null || str.length() == 0) {
return null;
return null;
}

ByteArrayOutputStream out = new ByteArrayOutputStream();
Expand All @@ -70,10 +75,15 @@ public static String compress(String str) {
return HashCode.fromBytes(out.toByteArray()).toString();
}

/**
* Decompresses a query plan that was compress with {@link PaginatedPlanCache.compress}.
* @param input compressed query plan
* @return seria
*/
@SneakyThrows
public static String decompress(String input) {
if (input == null || input.length() == 0) {
return null;
return null;
}
GZIPInputStream gzip = new GZIPInputStream(new ByteArrayInputStream(
HashCode.fromString(input).asBytes()));
Expand Down Expand Up @@ -114,10 +124,10 @@ public PhysicalPlan convertToPlan(String cursor) {
throw new UnsupportedOperationException("Unsupported cursor");
}
cursor = cursor.substring(cursor.indexOf(',') + 1);
int currentPageIndex = Integer.parseInt(cursor, 0, cursor.indexOf(','), 10);
final int currentPageIndex = Integer.parseInt(cursor, 0, cursor.indexOf(','), 10);

cursor = cursor.substring(cursor.indexOf(',') + 1);
int pageSize = Integer.parseInt(cursor, 0, cursor.indexOf(','), 10);
final int pageSize = Integer.parseInt(cursor, 0, cursor.indexOf(','), 10);

cursor = cursor.substring(cursor.indexOf(',') + 1);
if (!cursor.startsWith("(Project,")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import org.opensearch.sql.planner.logical.LogicalRelation;
import org.opensearch.sql.planner.optimizer.Rule;

import java.util.Objects;

public class PushPageSize
implements Rule<LogicalPaginate> {
/** Capture the table inside matched logical paginate operator. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package org.opensearch.sql.opensearch.storage;

import static org.opensearch.sql.opensearch.request.OpenSearchScrollRequest.DEFAULT_SCROLL_TIMEOUT;

import java.util.function.Consumer;
import java.util.function.Function;
import lombok.EqualsAndHashCode;
Expand All @@ -18,8 +20,6 @@
import org.opensearch.sql.opensearch.request.OpenSearchRequest;
import org.opensearch.sql.opensearch.response.OpenSearchResponse;

import static org.opensearch.sql.opensearch.request.OpenSearchScrollRequest.DEFAULT_SCROLL_TIMEOUT;

public class ContinueScrollRequest implements OpenSearchRequest {
final String initialScrollId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@

import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.opensearch.sql.data.model.ExprValue;
import org.opensearch.sql.opensearch.client.OpenSearchClient;
import org.opensearch.sql.opensearch.request.OpenSearchRequest;
import org.opensearch.sql.opensearch.request.OpenSearchScrollRequest;
import org.opensearch.sql.opensearch.response.OpenSearchResponse;
import org.opensearch.sql.storage.TableScanOperator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@

public interface PagedRequestBuilder {
OpenSearchRequest build();

OpenSearchRequest.IndexName getIndexName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@

package org.opensearch.sql.opensearch.storage;

import lombok.RequiredArgsConstructor;
import org.opensearch.sql.opensearch.data.value.OpenSearchExprValueFactory;
import org.opensearch.sql.opensearch.request.OpenSearchRequest;

@RequiredArgsConstructor
public class SubsequentPageRequestBuilder implements PagedRequestBuilder {
private OpenSearchRequest.IndexName indexName;
final OpenSearchRequest.IndexName indexName;
final String scrollId;
private OpenSearchExprValueFactory exprValueFactory;

public SubsequentPageRequestBuilder(OpenSearchRequest.IndexName indexName, String scanAsString,
OpenSearchExprValueFactory exprValueFactory) {
this.indexName = indexName;
scrollId = scanAsString;
this.exprValueFactory = exprValueFactory;
}
final OpenSearchExprValueFactory exprValueFactory;

@Override
public OpenSearchRequest build() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import org.opensearch.sql.expression.NamedExpression;
import org.opensearch.sql.expression.ReferenceExpression;
import org.opensearch.sql.expression.aggregation.NamedAggregator;
import org.opensearch.sql.expression.serialization.DefaultExpressionSerializer;
import org.opensearch.sql.opensearch.response.agg.OpenSearchAggregationResponseParser;
import org.opensearch.sql.opensearch.storage.OpenSearchIndexScan;
import org.opensearch.sql.opensearch.storage.script.aggregation.AggregationQueryBuilder;
import org.opensearch.sql.expression.serialization.DefaultExpressionSerializer;
import org.opensearch.sql.planner.logical.LogicalAggregation;
import org.opensearch.sql.planner.logical.LogicalSort;
import org.opensearch.sql.storage.TableScanOperator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import org.opensearch.sql.expression.ExpressionNodeVisitor;
import org.opensearch.sql.expression.NamedExpression;
import org.opensearch.sql.expression.ReferenceExpression;
import org.opensearch.sql.expression.serialization.DefaultExpressionSerializer;
import org.opensearch.sql.opensearch.storage.OpenSearchIndexScan;
import org.opensearch.sql.opensearch.storage.script.filter.FilterQueryBuilder;
import org.opensearch.sql.opensearch.storage.script.sort.SortQueryBuilder;
import org.opensearch.sql.expression.serialization.DefaultExpressionSerializer;
import org.opensearch.sql.planner.logical.LogicalFilter;
import org.opensearch.sql.planner.logical.LogicalHighlight;
import org.opensearch.sql.planner.logical.LogicalLimit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import org.opensearch.script.ScriptContext;
import org.opensearch.script.ScriptEngine;
import org.opensearch.sql.expression.Expression;
import org.opensearch.sql.expression.serialization.ExpressionSerializer;
import org.opensearch.sql.opensearch.storage.script.aggregation.ExpressionAggregationScriptFactory;
import org.opensearch.sql.opensearch.storage.script.filter.ExpressionFilterScriptFactory;
import org.opensearch.sql.expression.serialization.ExpressionSerializer;

/**
* Custom expression script engine that supports using core engine expression code in DSL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import org.opensearch.sql.expression.NamedExpression;
import org.opensearch.sql.expression.ReferenceExpression;
import org.opensearch.sql.expression.aggregation.NamedAggregator;
import org.opensearch.sql.expression.serialization.ExpressionSerializer;
import org.opensearch.sql.opensearch.response.agg.CompositeAggregationParser;
import org.opensearch.sql.opensearch.response.agg.MetricParser;
import org.opensearch.sql.opensearch.response.agg.NoBucketAggregationParser;
import org.opensearch.sql.opensearch.response.agg.OpenSearchAggregationResponseParser;
import org.opensearch.sql.opensearch.storage.script.aggregation.dsl.BucketAggregationBuilder;
import org.opensearch.sql.opensearch.storage.script.aggregation.dsl.MetricAggregationBuilder;
import org.opensearch.sql.expression.serialization.ExpressionSerializer;

/**
* Build the AggregationBuilder from the list of {@link NamedAggregator}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import org.opensearch.sql.expression.FunctionExpression;
import org.opensearch.sql.expression.LiteralExpression;
import org.opensearch.sql.expression.ReferenceExpression;
import org.opensearch.sql.opensearch.storage.script.ScriptUtils;
import org.opensearch.sql.expression.serialization.ExpressionSerializer;
import org.opensearch.sql.opensearch.storage.script.ScriptUtils;

/**
* Abstract Aggregation Builder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import org.opensearch.search.sort.SortOrder;
import org.opensearch.sql.ast.expression.SpanUnit;
import org.opensearch.sql.expression.NamedExpression;
import org.opensearch.sql.expression.span.SpanExpression;
import org.opensearch.sql.expression.serialization.ExpressionSerializer;
import org.opensearch.sql.expression.span.SpanExpression;

/**
* Bucket Aggregation Builder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
import org.opensearch.sql.expression.LiteralExpression;
import org.opensearch.sql.expression.ReferenceExpression;
import org.opensearch.sql.expression.aggregation.NamedAggregator;
import org.opensearch.sql.expression.serialization.ExpressionSerializer;
import org.opensearch.sql.opensearch.response.agg.FilterParser;
import org.opensearch.sql.opensearch.response.agg.MetricParser;
import org.opensearch.sql.opensearch.response.agg.SingleValueParser;
import org.opensearch.sql.opensearch.response.agg.StatsParser;
import org.opensearch.sql.opensearch.response.agg.TopHitsParser;
import org.opensearch.sql.opensearch.storage.script.filter.FilterQueryBuilder;
import org.opensearch.sql.expression.serialization.ExpressionSerializer;

/**
* Build the Metric Aggregation and List of {@link MetricParser} from {@link NamedAggregator}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.opensearch.sql.expression.FunctionExpression;
import org.opensearch.sql.expression.function.BuiltinFunctionName;
import org.opensearch.sql.expression.function.FunctionName;
import org.opensearch.sql.expression.serialization.ExpressionSerializer;
import org.opensearch.sql.opensearch.storage.script.filter.lucene.LikeQuery;
import org.opensearch.sql.opensearch.storage.script.filter.lucene.LuceneQuery;
import org.opensearch.sql.opensearch.storage.script.filter.lucene.RangeQuery;
Expand All @@ -38,7 +39,6 @@
import org.opensearch.sql.opensearch.storage.script.filter.lucene.relevance.QueryStringQuery;
import org.opensearch.sql.opensearch.storage.script.filter.lucene.relevance.SimpleQueryStringQuery;
import org.opensearch.sql.opensearch.storage.script.filter.lucene.relevance.WildcardQuery;
import org.opensearch.sql.expression.serialization.ExpressionSerializer;

@RequiredArgsConstructor
public class FilterQueryBuilder extends ExpressionNodeVisitor<QueryBuilder, Object> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.opensearch.sql.datasource.DataSourceServiceImpl;
import org.opensearch.sql.datasource.model.DataSource;
import org.opensearch.sql.datasource.model.DataSourceMetadata;
import org.opensearch.sql.expression.serialization.DefaultExpressionSerializer;
import org.opensearch.sql.legacy.esdomain.LocalClusterState;
import org.opensearch.sql.legacy.executor.AsyncRestExecutor;
import org.opensearch.sql.legacy.metrics.Metrics;
Expand All @@ -68,7 +69,6 @@
import org.opensearch.sql.opensearch.setting.OpenSearchSettings;
import org.opensearch.sql.opensearch.storage.OpenSearchDataSourceFactory;
import org.opensearch.sql.opensearch.storage.script.ExpressionScriptEngine;
import org.opensearch.sql.expression.serialization.DefaultExpressionSerializer;
import org.opensearch.sql.plugin.config.OpenSearchPluginModule;
import org.opensearch.sql.plugin.datasource.DataSourceSettings;
import org.opensearch.sql.plugin.rest.RestPPLQueryAction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,20 @@ public class SQLQueryRequest {
private boolean sanitize = true;

private String cursor = "";

/**
* Constructor of SQLQueryRequest that passes request params.
*/
public SQLQueryRequest(
JSONObject jsonContent, String query, String path, Map<String, String> params, String cursor) {
public SQLQueryRequest(JSONObject jsonContent, String query, String path,
Map<String, String> params, String cursor) {
this.jsonContent = jsonContent;
this.query = query;
this.path = path;
this.params = params;
this.format = getFormat(params);
this.sanitize = shouldSanitize(params);
// TODO hack
this.cursor = cursor == null? "" : cursor;
this.cursor = cursor == null ? "" : cursor;
}

/**
Expand Down