Skip to content

Commit ae39e70

Browse files
authored
Merge pull request #314 from Bit-Quill/dev/sl_GoogleJavaFormat3
[Spotless] Applying Google Code Format for core/src/main files #3
2 parents d00dc4d + d52b65c commit ae39e70

File tree

89 files changed

+768
-1155
lines changed

Some content is hidden

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

89 files changed

+768
-1155
lines changed

build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ repositories {
8383
// Spotless checks will be added as PRs are applied to resolve each style issue is approved.
8484
spotless {
8585
java {
86-
// target fileTree('.') {
87-
// include '**/*.java', 'src/*/java/**/*.java'
88-
// exclude '**/build/**', '**/build-*/**'
89-
// }
86+
target fileTree('.') {
87+
include 'core/src/main/java/org/opensearch/sql/planner/**/*.java',
88+
'core/src/main/java/org/opensearch/sql/storage/**/*.java',
89+
'core/src/main/java/org/opensearch/sql/utils/**/*.java'
90+
exclude '**/build/**', '**/build-*/**'
91+
}
9092
// importOrder()
9193
// licenseHeader("/*\n" +
9294
// " * Copyright OpenSearch Contributors\n" +
@@ -95,7 +97,7 @@ spotless {
9597
// removeUnusedImports()
9698
// trimTrailingWhitespace()
9799
// endWithNewline()
98-
// googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format')
100+
googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format')
99101
}
100102
}
101103

core/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ repositories {
3434
mavenCentral()
3535
}
3636

37+
checkstyleTest.ignoreFailures = true
38+
checkstyleMain.ignoreFailures = true
39+
3740
pitest {
3841
targetClasses = ['org.opensearch.sql.*']
3942
pitestVersion = '1.9.0'

core/src/main/java/org/opensearch/sql/planner/DefaultImplementor.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@
4545

4646
/**
4747
* Default implementor for implementing logical to physical translation. "Default" here means all
48-
* logical operator will be translated to correspondent physical operator to pipeline operations
49-
* in post-processing style in memory.
50-
* Different storage can override methods here to optimize default pipelining operator, for example
51-
* a storage has the flexibility to override visitFilter and visitRelation to push down filtering
52-
* operation and return a single physical index scan operator.
48+
* logical operator will be translated to correspondent physical operator to pipeline operations in
49+
* post-processing style in memory. Different storage can override methods here to optimize default
50+
* pipelining operator, for example a storage has the flexibility to override visitFilter and
51+
* visitRelation to push down filtering operation and return a single physical index scan operator.
5352
*
54-
* @param <C> context type
53+
* @param <C> context type
5554
*/
5655
public class DefaultImplementor<C> extends LogicalPlanNodeVisitor<PhysicalPlan, C> {
5756

@@ -62,8 +61,7 @@ public PhysicalPlan visitRareTopN(LogicalRareTopN node, C context) {
6261
node.getCommandType(),
6362
node.getNoOfResults(),
6463
node.getFieldList(),
65-
node.getGroupByList()
66-
);
64+
node.getGroupByList());
6765
}
6866

6967
@Override
@@ -78,16 +76,14 @@ public PhysicalPlan visitDedupe(LogicalDedupe node, C context) {
7876

7977
@Override
8078
public PhysicalPlan visitProject(LogicalProject node, C context) {
81-
return new ProjectOperator(visitChild(node, context), node.getProjectList(),
82-
node.getNamedParseExpressions());
79+
return new ProjectOperator(
80+
visitChild(node, context), node.getProjectList(), node.getNamedParseExpressions());
8381
}
8482

8583
@Override
8684
public PhysicalPlan visitWindow(LogicalWindow node, C context) {
8785
return new WindowOperator(
88-
visitChild(node, context),
89-
node.getWindowFunction(),
90-
node.getWindowDefinition());
86+
visitChild(node, context), node.getWindowFunction(), node.getWindowDefinition());
9187
}
9288

9389
@Override
@@ -148,8 +144,9 @@ public PhysicalPlan visitTableWriteBuilder(TableWriteBuilder plan, C context) {
148144

149145
@Override
150146
public PhysicalPlan visitRelation(LogicalRelation node, C context) {
151-
throw new UnsupportedOperationException("Storage engine is responsible for "
152-
+ "implementing and optimizing logical plan with relation involved");
147+
throw new UnsupportedOperationException(
148+
"Storage engine is responsible for "
149+
+ "implementing and optimizing logical plan with relation involved");
153150
}
154151

155152
@Override

core/src/main/java/org/opensearch/sql/planner/PlanContext.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@
99
import lombok.Getter;
1010
import org.opensearch.sql.storage.split.Split;
1111

12-
/**
13-
* Plan context hold planning related information.
14-
*/
12+
/** Plan context hold planning related information. */
1513
public class PlanContext {
1614

17-
@Getter
18-
private final Optional<Split> split;
15+
@Getter private final Optional<Split> split;
1916

2017
public PlanContext(Split split) {
2118
this.split = Optional.of(split);

core/src/main/java/org/opensearch/sql/planner/PlanNode.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.planner;
87

98
import java.util.List;
109

11-
/**
12-
* The definition of Plan Node.
13-
*/
10+
/** The definition of Plan Node. */
1411
public interface PlanNode<T extends PlanNode> {
1512

1613
/**

core/src/main/java/org/opensearch/sql/planner/Planner.java

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.planner;
87

9-
108
import java.util.List;
119
import lombok.RequiredArgsConstructor;
1210
import org.opensearch.sql.planner.logical.LogicalPlan;
@@ -16,17 +14,15 @@
1614
import org.opensearch.sql.planner.physical.PhysicalPlan;
1715
import org.opensearch.sql.storage.Table;
1816

19-
/**
20-
* Planner that plans and chooses the optimal physical plan.
21-
*/
17+
/** Planner that plans and chooses the optimal physical plan. */
2218
@RequiredArgsConstructor
2319
public class Planner {
2420

2521
private final LogicalPlanOptimizer logicalOptimizer;
2622

2723
/**
28-
* Generate optimal physical plan for logical plan. If no table involved,
29-
* translate logical plan to physical by default implementor.
24+
* Generate optimal physical plan for logical plan. If no table involved, translate logical plan
25+
* to physical by default implementor.<br>
3026
* TODO: for now just delegate entire logical plan to storage engine.
3127
*
3228
* @param plan logical plan
@@ -37,28 +33,28 @@ public PhysicalPlan plan(LogicalPlan plan) {
3733
if (table == null) {
3834
return plan.accept(new DefaultImplementor<>(), null);
3935
}
40-
return table.implement(
41-
table.optimize(optimize(plan)));
36+
return table.implement(table.optimize(optimize(plan)));
4237
}
4338

4439
private Table findTable(LogicalPlan plan) {
45-
return plan.accept(new LogicalPlanNodeVisitor<Table, Object>() {
46-
47-
@Override
48-
public Table visitNode(LogicalPlan node, Object context) {
49-
List<LogicalPlan> children = node.getChild();
50-
if (children.isEmpty()) {
51-
return null;
52-
}
53-
return children.get(0).accept(this, context);
54-
}
55-
56-
@Override
57-
public Table visitRelation(LogicalRelation node, Object context) {
58-
return node.getTable();
59-
}
60-
61-
}, null);
40+
return plan.accept(
41+
new LogicalPlanNodeVisitor<Table, Object>() {
42+
43+
@Override
44+
public Table visitNode(LogicalPlan node, Object context) {
45+
List<LogicalPlan> children = node.getChild();
46+
if (children.isEmpty()) {
47+
return null;
48+
}
49+
return children.get(0).accept(this, context);
50+
}
51+
52+
@Override
53+
public Table visitRelation(LogicalRelation node, Object context) {
54+
return node.getTable();
55+
}
56+
},
57+
null);
6258
}
6359

6460
private LogicalPlan optimize(LogicalPlan plan) {

core/src/main/java/org/opensearch/sql/planner/SerializablePlan.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,37 @@
1010
/**
1111
* All subtypes of PhysicalPlan which needs to be serialized (in cursor, for pagination feature)
1212
* should follow one of the following options.
13+
*
1314
* <ul>
1415
* <li>Both:
15-
* <ul>
16-
* <li>Override both methods from {@link Externalizable}.</li>
17-
* <li>Define a public no-arg constructor.</li>
18-
* </ul>
19-
* </li>
20-
* <li>
21-
* Overwrite {@link #getPlanForSerialization} to return
22-
* another instance of {@link SerializablePlan}.
23-
* </li>
16+
* <ul>
17+
* <li>Override both methods from {@link Externalizable}.
18+
* <li>Define a public no-arg constructor.
19+
* </ul>
20+
* <li>Overwrite {@link #getPlanForSerialization} to return another instance of {@link
21+
* SerializablePlan}.
2422
* </ul>
2523
*/
2624
public interface SerializablePlan extends Externalizable {
2725

2826
/**
29-
* Override to return child or delegated plan, so parent plan should skip this one
30-
* for serialization, but it should try to serialize grandchild plan.
31-
* Imagine plan structure like this
27+
* Override to return child or delegated plan, so parent plan should skip this one for
28+
* serialization, but it should try to serialize grandchild plan. Imagine plan structure like this
29+
*
3230
* <pre>
3331
* A -> this
3432
* `- B -> child
3533
* `- C -> this
3634
* </pre>
37-
* In that case only plans A and C should be attempted to serialize.
38-
* It is needed to skip a `ResourceMonitorPlan` instance only, actually.
3935
*
40-
* <pre>{@code
41-
* * A.writeObject(B.getPlanForSerialization());
42-
* }</pre>
36+
* In that case only plans A and C should be attempted to serialize. It is needed to skip a
37+
* `ResourceMonitorPlan` instance only, actually.
38+
*
39+
* <pre>{@code
40+
* * A.writeObject(B.getPlanForSerialization());
41+
*
42+
* }</pre>
43+
*
4344
* @return Next plan for serialization.
4445
*/
4546
default SerializablePlan getPlanForSerialization() {

core/src/main/java/org/opensearch/sql/planner/logical/LogicalAD.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class LogicalAD extends LogicalPlan {
1818

1919
/**
2020
* Constructor of LogicalAD.
21+
*
2122
* @param child child logical plan
2223
* @param arguments arguments of the algorithm
2324
*/

core/src/main/java/org/opensearch/sql/planner/logical/LogicalAggregation.java

Lines changed: 5 additions & 14 deletions
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.planner.logical;
87

98
import java.util.Collections;
@@ -14,26 +13,18 @@
1413
import org.opensearch.sql.expression.NamedExpression;
1514
import org.opensearch.sql.expression.aggregation.NamedAggregator;
1615

17-
/**
18-
* Logical Aggregation.
19-
*/
16+
/** Logical Aggregation. */
2017
@ToString
2118
@EqualsAndHashCode(callSuper = true)
2219
public class LogicalAggregation extends LogicalPlan {
2320

24-
@Getter
25-
private final List<NamedAggregator> aggregatorList;
21+
@Getter private final List<NamedAggregator> aggregatorList;
2622

27-
@Getter
28-
private final List<NamedExpression> groupByList;
23+
@Getter private final List<NamedExpression> groupByList;
2924

30-
/**
31-
* Constructor of LogicalAggregation.
32-
*/
25+
/** Constructor of LogicalAggregation. */
3326
public LogicalAggregation(
34-
LogicalPlan child,
35-
List<NamedAggregator> aggregatorList,
36-
List<NamedExpression> groupByList) {
27+
LogicalPlan child, List<NamedAggregator> aggregatorList, List<NamedExpression> groupByList) {
3728
super(Collections.singletonList(child));
3829
this.aggregatorList = aggregatorList;
3930
this.groupByList = groupByList;

core/src/main/java/org/opensearch/sql/planner/logical/LogicalCloseCursor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import lombok.ToString;
1111

1212
/**
13-
* A logical plan node which wraps {@link org.opensearch.sql.planner.LogicalCursor}
14-
* and represent a cursor close operation.
13+
* A logical plan node which wraps {@link org.opensearch.sql.planner.LogicalCursor} and represent a
14+
* cursor close operation.
1515
*/
1616
@ToString
1717
@EqualsAndHashCode(callSuper = false)

core/src/main/java/org/opensearch/sql/planner/logical/LogicalDedupe.java

Lines changed: 5 additions & 8 deletions
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.planner.logical;
87

98
import java.util.Arrays;
@@ -13,9 +12,7 @@
1312
import lombok.ToString;
1413
import org.opensearch.sql.expression.Expression;
1514

16-
/**
17-
* Logical Dedupe Plan.
18-
*/
15+
/** Logical Dedupe Plan. */
1916
@Getter
2017
@ToString
2118
@EqualsAndHashCode(callSuper = true)
@@ -26,12 +23,12 @@ public class LogicalDedupe extends LogicalPlan {
2623
private final Boolean keepEmpty;
2724
private final Boolean consecutive;
2825

29-
/**
30-
* Constructor of LogicalDedupe.
31-
*/
26+
/** Constructor of LogicalDedupe. */
3227
public LogicalDedupe(
3328
LogicalPlan child,
34-
List<Expression> dedupeList, Integer allowedDuplication, Boolean keepEmpty,
29+
List<Expression> dedupeList,
30+
Integer allowedDuplication,
31+
Boolean keepEmpty,
3532
Boolean consecutive) {
3633
super(Arrays.asList(child));
3734
this.dedupeList = dedupeList;

core/src/main/java/org/opensearch/sql/planner/logical/LogicalEval.java

Lines changed: 3 additions & 9 deletions
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.planner.logical;
87

98
import java.util.Collections;
@@ -24,15 +23,10 @@
2423
@EqualsAndHashCode(callSuper = true)
2524
public class LogicalEval extends LogicalPlan {
2625

27-
@Getter
28-
private final List<Pair<ReferenceExpression, Expression>> expressions;
26+
@Getter private final List<Pair<ReferenceExpression, Expression>> expressions;
2927

30-
/**
31-
* Constructor of LogicalEval.
32-
*/
33-
public LogicalEval(
34-
LogicalPlan child,
35-
List<Pair<ReferenceExpression, Expression>> expressions) {
28+
/** Constructor of LogicalEval. */
29+
public LogicalEval(LogicalPlan child, List<Pair<ReferenceExpression, Expression>> expressions) {
3630
super(Collections.singletonList(child));
3731
this.expressions = expressions;
3832
}

0 commit comments

Comments
 (0)