DRILL-1402: Add check-style rules for trailing space, TABs and blocks without braces
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/676f5df6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/676f5df6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/676f5df6 Branch: refs/heads/master Commit: 676f5df6b14b10ccc3603360e0efee9c745c5b97 Parents: 7ae257c Author: Aditya Kishore <adi...@maprtech.com> Authored: Thu Sep 11 10:43:08 2014 -0700 Committer: Aditya Kishore <adi...@maprtech.com> Committed: Thu Sep 11 19:25:28 2014 -0700 ---------------------------------------------------------------------- .../org/apache/drill/common/JSONOptions.java | 39 +-- .../apache/drill/common/config/DrillConfig.java | 38 ++- .../exceptions/ExecutionSetupException.java | 5 +- .../common/expression/ExpressionFunction.java | 5 +- .../expression/ExpressionStringBuilder.java | 25 +- .../drill/common/expression/FieldReference.java | 36 ++- .../drill/common/expression/FunctionCall.java | 5 +- .../common/expression/FunctionCallFactory.java | 9 +- .../expression/FunctionHolderExpression.java | 5 +- .../drill/common/expression/FunctionName.java | 2 +- .../drill/common/expression/IfExpression.java | 80 ++--- .../common/expression/LogicalExpression.java | 5 +- .../expression/LogicalExpressionBase.java | 28 +- .../drill/common/expression/PathSegment.java | 97 +++--- .../drill/common/expression/SchemaPath.java | 107 ++++--- .../common/expression/fn/CastFunctions.java | 5 +- .../drill/common/expression/types/DataType.java | 24 +- .../expression/visitors/AggregateChecker.java | 25 +- .../expression/visitors/ConstantChecker.java | 19 +- .../drill/common/graph/AdjacencyList.java | 19 +- .../common/graph/AdjacencyListBuilder.java | 7 +- .../apache/drill/common/graph/GraphAlgos.java | 14 +- .../drill/common/logical/PlanProperties.java | 26 +- .../drill/common/logical/data/Filter.java | 8 +- .../apache/drill/common/logical/data/Join.java | 17 +- .../logical/data/LogicalOperatorBase.java | 42 +-- .../drill/common/logical/data/Project.java | 4 +- .../apache/drill/common/logical/data/Scan.java | 11 +- .../drill/common/logical/data/Sequence.java | 19 +- .../logical/data/SingleInputOperator.java | 5 +- .../drill/common/logical/data/Transform.java | 25 +- .../org/apache/drill/common/types/Types.java | 96 +++--- .../drill/common/util/ConstructorChecker.java | 22 +- .../drill/common/util/DrillStringUtils.java | 9 +- .../org/apache/drill/common/util/FileUtils.java | 5 +- .../apache/drill/common/util/PathScanner.java | 29 +- common/src/main/resources/drill-module.conf | 4 +- .../java/org/apache/drill/test/DrillAssert.java | 13 +- common/src/test/resources/basic_physical.json | 10 +- common/src/test/resources/drill-module.conf | 4 +- common/src/test/resources/dsort-logical.json | 6 +- common/src/test/resources/logback.xml | 4 +- common/src/test/resources/simple_plan.json | 19 +- .../src/test/resources/storage_engine_plan.json | 2 +- .../drill/exec/store/hbase/HBaseGroupScan.java | 6 +- .../drill/exec/store/hbase/HBaseUtils.java | 16 +- .../drill/hbase/TestHBaseCFAsJSONString.java | 4 +- .../src/test/resources/logback.xml | 2 +- .../exec/expr/fn/HiveFunctionRegistry.java | 37 ++- .../exec/store/hive/HiveFieldConverter.java | 4 +- .../apache/drill/exec/store/hive/HiveScan.java | 9 +- .../store/hive/HiveStoragePluginConfig.java | 13 +- .../apache/drill/exec/store/hive/HiveTable.java | 33 ++- .../exec/store/hive/HiveTextRecordReader.java | 9 +- .../store/hive/schema/HiveSchemaFactory.java | 42 +-- .../apache/drill/exec/fn/hive/TestHiveUDFs.java | 18 +- .../exec/store/hive/HiveTestDataGenerator.java | 12 +- .../core/src/test/resources/logback.xml | 2 +- .../src/main/java/io/netty/buffer/DrillBuf.java | 94 +++--- .../netty/buffer/UnsafeDirectLittleEndian.java | 6 +- .../drill/exec/cache/CachedVectorContainer.java | 6 +- .../drill/exec/cache/DistributedCache.java | 58 ++-- .../cache/VectorAccessibleSerializable.java | 28 +- .../drill/exec/cache/local/LocalCache.java | 43 +-- .../apache/drill/exec/client/DrillClient.java | 37 ++- .../org/apache/drill/exec/client/DumpCat.java | 38 +-- .../exec/client/PrintingResultsListener.java | 7 +- .../drill/exec/client/QuerySubmitter.java | 17 +- .../exec/compile/AbstractClassCompiler.java | 8 +- .../drill/exec/compile/ByteCodeLoader.java | 10 +- .../drill/exec/compile/ClassTransformer.java | 71 +++-- .../drill/exec/compile/DrillJavaFileObject.java | 5 +- .../drill/exec/compile/JDKClassCompiler.java | 8 +- .../apache/drill/exec/compile/MergeAdapter.java | 77 ++--- .../drill/exec/compile/QueryClassLoader.java | 8 +- .../compile/bytecode/InstructionModifier.java | 43 ++- .../exec/compile/bytecode/ValueHolderIden.java | 54 ++-- .../exec/compile/sig/CodeGeneratorMethod.java | 19 +- .../drill/exec/compile/sig/MappingSet.java | 8 +- .../drill/exec/compile/sig/SignatureHolder.java | 37 +-- .../coord/local/LocalClusterCoordinator.java | 38 ++- .../exec/coord/zk/ZKClusterCoordinator.java | 17 +- .../org/apache/drill/exec/dotdrill/View.java | 5 +- .../apache/drill/exec/expr/ClassGenerator.java | 99 ++++--- .../apache/drill/exec/expr/CodeGenerator.java | 30 +- .../drill/exec/expr/DirectExpression.java | 16 +- .../drill/exec/expr/EvaluationVisitor.java | 30 +- .../exec/expr/ExpressionTreeMaterializer.java | 27 +- .../drill/exec/expr/fn/DrillFuncHolder.java | 20 +- .../exec/expr/fn/DrillFunctionRegistry.java | 11 +- .../exec/expr/fn/DrillSimpleFuncHolder.java | 30 +- .../drill/exec/expr/fn/FunctionConverter.java | 103 ++++--- .../exec/expr/fn/FunctionGenerationHelper.java | 16 +- .../exec/expr/fn/ModifiedUnparseVisitor.java | 4 +- .../exec/expr/fn/impl/ByteFunctionHelpers.java | 14 +- .../drill/exec/expr/fn/impl/ByteSubstring.java | 11 +- .../drill/exec/expr/fn/impl/CharSubstring.java | 10 +- .../drill/exec/expr/fn/impl/HashFunctions.java | 74 +++-- .../apache/drill/exec/expr/fn/impl/IsFalse.java | 7 +- .../drill/exec/expr/fn/impl/IsNotFalse.java | 7 +- .../drill/exec/expr/fn/impl/IsNotTrue.java | 8 +- .../apache/drill/exec/expr/fn/impl/IsTrue.java | 8 +- .../exec/expr/fn/impl/StringFunctionUtil.java | 23 +- .../exec/expr/fn/impl/StringFunctions.java | 145 +++++---- .../drill/exec/expr/fn/impl/VarHelpers.java | 9 +- .../org/apache/drill/exec/memory/Accountor.java | 49 +-- .../drill/exec/memory/AtomicRemainder.java | 18 +- .../drill/exec/memory/TopLevelAllocator.java | 45 +-- .../apache/drill/exec/metrics/DrillMetrics.java | 6 +- .../apache/drill/exec/ops/FragmentContext.java | 30 +- .../apache/drill/exec/ops/OperatorContext.java | 27 +- .../apache/drill/exec/opt/BasicOptimizer.java | 4 +- .../drill/exec/physical/base/AbstractBase.java | 8 +- .../physical/base/AbstractPhysicalVisitor.java | 4 +- .../drill/exec/physical/config/Screen.java | 4 +- .../physical/config/SingleMergeExchange.java | 3 +- .../exec/physical/config/UnionExchange.java | 4 +- .../drill/exec/physical/impl/ImplCreator.java | 10 +- .../physical/impl/OperatorCreatorRegistry.java | 11 +- .../drill/exec/physical/impl/ScanBatch.java | 17 +- .../exec/physical/impl/SingleSenderCreator.java | 9 +- .../exec/physical/impl/TopN/TopNBatch.java | 31 +- .../drill/exec/physical/impl/TraceInjector.java | 8 +- .../exec/physical/impl/WriterRecordBatch.java | 13 +- .../physical/impl/aggregate/HashAggBatch.java | 43 +-- .../impl/aggregate/HashAggTemplate.java | 78 +++-- .../physical/impl/aggregate/HashAggregator.java | 2 +- .../physical/impl/aggregate/InternalBatch.java | 16 +- .../impl/aggregate/StreamingAggBatch.java | 71 +++-- .../impl/aggregate/StreamingAggTemplate.java | 173 +++++++---- .../impl/aggregate/StreamingAggregator.java | 4 +- .../physical/impl/common/ChainedHashTable.java | 27 +- .../physical/impl/common/HashTableTemplate.java | 68 +++-- .../physical/impl/filter/FilterRecordBatch.java | 21 +- .../exec/physical/impl/join/HashJoinBatch.java | 11 +- .../impl/join/HashJoinProbeTemplate.java | 29 +- .../exec/physical/impl/join/JoinStatus.java | 61 ++-- .../exec/physical/impl/join/JoinTemplate.java | 27 +- .../exec/physical/impl/join/MergeJoinBatch.java | 29 +- .../impl/join/MergeJoinBatchBuilder.java | 39 ++- .../impl/mergereceiver/MergingRecordBatch.java | 27 +- .../OrderedPartitionRecordBatch.java | 23 +- .../impl/producer/ProducerConsumerBatch.java | 5 +- .../impl/project/ProjectRecordBatch.java | 75 +++-- .../impl/project/ProjectorTemplate.java | 24 +- .../physical/impl/sort/RecordBatchData.java | 12 +- .../exec/physical/impl/sort/SortBatch.java | 34 +-- .../impl/sort/SortRecordBatchBuilder.java | 60 ++-- .../physical/impl/trace/TraceRecordBatch.java | 11 +- .../IteratorValidatorBatchIterator.java | 15 +- .../validate/IteratorValidatorInjector.java | 8 +- .../exec/physical/impl/xsort/BatchGroup.java | 21 +- .../physical/impl/xsort/ExternalSortBatch.java | 46 +-- .../exec/physical/impl/xsort/MSortTemplate.java | 12 +- .../drill/exec/planner/StarColumnHelper.java | 6 +- .../drill/exec/planner/cost/DrillCostBase.java | 90 +++--- .../exec/planner/cost/DrillRelOptCost.java | 3 +- .../drill/exec/planner/fragment/Fragment.java | 69 +++-- .../planner/fragment/MakeFragmentsVisitor.java | 14 +- .../planner/fragment/SimpleParallelizer.java | 11 +- .../exec/planner/logical/DrillAggregateRel.java | 9 +- .../planner/logical/DrillPushProjIntoScan.java | 10 +- .../drill/exec/planner/logical/DrillTable.java | 40 +-- .../drill/exec/planner/logical/ExprHelper.java | 9 +- .../exec/planner/logical/StoragePlugins.java | 6 +- .../exec/planner/physical/AggPrelBase.java | 10 +- .../exec/planner/physical/HashAggPrule.java | 7 +- .../exec/planner/physical/HashJoinPrule.java | 4 +- .../physical/HashToMergeExchangePrel.java | 9 +- .../physical/HashToRandomExchangePrel.java | 5 +- .../exec/planner/physical/JoinPruleBase.java | 5 +- .../drill/exec/planner/physical/PrelUtil.java | 59 ++-- .../physical/SingleMergeExchangePrel.java | 9 +- .../planner/physical/SubsetTransformer.java | 14 +- .../planner/physical/UnionExchangePrel.java | 7 +- .../planner/physical/explain/PrelSequencer.java | 83 +++--- .../visitor/ExcessiveExchangeIdentifier.java | 28 +- .../physical/visitor/FinalColumnReorderer.java | 21 +- .../planner/physical/visitor/RelUniqifier.java | 14 +- .../visitor/SelectionVectorPrelVisitor.java | 13 +- .../physical/visitor/StarColumnConverter.java | 7 +- .../planner/sql/ExpandingConcurrentMap.java | 31 +- .../sql/handlers/AbstractSqlHandler.java | 20 +- .../sql/handlers/CreateTableHandler.java | 15 +- .../planner/sql/handlers/ExplainHandler.java | 16 +- .../planner/sql/handlers/UseSchemaHandler.java | 9 +- .../exec/planner/sql/handlers/ViewHandler.java | 21 +- .../planner/sql/parser/DrillParserUtil.java | 4 +- .../exec/planner/sql/parser/SqlCreateTable.java | 11 +- .../exec/planner/sql/parser/SqlCreateView.java | 14 +- .../planner/sql/parser/SqlDescribeTable.java | 11 +- .../exec/planner/sql/parser/SqlDropView.java | 6 +- .../exec/planner/sql/parser/SqlShowFiles.java | 8 +- .../exec/planner/sql/parser/SqlShowSchemas.java | 7 +- .../exec/planner/sql/parser/SqlShowTables.java | 11 +- .../types/DrillFixedRelDataTypeImpl.java | 8 +- .../planner/types/RelDataTypeDrillImpl.java | 17 +- .../exec/record/AbstractSingleRecordBatch.java | 13 +- .../apache/drill/exec/record/BatchSchema.java | 29 +- .../drill/exec/record/HyperVectorWrapper.java | 31 +- .../drill/exec/record/MajorTypeSerDe.java | 33 ++- .../drill/exec/record/MaterializedField.java | 54 ++-- .../drill/exec/record/RawFragmentBatch.java | 12 +- .../apache/drill/exec/record/SchemaBuilder.java | 19 +- .../drill/exec/record/SimpleVectorWrapper.java | 29 +- .../apache/drill/exec/record/TypedFieldId.java | 99 ++++--- .../drill/exec/record/VectorContainer.java | 31 +- .../apache/drill/exec/record/WritableBatch.java | 10 +- .../exec/record/selection/SelectionVector4.java | 24 +- .../selection/SelectionVector4Builder.java | 14 +- .../exec/resolver/DefaultFunctionResolver.java | 5 +- .../drill/exec/resolver/FunctionResolver.java | 2 +- .../exec/resolver/FunctionResolverFactory.java | 6 +- .../exec/resolver/ResolverTypePrecedence.java | 40 +-- .../drill/exec/resolver/TypeCastRules.java | 4 +- .../exec/rpc/AbstractHandshakeHandler.java | 11 +- .../drill/exec/rpc/CoordinationQueue.java | 24 +- .../drill/exec/rpc/DrillRpcFutureImpl.java | 10 +- .../drill/exec/rpc/InboundRpcMessage.java | 21 +- .../drill/exec/rpc/OutboundRpcMessage.java | 23 +- .../drill/exec/rpc/ProtobufLengthDecoder.java | 8 +- .../drill/exec/rpc/ReconnectingConnection.java | 7 +- .../drill/exec/rpc/ResettableBarrier.java | 7 +- .../java/org/apache/drill/exec/rpc/RpcBus.java | 44 ++- .../org/apache/drill/exec/rpc/RpcConfig.java | 61 ++-- .../org/apache/drill/exec/rpc/RpcDecoder.java | 43 ++- .../org/apache/drill/exec/rpc/RpcEncoder.java | 37 ++- .../org/apache/drill/exec/rpc/RpcException.java | 16 +- .../rpc/control/ConnectionManagerRegistry.java | 12 +- .../drill/exec/rpc/control/ControlClient.java | 6 +- .../exec/rpc/control/ControlConnection.java | 21 +- .../drill/exec/rpc/control/ControlServer.java | 11 +- .../drill/exec/rpc/control/WorkEventBus.java | 17 +- .../apache/drill/exec/rpc/data/DataClient.java | 8 +- .../exec/rpc/data/DataClientConnection.java | 29 +- .../apache/drill/exec/rpc/data/DataServer.java | 13 +- .../drill/exec/rpc/user/QueryResultBatch.java | 16 +- .../drill/exec/rpc/user/QueryResultHandler.java | 20 +- .../apache/drill/exec/rpc/user/UserClient.java | 3 +- .../apache/drill/exec/rpc/user/UserSession.java | 18 +- .../org/apache/drill/exec/server/Drillbit.java | 17 +- .../drill/exec/server/RemoteServiceSet.java | 17 +- .../drill/exec/server/options/OptionValue.java | 48 +-- .../server/options/SystemOptionManager.java | 23 +- .../exec/server/options/TypeValidators.java | 27 +- .../drill/exec/store/ResourceInputStream.java | 18 +- .../drill/exec/store/StoragePluginRegistry.java | 23 +- .../exec/store/dfs/BasicFormatMatcher.java | 40 ++- .../drill/exec/store/dfs/FileSelection.java | 22 +- .../drill/exec/store/dfs/FileSystemPlugin.java | 29 +- .../drill/exec/store/dfs/FormatCreator.java | 44 ++- .../drill/exec/store/dfs/WorkspaceConfig.java | 3 +- .../exec/store/dfs/WorkspaceSchemaFactory.java | 39 ++- .../exec/store/dfs/easy/EasyGroupScan.java | 18 +- .../exec/store/easy/json/JSONFormatPlugin.java | 8 +- .../exec/store/easy/text/TextFormatPlugin.java | 12 +- .../drill/exec/store/mock/MockGroupScanPOP.java | 26 +- .../drill/exec/store/mock/MockRecordReader.java | 7 +- .../store/mock/MockStorageEngineConfig.java | 13 +- .../exec/store/parquet/ParquetGroupScan.java | 20 +- .../parquet/columnreaders/ColumnReader.java | 15 +- .../columnreaders/FixedWidthRepeatedReader.java | 27 +- .../NullableVarLengthValuesColumn.java | 12 +- .../columnreaders/ParquetRecordReader.java | 25 +- .../columnreaders/VarLenBinaryReader.java | 10 +- .../columnreaders/VarLengthColumnReaders.java | 18 +- .../drill/exec/store/pojo/PojoDataType.java | 30 +- .../drill/exec/store/pojo/PojoRecordReader.java | 67 +++-- .../apache/drill/exec/store/pojo/Writers.java | 71 +++-- .../exec/store/schedule/AssignmentCreator.java | 3 +- .../exec/store/schedule/BlockMapBuilder.java | 11 +- .../drill/exec/store/sys/local/LocalPStore.java | 35 +-- .../store/sys/local/LocalPStoreProvider.java | 10 +- .../exec/store/text/DrillTextRecordWriter.java | 11 +- .../drill/exec/vector/BaseDataValueVector.java | 16 +- .../org/apache/drill/exec/vector/BitVector.java | 27 +- .../vector/complex/AbstractContainerVector.java | 28 +- .../drill/exec/vector/complex/MapVector.java | 96 +++--- .../exec/vector/complex/RepeatedListVector.java | 101 ++++--- .../exec/vector/complex/RepeatedMapVector.java | 138 +++++---- .../drill/exec/vector/complex/StateTool.java | 9 +- .../exec/vector/complex/fn/JsonReader.java | 36 ++- .../vector/complex/fn/JsonReaderWithState.java | 5 +- .../complex/impl/RepeatedListReaderImpl.java | 53 ++-- .../complex/impl/RepeatedMapReaderImpl.java | 63 ++-- .../complex/impl/SingleListReaderImpl.java | 28 +- .../org/apache/drill/exec/work/ErrorHelper.java | 7 +- .../exec/work/batch/ControlHandlerImpl.java | 27 +- .../drill/exec/work/batch/IncomingBuffers.java | 20 +- .../work/batch/UnlimitedRawBatchBuffer.java | 19 +- .../apache/drill/exec/work/foreman/Foreman.java | 79 ++--- .../drill/exec/work/foreman/QueryStatus.java | 50 ++-- .../exec/work/fragment/FragmentExecutor.java | 34 ++- .../work/fragment/NonRootFragmentManager.java | 24 +- .../apache/drill/exec/work/user/UserWorker.java | 23 +- .../src/main/resources/drill-module.conf | 22 +- .../src/main/resources/rest/profile/profile.ftl | 12 +- .../src/main/resources/rest/www/graph.js | 4 +- .../java/org/apache/drill/BaseTestQuery.java | 46 ++- .../java/org/apache/drill/PlanTestBase.java | 9 +- .../java/org/apache/drill/PlanningBase.java | 12 +- .../org/apache/drill/TestProjectPushDown.java | 3 +- .../apache/drill/exec/TestOpSerialization.java | 14 +- .../drill/exec/cache/TestWriteToDisk.java | 5 +- .../exec/fn/impl/TestAggregateFunction.java | 85 +++--- .../exec/fn/impl/TestNewMathFunctions.java | 173 +++++------ .../exec/physical/impl/SimpleRootExec.java | 22 +- .../physical/impl/TestBroadcastExchange.java | 17 +- .../physical/impl/TestComparisonFunctions.java | 19 +- .../physical/impl/TestConvertFunctions.java | 7 +- .../physical/impl/TestHashToRandomExchange.java | 8 +- .../impl/TestImplicitCastFunctions.java | 50 ++-- .../physical/impl/TestSimpleFragmentRun.java | 16 +- .../exec/physical/impl/TestStringFunctions.java | 24 +- .../exec/physical/impl/TestUnionExchange.java | 8 +- .../exec/physical/impl/TopN/TestSimpleTopN.java | 17 +- .../exec/physical/impl/join/TestHashJoin.java | 296 ++++++++++--------- .../exec/physical/impl/join/TestMergeJoin.java | 78 +++-- .../impl/join/TestMergeJoinMulCondition.java | 22 +- .../impl/mergereceiver/TestMergingReceiver.java | 37 ++- .../impl/project/TestSimpleProjection.java | 15 +- .../physical/impl/writer/TestParquetWriter.java | 31 +- .../exec/physical/impl/writer/TestWriter.java | 9 +- .../impl/xsort/TestSimpleExternalSort.java | 49 +-- .../drill/exec/pop/TestFragmentChecker.java | 13 +- .../record/ExpressionTreeMaterializerTest.java | 4 +- .../drill/exec/record/vector/TestLoad.java | 9 +- .../apache/drill/exec/server/TestBitRpc.java | 11 +- .../apache/drill/exec/store/ByteArrayUtil.java | 65 ++-- .../exec/store/CachedSingleFileSystem.java | 23 +- .../drill/exec/store/TestOutputMutator.java | 12 +- .../store/parquet/ParquetRecordReaderTest.java | 20 +- .../exec/store/parquet/TestFileGenerator.java | 30 +- .../store/parquet/TestParquetPhysicalPlan.java | 10 +- .../drill/exec/util/MiniZooKeeperCluster.java | 4 +- .../vector/complex/writer/TestJsonReader.java | 17 +- .../exec/work/batch/TestSpoolingBuffer.java | 3 +- .../src/test/resources/agg/hashagg/q6.json | 2 +- .../src/test/resources/agg/hashagg/q7_1.json | 2 +- .../src/test/resources/agg/hashagg/q7_2.json | 2 +- .../src/test/resources/agg/hashagg/q7_3.json | 2 +- .../src/test/resources/agg/hashagg/q8_1.json | 4 +- .../java-exec/src/test/resources/agg/test1.json | 16 +- .../src/test/resources/agg/twokey.json | 18 +- exec/java-exec/src/test/resources/donuts.json | 249 ++++++++-------- .../src/test/resources/drill-module.conf | 18 +- .../test/resources/drill-spool-test-module.conf | 28 +- .../src/test/resources/filter/test1.json | 16 +- .../src/test/resources/filter/test_sv4.json | 14 +- .../functions/cast/testCastBigInt.json | 26 +- .../functions/cast/testCastFloat4.json | 28 +- .../functions/cast/testCastFloat8.json | 28 +- .../resources/functions/cast/testCastInt.json | 26 +- .../functions/cast/testCastNested.json | 24 +- .../functions/cast/testCastNumException.json | 14 +- .../functions/cast/testCastVarBinary.json | 50 ++-- .../functions/cast/testCastVarChar.json | 38 +-- .../functions/cast/testCastVarCharNull.json | 8 +- .../functions/cast/testICastConstant.json | 54 ++-- .../functions/cast/testICastMockCol.json | 36 +-- .../functions/cast/testICastNullExp.json | 34 +-- .../functions/cast/two_way_implicit_cast.json | 12 +- .../resources/functions/comparisonTest.json | 24 +- .../functions/string/testCharLength.json | 34 +-- .../resources/functions/string/testConcat.json | 16 +- .../resources/functions/string/testLeft.json | 14 +- .../resources/functions/string/testLike.json | 8 +- .../resources/functions/string/testLower.json | 12 +- .../resources/functions/string/testLpad.json | 31 +- .../resources/functions/string/testLtrim.json | 22 +- .../functions/string/testPosition.json | 8 +- .../functions/string/testRegexpReplace.json | 17 +- .../resources/functions/string/testReplace.json | 22 +- .../resources/functions/string/testRight.json | 14 +- .../resources/functions/string/testRpad.json | 29 +- .../resources/functions/string/testRtrim.json | 22 +- .../resources/functions/string/testSimilar.json | 8 +- .../functions/string/testStringFuncs.json | 8 +- .../resources/functions/string/testSubstr.json | 8 +- .../resources/functions/string/testTrim.json | 8 +- .../resources/functions/string/testUpper.json | 12 +- .../resources/functions/testByteSubstring.json | 14 +- .../test/resources/functions/testSubstring.json | 14 +- .../functions/testSubstringNegative.json | 14 +- .../src/test/resources/join/hash_join.json | 86 +++--- .../resources/join/hj_multi_condition_join.json | 2 +- .../src/test/resources/join/join_batchsize.json | 14 +- .../join/merge_inner_single_batch.json | 6 +- .../test/resources/join/merge_multi_batch.json | 6 +- .../test/resources/join/merge_single_batch.json | 6 +- .../src/test/resources/jsoninput/input1.json | 4 +- .../src/test/resources/jsoninput/input2.json | 8 +- .../src/test/resources/jsoninput/vvtypes.json | 4 +- .../test/resources/limit/limit_exchanges.json | 4 +- .../src/test/resources/limit/test1.json | 14 +- .../src/test/resources/limit/test2.json | 14 +- .../src/test/resources/limit/test3.json | 14 +- .../src/test/resources/limit/test4.json | 14 +- .../java-exec/src/test/resources/mock-scan.json | 12 +- .../resources/physical_double_exchange.json | 22 +- .../src/test/resources/physical_join.json | 4 +- .../resources/physical_json_scan_test1.json | 6 +- .../src/test/resources/physical_repeated_1.json | 6 +- .../src/test/resources/physical_test1.json | 14 +- .../src/test/resources/physical_test2.json | 25 +- .../src/test/resources/project/test1.json | 16 +- .../src/test/resources/queries/tpch.json | 7 +- .../src/test/resources/queries/tpch/04.sql | 2 +- .../src/test/resources/queries/tpch/13.sql | 6 +- .../src/test/resources/queries/tpch/15.sql | 6 +- .../src/test/resources/queries/tpch/19_1.sql | 4 +- .../src/test/resources/remover/test1.json | 14 +- .../src/test/resources/scan_json_test_3.json | 18 +- .../src/test/resources/scan_json_test_6.json | 6 +- .../src/test/resources/scan_screen_logical.json | 6 +- .../resources/sender/broadcast_exchange.json | 6 +- .../resources/server/options_session_check.json | 2 +- .../src/test/resources/server/options_set.json | 3 +- .../src/test/resources/simple_plan.json | 19 +- .../src/test/resources/sort/one_key_sort.json | 12 +- .../src/test/resources/sort/two_key_sort.json | 12 +- .../src/test/resources/store/text/test.json | 4 +- .../src/test/resources/testRepeatedWrite.json | 146 ++++----- .../src/test/resources/topN/one_key_sort.json | 12 +- .../src/test/resources/topN/two_key_sort.json | 12 +- .../src/test/resources/union/test1.json | 26 +- .../xsort/one_key_sort_descending.json | 4 +- .../xsort/one_key_sort_descending_sv2.json | 4 +- .../src/test/resources/xsort/oom_sort_test.json | 4 +- .../apache/drill/jdbc/DrillConnectionImpl.java | 32 +- .../java/org/apache/drill/jdbc/DrillCursor.java | 30 +- .../org/apache/drill/jdbc/DrillResultSet.java | 17 +- .../java/org/apache/drill/jdbc/MetaImpl.java | 34 ++- .../drill/jdbc/test/JdbcTestActionBase.java | 4 +- .../drill/jdbc/test/JdbcTestQueryBase.java | 6 +- .../drill/jdbc/test/TestJdbcDistQuery.java | 10 +- exec/jdbc/src/test/resources/test-models.json | 2 - pom.xml | 4 + protocol/pom.xml | 8 + .../resources/assemblies/source-assembly.xml | 34 +-- src/main/resources/checkstyle-config.xml | 27 +- src/main/resources/checkstyle-suppressions.xml | 22 +- 442 files changed, 6073 insertions(+), 4629 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/JSONOptions.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/JSONOptions.java b/common/src/main/java/org/apache/drill/common/JSONOptions.java index b8157e8..64e6d52 100644 --- a/common/src/main/java/org/apache/drill/common/JSONOptions.java +++ b/common/src/main/java/org/apache/drill/common/JSONOptions.java @@ -54,22 +54,22 @@ public class JSONOptions { private JsonLocation location; private Object opaque; - public JSONOptions(Object opaque){ + public JSONOptions(Object opaque) { this.opaque = opaque; } - public JSONOptions(JsonNode n, JsonLocation location){ + public JSONOptions(JsonNode n, JsonLocation location) { this.root = n; this.location = location; } @SuppressWarnings("unchecked") - public <T> T getWith(DrillConfig config, Class<T> c){ + public <T> T getWith(DrillConfig config, Class<T> c) { try { - if(opaque != null){ - if (opaque.getClass().equals(c)){ + if (opaque != null) { + if (opaque.getClass().equals(c)) { return (T) opaque; - }else{ + } else { throw new IllegalArgumentException(String.format("Attmpted to retrieve a option with type of %s. However, the JSON options carried an opaque value of type %s.", c.getName(), opaque.getClass().getName())); } } @@ -87,24 +87,28 @@ public class JSONOptions { @SuppressWarnings("unchecked") public <T> T getListWith(ObjectMapper mapper, TypeReference<T> t) throws IOException { - if(opaque != null){ + if (opaque != null) { Type c = t.getType(); - if(c instanceof ParameterizedType) c = ((ParameterizedType)c).getRawType(); - if ( c.equals(opaque.getClass())){ + if (c instanceof ParameterizedType) { + c = ((ParameterizedType)c).getRawType(); + } + if ( c.equals(opaque.getClass())) { return (T) opaque; - }else{ + } else { throw new IOException(String.format("Attmpted to retrieve a list with type of %s. However, the JSON options carried an opaque value of type %s.", t.getType(), opaque.getClass().getName())); } } - if(root == null) return null; + if (root == null) { + return null; + } return mapper.treeAsTokens(root).readValueAs(t); } - public JsonNode path(String name){ + public JsonNode path(String name) { return root.path(name); } - public JsonNode getRoot(){ + public JsonNode getRoot() { return root; } @@ -122,9 +126,9 @@ public class JSONOptions { // logger.debug("Reading tree."); TreeNode n = jp.readValueAsTree(); // logger.debug("Tree {}", n); - if(n instanceof JsonNode){ + if (n instanceof JsonNode) { return new JSONOptions( (JsonNode) n, l); - }else{ + } else { throw new IllegalArgumentException(String.format("Received something other than a JsonNode %s", n)); } } @@ -140,13 +144,14 @@ public class JSONOptions { @Override public void serialize(JSONOptions value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { - if(value.opaque != null){ + if (value.opaque != null) { jgen.writeObject(value.opaque); - }else{ + } else { jgen.writeTree(value.root); } } } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/config/DrillConfig.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/config/DrillConfig.java b/common/src/main/java/org/apache/drill/common/config/DrillConfig.java index ad3cb78..4c6c766 100644 --- a/common/src/main/java/org/apache/drill/common/config/DrillConfig.java +++ b/common/src/main/java/org/apache/drill/common/config/DrillConfig.java @@ -61,7 +61,7 @@ public final class DrillConfig extends NestedConfig{ mapper = new ObjectMapper(); - if(enableServer){ + if (enableServer) { SimpleModule deserModule = new SimpleModule("LogicalExpressionDeserializationModule") .addDeserializer(LogicalExpression.class, new LogicalExpression.De(this)) .addDeserializer(SchemaPath.class, new SchemaPath.De(this)); @@ -83,7 +83,7 @@ public final class DrillConfig extends NestedConfig{ }; - public List<String> getStartupArguments(){ + public List<String> getStartupArguments() { return startupArguments; } @@ -95,7 +95,7 @@ public final class DrillConfig extends NestedConfig{ return create(null, true); } - public static DrillConfig createClient(){ + public static DrillConfig createClient() { return create(null, false); } @@ -164,17 +164,21 @@ public final class DrillConfig extends NestedConfig{ public <T> Class<T> getClassAt(String location, Class<T> clazz) throws DrillConfigurationException{ String className = this.getString(location); - if(className == null) throw new DrillConfigurationException(String.format("No class defined at location '%s'. Expected a definition of the class []", location, clazz.getCanonicalName())); + if (className == null) { + throw new DrillConfigurationException(String.format("No class defined at location '%s'. Expected a definition of the class []", location, clazz.getCanonicalName())); + } try{ Class<?> c = Class.forName(className); - if(clazz.isAssignableFrom(c)){ + if (clazz.isAssignableFrom(c)) { @SuppressWarnings("unchecked") Class<T> t = (Class<T>) c; return t; - }else{ + } else { throw new DrillConfigurationException(String.format("The class [%s] listed at location '%s' should be of type [%s]. It isn't.", className, location, clazz.getCanonicalName())); } - }catch(Exception ex){ - if(ex instanceof DrillConfigurationException) throw (DrillConfigurationException) ex; + } catch (Exception ex) { + if (ex instanceof DrillConfigurationException) { + throw (DrillConfigurationException) ex; + } throw new DrillConfigurationException(String.format("Failure while initializing class [%s] described at configuration value '%s'.", className, location), ex); } @@ -182,29 +186,31 @@ public final class DrillConfig extends NestedConfig{ public <T> T getInstanceOf(String location, Class<T> clazz) throws DrillConfigurationException{ Class<T> c = getClassAt(location, clazz); - try{ + try { T t = c.newInstance(); return t; - }catch(Exception ex){ + } catch (Exception ex) { throw new DrillConfigurationException(String.format("Failure while instantiating class [%s] located at '%s.", clazz.getCanonicalName(), location), ex); } } - public void setSinkQueues(int number, Queue<Object> queue){ + public void setSinkQueues(int number, Queue<Object> queue) { sinkQueues.set(number, queue); } - public Queue<Object> getQueue(int number){ - if(sinkQueues.size() <= number || number < 0 || sinkQueues == null) throw new IllegalArgumentException(String.format("Queue %d is not available.", number)); + public Queue<Object> getQueue(int number) { + if (sinkQueues.size() <= number || number < 0 || sinkQueues == null) { + throw new IllegalArgumentException(String.format("Queue %d is not available.", number)); + } return sinkQueues.get(number); } - public ObjectMapper getMapper(){ + public ObjectMapper getMapper() { return mapper; } @Override - public String toString(){ + public String toString() { return this.root().render(); } @@ -214,7 +220,7 @@ public final class DrillConfig extends NestedConfig{ } - public static long getMaxDirectMemory(){ + public static long getMaxDirectMemory() { return MAX_DIRECT_MEMORY; } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/exceptions/ExecutionSetupException.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/exceptions/ExecutionSetupException.java b/common/src/main/java/org/apache/drill/common/exceptions/ExecutionSetupException.java index d50e52e..b9c16ad 100644 --- a/common/src/main/java/org/apache/drill/common/exceptions/ExecutionSetupException.java +++ b/common/src/main/java/org/apache/drill/common/exceptions/ExecutionSetupException.java @@ -19,7 +19,6 @@ package org.apache.drill.common.exceptions; import java.lang.reflect.InvocationTargetException; - public class ExecutionSetupException extends DrillException{ private static final long serialVersionUID = -6943409010231014085L; static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ExecutionSetupException.class); @@ -27,7 +26,9 @@ public class ExecutionSetupException extends DrillException{ public static ExecutionSetupException fromThrowable(String message, Throwable cause) { Throwable t = cause instanceof InvocationTargetException ? ((InvocationTargetException)cause).getTargetException() : cause; - if(t instanceof ExecutionSetupException) return ((ExecutionSetupException) t); + if (t instanceof ExecutionSetupException) { + return ((ExecutionSetupException) t); + } return new ExecutionSetupException(message, t); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/ExpressionFunction.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/ExpressionFunction.java b/common/src/main/java/org/apache/drill/common/expression/ExpressionFunction.java index 3fe0d4c..bc478dd 100644 --- a/common/src/main/java/org/apache/drill/common/expression/ExpressionFunction.java +++ b/common/src/main/java/org/apache/drill/common/expression/ExpressionFunction.java @@ -74,7 +74,6 @@ public class ExpressionFunction { "Failure while attempting to retrieve Logical Expression list constructor on class [{}]. Functions must have one of these.", c, e); } - } FUNCTION_MAP = builder.build(); @@ -84,12 +83,14 @@ public class ExpressionFunction { throws ExpressionValidationException { // logger.debug("Requesting generation of new function with name {}.", // functionName); - if (!FUNCTION_MAP.containsKey(functionName)) + if (!FUNCTION_MAP.containsKey(functionName)) { throw new ExpressionValidationException(String.format("Unknown function with name '%s'", functionName)); + } try { return FUNCTION_MAP.get(functionName).newInstance(expressions); } catch (Exception e) { throw new ExpressionValidationException("Failure while attempting to build type of " + functionName, e); } } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/ExpressionStringBuilder.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/ExpressionStringBuilder.java b/common/src/main/java/org/apache/drill/common/expression/ExpressionStringBuilder.java index a15536e..405ac06 100644 --- a/common/src/main/java/org/apache/drill/common/expression/ExpressionStringBuilder.java +++ b/common/src/main/java/org/apache/drill/common/expression/ExpressionStringBuilder.java @@ -46,13 +46,13 @@ public class ExpressionStringBuilder extends AbstractExprVisitor<Void, StringBui static final ExpressionStringBuilder INSTANCE = new ExpressionStringBuilder(); - public static String toString(LogicalExpression expr){ + public static String toString(LogicalExpression expr) { StringBuilder sb = new StringBuilder(); expr.accept(INSTANCE, sb); return sb.toString(); } - public static void toString(LogicalExpression expr, StringBuilder sb){ + public static void toString(LogicalExpression expr, StringBuilder sb) { expr.accept(INSTANCE, sb); } @@ -63,7 +63,9 @@ public class ExpressionStringBuilder extends AbstractExprVisitor<Void, StringBui sb.append(call.getName()); sb.append("("); for (int i = 0; i < args.size(); i++) { - if (i != 0) sb.append(", "); + if (i != 0) { + sb.append(", "); + } args.get(i).accept(this, sb); } sb.append(") "); @@ -103,25 +105,25 @@ public class ExpressionStringBuilder extends AbstractExprVisitor<Void, StringBui @Override public Void visitSchemaPath(SchemaPath path, StringBuilder sb) throws RuntimeException { PathSegment seg = path.getRootSegment(); - if(seg.isArray()) throw new IllegalStateException("Drill doesn't currently support top level arrays"); + if (seg.isArray()) { + throw new IllegalStateException("Drill doesn't currently support top level arrays"); + } sb.append('`'); sb.append(seg.getNameSegment().getPath()); sb.append('`'); - while( (seg = seg.getChild()) != null){ - if(seg.isNamed()){ + while ( (seg = seg.getChild()) != null) { + if (seg.isNamed()) { sb.append('.'); sb.append('`'); sb.append(seg.getNameSegment().getPath()); sb.append('`'); - }else{ + } else { sb.append('['); sb.append(seg.getArraySegment().getIndex()); sb.append(']'); } } - - return null; } @@ -131,7 +133,6 @@ public class ExpressionStringBuilder extends AbstractExprVisitor<Void, StringBui return null; } - @Override public Void visitDateConstant(DateExpression lExpr, StringBuilder sb) throws RuntimeException { sb.append("cast( "); @@ -186,7 +187,6 @@ public class ExpressionStringBuilder extends AbstractExprVisitor<Void, StringBui return null; } - @Override public Void visitDecimal28Constant(Decimal28Expression decExpr, StringBuilder sb) throws RuntimeException { sb.append(decExpr.toString()); @@ -236,7 +236,7 @@ public class ExpressionStringBuilder extends AbstractExprVisitor<Void, StringBui sb.append(" ) as "); sb.append(mt.getMinorType().name()); - switch(mt.getMinorType()){ + switch(mt.getMinorType()) { case FLOAT4: case FLOAT8: case BIT: @@ -313,4 +313,5 @@ public class ExpressionStringBuilder extends AbstractExprVisitor<Void, StringBui sb.append("NULL"); return null; } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/FieldReference.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/FieldReference.java b/common/src/main/java/org/apache/drill/common/expression/FieldReference.java index 733e585..e1f7c4b 100644 --- a/common/src/main/java/org/apache/drill/common/expression/FieldReference.java +++ b/common/src/main/java/org/apache/drill/common/expression/FieldReference.java @@ -40,27 +40,31 @@ import com.fasterxml.jackson.databind.ser.std.StdSerializer; public class FieldReference extends SchemaPath { MajorType overrideType; - public FieldReference(SchemaPath sp){ + public FieldReference(SchemaPath sp) { super(sp); checkData(); } - private void checkData(){ - if(getRootSegment().getChild() != null) throw new UnsupportedOperationException("Field references must be singular names."); + private void checkData() { + if (getRootSegment().getChild() != null) { + throw new UnsupportedOperationException("Field references must be singular names."); + } } - private void checkSimpleString(CharSequence value){ - if(value.toString().contains(".")) throw new UnsupportedOperationException("Field references must be singular names."); + private void checkSimpleString(CharSequence value) { + if (value.toString().contains(".")) { + throw new UnsupportedOperationException("Field references must be singular names."); + } } - public FieldReference(CharSequence value){ + public FieldReference(CharSequence value) { this(value, ExpressionPosition.UNKNOWN); checkSimpleString(value); } - public static FieldReference getWithQuotedRef(CharSequence safeString){ + public static FieldReference getWithQuotedRef(CharSequence safeString) { return new FieldReference(safeString, ExpressionPosition.UNKNOWN, false); } @@ -71,7 +75,7 @@ public class FieldReference extends SchemaPath { public FieldReference(CharSequence value, ExpressionPosition pos, boolean check) { super(new NameSegment(value), pos); - if(check){ + if (check) { checkData(); checkSimpleString(value); } @@ -83,16 +87,16 @@ public class FieldReference extends SchemaPath { this.overrideType = dataType; } - @Override - public MajorType getMajorType() { - if(overrideType == null) { - return super.getMajorType(); - } else { - return overrideType; - } + @Override + public MajorType getMajorType() { + if (overrideType == null) { + return super.getMajorType(); + } else { + return overrideType; } + } - public static class De extends StdDeserializer<FieldReference> { + public static class De extends StdDeserializer<FieldReference> { public De() { super(FieldReference.class); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/FunctionCall.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/FunctionCall.java b/common/src/main/java/org/apache/drill/common/expression/FunctionCall.java index f6c6588..938ab0a 100644 --- a/common/src/main/java/org/apache/drill/common/expression/FunctionCall.java +++ b/common/src/main/java/org/apache/drill/common/expression/FunctionCall.java @@ -35,7 +35,9 @@ public class FunctionCall extends LogicalExpressionBase implements Iterable<Logi super(pos); this.name = name; - if(args == null) args = Lists.newArrayList(); + if (args == null) { + args = Lists.newArrayList(); + } if (!(args instanceof ImmutableList)) { args = ImmutableList.copyOf(args); @@ -75,4 +77,5 @@ public class FunctionCall extends LogicalExpressionBase implements Iterable<Logi return "FunctionCall [func=" + name + ", args=" + (args != null ? args.subList(0, Math.min(args.size(), maxLen)) : null) + ", pos=" + pos + "]"; } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/FunctionCallFactory.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/FunctionCallFactory.java b/common/src/main/java/org/apache/drill/common/expression/FunctionCallFactory.java index e19f546..0a2006a 100644 --- a/common/src/main/java/org/apache/drill/common/expression/FunctionCallFactory.java +++ b/common/src/main/java/org/apache/drill/common/expression/FunctionCallFactory.java @@ -92,10 +92,11 @@ public class FunctionCallFactory { public static LogicalExpression createExpression(String functionName, ExpressionPosition ep, List<LogicalExpression> args){ String name = replaceOpWithFuncName(functionName); - if (isBooleanOperator(name)) + if (isBooleanOperator(name)) { return new BooleanOperator(name, args, ep); - else + } else { return new FunctionCall(name, args, ep); + } } public static LogicalExpression createExpression(String functionName, ExpressionPosition ep, LogicalExpression... e){ @@ -115,8 +116,9 @@ public class FunctionCallFactory { return args.get(0); } - if (args.size() - 1 != opTypes.size()) + if (args.size() - 1 != opTypes.size()) { throw new DrillRuntimeException("Must receive one more expression then the provided number of operators."); + } LogicalExpression first = args.get(0); for (int i = 0; i < opTypes.size(); i++) { @@ -127,4 +129,5 @@ public class FunctionCallFactory { } return first; } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/FunctionHolderExpression.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/FunctionHolderExpression.java b/common/src/main/java/org/apache/drill/common/expression/FunctionHolderExpression.java index 8c50d6f..d5497f7 100644 --- a/common/src/main/java/org/apache/drill/common/expression/FunctionHolderExpression.java +++ b/common/src/main/java/org/apache/drill/common/expression/FunctionHolderExpression.java @@ -31,7 +31,9 @@ public abstract class FunctionHolderExpression extends LogicalExpressionBase { public FunctionHolderExpression(String nameUsed, ExpressionPosition pos, List<LogicalExpression> args) { super(pos); - if(args == null) args = Lists.newArrayList(); + if (args == null) { + args = Lists.newArrayList(); + } if (!(args instanceof ImmutableList)) { args = ImmutableList.copyOf(args); @@ -77,4 +79,5 @@ public abstract class FunctionHolderExpression extends LogicalExpressionBase { /** Return the underlying function implementation holder. */ public abstract FuncHolder getHolder(); + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/FunctionName.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/FunctionName.java b/common/src/main/java/org/apache/drill/common/expression/FunctionName.java index 21a323d..2164cb2 100644 --- a/common/src/main/java/org/apache/drill/common/expression/FunctionName.java +++ b/common/src/main/java/org/apache/drill/common/expression/FunctionName.java @@ -25,5 +25,5 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface FunctionName { - String value(); + String value(); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/IfExpression.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/IfExpression.java b/common/src/main/java/org/apache/drill/common/expression/IfExpression.java index a65ea09..a1cbbd7 100644 --- a/common/src/main/java/org/apache/drill/common/expression/IfExpression.java +++ b/common/src/main/java/org/apache/drill/common/expression/IfExpression.java @@ -29,63 +29,63 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; -public class IfExpression extends LogicalExpressionBase{ - static final Logger logger = LoggerFactory.getLogger(IfExpression.class); +public class IfExpression extends LogicalExpressionBase { + static final Logger logger = LoggerFactory.getLogger(IfExpression.class); - public final IfCondition ifCondition; - public final LogicalExpression elseExpression; + public final IfCondition ifCondition; + public final LogicalExpression elseExpression; - private IfExpression(ExpressionPosition pos, IfCondition conditions, LogicalExpression elseExpression){ - super(pos); - this.ifCondition = conditions; - this.elseExpression = elseExpression; - } + private IfExpression(ExpressionPosition pos, IfCondition conditions, LogicalExpression elseExpression) { + super(pos); + this.ifCondition = conditions; + this.elseExpression = elseExpression; + } - public static class IfCondition{ - public final LogicalExpression condition; - public final LogicalExpression expression; + public static class IfCondition{ + public final LogicalExpression condition; + public final LogicalExpression expression; - public IfCondition(LogicalExpression condition, LogicalExpression expression) { - //logger.debug("Generating IfCondition {}, {}", condition, expression); + public IfCondition(LogicalExpression condition, LogicalExpression expression) { + //logger.debug("Generating IfCondition {}, {}", condition, expression); - this.condition = condition; - this.expression = expression; - } + this.condition = condition; + this.expression = expression; + } - } + } - @Override - public <T, V, E extends Exception> T accept(ExprVisitor<T, V, E> visitor, V value) throws E{ + @Override + public <T, V, E extends Exception> T accept(ExprVisitor<T, V, E> visitor, V value) throws E { return visitor.visitIfExpression(this, value); } - public static class Builder{ - IfCondition conditions; - private LogicalExpression elseExpression; - private ExpressionPosition pos = ExpressionPosition.UNKNOWN; + public static class Builder { + IfCondition conditions; + private LogicalExpression elseExpression; + private ExpressionPosition pos = ExpressionPosition.UNKNOWN; - public Builder setPosition(ExpressionPosition pos){ - this.pos = pos; - return this; - } + public Builder setPosition(ExpressionPosition pos) { + this.pos = pos; + return this; + } - public Builder setElse(LogicalExpression elseExpression) { - this.elseExpression = elseExpression; + public Builder setElse(LogicalExpression elseExpression) { + this.elseExpression = elseExpression; return this; - } + } public Builder setIfCondition(IfCondition conditions) { this.conditions = conditions; return this; } - public IfExpression build(){ - Preconditions.checkNotNull(pos); - Preconditions.checkNotNull(conditions); - return new IfExpression(pos, conditions, elseExpression); - } + public IfExpression build(){ + Preconditions.checkNotNull(pos); + Preconditions.checkNotNull(conditions); + return new IfExpression(pos, conditions, elseExpression); + } - } + } @Override public MajorType getMajorType() { @@ -105,9 +105,9 @@ public class IfExpression extends LogicalExpressionBase{ return majorType; } - public static Builder newBuilder(){ - return new Builder(); - } + public static Builder newBuilder() { + return new Builder(); + } @Override public Iterator<LogicalExpression> iterator() { http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/LogicalExpression.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/LogicalExpression.java b/common/src/main/java/org/apache/drill/common/expression/LogicalExpression.java index c73db49..a74ae29 100644 --- a/common/src/main/java/org/apache/drill/common/expression/LogicalExpression.java +++ b/common/src/main/java/org/apache/drill/common/expression/LogicalExpression.java @@ -68,8 +68,9 @@ public interface LogicalExpression extends Iterable<LogicalExpression>{ JsonProcessingException { String expr = jp.getText(); - if (expr == null || expr.isEmpty()) + if (expr == null || expr.isEmpty()) { return null; + } try { // logger.debug("Parsing expression string '{}'", expr); ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr)); @@ -106,6 +107,4 @@ public interface LogicalExpression extends Iterable<LogicalExpression>{ } - - } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/LogicalExpressionBase.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/LogicalExpressionBase.java b/common/src/main/java/org/apache/drill/common/expression/LogicalExpressionBase.java index d113cde..c125357 100644 --- a/common/src/main/java/org/apache/drill/common/expression/LogicalExpressionBase.java +++ b/common/src/main/java/org/apache/drill/common/expression/LogicalExpressionBase.java @@ -25,11 +25,11 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonPropertyOrder({ "type" }) -public abstract class LogicalExpressionBase implements LogicalExpression{ +public abstract class LogicalExpressionBase implements LogicalExpression { private final ExpressionPosition pos; - protected LogicalExpressionBase(ExpressionPosition pos) { + protected LogicalExpressionBase(ExpressionPosition pos) { super(); this.pos = pos; } @@ -39,21 +39,21 @@ public abstract class LogicalExpressionBase implements LogicalExpression{ return pos; } - protected void i(StringBuilder sb, int indent){ - for(int i = 0; i < indent; i++){ - sb.append(" "); - } - } + protected void i(StringBuilder sb, int indent) { + for (int i = 0; i < indent; i++){ + sb.append(" "); + } + } - @Override - public MajorType getMajorType() { - throw new UnsupportedOperationException(String.format("The type of %s doesn't currently support LogicalExpression.getDataType().", this.getClass().getCanonicalName())); - } + @Override + public MajorType getMajorType() { + throw new UnsupportedOperationException(String.format("The type of %s doesn't currently support LogicalExpression.getDataType().", this.getClass().getCanonicalName())); + } @JsonProperty("type") - public String getDescription(){ - return this.getClass().getSimpleName(); - } + public String getDescription() { + return this.getClass().getSimpleName(); + } @JsonIgnore public int getSelfCost() { http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/PathSegment.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/PathSegment.java b/common/src/main/java/org/apache/drill/common/expression/PathSegment.java index ebce7db..24dd945 100644 --- a/common/src/main/java/org/apache/drill/common/expression/PathSegment.java +++ b/common/src/main/java/org/apache/drill/common/expression/PathSegment.java @@ -30,41 +30,43 @@ public abstract class PathSegment{ public static final class ArraySegment extends PathSegment { private final int index; - public ArraySegment(String numberAsText, PathSegment child){ + public ArraySegment(String numberAsText, PathSegment child) { this(Integer.parseInt(numberAsText), child); } - public ArraySegment(int index, PathSegment child){ + public ArraySegment(int index, PathSegment child) { this.child = child; this.index = index; assert index >=0; } - public ArraySegment(PathSegment child){ + public ArraySegment(PathSegment child) { this.child = child; this.index = -1; } - public boolean hasIndex(){ + public boolean hasIndex() { return index != -1; } - public ArraySegment(int index){ - if(index < 0 ) throw new IllegalArgumentException(); + public ArraySegment(int index) { + if (index < 0 ) { + throw new IllegalArgumentException(); + } this.index = index; } - public int getIndex(){ + public int getIndex() { return index; } @Override - public boolean isArray(){ + public boolean isArray() { return true; } @Override - public boolean isNamed(){ + public boolean isNamed() { return false; } @@ -85,28 +87,31 @@ public abstract class PathSegment{ @Override public boolean segmentEquals(PathSegment obj) { - if (this == obj) + if (this == obj) { return true; - else if (obj == null) + } else if (obj == null) { return false; - else if (obj instanceof ArraySegment) + } else if (obj instanceof ArraySegment) { return index == ((ArraySegment)obj).getIndex(); + } return false; } @Override public PathSegment clone() { PathSegment seg = new ArraySegment(index); - if(child != null) seg.setChild(child.clone()); + if (child != null) { + seg.setChild(child.clone()); + } return seg; } @Override - public ArraySegment cloneWithNewChild(PathSegment newChild){ + public ArraySegment cloneWithNewChild(PathSegment newChild) { ArraySegment seg = new ArraySegment(index); - if(child != null){ + if (child != null) { seg.setChild(child.cloneWithNewChild(newChild)); - }else{ + } else { seg.setChild(newChild); } return seg; @@ -117,26 +122,26 @@ public abstract class PathSegment{ public static final class NameSegment extends PathSegment { private final String path; - public NameSegment(CharSequence n, PathSegment child){ + public NameSegment(CharSequence n, PathSegment child) { this.child = child; this.path = n.toString(); } - public NameSegment(CharSequence n){ + public NameSegment(CharSequence n) { this.path = n.toString(); } - public String getPath(){ + public String getPath() { return path; } @Override - public boolean isArray(){ + public boolean isArray() { return false; } @Override - public boolean isNamed(){ + public boolean isNamed() { return true; } @@ -157,12 +162,13 @@ public abstract class PathSegment{ @Override public boolean segmentEquals(PathSegment obj) { - if (this == obj) + if (this == obj) { return true; - else if (obj == null) + } else if (obj == null) { return false; - else if (getClass() != obj.getClass()) + } else if (getClass() != obj.getClass()) { return false; + } NameSegment other = (NameSegment) obj; if (path == null) { @@ -174,16 +180,18 @@ public abstract class PathSegment{ @Override public NameSegment clone() { NameSegment s = new NameSegment(this.path); - if(child != null) s.setChild(child.clone()); + if (child != null) { + s.setChild(child.clone()); + } return s; } @Override public NameSegment cloneWithNewChild(PathSegment newChild) { NameSegment s = new NameSegment(this.path); - if(child != null){ + if (child != null) { s.setChild(child.cloneWithNewChild(newChild)); - }else{ + } else { s.setChild(newChild); } return s; @@ -191,18 +199,18 @@ public abstract class PathSegment{ } - public NameSegment getNameSegment(){ + public NameSegment getNameSegment() { throw new UnsupportedOperationException(); } - public ArraySegment getArraySegment(){ + public ArraySegment getArraySegment() { throw new UnsupportedOperationException(); } public abstract boolean isArray(); public abstract boolean isNamed(); - public boolean isLastPath(){ + public boolean isLastPath() { return child == null; } @@ -230,19 +238,24 @@ public abstract class PathSegment{ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } PathSegment other = (PathSegment) obj; if (!segmentEquals(other)) { return false; } else if (child == null) { return (other.child == null); - } else return child.equals(other.child); + } else { + return child.equals(other.child); + } } /** @@ -266,24 +279,30 @@ public abstract class PathSegment{ * @return - is this a match */ public boolean contains(PathSegment otherSeg) { - if (this == otherSeg) + if (this == otherSeg) { return true; - if (otherSeg == null) + } + if (otherSeg == null) { return false; + } // TODO - fix this in the future to match array segments are part of the path // the current behavior to always return true when we hit an array may be useful in some cases, // but we can get better performance in the JSON reader if we avoid reading unwanted elements in arrays - if (otherSeg.isArray() || this.isArray()) + if (otherSeg.isArray() || this.isArray()) { return true; - if (getClass() != otherSeg.getClass()) + } + if (getClass() != otherSeg.getClass()) { return false; + } if (!segmentEquals(otherSeg)) { return false; } else if (child == null || otherSeg.child == null) { return true; - } else return child.contains(otherSeg.child); + } else { + return child.contains(otherSeg.child); + } } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java b/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java index eb1ec90..3b31a15 100644 --- a/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java +++ b/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java @@ -49,23 +49,23 @@ public class SchemaPath extends LogicalExpressionBase { private final NameSegment rootSegment; - public static SchemaPath getSimplePath(String name){ + public static SchemaPath getSimplePath(String name) { return getCompoundPath(name); } - public static SchemaPath getCompoundPath(String... strings){ + public static SchemaPath getCompoundPath(String... strings) { List<String> paths = Arrays.asList(strings); Collections.reverse(paths); NameSegment s = null; - for(String p : paths){ + for (String p : paths) { s = new NameSegment(p, s); } return new SchemaPath(s); } - public PathSegment getLastSegment(){ + public PathSegment getLastSegment() { PathSegment s= rootSegment; - while(s.getChild() != null){ + while (s.getChild() != null) { s = s.getChild(); } return s; @@ -76,74 +76,81 @@ public class SchemaPath extends LogicalExpressionBase { * @param simpleName */ @Deprecated - public SchemaPath(String simpleName, ExpressionPosition pos){ + public SchemaPath(String simpleName, ExpressionPosition pos) { super(pos); this.rootSegment = new NameSegment(simpleName); - if(simpleName.contains(".")) throw new IllegalStateException("This is deprecated and only supports simpe paths."); + if (simpleName.contains(".")) { + throw new IllegalStateException("This is deprecated and only supports simpe paths."); + } } - public NamePart getAsNamePart(){ + public NamePart getAsNamePart() { return getNamePart(rootSegment); } - private static NamePart getNamePart(PathSegment s){ - if(s == null) return null; + private static NamePart getNamePart(PathSegment s) { + if (s == null) { + return null; + } NamePart.Builder b = NamePart.newBuilder(); - if(s.getChild() != null){ + if (s.getChild() != null) { b.setChild(getNamePart(s.getChild())); } - if(s.isArray()){ - if(s.getArraySegment().hasIndex()) throw new IllegalStateException("You cannot convert a indexed schema path to a NamePart. NameParts can only reference Vectors, not individual records or values."); + if (s.isArray()) { + if (s.getArraySegment().hasIndex()) { + throw new IllegalStateException("You cannot convert a indexed schema path to a NamePart. NameParts can only reference Vectors, not individual records or values."); + } b.setType(Type.ARRAY); - }else{ + } else { b.setType(Type.NAME); b.setName(s.getNameSegment().getPath()); } return b.build(); } - private static PathSegment getPathSegment(NamePart n){ + private static PathSegment getPathSegment(NamePart n) { PathSegment child = n.hasChild() ? getPathSegment(n.getChild()) : null; - if(n.getType() == Type.ARRAY){ + if (n.getType() == Type.ARRAY) { return new ArraySegment(child); - }else{ + } else { return new NameSegment(n.getName(), child); } } - public static SchemaPath create(NamePart namePart){ + public static SchemaPath create(NamePart namePart) { Preconditions.checkArgument(namePart.getType() == NamePart.Type.NAME); return new SchemaPath((NameSegment) getPathSegment(namePart)); } - /** * A simple is a path where there are no repeated elements outside the lowest level of the path. * @return Whether this path is a simple path. */ - public boolean isSimplePath(){ + public boolean isSimplePath() { PathSegment seg = rootSegment; - while(seg != null){ - if(seg.isArray() && !seg.isLastPath()) return false; + while (seg != null) { + if (seg.isArray() && !seg.isLastPath()) { + return false; + } seg = seg.getChild(); } return true; } - public SchemaPath(SchemaPath path){ + public SchemaPath(SchemaPath path) { super(path.getPosition()); this.rootSegment = path.rootSegment; } - public SchemaPath(NameSegment rootSegment){ + public SchemaPath(NameSegment rootSegment) { super(ExpressionPosition.UNKNOWN); this.rootSegment = rootSegment; } - public SchemaPath(NameSegment rootSegment, ExpressionPosition pos){ + public SchemaPath(NameSegment rootSegment, ExpressionPosition pos) { super(pos); this.rootSegment = rootSegment; } @@ -153,17 +160,17 @@ public class SchemaPath extends LogicalExpressionBase { return visitor.visitSchemaPath(this, value); } - public SchemaPath getChild(String childPath){ + public SchemaPath getChild(String childPath) { NameSegment newRoot = rootSegment.cloneWithNewChild(new NameSegment(childPath)); return new SchemaPath(newRoot); } - public SchemaPath getUnindexedArrayChild(){ + public SchemaPath getUnindexedArrayChild() { NameSegment newRoot = rootSegment.cloneWithNewChild(new ArraySegment(null)); return new SchemaPath(newRoot); } - public SchemaPath getChild(int index){ + public SchemaPath getChild(int index) { NameSegment newRoot = rootSegment.cloneWithNewChild(new ArraySegment(index)); return new SchemaPath(newRoot); } @@ -184,12 +191,15 @@ public class SchemaPath extends LogicalExpressionBase { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (!(obj instanceof SchemaPath)) + } + if (!(obj instanceof SchemaPath)) { return false; + } SchemaPath other = (SchemaPath) obj; if (rootSegment == null) { @@ -199,19 +209,21 @@ public class SchemaPath extends LogicalExpressionBase { } public boolean contains(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (!(obj instanceof SchemaPath)) + } + if (!(obj instanceof SchemaPath)) { return false; + } SchemaPath other = (SchemaPath) obj; if (rootSegment == null) { return true; } return rootSegment.contains(other.rootSegment); - } @Override @@ -219,28 +231,29 @@ public class SchemaPath extends LogicalExpressionBase { return Iterators.emptyIterator(); } - @Override public String toString() { String expr = ExpressionStringBuilder.toString(this); return "SchemaPath ["+ expr + "]"; } - public String toExpr(){ + public String toExpr() { return ExpressionStringBuilder.toString(this); } - public String getAsUnescapedPath(){ + public String getAsUnescapedPath() { StringBuilder sb = new StringBuilder(); PathSegment seg = getRootSegment(); - if(seg.isArray()) throw new IllegalStateException("Drill doesn't currently support top level arrays"); + if (seg.isArray()) { + throw new IllegalStateException("Drill doesn't currently support top level arrays"); + } sb.append(seg.getNameSegment().getPath()); - while( (seg = seg.getChild()) != null){ - if(seg.isNamed()){ + while ( (seg = seg.getChild()) != null) { + if (seg.isNamed()) { sb.append('.'); sb.append(seg.getNameSegment().getPath()); - }else{ + } else { sb.append('['); sb.append(seg.getArraySegment().getIndex()); sb.append(']'); @@ -249,7 +262,6 @@ public class SchemaPath extends LogicalExpressionBase { return sb.toString(); } - public static class De extends StdDeserializer<SchemaPath> { DrillConfig config; @@ -263,8 +275,9 @@ public class SchemaPath extends LogicalExpressionBase { JsonProcessingException { String expr = jp.getText(); - if (expr == null || expr.isEmpty()) + if (expr == null || expr.isEmpty()) { return null; + } try { // logger.debug("Parsing expression string '{}'", expr); ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr)); @@ -276,9 +289,9 @@ public class SchemaPath extends LogicalExpressionBase { parse_return ret = parser.parse(); // ret.e.resolveAndValidate(expr, errorCollector); - if(ret.e instanceof SchemaPath){ + if (ret.e instanceof SchemaPath) { return (SchemaPath) ret.e; - }else{ + } else { throw new IllegalStateException("Schema path is not a valid format."); } } catch (RecognitionException e) { @@ -288,4 +301,4 @@ public class SchemaPath extends LogicalExpressionBase { } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/fn/CastFunctions.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/fn/CastFunctions.java b/common/src/main/java/org/apache/drill/common/expression/fn/CastFunctions.java index 7041760..61d149d 100644 --- a/common/src/main/java/org/apache/drill/common/expression/fn/CastFunctions.java +++ b/common/src/main/java/org/apache/drill/common/expression/fn/CastFunctions.java @@ -53,11 +53,12 @@ public class CastFunctions { public static String getCastFunc(MinorType targetMinorType) { String func = TYPE2FUNC.get(targetMinorType); - if (func != null) + if (func != null) { return func; + } throw new RuntimeException( String.format("cast function for type %s is not defined", targetMinorType.name())); } -} +} http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/types/DataType.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/types/DataType.java b/common/src/main/java/org/apache/drill/common/expression/types/DataType.java index b68f9bc..56102ee 100644 --- a/common/src/main/java/org/apache/drill/common/expression/types/DataType.java +++ b/common/src/main/java/org/apache/drill/common/expression/types/DataType.java @@ -75,12 +75,12 @@ abstract class DataType { public static final DataType NULL = new AtomType("NULL", Comparability.NONE, false); //TODO: Hack to get some size data, needs to be fixed so that each type reveals it's size. - public int size(){ - if(this == BOOLEAN){ + public int size() { + if(this == BOOLEAN) { return 1; - }else if(this == INT32){ + }else if(this == INT32) { return 4; - }else if(this == INT16){ + }else if(this == INT16) { return 4; } return 2; @@ -90,27 +90,28 @@ abstract class DataType { static { Field[] fields = DataType.class.getFields(); Map<String, DataType> types = new HashMap<String, DataType>(); - for(Field f : fields){ + for (Field f : fields) { //logger.debug("Reviewing {}, Field: {}", f.getClass(), f); - if(Modifier.isStatic(f.getModifiers())){ + if (Modifier.isStatic(f.getModifiers())) { try { Object o = f.get(null); //logger.debug("Object {}", o); - if(o instanceof DataType) types.put(((DataType) o).getName(), (DataType) o); + if (o instanceof DataType) { + types.put(((DataType) o).getName(), (DataType) o); + } } catch (IllegalArgumentException | IllegalAccessException e) { logger.warn("Failure while reading DataType.", e); } } } TYPES = Collections.unmodifiableMap(types); - } - public static DataType getDataType(String name){ - if(TYPES.containsKey(name)){ + public static DataType getDataType(String name) { + if (TYPES.containsKey(name)) { return TYPES.get(name); - }else{ + } else { throw new IllegalArgumentException(String.format("Unknown type requested of [%s].", name)); } } @@ -142,4 +143,5 @@ abstract class DataType { } } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/visitors/AggregateChecker.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/visitors/AggregateChecker.java b/common/src/main/java/org/apache/drill/common/expression/visitors/AggregateChecker.java index 881dc15..46789e3 100644 --- a/common/src/main/java/org/apache/drill/common/expression/visitors/AggregateChecker.java +++ b/common/src/main/java/org/apache/drill/common/expression/visitors/AggregateChecker.java @@ -49,7 +49,7 @@ public final class AggregateChecker implements ExprVisitor<Boolean, ErrorCollect public static final AggregateChecker INSTANCE = new AggregateChecker(); - public static boolean isAggregating(LogicalExpression e, ErrorCollector errors){ + public static boolean isAggregating(LogicalExpression e, ErrorCollector errors) { return e.accept(INSTANCE, errors); } @@ -61,38 +61,42 @@ public final class AggregateChecker implements ExprVisitor<Boolean, ErrorCollect @Override public Boolean visitFunctionHolderExpression(FunctionHolderExpression holder, ErrorCollector errors) { - if(holder.isAggregating()){ + if (holder.isAggregating()) { for (int i = 0; i < holder.args.size(); i++) { LogicalExpression e = holder.args.get(i); - if(e.accept(this, errors)){ + if(e.accept(this, errors)) { errors.addGeneralError(e.getPosition(), String.format("Aggregating function call %s includes nested aggregations at arguments number %d. " + "This isn't allowed.", holder.getName(), i)); } } return true; - }else{ - for(LogicalExpression e : holder.args){ - if(e.accept(this, errors)) return true; + } else { + for (LogicalExpression e : holder.args) { + if (e.accept(this, errors)) { + return true; + } } return false; } } @Override - public Boolean visitBooleanOperator(BooleanOperator op, ErrorCollector errors){ + public Boolean visitBooleanOperator(BooleanOperator op, ErrorCollector errors) { for (LogicalExpression arg : op.args) { - if (arg.accept(this, errors)) + if (arg.accept(this, errors)) { return true; + } } - return false; } @Override public Boolean visitIfExpression(IfExpression ifExpr, ErrorCollector errors) { IfCondition c = ifExpr.ifCondition; - if(c.condition.accept(this, errors) || c.expression.accept(this, errors)) return true; + if (c.condition.accept(this, errors) || c.expression.accept(this, errors)) { + return true; + } return ifExpr.elseExpression.accept(this, errors); } @@ -198,4 +202,5 @@ public final class AggregateChecker implements ExprVisitor<Boolean, ErrorCollect public Boolean visitNullExpression(NullExpression e, ErrorCollector value) throws RuntimeException { return false; } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/expression/visitors/ConstantChecker.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/expression/visitors/ConstantChecker.java b/common/src/main/java/org/apache/drill/common/expression/visitors/ConstantChecker.java index 5f20c25..ccb11a6 100644 --- a/common/src/main/java/org/apache/drill/common/expression/visitors/ConstantChecker.java +++ b/common/src/main/java/org/apache/drill/common/expression/visitors/ConstantChecker.java @@ -50,9 +50,9 @@ final class ConstantChecker implements ExprVisitor<Boolean, ErrorCollector, Runt private final static ConstantChecker INSTANCE = new ConstantChecker(); - private ConstantChecker(){} + private ConstantChecker() {} - public static void checkConstants(LogicalExpression e, ErrorCollector errors){ + public static void checkConstants(LogicalExpression e, ErrorCollector errors) { e.accept(INSTANCE, errors); } @@ -67,7 +67,7 @@ final class ConstantChecker implements ExprVisitor<Boolean, ErrorCollector, Runt boolean allArgsAreConstant = true; for (int i = 0; i < holder.args.size(); i++) { boolean thisArgIsConstant = holder.args.get(i).accept(this, errors); - if(!thisArgIsConstant){ + if (!thisArgIsConstant) { allArgsAreConstant = false; if (holder.argConstantOnly(i)) { errors.addGeneralError( // @@ -82,8 +82,9 @@ final class ConstantChecker implements ExprVisitor<Boolean, ErrorCollector, Runt @Override public Boolean visitBooleanOperator(BooleanOperator op, ErrorCollector errors) { for (LogicalExpression e : op.args) { - if (!e.accept(this, errors)) + if (!e.accept(this, errors)) { return false; + } } return true; } @@ -91,10 +92,13 @@ final class ConstantChecker implements ExprVisitor<Boolean, ErrorCollector, Runt @Override public Boolean visitIfExpression(IfExpression ifExpr, ErrorCollector errors) { IfCondition c = ifExpr.ifCondition; - if (!c.condition.accept(this, errors) || !c.expression.accept(this, errors)) + if (!c.condition.accept(this, errors) || !c.expression.accept(this, errors)) { return false; + } - if (!ifExpr.elseExpression.accept(this, errors)) return false; + if (!ifExpr.elseExpression.accept(this, errors)) { + return false; + } return true; } @@ -179,7 +183,7 @@ final class ConstantChecker implements ExprVisitor<Boolean, ErrorCollector, Runt } @Override - public Boolean visitUnknown(LogicalExpression e, ErrorCollector errors){ + public Boolean visitUnknown(LogicalExpression e, ErrorCollector errors) { return false; } @@ -202,4 +206,5 @@ final class ConstantChecker implements ExprVisitor<Boolean, ErrorCollector, Runt public Boolean visitNullExpression(NullExpression e, ErrorCollector value) throws RuntimeException { return true; } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/graph/AdjacencyList.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/graph/AdjacencyList.java b/common/src/main/java/org/apache/drill/common/graph/AdjacencyList.java index ae74194..a4edfc1 100644 --- a/common/src/main/java/org/apache/drill/common/graph/AdjacencyList.java +++ b/common/src/main/java/org/apache/drill/common/graph/AdjacencyList.java @@ -47,7 +47,7 @@ class AdjacencyList<V extends GraphValue<V>> { } } - Node getNewNode(V value){ + Node getNewNode(V value) { return new Node(value); } @@ -83,7 +83,9 @@ class AdjacencyList<V extends GraphValue<V>> { // remove any nodes that have one or more outbound edges. List<Edge<Node>> adjList = this.getAdjacent(n); - if (adjList != null && !adjList.isEmpty()) i.remove(); + if (adjList != null && !adjList.isEmpty()) { + i.remove(); + } } return nodes; @@ -94,7 +96,7 @@ class AdjacencyList<V extends GraphValue<V>> { * * @return */ - public Collection<V> getLeafNodes(){ + public Collection<V> getLeafNodes() { return convert(getInternalLeafNodes()); } @@ -112,7 +114,7 @@ class AdjacencyList<V extends GraphValue<V>> { * * @return */ - public List<V> getRootNodes(){ + public List<V> getRootNodes() { return convert(getInternalRootNodes()); } @@ -149,7 +151,9 @@ class AdjacencyList<V extends GraphValue<V>> { int index = -1; // used for Tarjan's algorithm public Node(final V operator) { - if (operator == null) throw new IllegalArgumentException("Operator node was null."); + if (operator == null) { + throw new IllegalArgumentException("Operator node was null."); + } this.nodeValue = operator; } @@ -174,12 +178,13 @@ class AdjacencyList<V extends GraphValue<V>> { } - public static <V extends GraphValue<V>> AdjacencyList<V> newInstance(Collection<V> nodes){ + public static <V extends GraphValue<V>> AdjacencyList<V> newInstance(Collection<V> nodes) { AdjacencyList<V> list = new AdjacencyList<V>(); AdjacencyListBuilder<V> builder = new AdjacencyListBuilder<V>(list); - for(V v : nodes){ + for (V v : nodes) { v.accept(builder); } return builder.getAdjacencyList(); } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/graph/AdjacencyListBuilder.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/graph/AdjacencyListBuilder.java b/common/src/main/java/org/apache/drill/common/graph/AdjacencyListBuilder.java index 369ff06..e90d70a 100644 --- a/common/src/main/java/org/apache/drill/common/graph/AdjacencyListBuilder.java +++ b/common/src/main/java/org/apache/drill/common/graph/AdjacencyListBuilder.java @@ -30,7 +30,6 @@ import java.util.Map; this.parent = parent; } - protected boolean requireDirected() { return true; } @@ -46,7 +45,9 @@ import java.util.Map; @Override public boolean visit(V o) { - if (o == null) throw new IllegalArgumentException("Null operator."); + if (o == null) { + throw new IllegalArgumentException("Null operator."); + } if (!ops.containsKey(o)) { ops.put(o, parent.getNewNode(o)); @@ -71,4 +72,4 @@ import java.util.Map; return a; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/common/src/main/java/org/apache/drill/common/graph/GraphAlgos.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/graph/GraphAlgos.java b/common/src/main/java/org/apache/drill/common/graph/GraphAlgos.java index 484d2af..0b82c7b 100644 --- a/common/src/main/java/org/apache/drill/common/graph/GraphAlgos.java +++ b/common/src/main/java/org/apache/drill/common/graph/GraphAlgos.java @@ -35,10 +35,9 @@ public class GraphAlgos { private TopoSorter(AdjacencyList<V> graph, boolean reverse) { graph.clearVisited(); - if (reverse){ + if (reverse) { this.rGraph = graph.getReversedList(); - } - else{ + } else { this.rGraph = graph; } Collection<AdjacencyList<V>.Node> sourceNodes = rGraph.getInternalRootNodes(); @@ -49,7 +48,9 @@ public class GraphAlgos { } private void visit(AdjacencyList<V>.Node n) { - if (n.visited) return; + if (n.visited) { + return; + } n.visited = true; List<Edge<AdjacencyList<V>.Node>> edges = rGraph.getAdjacent(n); @@ -93,7 +94,9 @@ public class GraphAlgos { List<List<AdjacencyList<V>.Node>> subgraphs = t.executeTarjan(graph); for (Iterator<List<AdjacencyList<V>.Node>> i = subgraphs.iterator(); i.hasNext();) { List<AdjacencyList<V>.Node> l = i.next(); - if (l.size() == 1) i.remove(); + if (l.size() == 1) { + i.remove(); + } } return subgraphs; } @@ -152,4 +155,5 @@ public class GraphAlgos { return SCC; } } + }