http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/linq4j/src/main/java/org/apache/calcite/linq4j/tree/OptimizeShuttle.java ---------------------------------------------------------------------- diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/OptimizeShuttle.java b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/OptimizeShuttle.java index 676393b..53966e4 100644 --- a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/OptimizeShuttle.java +++ b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/OptimizeShuttle.java @@ -51,7 +51,7 @@ public class OptimizeShuttle extends Shuttle { static { for (Class aClass : new Class[]{Boolean.class, Byte.class, Short.class, - Integer.class, Long.class, String.class}) { + Integer.class, Long.class, String.class}) { for (Method method : aClass.getMethods()) { if ("valueOf".equals(method.getName()) && Modifier.isStatic(method.getModifiers())) { @@ -61,8 +61,7 @@ public class OptimizeShuttle extends Shuttle { } } - private static final - Map<ExpressionType, ExpressionType> NOT_BINARY_COMPLEMENT = + private static final Map<ExpressionType, ExpressionType> NOT_BINARY_COMPLEMENT = new EnumMap<>(ExpressionType.class); static { @@ -173,7 +172,7 @@ public class OptimizeShuttle extends Shuttle { if (eq(expression0, expression1)) { return binary.getNodeType() == Equal ? TRUE_EXPR : FALSE_EXPR; } else if (expression0 instanceof ConstantExpression && expression1 - instanceof ConstantExpression) { + instanceof ConstantExpression) { ConstantExpression c0 = (ConstantExpression) expression0; ConstantExpression c1 = (ConstantExpression) expression1; if (c0.getType() == c1.getType() @@ -201,7 +200,7 @@ public class OptimizeShuttle extends Shuttle { return expr.accept(this); } } - // drop down + // fall through case AndAlso: case OrElse: result = visit0(binary, expression0, expression1);
http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/linq4j/src/test/java/com/example/Linq4jExample.java ---------------------------------------------------------------------- diff --git a/linq4j/src/test/java/com/example/Linq4jExample.java b/linq4j/src/test/java/com/example/Linq4jExample.java index aa88f16..80413bf 100644 --- a/linq4j/src/test/java/com/example/Linq4jExample.java +++ b/linq4j/src/test/java/com/example/Linq4jExample.java @@ -46,10 +46,10 @@ public class Linq4jExample { } public static final Employee[] EMPS = { - new Employee(100, "Fred", 10), - new Employee(110, "Bill", 30), - new Employee(120, "Eric", 10), - new Employee(130, "Janet", 10), + new Employee(100, "Fred", 10), + new Employee(110, "Bill", 30), + new Employee(120, "Eric", 10), + new Employee(130, "Janet", 10), }; public static final Function1<Employee, Integer> EMP_DEPTNO_SELECTOR = http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/linq4j/src/test/java/org/apache/calcite/linq4j/test/CorrelateJoinTest.java ---------------------------------------------------------------------- diff --git a/linq4j/src/test/java/org/apache/calcite/linq4j/test/CorrelateJoinTest.java b/linq4j/src/test/java/org/apache/calcite/linq4j/test/CorrelateJoinTest.java index 6c49453..10e4663 100644 --- a/linq4j/src/test/java/org/apache/calcite/linq4j/test/CorrelateJoinTest.java +++ b/linq4j/src/test/java/org/apache/calcite/linq4j/test/CorrelateJoinTest.java @@ -45,38 +45,38 @@ public class CorrelateJoinTest { @Test public void testInner() { testJoin(CorrelateJoinType.INNER, new Integer[][]{ - {2, 20}, - {3, -30}, - {3, -60}, - {20, 200}, - {30, -300}, - {30, -600}}); + {2, 20}, + {3, -30}, + {3, -60}, + {20, 200}, + {30, -300}, + {30, -600}}); } @Test public void testLeft() { testJoin(CorrelateJoinType.LEFT, new Integer[][]{ - {1, null}, - {2, 20}, - {3, -30}, - {3, -60}, - {10, null}, - {20, 200}, - {30, -300}, - {30, -600}}); + {1, null}, + {2, 20}, + {3, -30}, + {3, -60}, + {10, null}, + {20, 200}, + {30, -300}, + {30, -600}}); } @Test public void testSemi() { testJoin(CorrelateJoinType.SEMI, new Integer[][]{ - {2, null}, - {3, null}, - {20, null}, - {30, null}}); + {2, null}, + {3, null}, + {20, null}, + {30, null}}); } @Test public void testAnti() { testJoin(CorrelateJoinType.ANTI, new Integer[][]{ - {1, null}, - {10, null}}); + {1, null}, + {10, null}}); } public void testJoin(CorrelateJoinType joinType, Integer[][] expected) { http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/linq4j/src/test/java/org/apache/calcite/linq4j/test/DeterministicTest.java ---------------------------------------------------------------------- diff --git a/linq4j/src/test/java/org/apache/calcite/linq4j/test/DeterministicTest.java b/linq4j/src/test/java/org/apache/calcite/linq4j/test/DeterministicTest.java index 540dce5..9194613 100644 --- a/linq4j/src/test/java/org/apache/calcite/linq4j/test/DeterministicTest.java +++ b/linq4j/src/test/java/org/apache/calcite/linq4j/test/DeterministicTest.java @@ -80,7 +80,7 @@ public class DeterministicTest { private boolean isAtomic(Expression e) { /** Subclass to make a protected method public. */ class MyDeterministicCodeOptimizer extends DeterministicCodeOptimizer { - public MyDeterministicCodeOptimizer() { + MyDeterministicCodeOptimizer() { super(ClassDeclarationFinder.create()); } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/linq4j/src/test/java/org/apache/calcite/linq4j/test/ExpressionTest.java ---------------------------------------------------------------------- diff --git a/linq4j/src/test/java/org/apache/calcite/linq4j/test/ExpressionTest.java b/linq4j/src/test/java/org/apache/calcite/linq4j/test/ExpressionTest.java index f888814..a8c1053 100644 --- a/linq4j/src/test/java/org/apache/calcite/linq4j/test/ExpressionTest.java +++ b/linq4j/src/test/java/org/apache/calcite/linq4j/test/ExpressionTest.java @@ -986,14 +986,14 @@ public class ExpressionTest { @Test public void testConstantExpression() { final Expression constant = Expressions.constant( new Object[] { - 1, - new Object[] { - (byte) 1, (short) 2, (int) 3, (long) 4, - (float) 5, (double) 6, (char) 7, true, "string", null - }, - new AllType(true, (byte) 100, (char) 101, (short) 102, 103, - (long) 104, (float) 105, (double) 106, new BigDecimal(107), - new BigInteger("108"), "109", null) + 1, + new Object[] { + (byte) 1, (short) 2, (int) 3, (long) 4, + (float) 5, (double) 6, (char) 7, true, "string", null + }, + new AllType(true, (byte) 100, (char) 101, (short) 102, 103, + (long) 104, (float) 105, (double) 106, new BigDecimal(107), + new BigInteger("108"), "109", null) }); assertEquals( "new Object[] {\n" http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/linq4j/src/test/java/org/apache/calcite/linq4j/test/Linq4jSuite.java ---------------------------------------------------------------------- diff --git a/linq4j/src/test/java/org/apache/calcite/linq4j/test/Linq4jSuite.java b/linq4j/src/test/java/org/apache/calcite/linq4j/test/Linq4jSuite.java index b1dd7a3..17d8b46 100644 --- a/linq4j/src/test/java/org/apache/calcite/linq4j/test/Linq4jSuite.java +++ b/linq4j/src/test/java/org/apache/calcite/linq4j/test/Linq4jSuite.java @@ -38,7 +38,7 @@ import org.junit.runners.Suite; FunctionTest.class, TypeTest.class, CorrelateJoinTest.class -}) + }) public class Linq4jSuite { } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/linq4j/src/test/java/org/apache/calcite/linq4j/test/Linq4jTest.java ---------------------------------------------------------------------- diff --git a/linq4j/src/test/java/org/apache/calcite/linq4j/test/Linq4jTest.java b/linq4j/src/test/java/org/apache/calcite/linq4j/test/Linq4jTest.java index e55a025..fb24043 100644 --- a/linq4j/src/test/java/org/apache/calcite/linq4j/test/Linq4jTest.java +++ b/linq4j/src/test/java/org/apache/calcite/linq4j/test/Linq4jTest.java @@ -98,8 +98,7 @@ public class Linq4jTest { } }; - public static final Function1<Department, Enumerable<Employee>> - DEPT_EMPLOYEES_SELECTOR = + public static final Function1<Department, Enumerable<Employee>> DEPT_EMPLOYEES_SELECTOR = new Function1<Department, Enumerable<Employee>>() { public Enumerable<Employee> apply(Department a0) { return Linq4j.asEnumerable(a0.employees); @@ -803,8 +802,7 @@ public class Linq4jTest { buf.toString()); } - private static <K extends Comparable, V> Function1<Grouping<K, V>, K> - groupingKeyExtractor() { + private static <K extends Comparable, V> Function1<Grouping<K, V>, K> groupingKeyExtractor() { return new Function1<Grouping<K, V>, K>() { public K apply(Grouping<K, V> a0) { return a0.getKey(); @@ -1011,8 +1009,8 @@ public class Linq4jTest { @Test public void testIntersect() { final Employee[] emps2 = { - new Employee(150, "Theodore", 10), - emps[3], + new Employee(150, "Theodore", 10), + emps[3], }; assertEquals( 1, @@ -1023,8 +1021,8 @@ public class Linq4jTest { @Test public void testExcept() { final Employee[] emps2 = { - new Employee(150, "Theodore", 10), - emps[3], + new Employee(150, "Theodore", 10), + emps[3], }; assertEquals( 3, @@ -1035,10 +1033,10 @@ public class Linq4jTest { @Test public void testDistinct() { final Employee[] emps2 = { - new Employee(150, "Theodore", 10), - emps[3], - emps[0], - emps[3], + new Employee(150, "Theodore", 10), + emps[3], + emps[0], + emps[3], }; assertEquals( 3, @@ -1049,10 +1047,10 @@ public class Linq4jTest { @Test public void testDistinctWithEqualityComparer() { final Employee[] emps2 = { - new Employee(150, "Theodore", 10), - emps[3], - emps[1], - emps[3], + new Employee(150, "Theodore", 10), + emps[3], + emps[1], + emps[3], }; assertEquals( 2, @@ -2357,11 +2355,11 @@ public class Linq4jTest { final Enumerable<String> e2 = Linq4j.asEnumerable(Arrays.asList("1", "2", "3")); final Enumerable<String> zipped = e1.zip(e2, - new Function2<String, String, String>() { - public String apply(String v0, String v1) { - return v0 + v1; - } - }); + new Function2<String, String, String>() { + public String apply(String v0, String v1) { + return v0 + v1; + } + }); assertEquals(3, zipped.count()); zipped.enumerator().reset(); for (int i = 0; i < 3; i++) { @@ -2518,22 +2516,22 @@ public class Linq4jTest { // Cedric works in a non-existent department. //CHECKSTYLE: IGNORE 1 public static final Employee[] badEmps = { - new Employee(140, "Cedric", 40), + new Employee(140, "Cedric", 40), }; //CHECKSTYLE: IGNORE 1 public static final Employee[] emps = { - new Employee(100, "Fred", 10), - new Employee(110, "Bill", 30), - new Employee(120, "Eric", 10), - new Employee(130, "Janet", 10), + new Employee(100, "Fred", 10), + new Employee(110, "Bill", 30), + new Employee(120, "Eric", 10), + new Employee(130, "Janet", 10), }; //CHECKSTYLE: IGNORE 1 public static final Department[] depts = { - new Department("Sales", 10, Arrays.asList(emps[0], emps[2], emps[3])), - new Department("HR", 20, Collections.<Employee>emptyList()), - new Department("Marketing", 30, ImmutableList.of(emps[1])), + new Department("Sales", 10, Arrays.asList(emps[0], emps[2], emps[3])), + new Department("HR", 20, Collections.<Employee>emptyList()), + new Department("Marketing", 30, ImmutableList.of(emps[1])), }; } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoEnumerator.java ---------------------------------------------------------------------- diff --git a/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoEnumerator.java b/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoEnumerator.java index 0821f32..1294c58 100644 --- a/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoEnumerator.java +++ b/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoEnumerator.java @@ -40,7 +40,7 @@ class MongoEnumerator implements Enumerator<Object> { * @param cursor Mongo iterator (usually a {@link com.mongodb.DBCursor}) * @param getter Converts an object into a list of fields */ - public MongoEnumerator(Iterator<DBObject> cursor, + MongoEnumerator(Iterator<DBObject> cursor, Function1<DBObject, Object> getter) { this.cursor = cursor; this.getter = getter; http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java ---------------------------------------------------------------------- diff --git a/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java b/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java index d60c476..7e00821 100644 --- a/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java +++ b/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java @@ -65,10 +65,10 @@ public class MongoRules { protected static final Logger LOGGER = CalciteTrace.getPlannerTracer(); public static final RelOptRule[] RULES = { - MongoSortRule.INSTANCE, - MongoFilterRule.INSTANCE, - MongoProjectRule.INSTANCE, - MongoAggregateRule.INSTANCE, + MongoSortRule.INSTANCE, + MongoFilterRule.INSTANCE, + MongoProjectRule.INSTANCE, + MongoAggregateRule.INSTANCE, }; /** Returns 'string' if it is a call to item['string'], null otherwise. */ @@ -248,11 +248,9 @@ public class MongoRules { * MongoDB calling convention. */ abstract static class MongoConverterRule extends ConverterRule { protected final Convention out; - public MongoConverterRule( - Class<? extends RelNode> clazz, - RelTrait in, - Convention out, - String description) { + + MongoConverterRule(Class<? extends RelNode> clazz, RelTrait in, + Convention out, String description) { super(clazz, in, out, description); this.out = out; } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoTable.java ---------------------------------------------------------------------- diff --git a/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoTable.java b/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoTable.java index a2b9d58..9cd05c8 100644 --- a/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoTable.java +++ b/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoTable.java @@ -218,7 +218,9 @@ public class MongoTable extends AbstractQueryableTable } /** Implementation of {@link org.apache.calcite.linq4j.Queryable} based on - * a {@link org.apache.calcite.adapter.mongodb.MongoTable}. */ + * a {@link org.apache.calcite.adapter.mongodb.MongoTable}. + * + * @param <T> element type */ public static class MongoQueryable<T> extends AbstractTableQueryable<T> { MongoQueryable(QueryProvider queryProvider, SchemaPlus schema, MongoTable table, String tableName) { http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/pig/src/main/java/org/apache/calcite/adapter/pig/PigAggFunction.java ---------------------------------------------------------------------- diff --git a/pig/src/main/java/org/apache/calcite/adapter/pig/PigAggFunction.java b/pig/src/main/java/org/apache/calcite/adapter/pig/PigAggFunction.java index da88b4e..a01d85b 100644 --- a/pig/src/main/java/org/apache/calcite/adapter/pig/PigAggFunction.java +++ b/pig/src/main/java/org/apache/calcite/adapter/pig/PigAggFunction.java @@ -29,11 +29,11 @@ public enum PigAggFunction { private final SqlKind calciteFunc; private final boolean star; // as in COUNT(*) - private PigAggFunction(SqlKind calciteFunc) { + PigAggFunction(SqlKind calciteFunc) { this(calciteFunc, false); } - private PigAggFunction(SqlKind calciteFunc, boolean star) { + PigAggFunction(SqlKind calciteFunc, boolean star) { this.calciteFunc = calciteFunc; this.star = star; } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/pig/src/main/java/org/apache/calcite/adapter/pig/PigDataType.java ---------------------------------------------------------------------- diff --git a/pig/src/main/java/org/apache/calcite/adapter/pig/PigDataType.java b/pig/src/main/java/org/apache/calcite/adapter/pig/PigDataType.java index a552fb8..a50b3b4 100644 --- a/pig/src/main/java/org/apache/calcite/adapter/pig/PigDataType.java +++ b/pig/src/main/java/org/apache/calcite/adapter/pig/PigDataType.java @@ -32,7 +32,7 @@ public enum PigDataType { private byte pigType; // Pig defines types using bytes private SqlTypeName sqlType; - private PigDataType(byte pigType, SqlTypeName sqlType) { + PigDataType(byte pigType, SqlTypeName sqlType) { this.pigType = pigType; this.sqlType = sqlType; } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/pig/src/main/java/org/apache/calcite/adapter/pig/PigTableScan.java ---------------------------------------------------------------------- diff --git a/pig/src/main/java/org/apache/calcite/adapter/pig/PigTableScan.java b/pig/src/main/java/org/apache/calcite/adapter/pig/PigTableScan.java index 8d5f45e..95c3536 100644 --- a/pig/src/main/java/org/apache/calcite/adapter/pig/PigTableScan.java +++ b/pig/src/main/java/org/apache/calcite/adapter/pig/PigTableScan.java @@ -48,9 +48,9 @@ public class PigTableScan extends TableScan implements PigRel { final PigTable pigTable = getPigTable(implementor.getTableName(this)); final String alias = implementor.getPigRelationAlias(this); final String schema = '(' + getSchemaForPigStatement(implementor) - + ')'; + + ')'; final String statement = alias + " = LOAD '" + pigTable.getFilePath() - + "' USING PigStorage() AS " + schema + ';'; + + "' USING PigStorage() AS " + schema + ';'; implementor.addStatement(statement); } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/pig/src/main/java/org/apache/calcite/adapter/pig/PigToEnumerableConverterRule.java ---------------------------------------------------------------------- diff --git a/pig/src/main/java/org/apache/calcite/adapter/pig/PigToEnumerableConverterRule.java b/pig/src/main/java/org/apache/calcite/adapter/pig/PigToEnumerableConverterRule.java index e312186..ef610f2 100644 --- a/pig/src/main/java/org/apache/calcite/adapter/pig/PigToEnumerableConverterRule.java +++ b/pig/src/main/java/org/apache/calcite/adapter/pig/PigToEnumerableConverterRule.java @@ -27,7 +27,7 @@ import org.apache.calcite.rel.convert.ConverterRule; */ public class PigToEnumerableConverterRule extends ConverterRule { public static final ConverterRule INSTANCE = - new PigToEnumerableConverterRule(); + new PigToEnumerableConverterRule(); private PigToEnumerableConverterRule() { super(RelNode.class, PigRel.CONVENTION, EnumerableConvention.INSTANCE, http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/pig/src/test/java/org/apache/calcite/test/PigAdapterTest.java ---------------------------------------------------------------------- diff --git a/pig/src/test/java/org/apache/calcite/test/PigAdapterTest.java b/pig/src/test/java/org/apache/calcite/test/PigAdapterTest.java index e02c90a..77ebb18 100644 --- a/pig/src/test/java/org/apache/calcite/test/PigAdapterTest.java +++ b/pig/src/test/java/org/apache/calcite/test/PigAdapterTest.java @@ -34,8 +34,8 @@ public class PigAdapterTest extends AbstractPigTest { // Undo the %20 replacement of a space by URL public static final ImmutableMap<String, String> MODEL = - ImmutableMap.of("model", - decodeUrl(PigAdapterTest.class.getResource("/model.json").getPath())); + ImmutableMap.of("model", + decodeUrl(PigAdapterTest.class.getResource("/model.json").getPath())); /** URL-decodes the given string with UTF-8 encoding */ private static String decodeUrl(String urlEncoded) { @@ -46,139 +46,125 @@ public class PigAdapterTest extends AbstractPigTest { } } - @Test - public void testScanAndFilter() throws Exception { + @Test public void testScanAndFilter() throws Exception { CalciteAssert.that() - .with(MODEL) - .query("select * from \"t\" where \"tc0\" > 'abc'") - .explainContains( - "PigToEnumerableConverter\n" - + " PigFilter(condition=[>($0, 'abc')])\n" - + " PigTableScan(table=[[PIG, t]])") - .runs() - .queryContains( - pigScriptChecker( - "t = LOAD '" + getFullPathForTestDataFile("data.txt") - + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" - + "t = FILTER t BY (tc0 > 'abc');")); + .with(MODEL) + .query("select * from \"t\" where \"tc0\" > 'abc'") + .explainContains("PigToEnumerableConverter\n" + + " PigFilter(condition=[>($0, 'abc')])\n" + + " PigTableScan(table=[[PIG, t]])") + .runs() + .queryContains( + pigScriptChecker("t = LOAD '" + + getFullPathForTestDataFile("data.txt") + + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" + + "t = FILTER t BY (tc0 > 'abc');")); } - @Test - public void testImplWithMultipleFilters() { + @Test public void testImplWithMultipleFilters() { CalciteAssert.that() - .with(MODEL) - .query("select * from \"t\" where \"tc0\" > 'abc' and \"tc1\" = '3'") - .explainContains( - "PigToEnumerableConverter\n" + .with(MODEL) + .query("select * from \"t\" where \"tc0\" > 'abc' and \"tc1\" = '3'") + .explainContains("PigToEnumerableConverter\n" + " PigFilter(condition=[AND(>($0, 'abc'), =($1, '3'))])\n" + " PigTableScan(table=[[PIG, t]])") - .runs() - .queryContains( - pigScriptChecker( - "t = LOAD '" + getFullPathForTestDataFile("data.txt") - + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" - + "t = FILTER t BY (tc0 > 'abc') AND (tc1 == '3');")); + .runs() + .queryContains( + pigScriptChecker("t = LOAD '" + + getFullPathForTestDataFile("data.txt") + + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" + + "t = FILTER t BY (tc0 > 'abc') AND (tc1 == '3');")); } - @Test - public void testImplWithGroupByAndCount() { + @Test public void testImplWithGroupByAndCount() { CalciteAssert.that() - .with(MODEL) - .query("select count(\"tc1\") c from \"t\" group by \"tc0\"") - .explainContains( - "PigToEnumerableConverter\n" - + " PigAggregate(group=[{0}], C=[COUNT($1)])\n" - + " PigTableScan(table=[[PIG, t]])") - .runs() - .queryContains( - pigScriptChecker( - "t = LOAD '" + getFullPathForTestDataFile("data.txt") - + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" - + "t = GROUP t BY (tc0);\n" - + "t = FOREACH t {\n" - + " GENERATE group AS tc0, COUNT(t.tc1) AS C;\n" - + "};")); + .with(MODEL) + .query("select count(\"tc1\") c from \"t\" group by \"tc0\"") + .explainContains("PigToEnumerableConverter\n" + + " PigAggregate(group=[{0}], C=[COUNT($1)])\n" + + " PigTableScan(table=[[PIG, t]])") + .runs() + .queryContains( + pigScriptChecker("t = LOAD '" + + getFullPathForTestDataFile("data.txt") + + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" + + "t = GROUP t BY (tc0);\n" + + "t = FOREACH t {\n" + + " GENERATE group AS tc0, COUNT(t.tc1) AS C;\n" + + "};")); } - @Test - public void testImplWithCountWithoutGroupBy() { + @Test public void testImplWithCountWithoutGroupBy() { CalciteAssert.that() - .with(MODEL) - .query("select count(\"tc0\") c from \"t\"") - .explainContains( - "PigToEnumerableConverter\n" - + " PigAggregate(group=[{}], C=[COUNT($0)])\n" - + " PigTableScan(table=[[PIG, t]])") - .runs() - .queryContains( - pigScriptChecker( - "t = LOAD '" + getFullPathForTestDataFile("data.txt") - + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" - + "t = GROUP t ALL;\n" - + "t = FOREACH t {\n" - + " GENERATE COUNT(t.tc0) AS C;\n" - + "};")); + .with(MODEL) + .query("select count(\"tc0\") c from \"t\"") + .explainContains("PigToEnumerableConverter\n" + + " PigAggregate(group=[{}], C=[COUNT($0)])\n" + + " PigTableScan(table=[[PIG, t]])") + .runs() + .queryContains( + pigScriptChecker("t = LOAD '" + + getFullPathForTestDataFile("data.txt") + + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" + + "t = GROUP t ALL;\n" + + "t = FOREACH t {\n" + + " GENERATE COUNT(t.tc0) AS C;\n" + + "};")); } - @Test - public void testImplWithGroupByMultipleFields() { + @Test public void testImplWithGroupByMultipleFields() { CalciteAssert.that() - .with(MODEL) - .query("select * from \"t\" group by \"tc1\", \"tc0\"") - .explainContains( - "PigToEnumerableConverter\n" - + " PigAggregate(group=[{0, 1}])\n" - + " PigTableScan(table=[[PIG, t]])") - .runs() - .queryContains( - pigScriptChecker( - "t = LOAD '" + getFullPathForTestDataFile("data.txt") - + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" - + "t = GROUP t BY (tc0, tc1);\n" - + "t = FOREACH t {\n" - + " GENERATE group.tc0 AS tc0, group.tc1 AS tc1;\n" - + "};")); + .with(MODEL) + .query("select * from \"t\" group by \"tc1\", \"tc0\"") + .explainContains("PigToEnumerableConverter\n" + + " PigAggregate(group=[{0, 1}])\n" + + " PigTableScan(table=[[PIG, t]])") + .runs() + .queryContains( + pigScriptChecker("t = LOAD '" + + getFullPathForTestDataFile("data.txt") + + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" + + "t = GROUP t BY (tc0, tc1);\n" + + "t = FOREACH t {\n" + + " GENERATE group.tc0 AS tc0, group.tc1 AS tc1;\n" + + "};")); } - @Test - public void testImplWithGroupByCountDistinct() { + @Test public void testImplWithGroupByCountDistinct() { CalciteAssert.that() - .with(MODEL) - .query("select count(distinct \"tc0\") c from \"t\" group by \"tc1\"") - .explainContains( - "PigToEnumerableConverter\n" + .with(MODEL) + .query("select count(distinct \"tc0\") c from \"t\" group by \"tc1\"") + .explainContains("PigToEnumerableConverter\n" + " PigAggregate(group=[{1}], C=[COUNT(DISTINCT $0)])\n" + " PigTableScan(table=[[PIG, t]])") - .runs() - .queryContains( - pigScriptChecker( - "t = LOAD '" + getFullPathForTestDataFile("data.txt") - + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" - + "t = GROUP t BY (tc1);\n" - + "t = FOREACH t {\n" - + " tc0_DISTINCT = DISTINCT t.tc0;\n" - + " GENERATE group AS tc1, COUNT(tc0_DISTINCT) AS C;\n" - + "};")); + .runs() + .queryContains( + pigScriptChecker("t = LOAD '" + + getFullPathForTestDataFile("data.txt") + + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" + + "t = GROUP t BY (tc1);\n" + + "t = FOREACH t {\n" + + " tc0_DISTINCT = DISTINCT t.tc0;\n" + + " GENERATE group AS tc1, COUNT(tc0_DISTINCT) AS C;\n" + + "};")); } - @Test - public void testImplWithJoin() throws Exception { + @Test public void testImplWithJoin() throws Exception { CalciteAssert.that() - .with(MODEL) - .query("select * from \"t\" join \"s\" on \"tc1\"=\"sc0\"") - .explainContains( - "PigToEnumerableConverter\n" - + " PigJoin(condition=[=($1, $2)], joinType=[inner])\n" - + " PigTableScan(table=[[PIG, t]])\n" - + " PigTableScan(table=[[PIG, s]])") - .runs() - .queryContains( - pigScriptChecker( - "t = LOAD '" + getFullPathForTestDataFile("data.txt") - + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" - + "s = LOAD '" + getFullPathForTestDataFile("data2.txt") - + "' USING PigStorage() AS (sc0:chararray, sc1:chararray);\n" - + "t = JOIN t BY tc1 , s BY sc0;")); + .with(MODEL) + .query("select * from \"t\" join \"s\" on \"tc1\"=\"sc0\"") + .explainContains("PigToEnumerableConverter\n" + + " PigJoin(condition=[=($1, $2)], joinType=[inner])\n" + + " PigTableScan(table=[[PIG, t]])\n" + + " PigTableScan(table=[[PIG, s]])") + .runs() + .queryContains( + pigScriptChecker("t = LOAD '" + + getFullPathForTestDataFile("data.txt") + + "' USING PigStorage() AS (tc0:chararray, tc1:chararray);\n" + + "s = LOAD '" + getFullPathForTestDataFile("data2.txt") + + "' USING PigStorage() AS (sc0:chararray, sc1:chararray);\n" + + "t = JOIN t BY tc1 , s BY sc0;")); } /** Returns a function that checks that a particular Pig Latin scriptis http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/piglet/src/main/java/org/apache/calcite/piglet/Handler.java ---------------------------------------------------------------------- diff --git a/piglet/src/main/java/org/apache/calcite/piglet/Handler.java b/piglet/src/main/java/org/apache/calcite/piglet/Handler.java index 5b5be39..0a26e29 100644 --- a/piglet/src/main/java/org/apache/calcite/piglet/Handler.java +++ b/piglet/src/main/java/org/apache/calcite/piglet/Handler.java @@ -178,8 +178,8 @@ public class Handler { protected void dump(RelNode rel) { } - private ImmutableList<ImmutableList<RexLiteral>> - tuples(Ast.ValuesStmt valuesStmt, RelDataType rowType) { + private ImmutableList<ImmutableList<RexLiteral>> tuples( + Ast.ValuesStmt valuesStmt, RelDataType rowType) { final ImmutableList.Builder<ImmutableList<RexLiteral>> listBuilder = ImmutableList.builder(); for (List<Ast.Node> nodeList : valuesStmt.tupleList) { http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/piglet/src/test/java/org/apache/calcite/test/CalciteHandler.java ---------------------------------------------------------------------- diff --git a/piglet/src/test/java/org/apache/calcite/test/CalciteHandler.java b/piglet/src/test/java/org/apache/calcite/test/CalciteHandler.java index 66cb671..559490a 100644 --- a/piglet/src/test/java/org/apache/calcite/test/CalciteHandler.java +++ b/piglet/src/test/java/org/apache/calcite/test/CalciteHandler.java @@ -36,7 +36,7 @@ import java.sql.Types; class CalciteHandler extends Handler { private final PrintWriter writer; - public CalciteHandler(PigRelBuilder builder, Writer writer) { + CalciteHandler(PigRelBuilder builder, Writer writer) { super(builder); this.writer = new PrintWriter(writer); } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/piglet/src/test/java/org/apache/calcite/test/Fluent.java ---------------------------------------------------------------------- diff --git a/piglet/src/test/java/org/apache/calcite/test/Fluent.java b/piglet/src/test/java/org/apache/calcite/test/Fluent.java index cefdab8..7afd781 100644 --- a/piglet/src/test/java/org/apache/calcite/test/Fluent.java +++ b/piglet/src/test/java/org/apache/calcite/test/Fluent.java @@ -40,7 +40,7 @@ import static org.junit.Assert.assertThat; class Fluent { private final String pig; - public Fluent(String pig) { + Fluent(String pig) { this.pig = pig; } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/plus/src/main/java/org/apache/calcite/adapter/os/FilesTableFunction.java ---------------------------------------------------------------------- diff --git a/plus/src/main/java/org/apache/calcite/adapter/os/FilesTableFunction.java b/plus/src/main/java/org/apache/calcite/adapter/os/FilesTableFunction.java index d54cfb2..7abec05 100644 --- a/plus/src/main/java/org/apache/calcite/adapter/os/FilesTableFunction.java +++ b/plus/src/main/java/org/apache/calcite/adapter/os/FilesTableFunction.java @@ -89,28 +89,28 @@ public class FilesTableFunction { private Enumerable<String> sourceLinux() { final String[] args = { - "find", path, "-printf", "" - + "%A@\\0" // access_time - + "%b\\0" // block_count - + "%C@\\0" // change_time - + "%d\\0" // depth - + "%D\\0" // device - + "%f\\0" // file_name - + "%F\\0" // fstype - + "%g\\0" // gname - + "%G\\0" // gid - + "%h\\0" // dir_name - + "%i\\0" // inode - + "%l\\0" // link - + "%#m\\0" // perm - + "%n\\0" // hard - + "%P\\0" // path - + "%s\\0" // size - + "%S\\0" // sparseness - + "%T@\\0" // mod_time - + "%u\\0" // user - + "%U\\0" // uid - + "%Y\\0" // type + "find", path, "-printf", "" + + "%A@\\0" // access_time + + "%b\\0" // block_count + + "%C@\\0" // change_time + + "%d\\0" // depth + + "%D\\0" // device + + "%f\\0" // file_name + + "%F\\0" // fstype + + "%g\\0" // gname + + "%G\\0" // gid + + "%h\\0" // dir_name + + "%i\\0" // inode + + "%l\\0" // link + + "%#m\\0" // perm + + "%n\\0" // hard + + "%P\\0" // path + + "%s\\0" // size + + "%S\\0" // sparseness + + "%T@\\0" // mod_time + + "%u\\0" // user + + "%U\\0" // uid + + "%Y\\0" // type }; return Processes.processLines('\0', args); } @@ -121,28 +121,28 @@ public class FilesTableFunction { throw new IllegalArgumentException(); } final String[] args = {"/bin/sh", "-c", "find '" + path - + "' | xargs stat -f " - + "%a%n" // access_time - + "%b%n" // block_count - + "%c%n" // change_time - + "0%n" // depth: not supported by macOS stat - + "%Hd%n" // device: we only use the high part of "H,L" device - + "filename%n" // filename: not supported by macOS stat - + "fstype%n" // fstype: not supported by macOS stat - + "%Sg%n" // gname - + "%g%n" // gid - + "dir_name%n" // dir_name: not supported by macOS stat - + "%i%n" // inode - + "%Y%n" // link - + "%Lp%n" // perm - + "%l%n" // hard - + "%SN%n" // path - + "%z%n" // size - + "0%n" // sparseness: not supported by macOS stat - + "%m%n" // mod_time - + "%Su%n" // user - + "%u%n" // uid - + "%LT%n" // type + + "' | xargs stat -f " + + "%a%n" // access_time + + "%b%n" // block_count + + "%c%n" // change_time + + "0%n" // depth: not supported by macOS stat + + "%Hd%n" // device: we only use the high part of "H,L" device + + "filename%n" // filename: not supported by macOS stat + + "fstype%n" // fstype: not supported by macOS stat + + "%Sg%n" // gname + + "%g%n" // gid + + "dir_name%n" // dir_name: not supported by macOS stat + + "%i%n" // inode + + "%Y%n" // link + + "%Lp%n" // perm + + "%l%n" // hard + + "%SN%n" // path + + "%z%n" // size + + "0%n" // sparseness: not supported by macOS stat + + "%m%n" // mod_time + + "%Su%n" // user + + "%u%n" // uid + + "%LT%n" // type }; return Processes.processLines('\n', args); } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/plus/src/main/java/org/apache/calcite/adapter/os/Processes.java ---------------------------------------------------------------------- diff --git a/plus/src/main/java/org/apache/calcite/adapter/os/Processes.java b/plus/src/main/java/org/apache/calcite/adapter/os/Processes.java index 19766a8..6742195 100644 --- a/plus/src/main/java/org/apache/calcite/adapter/os/Processes.java +++ b/plus/src/main/java/org/apache/calcite/adapter/os/Processes.java @@ -184,7 +184,7 @@ public class Processes { private static class ProcessFactory implements Supplier<Process> { private final String[] args; - public ProcessFactory(String... args) { + ProcessFactory(String... args) { this.args = args; } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/plus/src/main/java/org/apache/calcite/adapter/os/PsTableFunction.java ---------------------------------------------------------------------- diff --git a/plus/src/main/java/org/apache/calcite/adapter/os/PsTableFunction.java b/plus/src/main/java/org/apache/calcite/adapter/os/PsTableFunction.java index 62a4f04..9af23ef 100644 --- a/plus/src/main/java/org/apache/calcite/adapter/os/PsTableFunction.java +++ b/plus/src/main/java/org/apache/calcite/adapter/os/PsTableFunction.java @@ -63,14 +63,16 @@ public class PsTableFunction { Util.discard(osVersion); switch (osName) { case "Mac OS X": // tested on version 10.12.5 - args = new String[]{"ps", "ax", "-o", "ppid=,pid=,pgid=,tpgid=,stat=," - + "user=,pcpu=,pmem=,vsz=,rss=,tty=,start=,time=,uid=,ruid=," - + "sess=,comm="}; + args = new String[] { + "ps", "ax", "-o", "ppid=,pid=,pgid=,tpgid=,stat=," + + "user=,pcpu=,pmem=,vsz=,rss=,tty=,start=,time=,uid=,ruid=," + + "sess=,comm="}; break; default: - args = new String[]{"ps", "--no-headers", "axo", "ppid,pid,pgrp," - + "tpgid,stat,user,pcpu,pmem,vsz,rss,tty,start_time,time,euid," - + "ruid,sess,comm"}; + args = new String[] { + "ps", "--no-headers", "axo", "ppid,pid,pgrp," + + "tpgid,stat,user,pcpu,pmem,vsz,rss,tty,start_time,time,euid," + + "ruid,sess,comm"}; } return Processes.processLines(args) .select( http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/plus/src/main/java/org/apache/calcite/adapter/os/VmstatTableFunction.java ---------------------------------------------------------------------- diff --git a/plus/src/main/java/org/apache/calcite/adapter/os/VmstatTableFunction.java b/plus/src/main/java/org/apache/calcite/adapter/os/VmstatTableFunction.java index 65b48b6..d014b5f 100644 --- a/plus/src/main/java/org/apache/calcite/adapter/os/VmstatTableFunction.java +++ b/plus/src/main/java/org/apache/calcite/adapter/os/VmstatTableFunction.java @@ -58,9 +58,10 @@ public class VmstatTableFunction { // Could do this here too.. switch (osName) { case "Mac OS X": // tested on version 10.11.6 - args = new String[]{ - "/bin/sh", "-c", - "vm_stat | tail -n +2 | awk '{print $NF}' | sed 's/\\.//' | tr '\\n' ' '"}; + args = new String[] { + "/bin/sh", "-c", + "vm_stat | tail -n +2 | awk '{print $NF}' | sed 's/\\.//' | tr '\\n' ' '" + }; break; default: args = new String[]{"/bin/sh", "-c", "vmstat -n | tail -n +3"}; http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/plus/src/main/java/org/apache/calcite/adapter/tpcds/TpcdsSchema.java ---------------------------------------------------------------------- diff --git a/plus/src/main/java/org/apache/calcite/adapter/tpcds/TpcdsSchema.java b/plus/src/main/java/org/apache/calcite/adapter/tpcds/TpcdsSchema.java index 3822380..e18ba84 100644 --- a/plus/src/main/java/org/apache/calcite/adapter/tpcds/TpcdsSchema.java +++ b/plus/src/main/java/org/apache/calcite/adapter/tpcds/TpcdsSchema.java @@ -99,7 +99,9 @@ public class TpcdsSchema extends AbstractSchema { return tableMap; } - /** Definition of a table in the TPC-DS schema. */ + /** Definition of a table in the TPC-DS schema. + * + * @param <E> entity type */ private class TpcdsQueryableTable<E extends TpcdsEntity> extends AbstractQueryableTable { private final TpcdsTable<E> tpcdsTable; http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/plus/src/main/java/org/apache/calcite/adapter/tpch/TpchSchema.java ---------------------------------------------------------------------- diff --git a/plus/src/main/java/org/apache/calcite/adapter/tpch/TpchSchema.java b/plus/src/main/java/org/apache/calcite/adapter/tpch/TpchSchema.java index d0f822d..a942dc3 100644 --- a/plus/src/main/java/org/apache/calcite/adapter/tpch/TpchSchema.java +++ b/plus/src/main/java/org/apache/calcite/adapter/tpch/TpchSchema.java @@ -79,7 +79,9 @@ public class TpchSchema extends AbstractSchema { return tableMap; } - /** Definition of a table in the TPC-H schema. */ + /** Definition of a table in the TPC-H schema. + * + * @param <E> entity type */ private class TpchQueryableTable<E extends TpchEntity> extends AbstractQueryableTable { private final TpchTable<E> tpchTable; http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/plus/src/test/java/org/apache/calcite/adapter/tpcds/TpcdsTest.java ---------------------------------------------------------------------- diff --git a/plus/src/test/java/org/apache/calcite/adapter/tpcds/TpcdsTest.java b/plus/src/test/java/org/apache/calcite/adapter/tpcds/TpcdsTest.java index 715e6f4..f100197 100644 --- a/plus/src/test/java/org/apache/calcite/adapter/tpcds/TpcdsTest.java +++ b/plus/src/test/java/org/apache/calcite/adapter/tpcds/TpcdsTest.java @@ -51,9 +51,8 @@ import java.util.Random; * command-line. * (See {@link org.apache.calcite.test.CalciteAssert#ENABLE_SLOW}.)</p> */ public class TpcdsTest { - private static - Function<Pair<List<Prepare.Materialization>, Holder<Program>>, Void> - handler(final boolean bushy, final int minJoinCount) { + private static Function<Pair<List<Prepare.Materialization>, Holder<Program>>, Void> handler( + final boolean bushy, final int minJoinCount) { return new Function<Pair<List<Prepare.Materialization>, Holder<Program>>, Void>() { public Void apply( http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/plus/src/test/java/org/apache/calcite/test/PlusSuite.java ---------------------------------------------------------------------- diff --git a/plus/src/test/java/org/apache/calcite/test/PlusSuite.java b/plus/src/test/java/org/apache/calcite/test/PlusSuite.java index 8b4fb25..3a2d0e4 100644 --- a/plus/src/test/java/org/apache/calcite/test/PlusSuite.java +++ b/plus/src/test/java/org/apache/calcite/test/PlusSuite.java @@ -31,7 +31,7 @@ import org.junit.runners.Suite; OsAdapterTest.class, TpcdsTest.class, TpchTest.class -}) + }) public class PlusSuite { } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 936908b..3372f99 100644 --- a/pom.xml +++ b/pom.xml @@ -93,7 +93,7 @@ limitations under the License. <jmh.version>1.12</jmh.version> <jsoup.version>1.10.2</jsoup.version> <junit.version>4.12</junit.version> - <maven-checkstyle-plugin.version>2.12.1</maven-checkstyle-plugin.version> + <maven-checkstyle-plugin.version>2.17</maven-checkstyle-plugin.version> <maven-dependency-plugin.version>2.10</maven-dependency-plugin.version> <!-- Apache 18 has 3.0.1, but need 3.0.2 for [MSOURCES-94]. --> <maven-jar-plugin.version>3.0.2</maven-jar-plugin.version> @@ -608,6 +608,12 @@ limitations under the License. <groupId>net.hydromatic</groupId> <artifactId>toolbox</artifactId> <version>${hydromatic-toolbox.version}</version> + <exclusions> + <exclusion> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </exclusion> + </exclusions> </dependency> </dependencies> </plugin> http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/spark/src/main/java/org/apache/calcite/adapter/spark/SparkRel.java ---------------------------------------------------------------------- diff --git a/spark/src/main/java/org/apache/calcite/adapter/spark/SparkRel.java b/spark/src/main/java/org/apache/calcite/adapter/spark/SparkRel.java index 1563eca..6a99ba4 100644 --- a/spark/src/main/java/org/apache/calcite/adapter/spark/SparkRel.java +++ b/spark/src/main/java/org/apache/calcite/adapter/spark/SparkRel.java @@ -34,7 +34,7 @@ public interface SparkRel extends RelNode { /** Extension to {@link JavaRelImplementor} that can handle Spark relational * expressions. */ - public abstract class Implementor extends JavaRelImplementor { + abstract class Implementor extends JavaRelImplementor { public Implementor(RexBuilder rexBuilder) { super(rexBuilder); } @@ -46,7 +46,7 @@ public interface SparkRel extends RelNode { /** Result of generating Java code to implement a Spark relational * expression. */ - public class Result { + class Result { public final BlockStatement block; public final PhysType physType; http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/spark/src/main/java/org/apache/calcite/adapter/spark/SparkRuntime.java ---------------------------------------------------------------------- diff --git a/spark/src/main/java/org/apache/calcite/adapter/spark/SparkRuntime.java b/spark/src/main/java/org/apache/calcite/adapter/spark/SparkRuntime.java index 00d9f8d..d164521 100644 --- a/spark/src/main/java/org/apache/calcite/adapter/spark/SparkRuntime.java +++ b/spark/src/main/java/org/apache/calcite/adapter/spark/SparkRuntime.java @@ -61,7 +61,10 @@ public abstract class SparkRuntime { } /** Combines linq4j {@link org.apache.calcite.linq4j.function.Function} - * and Spark {@link org.apache.spark.api.java.function.FlatMapFunction}. */ + * and Spark {@link org.apache.spark.api.java.function.FlatMapFunction}. + * + * @param <T> argument type + * @param <R> result type */ public abstract static class CalciteFlatMapFunction<T, R> implements FlatMapFunction<T, R>, org.apache.calcite.linq4j.function.Function { http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/spark/src/main/java/org/apache/calcite/adapter/spark/SparkToEnumerableConverter.java ---------------------------------------------------------------------- diff --git a/spark/src/main/java/org/apache/calcite/adapter/spark/SparkToEnumerableConverter.java b/spark/src/main/java/org/apache/calcite/adapter/spark/SparkToEnumerableConverter.java index b96dd5f..8d74df5 100644 --- a/spark/src/main/java/org/apache/calcite/adapter/spark/SparkToEnumerableConverter.java +++ b/spark/src/main/java/org/apache/calcite/adapter/spark/SparkToEnumerableConverter.java @@ -95,7 +95,7 @@ public class SparkToEnumerableConverter private static class SparkImplementorImpl extends SparkRel.Implementor { private final EnumerableRelImplementor implementor; - public SparkImplementorImpl(EnumerableRelImplementor implementor) { + SparkImplementorImpl(EnumerableRelImplementor implementor) { super(implementor.getRexBuilder()); this.implementor = implementor; } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkDriver.java ---------------------------------------------------------------------- diff --git a/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkDriver.java b/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkDriver.java index 928440c..a7c8712 100644 --- a/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkDriver.java +++ b/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkDriver.java @@ -106,7 +106,7 @@ public class SplunkDriver extends org.apache.calcite.jdbc.Driver { private static class WrappingSplunkConnection implements SplunkConnection { private final SplunkConnection connection; - public WrappingSplunkConnection(SplunkConnection connection) { + WrappingSplunkConnection(SplunkConnection connection) { this.connection = connection; } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkTable.java ---------------------------------------------------------------------- diff --git a/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkTable.java b/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkTable.java index b752ec2..60906c4 100644 --- a/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkTable.java +++ b/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkTable.java @@ -75,10 +75,12 @@ class SplunkTable extends AbstractQueryableTable implements TranslatableTable { /** Implementation of {@link Queryable} backed by a {@link SplunkTable}. * Generated code uses this get a Splunk connection for executing arbitrary - * Splunk queries. */ + * Splunk queries. + * + * @param <T> element type */ public static class SplunkTableQueryable<T> extends AbstractTableQueryable<T> { - public SplunkTableQueryable(QueryProvider queryProvider, SchemaPlus schema, + SplunkTableQueryable(QueryProvider queryProvider, SchemaPlus schema, SplunkTable table, String tableName) { super(queryProvider, schema, table, tableName); } http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/splunk/src/main/java/org/apache/calcite/adapter/splunk/search/SplunkConnectionImpl.java ---------------------------------------------------------------------- diff --git a/splunk/src/main/java/org/apache/calcite/adapter/splunk/search/SplunkConnectionImpl.java b/splunk/src/main/java/org/apache/calcite/adapter/splunk/search/SplunkConnectionImpl.java index 8f08e23..9bf0e11 100644 --- a/splunk/src/main/java/org/apache/calcite/adapter/splunk/search/SplunkConnectionImpl.java +++ b/splunk/src/main/java/org/apache/calcite/adapter/splunk/search/SplunkConnectionImpl.java @@ -219,20 +219,20 @@ public class SplunkConnectionImpl implements SplunkConnection { public static void printUsage(String errorMsg) { String[] strings = { - "Usage: java Connection -<arg-name> <arg-value>", - "The following <arg-name> are valid", - "search - required, search string to execute", - "field_list - " - + "required, list of fields to request, comma delimited", - "uri - " - + "uri to splunk's mgmt port, default: https://localhost:8089", - "username - " - + "username to use for authentication, default: admin", - "password - " - + "password to use for authentication, default: changeme", - "earliest_time - earliest time for the search, default: -24h", - "latest_time - latest time for the search, default: now", - "-print - whether to print results or just the summary" + "Usage: java Connection -<arg-name> <arg-value>", + "The following <arg-name> are valid", + "search - required, search string to execute", + "field_list - " + + "required, list of fields to request, comma delimited", + "uri - " + + "uri to splunk's mgmt port, default: https://localhost:8089", + "username - " + + "username to use for authentication, default: admin", + "password - " + + "password to use for authentication, default: changeme", + "earliest_time - earliest time for the search, default: -24h", + "latest_time - latest time for the search, default: now", + "-print - whether to print results or just the summary" }; System.err.println(errorMsg); for (String s : strings) { http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/splunk/src/test/java/org/apache/calcite/test/SplunkAdapterTest.java ---------------------------------------------------------------------- diff --git a/splunk/src/test/java/org/apache/calcite/test/SplunkAdapterTest.java b/splunk/src/test/java/org/apache/calcite/test/SplunkAdapterTest.java index f67821d..bf30881 100644 --- a/splunk/src/test/java/org/apache/calcite/test/SplunkAdapterTest.java +++ b/splunk/src/test/java/org/apache/calcite/test/SplunkAdapterTest.java @@ -117,70 +117,70 @@ public class SplunkAdapterTest { } static final String[] SQL_STRINGS = { - "select \"source\", \"sourcetype\"\n" - + "from \"splunk\".\"splunk\"", - - "select \"sourcetype\"\n" - + "from \"splunk\".\"splunk\"", - - "select distinct \"sourcetype\"\n" - + "from \"splunk\".\"splunk\"", - - "select count(\"sourcetype\")\n" - + "from \"splunk\".\"splunk\"", - - // gives wrong answer, not error. currently returns same as count. - "select count(distinct \"sourcetype\")\n" - + "from \"splunk\".\"splunk\"", - - "select \"sourcetype\", count(\"source\")\n" - + "from \"splunk\".\"splunk\"\n" - + "group by \"sourcetype\"", - - "select \"sourcetype\", count(\"source\") as c\n" - + "from \"splunk\".\"splunk\"\n" - + "group by \"sourcetype\"\n" - + "order by c desc\n", - - // group + order - "select s.\"product_id\", count(\"source\") as c\n" - + "from \"splunk\".\"splunk\" as s\n" - + "where s.\"sourcetype\" = 'access_combined_wcookie'\n" - + "group by s.\"product_id\"\n" - + "order by c desc\n", - - // non-advertised field - "select s.\"sourcetype\", s.\"action\" from \"splunk\".\"splunk\" as s", - - "select s.\"source\", s.\"product_id\", s.\"product_name\", s.\"method\"\n" - + "from \"splunk\".\"splunk\" as s\n" - + "where s.\"sourcetype\" = 'access_combined_wcookie'\n", - - "select p.\"product_name\", s.\"action\"\n" - + "from \"splunk\".\"splunk\" as s\n" - + " join \"mysql\".\"products\" as p\n" - + "on s.\"product_id\" = p.\"product_id\"", - - "select s.\"source\", s.\"product_id\", p.\"product_name\", p.\"price\"\n" - + "from \"splunk\".\"splunk\" as s\n" - + " join \"mysql\".\"products\" as p\n" - + " on s.\"product_id\" = p.\"product_id\"\n" - + "where s.\"sourcetype\" = 'access_combined_wcookie'\n", + "select \"source\", \"sourcetype\"\n" + + "from \"splunk\".\"splunk\"", + + "select \"sourcetype\"\n" + + "from \"splunk\".\"splunk\"", + + "select distinct \"sourcetype\"\n" + + "from \"splunk\".\"splunk\"", + + "select count(\"sourcetype\")\n" + + "from \"splunk\".\"splunk\"", + + // gives wrong answer, not error. currently returns same as count. + "select count(distinct \"sourcetype\")\n" + + "from \"splunk\".\"splunk\"", + + "select \"sourcetype\", count(\"source\")\n" + + "from \"splunk\".\"splunk\"\n" + + "group by \"sourcetype\"", + + "select \"sourcetype\", count(\"source\") as c\n" + + "from \"splunk\".\"splunk\"\n" + + "group by \"sourcetype\"\n" + + "order by c desc\n", + + // group + order + "select s.\"product_id\", count(\"source\") as c\n" + + "from \"splunk\".\"splunk\" as s\n" + + "where s.\"sourcetype\" = 'access_combined_wcookie'\n" + + "group by s.\"product_id\"\n" + + "order by c desc\n", + + // non-advertised field + "select s.\"sourcetype\", s.\"action\" from \"splunk\".\"splunk\" as s", + + "select s.\"source\", s.\"product_id\", s.\"product_name\", s.\"method\"\n" + + "from \"splunk\".\"splunk\" as s\n" + + "where s.\"sourcetype\" = 'access_combined_wcookie'\n", + + "select p.\"product_name\", s.\"action\"\n" + + "from \"splunk\".\"splunk\" as s\n" + + " join \"mysql\".\"products\" as p\n" + + "on s.\"product_id\" = p.\"product_id\"", + + "select s.\"source\", s.\"product_id\", p.\"product_name\", p.\"price\"\n" + + "from \"splunk\".\"splunk\" as s\n" + + " join \"mysql\".\"products\" as p\n" + + " on s.\"product_id\" = p.\"product_id\"\n" + + "where s.\"sourcetype\" = 'access_combined_wcookie'\n", }; static final String[] ERROR_SQL_STRINGS = { - // gives error in SplunkPushDownRule - "select count(*) from \"splunk\".\"splunk\"", - - // gives no rows; suspect off-by-one because no base fields are - // referenced - "select s.\"product_id\", s.\"product_name\", s.\"method\"\n" - + "from \"splunk\".\"splunk\" as s\n" - + "where s.\"sourcetype\" = 'access_combined_wcookie'\n", - - // horrible error if you access a field that doesn't exist - "select s.\"sourcetype\", s.\"access\"\n" - + "from \"splunk\".\"splunk\" as s\n", + // gives error in SplunkPushDownRule + "select count(*) from \"splunk\".\"splunk\"", + + // gives no rows; suspect off-by-one because no base fields are + // referenced + "select s.\"product_id\", s.\"product_name\", s.\"method\"\n" + + "from \"splunk\".\"splunk\" as s\n" + + "where s.\"sourcetype\" = 'access_combined_wcookie'\n", + + // horrible error if you access a field that doesn't exist + "select s.\"sourcetype\", s.\"access\"\n" + + "from \"splunk\".\"splunk\" as s\n", }; // Fields: http://git-wip-us.apache.org/repos/asf/calcite/blob/9ab47c00/ubenchmark/src/main/java/org/apache/calcite/benchmarks/StatementTest.java ---------------------------------------------------------------------- diff --git a/ubenchmark/src/main/java/org/apache/calcite/benchmarks/StatementTest.java b/ubenchmark/src/main/java/org/apache/calcite/benchmarks/StatementTest.java index d716fdf..ee6e3c5 100644 --- a/ubenchmark/src/main/java/org/apache/calcite/benchmarks/StatementTest.java +++ b/ubenchmark/src/main/java/org/apache/calcite/benchmarks/StatementTest.java @@ -190,10 +190,18 @@ public class StatementTest { private static void close(ResultSet rs, Statement st) { if (rs != null) { - try { rs.close(); } catch (SQLException e) { /**/ } + try { + rs.close(); + } catch (SQLException e) { + // ignore + } } if (st != null) { - try { st.close(); } catch (SQLException e) { /**/ } + try { + st.close(); + } catch (SQLException e) { + // ignore + } } } @@ -204,15 +212,15 @@ public class StatementTest { } public final Employee[] emps = { - new Employee(100, 10, "Bill", 10000, 1000), - new Employee(200, 20, "Eric", 8000, 500), - new Employee(150, 10, "Sebastian", 7000, null), - new Employee(110, 10, "Theodore", 11500, 250), + new Employee(100, 10, "Bill", 10000, 1000), + new Employee(200, 20, "Eric", 8000, 500), + new Employee(150, 10, "Sebastian", 7000, null), + new Employee(110, 10, "Theodore", 11500, 250), }; public final Department[] depts = { - new Department(10, "Sales", Arrays.asList(emps[0], emps[2])), - new Department(30, "Marketing", Collections.<Employee>emptyList()), - new Department(40, "HR", Collections.singletonList(emps[1])), + new Department(10, "Sales", Arrays.asList(emps[0], emps[2])), + new Department(30, "Marketing", Collections.<Employee>emptyList()), + new Department(40, "HR", Collections.singletonList(emps[1])), }; }
