Skip to content

Commit ac9b5d8

Browse files
authored
[Spotless] Applying Google Code Format for legacy directory (pt 1/4) opensearch-project#19 (opensearch-project#1988)
* spotless apply for OpenSearch P1. Signed-off-by: Mitchell Gale <[email protected]> * Manual spotless changes Signed-off-by: Mitchell Gale <[email protected]> * spotless apply for OpenSearch P2. Signed-off-by: Mitchell Gale <[email protected]> * 90 files checked after spotless apply for legacy Signed-off-by: Mitchell Gale <[email protected]> * Added checkstyle ignore failures to legacy Signed-off-by: Mitchell Gale <[email protected]> * Fixed comma issue Signed-off-by: Mitchell Gale <[email protected]> * Spotless apply Signed-off-by: Mitchell Gale <[email protected]> * Revert build.gradle Signed-off-by: Mitchell Gale <[email protected]> --------- Signed-off-by: Mitchell Gale <[email protected]> Signed-off-by: Mitchell Gale <[email protected]>
1 parent ff059f0 commit ac9b5d8

File tree

92 files changed

+7517
-7685
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+7517
-7685
lines changed

benchmarks/src/jmh/java/org/opensearch/sql/expression/operator/predicate/ComparisonOperatorBenchmark.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
@Fork(value = 1)
3939
public class ComparisonOperatorBenchmark {
4040

41-
@Param(value = { "int", "string", "date" })
41+
@Param(value = {"int", "string", "date"})
4242
private String testDataType;
4343

4444
private final Map<String, ExprValue> params =
@@ -65,9 +65,7 @@ public void testGreaterOperator() {
6565

6666
private void run(Function<Expression[], FunctionExpression> dsl) {
6767
ExprValue param = params.get(testDataType);
68-
FunctionExpression func = dsl.apply(new Expression[] {
69-
literal(param), literal(param)
70-
});
68+
FunctionExpression func = dsl.apply(new Expression[] {literal(param), literal(param)});
7169
func.valueOf();
7270
}
7371
}

legacy/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ compileJava {
5353
}
5454
}
5555

56+
checkstyleTest.ignoreFailures = true
57+
checkstyleMain.ignoreFailures = true
58+
5659
// TODO: Similarly, need to fix compiling errors in test source code
5760
compileTestJava.options.warnings = false
5861
compileTestJava {

legacy/src/main/java/org/opensearch/sql/legacy/antlr/semantic/types/base/BaseType.java

+9-12
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,21 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.legacy.antlr.semantic.types.base;
87

98
import java.util.List;
109
import org.opensearch.sql.legacy.antlr.semantic.types.Type;
1110

12-
/**
13-
* Base type interface
14-
*/
11+
/** Base type interface */
1512
public interface BaseType extends Type {
1613

17-
@Override
18-
default Type construct(List<Type> others) {
19-
return this;
20-
}
14+
@Override
15+
default Type construct(List<Type> others) {
16+
return this;
17+
}
2118

22-
@Override
23-
default String usage() {
24-
return getName();
25-
}
19+
@Override
20+
default String usage() {
21+
return getName();
22+
}
2623
}

legacy/src/main/java/org/opensearch/sql/legacy/antlr/semantic/types/function/AggregateFunction.java

+33-37
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.legacy.antlr.semantic.types.function;
87

98
import static org.opensearch.sql.legacy.antlr.semantic.types.base.OpenSearchDataType.DOUBLE;
@@ -15,41 +14,38 @@
1514
import org.opensearch.sql.legacy.antlr.semantic.types.Type;
1615
import org.opensearch.sql.legacy.antlr.semantic.types.TypeExpression;
1716

18-
/**
19-
* Aggregate function
20-
*/
17+
/** Aggregate function */
2118
public enum AggregateFunction implements TypeExpression {
22-
COUNT(
23-
func().to(INTEGER), // COUNT(*)
24-
func(OPENSEARCH_TYPE).to(INTEGER)
25-
),
26-
MAX(func(T(NUMBER)).to(T)),
27-
MIN(func(T(NUMBER)).to(T)),
28-
AVG(func(T(NUMBER)).to(DOUBLE)),
29-
SUM(func(T(NUMBER)).to(T));
30-
31-
private TypeExpressionSpec[] specifications;
32-
33-
AggregateFunction(TypeExpressionSpec... specifications) {
34-
this.specifications = specifications;
35-
}
36-
37-
@Override
38-
public String getName() {
39-
return name();
40-
}
41-
42-
@Override
43-
public TypeExpressionSpec[] specifications() {
44-
return specifications;
45-
}
46-
47-
private static TypeExpressionSpec func(Type... argTypes) {
48-
return new TypeExpressionSpec().map(argTypes);
49-
}
50-
51-
@Override
52-
public String toString() {
53-
return "Function [" + name() + "]";
54-
}
19+
COUNT(
20+
func().to(INTEGER), // COUNT(*)
21+
func(OPENSEARCH_TYPE).to(INTEGER)),
22+
MAX(func(T(NUMBER)).to(T)),
23+
MIN(func(T(NUMBER)).to(T)),
24+
AVG(func(T(NUMBER)).to(DOUBLE)),
25+
SUM(func(T(NUMBER)).to(T));
26+
27+
private TypeExpressionSpec[] specifications;
28+
29+
AggregateFunction(TypeExpressionSpec... specifications) {
30+
this.specifications = specifications;
31+
}
32+
33+
@Override
34+
public String getName() {
35+
return name();
36+
}
37+
38+
@Override
39+
public TypeExpressionSpec[] specifications() {
40+
return specifications;
41+
}
42+
43+
private static TypeExpressionSpec func(Type... argTypes) {
44+
return new TypeExpressionSpec().map(argTypes);
45+
}
46+
47+
@Override
48+
public String toString() {
49+
return "Function [" + name() + "]";
50+
}
5551
}

legacy/src/main/java/org/opensearch/sql/legacy/antlr/semantic/types/operator/ComparisonOperator.java

+42-46
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.legacy.antlr.semantic.types.operator;
87

98
import static org.opensearch.sql.legacy.antlr.semantic.types.base.OpenSearchDataType.BOOLEAN;
@@ -12,53 +11,50 @@
1211
import java.util.List;
1312
import org.opensearch.sql.legacy.antlr.semantic.types.Type;
1413

15-
/**
16-
* Type for comparison operator
17-
*/
14+
/** Type for comparison operator */
1815
public enum ComparisonOperator implements Type {
19-
20-
EQUAL("="),
21-
NOT_EQUAL("<>"),
22-
NOT_EQUAL2("!="),
23-
GREATER_THAN(">"),
24-
GREATER_THAN_OR_EQUAL_TO(">="),
25-
SMALLER_THAN("<"),
26-
SMALLER_THAN_OR_EQUAL_TO("<="),
27-
IS("IS");
28-
29-
/** Actual name representing the operator */
30-
private final String name;
31-
32-
ComparisonOperator(String name) {
33-
this.name = name;
34-
}
35-
36-
@Override
37-
public String getName() {
38-
return name;
39-
}
40-
41-
@Override
42-
public Type construct(List<Type> actualArgs) {
43-
if (actualArgs.size() != 2) {
44-
return TYPE_ERROR;
45-
}
46-
47-
Type leftType = actualArgs.get(0);
48-
Type rightType = actualArgs.get(1);
49-
if (leftType.isCompatible(rightType) || rightType.isCompatible(leftType)) {
50-
return BOOLEAN;
51-
}
52-
return TYPE_ERROR;
53-
}
54-
55-
@Override
56-
public String usage() {
57-
return "Please use compatible types from each side.";
16+
EQUAL("="),
17+
NOT_EQUAL("<>"),
18+
NOT_EQUAL2("!="),
19+
GREATER_THAN(">"),
20+
GREATER_THAN_OR_EQUAL_TO(">="),
21+
SMALLER_THAN("<"),
22+
SMALLER_THAN_OR_EQUAL_TO("<="),
23+
IS("IS");
24+
25+
/** Actual name representing the operator */
26+
private final String name;
27+
28+
ComparisonOperator(String name) {
29+
this.name = name;
30+
}
31+
32+
@Override
33+
public String getName() {
34+
return name;
35+
}
36+
37+
@Override
38+
public Type construct(List<Type> actualArgs) {
39+
if (actualArgs.size() != 2) {
40+
return TYPE_ERROR;
5841
}
5942

60-
@Override
61-
public String toString() {
62-
return "Operator [" + getName() + "]";
43+
Type leftType = actualArgs.get(0);
44+
Type rightType = actualArgs.get(1);
45+
if (leftType.isCompatible(rightType) || rightType.isCompatible(leftType)) {
46+
return BOOLEAN;
6347
}
48+
return TYPE_ERROR;
49+
}
50+
51+
@Override
52+
public String usage() {
53+
return "Please use compatible types from each side.";
54+
}
55+
56+
@Override
57+
public String toString() {
58+
return "Operator [" + getName() + "]";
59+
}
6460
}

legacy/src/main/java/org/opensearch/sql/legacy/antlr/syntax/CaseInsensitiveCharStream.java

+46-46
Original file line numberDiff line numberDiff line change
@@ -3,71 +3,71 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.legacy.antlr.syntax;
87

98
import org.antlr.v4.runtime.CharStream;
109
import org.antlr.v4.runtime.CharStreams;
1110
import org.antlr.v4.runtime.misc.Interval;
1211

1312
/**
14-
* Custom stream to convert character to upper case for case insensitive grammar before sending to lexer.
13+
* Custom stream to convert character to upper case for case insensitive grammar before sending to
14+
* lexer.
1515
*/
1616
public class CaseInsensitiveCharStream implements CharStream {
1717

18-
/** Character stream */
19-
private final CharStream charStream;
18+
/** Character stream */
19+
private final CharStream charStream;
2020

21-
public CaseInsensitiveCharStream(String sql) {
22-
this.charStream = CharStreams.fromString(sql);
23-
}
21+
public CaseInsensitiveCharStream(String sql) {
22+
this.charStream = CharStreams.fromString(sql);
23+
}
2424

25-
@Override
26-
public String getText(Interval interval) {
27-
return charStream.getText(interval);
28-
}
25+
@Override
26+
public String getText(Interval interval) {
27+
return charStream.getText(interval);
28+
}
2929

30-
@Override
31-
public void consume() {
32-
charStream.consume();
33-
}
30+
@Override
31+
public void consume() {
32+
charStream.consume();
33+
}
3434

35-
@Override
36-
public int LA(int i) {
37-
int c = charStream.LA(i);
38-
if (c <= 0) {
39-
return c;
40-
}
41-
return Character.toUpperCase(c);
35+
@Override
36+
public int LA(int i) {
37+
int c = charStream.LA(i);
38+
if (c <= 0) {
39+
return c;
4240
}
41+
return Character.toUpperCase(c);
42+
}
4343

44-
@Override
45-
public int mark() {
46-
return charStream.mark();
47-
}
44+
@Override
45+
public int mark() {
46+
return charStream.mark();
47+
}
4848

49-
@Override
50-
public void release(int marker) {
51-
charStream.release(marker);
52-
}
49+
@Override
50+
public void release(int marker) {
51+
charStream.release(marker);
52+
}
5353

54-
@Override
55-
public int index() {
56-
return charStream.index();
57-
}
54+
@Override
55+
public int index() {
56+
return charStream.index();
57+
}
5858

59-
@Override
60-
public void seek(int index) {
61-
charStream.seek(index);
62-
}
59+
@Override
60+
public void seek(int index) {
61+
charStream.seek(index);
62+
}
6363

64-
@Override
65-
public int size() {
66-
return charStream.size();
67-
}
64+
@Override
65+
public int size() {
66+
return charStream.size();
67+
}
6868

69-
@Override
70-
public String getSourceName() {
71-
return charStream.getSourceName();
72-
}
69+
@Override
70+
public String getSourceName() {
71+
return charStream.getSourceName();
72+
}
7373
}

0 commit comments

Comments
 (0)