From b1bfafbc96993a0c5b110f38a0ea6b3dc7d9d714 Mon Sep 17 00:00:00 2001 From: mujtabachohan Date: Fri, 24 Jan 2014 17:18:24 -0800 Subject: [PATCH 1/7] Apache Phoenix --- LICENSE.txt | 202 ++++ NOTICE.txt | 25 + README.md | 136 --- bin/csv-bulk-loader.sh | 40 +- bin/performance.sh | 42 +- bin/psql.sh | 40 +- bin/sqlline.sh | 40 +- bin/upgradeTo2.sh | 40 +- build.txt | 33 +- config/apache-access-logs.properties | 2 +- dev/eclipse_prefs_phoenix.epf | 2 +- examples/pig/test.pig | 2 +- license.txt | 26 - phoenix-assembly/pom.xml | 16 +- phoenix-core/pom.xml | 74 +- phoenix-core/src/main/antlr3/PhoenixSQL.g | 158 ++- .../hbase/index/CapturingAbortable.java | 76 -- .../salesforce/hbase/index/ValueGetter.java | 46 - .../IndexBuildingFailureException.java | 58 -- .../salesforce/hbase/index/covered/Batch.java | 70 -- .../hbase/index/covered/CoveredColumns.java | 59 -- .../hbase/index/covered/IndexUpdate.java | 87 -- .../hbase/index/covered/KeyValueStore.java | 43 - .../index/covered/data/LazyValueGetter.java | 97 -- .../index/covered/data/LocalHBaseState.java | 57 -- ...umnTrackingNextLargestTimestampFilter.java | 82 -- .../covered/filter/MaxTimestampFilter.java | 84 -- .../covered/update/IndexedColumnGroup.java | 38 - .../index/exception/IndexWriteException.java | 53 - .../MultiIndexWriteFailureException.java | 54 - .../SingleIndexWriteFailureException.java | 71 -- .../index/parallel/EarlyExitFailure.java | 44 - .../parallel/QuickFailingTaskRunner.java | 59 -- .../salesforce/hbase/index/parallel/Task.java | 50 - .../hbase/index/parallel/TaskBatch.java | 84 -- .../parallel/WaitForCompletionTaskRunner.java | 61 -- .../scanner/FilteredKeyValueScanner.java | 134 --- .../hbase/index/write/IndexCommitter.java | 47 - .../hbase/index/write/IndexFailurePolicy.java | 54 - .../write/KillServerOnFailurePolicy.java | 90 -- .../recovery/PerRegionIndexWriteCache.java | 73 -- .../salesforce/phoenix/cache/HashCache.java | 48 - .../salesforce/phoenix/cache/TenantCache.java | 52 - .../phoenix/client/ClientKeyValueBuilder.java | 75 -- .../phoenix/compile/AggregationManager.java | 61 -- .../phoenix/compile/BindManager.java | 90 -- .../phoenix/compile/ColumnProjector.java | 78 -- .../phoenix/compile/ColumnResolver.java | 63 -- .../phoenix/compile/CreateIndexCompiler.java | 96 -- .../phoenix/compile/DropSequenceCompiler.java | 77 -- .../phoenix/compile/ExplainPlan.java | 47 - .../phoenix/compile/ExpressionManager.java | 78 -- .../phoenix/compile/ExpressionProjector.java | 101 -- .../phoenix/compile/MutationPlan.java | 39 - .../salesforce/phoenix/compile/QueryPlan.java | 77 -- .../phoenix/compile/StatementPlan.java | 55 - .../coprocessor/BaseRegionScanner.java | 77 -- .../BaseScannerRegionObserver.java | 65 -- .../phoenix/coprocessor/GroupByCache.java | 40 - .../coprocessor/MetaDataRegionObserver.java | 48 - .../ServerCachingEndpointImpl.java | 65 -- .../coprocessor/ServerCachingProtocol.java | 71 -- .../phoenix/exception/PhoenixIOException.java | 41 - .../exception/UnknownFunctionException.java | 45 - .../ValueTypeIncompatibleException.java | 46 - .../phoenix/execute/CommitException.java | 51 - .../phoenix/execute/DegenerateQueryPlan.java | 60 -- .../salesforce/phoenix/execute/ScanPlan.java | 119 --- .../phoenix/expression/AddExpression.java | 64 -- .../phoenix/expression/AndExpression.java | 87 -- .../expression/ArithmeticExpression.java | 53 - .../expression/BaseAddSubtractExpression.java | 61 -- .../phoenix/expression/BaseExpression.java | 116 --- .../expression/BaseSingleExpression.java | 99 -- .../expression/BaseTerminalExpression.java | 55 - .../expression/CurrentDateTimeFunction.java | 52 - .../phoenix/expression/DateAddExpression.java | 88 -- .../expression/DateSubtractExpression.java | 88 -- .../expression/DecimalDivideExpression.java | 87 -- .../expression/DecimalMultiplyExpression.java | 87 -- .../expression/DoubleAddExpression.java | 78 -- .../expression/DoubleDivideExpression.java | 82 -- .../expression/DoubleMultiplyExpression.java | 78 -- .../expression/DoubleSubtractExpression.java | 82 -- .../phoenix/expression/Expression.java | 90 -- .../phoenix/expression/LongAddExpression.java | 70 -- .../expression/LongDivideExpression.java | 74 -- .../expression/LongMultiplyExpression.java | 73 -- .../expression/LongSubtractExpression.java | 91 -- .../phoenix/expression/NotExpression.java | 94 -- .../phoenix/expression/OrExpression.java | 75 -- .../expression/SubtractExpression.java | 68 -- .../expression/aggregator/Aggregator.java | 56 -- .../expression/aggregator/BaseAggregator.java | 67 -- .../aggregator/ClientAggregators.java | 88 -- .../aggregator/CountAggregator.java | 100 -- .../DecimalStddevPopAggregator.java | 51 - .../DecimalStddevSampAggregator.java | 51 - .../aggregator/DecimalSumAggregator.java | 111 -- .../DistinctCountClientAggregator.java | 63 -- .../aggregator/DoubleSumAggregator.java | 102 -- .../aggregator/IntSumAggregator.java | 51 - .../aggregator/LongSumAggregator.java | 50 - .../expression/aggregator/MaxAggregator.java | 58 -- .../aggregator/StddevPopAggregator.java | 51 - .../aggregator/StddevSampAggregator.java | 51 - .../aggregator/UnsignedIntSumAggregator.java | 51 - .../aggregator/UnsignedLongSumAggregator.java | 52 - .../function/AggregateFunction.java | 62 -- .../function/ArrayIndexFunction.java | 96 -- .../function/ArrayLengthFunction.java | 83 -- .../function/CeilDateExpression.java | 85 -- .../function/CeilDecimalExpression.java | 85 -- .../expression/function/CeilFunction.java | 65 -- .../expression/function/CoalesceFunction.java | 108 -- .../function/CompositeAggregateFunction.java | 55 - .../function/CurrentDateFunction.java | 77 -- .../function/CurrentTimeFunction.java | 77 -- ...egateConstantToCountAggregateFunction.java | 83 -- ...stinctValueWithCountAggregateFunction.java | 58 -- .../function/FloorDecimalExpression.java | 85 -- .../expression/function/FloorFunction.java | 64 -- .../function/FunctionExpression.java | 79 -- .../function/IndexStateNameFunction.java | 89 -- .../expression/function/LengthFunction.java | 104 -- .../expression/function/MD5Function.java | 108 -- .../function/MaxAggregateFunction.java | 83 -- .../function/MinAggregateFunction.java | 97 -- .../PercentRankAggregateFunction.java | 82 -- .../PercentileContAggregateFunction.java | 83 -- .../PercentileDiscAggregateFunction.java | 80 -- .../expression/function/RoundFunction.java | 65 -- .../function/SQLTableTypeFunction.java | 88 -- .../function/SQLViewTypeFunction.java | 88 -- .../expression/function/ScalarFunction.java | 80 -- .../function/SqlTypeNameFunction.java | 94 -- .../function/StddevPopFunction.java | 86 -- .../function/StddevSampFunction.java | 86 -- .../phoenix/expression/function/TimeUnit.java | 58 -- .../expression/function/TrimFunction.java | 116 --- .../expression/function/TruncFunction.java | 73 -- .../visitor/KeyValueExpressionVisitor.java | 46 - .../SingleAggregateFunctionVisitor.java | 48 - .../visitor/TraverseAllExpressionVisitor.java | 65 -- .../visitor/TraverseNoExpressionVisitor.java | 43 - .../filter/EvaluateOnCompletionVisitor.java | 91 -- .../MultiCQKeyValueComparisonFilter.java | 78 -- .../SingleCFCQKeyValueComparisonFilter.java | 59 -- .../SingleCQKeyValueComparisonFilter.java | 57 -- .../phoenix/index/BaseIndexCodec.java | 69 -- .../index/IndexMetaDataCacheFactory.java | 62 -- .../iterate/AggregatingResultIterator.java | 48 - .../phoenix/iterate/BaseResultIterator.java | 51 - .../phoenix/iterate/ConcatResultIterator.java | 99 -- .../iterate/DelegateResultIterator.java | 58 -- .../FilterAggregatingResultIterator.java | 88 -- .../phoenix/iterate/FilterResultIterator.java | 86 -- .../iterate/LimitingResultIterator.java | 65 -- .../iterate/LookAheadResultIterator.java | 61 -- .../MergeSortRowKeyResultIterator.java | 67 -- .../OrderedAggregatingResultIterator.java | 71 -- .../ParallelIteratorRegionSplitter.java | 44 - ...ParallelIteratorRegionSplitterFactory.java | 48 - .../iterate/PeekingResultIterator.java | 71 -- .../iterate/RegionScannerResultIterator.java | 73 -- .../phoenix/iterate/ResultIterator.java | 62 -- .../phoenix/iterate/ResultIterators.java | 37 - .../iterate/ScanningResultIterator.java | 69 -- .../iterate/SequenceResultIterator.java | 67 -- .../phoenix/iterate/TableResultIterator.java | 94 -- .../UngroupedAggregatingResultIterator.java | 64 -- .../salesforce/phoenix/jdbc/Jdbc7Shim.java | 74 -- .../phoenix/jdbc/PhoenixStatementFactory.java | 32 - .../MaxServerCacheSizeExceededException.java | 57 -- .../memory/DelegatingMemoryManager.java | 69 -- .../memory/InsufficientMemoryException.java | 55 - .../phoenix/parse/AddColumnStatement.java | 59 -- .../phoenix/parse/AddParseNode.java | 57 -- .../parse/AggregateFunctionParseNode.java | 47 - .../salesforce/phoenix/parse/AliasedNode.java | 61 -- .../phoenix/parse/AlterIndexStatement.java | 61 -- .../phoenix/parse/AlterTableStatement.java | 43 - .../phoenix/parse/AndParseNode.java | 59 -- .../phoenix/parse/ArithmeticParseNode.java | 38 - .../phoenix/parse/ArrayConstructorNode.java | 52 - .../phoenix/parse/AvgAggregateParseNode.java | 56 -- .../phoenix/parse/BaseParseNodeVisitor.java | 78 -- .../phoenix/parse/BetweenParseNode.java | 62 -- .../phoenix/parse/BinaryParseNode.java | 52 - .../phoenix/parse/BindParseNode.java | 69 -- .../phoenix/parse/BindTableNode.java | 52 - .../phoenix/parse/BindableStatement.java | 33 - .../phoenix/parse/CaseParseNode.java | 57 -- .../phoenix/parse/CastParseNode.java | 88 -- .../phoenix/parse/CeilParseNode.java | 90 -- .../phoenix/parse/ColumnFamilyDef.java | 65 -- .../phoenix/parse/ComparisonParseNode.java | 67 -- .../phoenix/parse/CompoundParseNode.java | 83 -- .../phoenix/parse/ConcreteTableNode.java | 51 - .../parse/CreateSequenceStatement.java | 72 -- .../phoenix/parse/CurrentDateParseNode.java | 49 - .../phoenix/parse/CurrentTimeParseNode.java | 49 - .../DelegateConstantToCountParseNode.java | 56 -- .../phoenix/parse/DeleteStatement.java | 77 -- .../phoenix/parse/DerivedTableNode.java | 59 -- .../phoenix/parse/DistinctCountParseNode.java | 54 - .../phoenix/parse/DivideParseNode.java | 57 -- .../phoenix/parse/DropColumnStatement.java | 51 - .../phoenix/parse/DropIndexStatement.java | 58 -- .../phoenix/parse/DropSequenceStatement.java | 54 - .../phoenix/parse/DropTableStatement.java | 59 -- .../phoenix/parse/EqualParseNode.java | 55 - .../phoenix/parse/ExistsParseNode.java | 63 -- .../phoenix/parse/ExplainStatement.java | 45 - .../parse/FamilyWildcardParseNode.java | 63 -- .../phoenix/parse/FilterableStatement.java | 39 - .../phoenix/parse/FloorParseNode.java | 89 -- .../parse/GreaterThanOrEqualParseNode.java | 57 -- .../phoenix/parse/GreaterThanParseNode.java | 56 -- .../phoenix/parse/InListParseNode.java | 74 -- .../salesforce/phoenix/parse/InParseNode.java | 63 -- .../phoenix/parse/IndexKeyConstraint.java | 47 - .../phoenix/parse/IsNullParseNode.java | 63 -- .../phoenix/parse/JoinTableNode.java | 72 -- .../parse/LessThanOrEqualParseNode.java | 56 -- .../phoenix/parse/LessThanParseNode.java | 56 -- .../phoenix/parse/LikeParseNode.java | 63 -- .../salesforce/phoenix/parse/LimitNode.java | 48 - .../phoenix/parse/LiteralParseNode.java | 85 -- .../phoenix/parse/MaxAggregateParseNode.java | 49 - .../phoenix/parse/MinAggregateParseNode.java | 49 - .../phoenix/parse/MultiplyParseNode.java | 57 -- .../phoenix/parse/NamedParseNode.java | 61 -- .../phoenix/parse/NamedTableNode.java | 61 -- .../phoenix/parse/NotEqualParseNode.java | 56 -- .../phoenix/parse/NotParseNode.java | 57 -- .../salesforce/phoenix/parse/OrParseNode.java | 57 -- .../salesforce/phoenix/parse/OrderByNode.java | 65 -- .../phoenix/parse/OuterJoinParseNode.java | 57 -- .../phoenix/parse/ParseContext.java | 68 -- .../phoenix/parse/ParseException.java | 55 - .../salesforce/phoenix/parse/ParseNode.java | 60 -- .../phoenix/parse/PrimaryKeyConstraint.java | 77 -- .../phoenix/parse/RoundParseNode.java | 91 -- .../parse/RowValueConstructorParseNode.java | 56 -- .../parse/SingleTableSQLStatement.java | 47 - .../phoenix/parse/StringConcatParseNode.java | 59 -- .../phoenix/parse/SubqueryParseNode.java | 57 -- .../phoenix/parse/SubtractParseNode.java | 56 -- .../phoenix/parse/SumAggregateParseNode.java | 49 - .../salesforce/phoenix/parse/TableName.java | 97 -- .../salesforce/phoenix/parse/TableNode.java | 53 - .../phoenix/parse/TableNodeVisitor.java | 45 - .../phoenix/parse/TerminalParseNode.java | 45 - .../phoenix/parse/ToCharParseNode.java | 75 -- .../phoenix/parse/ToDateParseNode.java | 59 -- .../phoenix/parse/UnaryParseNode.java | 43 - .../phoenix/parse/UpsertStatement.java | 62 -- .../phoenix/parse/WildcardParseNode.java | 64 -- .../phoenix/query/BaseQueryServicesImpl.java | 88 -- .../phoenix/query/ChildQueryServices.java | 55 - .../phoenix/query/ConfigurationFactory.java | 54 - .../phoenix/query/DelegateQueryServices.java | 82 -- .../phoenix/query/HBaseFactoryProvider.java | 65 -- .../phoenix/query/HConnectionFactory.java | 59 -- .../phoenix/query/HTableFactory.java | 64 -- .../phoenix/query/MetaDataMutated.java | 50 - .../phoenix/query/QueryServicesImpl.java | 46 - .../phoenix/query/StatsManager.java | 67 -- .../schema/AmbiguousColumnException.java | 60 -- .../schema/AmbiguousTableException.java | 60 -- .../schema/ArgumentTypeMismatchException.java | 52 - .../schema/ColumnAlreadyExistsException.java | 70 -- .../schema/ColumnFamilyNotFoundException.java | 54 - .../schema/ColumnNotFoundException.java | 73 -- .../ConcurrentTableMutationException.java | 56 -- .../schema/ConstraintViolationException.java | 56 -- .../phoenix/schema/DelegateColumn.java | 72 -- .../phoenix/schema/DelegateDatum.java | 70 -- .../ExecuteQueryNotApplicableException.java | 47 - .../ExecuteUpdateNotApplicableException.java | 46 - .../phoenix/schema/IllegalDataException.java | 55 - .../MetaDataEntityNotFoundException.java | 38 - .../phoenix/schema/MetaDataSplitPolicy.java | 59 -- .../NewerTableAlreadyExistsException.java | 37 - .../phoenix/schema/PBaseColumn.java | 60 -- .../salesforce/phoenix/schema/PColumn.java | 54 - .../phoenix/schema/PColumnFamily.java | 62 -- .../phoenix/schema/PDateColumn.java | 35 - .../com/salesforce/phoenix/schema/PDatum.java | 62 -- .../phoenix/schema/PIntegerColumn.java | 43 - .../phoenix/schema/PLongColumn.java | 43 - .../salesforce/phoenix/schema/PMetaData.java | 38 - .../com/salesforce/phoenix/schema/PName.java | 104 -- .../phoenix/schema/PNormalizedName.java | 61 -- .../com/salesforce/phoenix/schema/PRow.java | 83 -- .../phoenix/schema/PStringColumn.java | 44 - .../schema/ReadOnlyTableException.java | 65 -- .../SequenceAlreadyExistsException.java | 56 -- .../schema/SequenceNotFoundException.java | 58 -- .../schema/TableAlreadyExistsException.java | 63 -- .../schema/TableNotFoundException.java | 81 -- .../salesforce/phoenix/schema/TableRef.java | 90 -- .../phoenix/schema/TypeMismatchException.java | 68 -- .../phoenix/schema/ValueRangeExcpetion.java | 48 - .../phoenix/schema/stat/PTableStats.java | 55 - .../phoenix/schema/stat/PTableStatsImpl.java | 78 -- .../schema/tuple/MultiKeyValueTuple.java | 93 -- .../phoenix/util/BigDecimalUtil.java | 78 -- .../salesforce/phoenix/util/NumberUtil.java | 62 -- .../salesforce/phoenix/util/SQLCloseable.java | 42 - .../util/TrustedByteArrayOutputStream.java | 64 -- .../hbase/index/CapturingAbortable.java | 68 ++ .../hbase/index/IndexLogRollSynchronizer.java | 48 +- .../apache/hadoop}/hbase/index/Indexer.java | 80 +- .../hadoop/hbase/index/ValueGetter.java | 38 + .../hbase/index/builder/BaseIndexBuilder.java | 50 +- .../index/builder/IndexBuildManager.java | 60 +- .../hbase/index/builder/IndexBuilder.java | 50 +- .../IndexBuildingFailureException.java | 50 + .../hadoop/hbase/index/covered/Batch.java | 62 ++ .../hbase/index/covered/CoveredColumns.java | 51 + .../covered/CoveredColumnsIndexBuilder.java | 62 +- .../hbase/index/covered/IndexCodec.java | 50 +- .../hbase/index/covered/IndexUpdate.java | 79 ++ .../hbase/index/covered/KeyValueStore.java | 35 + .../hbase/index/covered/LocalTableState.java | 62 +- .../hbase/index/covered/TableState.java | 8 +- .../index/covered/data/IndexMemStore.java | 69 +- .../index/covered/data/LazyValueGetter.java | 89 ++ .../index/covered/data/LocalHBaseState.java | 49 + .../hbase/index/covered/data/LocalTable.java | 52 +- .../index/covered/example/ColumnGroup.java | 2 +- .../index/covered/example/CoveredColumn.java | 4 +- .../example/CoveredColumnIndexCodec.java | 10 +- .../CoveredColumnIndexSpecifierBuilder.java | 8 +- .../covered/example/CoveredColumnIndexer.java | 10 +- .../filter/ApplyAndFilterDeletesFilter.java | 50 +- ...umnTrackingNextLargestTimestampFilter.java | 74 ++ .../covered/filter/FamilyOnlyFilter.java | 2 +- .../covered/filter/MaxTimestampFilter.java | 76 ++ .../covered/filter/NewerTimestampFilter.java | 2 +- .../index/covered/update/ColumnReference.java | 50 +- .../index/covered/update/ColumnTracker.java | 48 +- .../covered/update/IndexUpdateManager.java | 50 +- .../covered/update/IndexedColumnGroup.java | 30 + .../covered/update/SortedCollection.java | 48 +- .../index/exception/IndexWriteException.java | 45 + .../MultiIndexWriteFailureException.java | 46 + .../SingleIndexWriteFailureException.java | 63 ++ .../hbase/index/parallel/BaseTaskRunner.java | 39 +- .../index/parallel/EarlyExitFailure.java | 36 + .../parallel/QuickFailingTaskRunner.java | 51 + .../hadoop/hbase/index/parallel/Task.java | 42 + .../hbase/index/parallel/TaskBatch.java | 76 ++ .../hbase/index/parallel/TaskRunner.java | 39 +- .../index/parallel/ThreadPoolBuilder.java | 48 +- .../index/parallel/ThreadPoolManager.java | 48 +- .../parallel/WaitForCompletionTaskRunner.java | 53 + .../hbase/index/scanner/EmptyScanner.java | 2 +- .../scanner/FilteredKeyValueScanner.java | 144 +++ .../hadoop}/hbase/index/scanner/Scanner.java | 2 +- .../hbase/index/scanner/ScannerBuilder.java | 14 +- .../index/table/CachingHTableFactory.java | 50 +- .../index/table/CoprocessorHTableFactory.java | 6 +- .../hbase/index/table/HTableFactory.java | 4 +- .../index/table/HTableInterfaceReference.java | 4 +- .../hbase/index/util/ImmutableBytesPtr.java | 48 +- .../hbase/index/util/IndexManagementUtil.java | 46 +- .../hbase/index/wal/IndexedKeyValue.java | 4 +- .../hbase/index/wal/KeyValueCodec.java | 2 +- .../hbase/index/write/IndexCommitter.java | 39 + .../hbase/index/write/IndexFailurePolicy.java | 46 + .../hbase/index/write/IndexWriter.java | 54 +- .../hbase/index/write/IndexWriterUtils.java | 54 +- .../write/KillServerOnFailurePolicy.java | 82 ++ .../write/ParallelWriterIndexCommitter.java | 68 +- .../recovery/PerRegionIndexWriteCache.java | 65 ++ .../recovery/StoreFailuresInCachePolicy.java | 10 +- .../TrackingParallelWriterIndexCommitter.java | 82 +- .../IndexKeyValueSkipListSet.java | 46 +- .../regionserver/wal/IndexedWALEdit.java | 2 +- .../regionserver/wal/IndexedWALEditCodec.java | 4 +- .../apache}/phoenix/cache/GlobalCache.java | 66 +- .../org/apache/phoenix/cache/HashCache.java | 40 + .../phoenix/cache/IndexMetaDataCache.java | 4 +- .../phoenix/cache/ServerCacheClient.java | 74 +- .../org/apache/phoenix/cache/TenantCache.java | 44 + .../phoenix/cache/TenantCacheImpl.java | 58 +- .../phoenix/cache/aggcache/SpillFile.java | 2 +- .../phoenix/cache/aggcache/SpillManager.java | 61 +- .../phoenix/cache/aggcache/SpillMap.java | 4 +- .../cache/aggcache/SpillableGroupByCache.java | 40 +- .../phoenix/client/ClientKeyValue.java | 2 +- .../phoenix/client/ClientKeyValueBuilder.java | 67 ++ .../client/GenericKeyValueBuilder.java | 50 +- .../phoenix/client/KeyValueBuilder.java | 50 +- .../phoenix/compile/AggregationManager.java | 53 + .../apache/phoenix/compile/BindManager.java | 82 ++ .../phoenix/compile/ColumnProjector.java | 70 ++ .../phoenix/compile/ColumnResolver.java | 55 + .../phoenix/compile/CreateIndexCompiler.java | 88 ++ .../compile/CreateSequenceCompiler.java | 78 +- .../phoenix/compile/CreateTableCompiler.java | 92 +- .../phoenix/compile/DeleteCompiler.java | 122 ++- .../phoenix/compile/DropSequenceCompiler.java | 69 ++ .../apache/phoenix/compile/ExplainPlan.java | 39 + .../phoenix/compile/ExpressionCompiler.java | 194 ++-- .../phoenix/compile/ExpressionManager.java | 70 ++ .../phoenix/compile/ExpressionProjector.java | 93 ++ .../apache}/phoenix/compile/FromCompiler.java | 102 +- .../phoenix/compile/GroupByCompiler.java | 76 +- .../phoenix/compile/HavingCompiler.java | 96 +- .../compile/IndexStatementRewriter.java | 26 +- .../apache}/phoenix/compile/JoinCompiler.java | 150 ++- .../apache}/phoenix/compile/KeyPart.java | 56 +- .../phoenix/compile/LimitCompiler.java | 52 +- .../MutatingParallelIteratorFactory.java | 82 +- .../apache/phoenix/compile/MutationPlan.java | 31 + .../phoenix/compile/OrderByCompiler.java | 80 +- .../phoenix/compile/PostDDLCompiler.java | 98 +- .../phoenix/compile/PostIndexDDLCompiler.java | 64 +- .../phoenix/compile/ProjectionCompiler.java | 114 +-- .../phoenix/compile/QueryCompiler.java | 114 +-- .../org/apache/phoenix/compile/QueryPlan.java | 69 ++ .../apache}/phoenix/compile/RowProjector.java | 52 +- .../apache}/phoenix/compile/ScanRanges.java | 56 +- .../phoenix/compile/SequenceManager.java | 66 +- .../phoenix/compile/StatementContext.java | 64 +- .../phoenix/compile/StatementNormalizer.java | 64 +- .../apache/phoenix/compile/StatementPlan.java | 47 + ...rackOrderPreservingExpressionCompiler.java | 44 +- .../phoenix/compile/UpsertCompiler.java | 152 ++- .../phoenix/compile/WhereCompiler.java | 94 +- .../phoenix/compile/WhereOptimizer.java | 104 +- .../coprocessor/BaseRegionScanner.java | 69 ++ .../BaseScannerRegionObserver.java | 57 ++ .../phoenix/coprocessor/GroupByCache.java | 41 + .../GroupedAggregateRegionObserver.java | 85 +- .../coprocessor/HashJoinRegionScanner.java | 78 +- .../coprocessor/MetaDataEndpointImpl.java | 162 ++- .../phoenix/coprocessor/MetaDataProtocol.java | 58 +- .../coprocessor/MetaDataRegionObserver.java | 40 + .../phoenix/coprocessor/ScanProjector.java | 54 +- .../coprocessor/ScanRegionObserver.java | 74 +- .../coprocessor/SequenceRegionObserver.java | 20 +- .../ServerCachingEndpointImpl.java | 57 ++ .../coprocessor/ServerCachingProtocol.java | 63 ++ .../UngroupedAggregateRegionObserver.java | 106 +- .../phoenix/exception/PhoenixIOException.java | 33 + .../exception/PhoenixParserException.java | 48 +- .../phoenix/exception/SQLExceptionCode.java | 80 +- .../phoenix/exception/SQLExceptionInfo.java | 50 +- .../exception/UnknownFunctionException.java | 37 + .../ValueTypeIncompatibleException.java | 38 + .../phoenix/execute/AggregatePlan.java | 102 +- .../phoenix/execute/BasicQueryPlan.java | 76 +- .../phoenix/execute/CommitException.java | 43 + .../phoenix/execute/DegenerateQueryPlan.java | 52 + .../apache}/phoenix/execute/HashJoinPlan.java | 86 +- .../phoenix/execute/MutationState.java | 90 +- .../org/apache/phoenix/execute/ScanPlan.java | 116 +++ .../phoenix/expression/AddExpression.java | 56 ++ .../phoenix/expression/AndExpression.java | 79 ++ .../phoenix/expression/AndOrExpression.java | 52 +- .../expression/ArithmeticExpression.java | 45 + .../ArrayConstructorExpression.java | 46 +- .../expression/BaseAddSubtractExpression.java | 53 + .../expression/BaseCompoundExpression.java | 50 +- .../BaseDecimalAddSubtractExpression.java | 2 +- .../phoenix/expression/BaseExpression.java | 108 ++ .../expression/BaseSingleExpression.java | 91 ++ .../expression/BaseTerminalExpression.java | 47 + .../phoenix/expression/CaseExpression.java | 58 +- .../phoenix/expression/CoerceExpression.java | 56 +- .../phoenix/expression/ColumnExpression.java | 54 +- .../expression/ComparisonExpression.java | 60 +- .../expression/CurrentDateTimeFunction.java | 44 + .../phoenix/expression/DateAddExpression.java | 80 ++ .../expression/DateSubtractExpression.java | 80 ++ .../expression/DecimalAddExpression.java | 58 +- .../expression/DecimalDivideExpression.java | 79 ++ .../expression/DecimalMultiplyExpression.java | 79 ++ .../expression/DecimalSubtractExpression.java | 58 +- .../phoenix/expression/DivideExpression.java | 52 +- .../expression/DoubleAddExpression.java | 70 ++ .../expression/DoubleDivideExpression.java | 74 ++ .../expression/DoubleMultiplyExpression.java | 70 ++ .../expression/DoubleSubtractExpression.java | 74 ++ .../apache/phoenix/expression/Expression.java | 82 ++ .../phoenix/expression/ExpressionType.java | 136 ++- .../phoenix/expression/InListExpression.java | 54 +- .../IndexKeyValueColumnExpression.java | 8 +- .../phoenix/expression/IsNullExpression.java | 54 +- .../expression/KeyValueColumnExpression.java | 56 +- .../phoenix/expression/LikeExpression.java | 56 +- .../phoenix/expression/LiteralExpression.java | 68 +- .../phoenix/expression/LongAddExpression.java | 62 ++ .../expression/LongDivideExpression.java | 66 ++ .../expression/LongMultiplyExpression.java | 65 ++ .../expression/LongSubtractExpression.java | 83 ++ .../expression/MultiplyExpression.java | 52 +- .../phoenix/expression/NotExpression.java | 86 ++ .../phoenix/expression/OrExpression.java | 67 ++ .../phoenix/expression/OrderByExpression.java | 2 +- .../expression/ProjectedColumnExpression.java | 66 +- .../expression/RowKeyColumnExpression.java | 60 +- .../phoenix/expression/RowKeyExpression.java | 6 +- .../RowValueConstructorExpression.java | 72 +- .../expression/StringConcatExpression.java | 58 +- .../expression/SubtractExpression.java | 60 ++ .../expression/TimestampAddExpression.java | 58 +- .../TimestampSubtractExpression.java | 56 +- .../expression/aggregator/Aggregator.java | 48 + .../expression/aggregator/Aggregators.java | 60 +- .../expression/aggregator/BaseAggregator.java | 59 ++ .../BaseDecimalStddevAggregator.java | 64 +- .../aggregator/BaseStddevAggregator.java | 58 +- .../aggregator/ClientAggregators.java | 80 ++ .../aggregator/CountAggregator.java | 92 ++ .../DecimalStddevPopAggregator.java | 43 + .../DecimalStddevSampAggregator.java | 43 + .../aggregator/DecimalSumAggregator.java | 103 ++ .../DistinctCountClientAggregator.java | 55 + ...istinctValueWithCountClientAggregator.java | 56 +- ...istinctValueWithCountServerAggregator.java | 62 +- .../aggregator/DoubleSumAggregator.java | 94 ++ .../aggregator/IntSumAggregator.java | 43 + .../aggregator/LongSumAggregator.java | 42 + .../expression/aggregator/MaxAggregator.java | 50 + .../expression/aggregator/MinAggregator.java | 56 +- .../aggregator/NumberSumAggregator.java | 56 +- .../PercentRankClientAggregator.java | 56 +- .../PercentileClientAggregator.java | 56 +- .../PercentileDiscClientAggregator.java | 56 +- .../aggregator/ServerAggregators.java | 56 +- .../aggregator/StddevPopAggregator.java | 43 + .../aggregator/StddevSampAggregator.java | 43 + .../aggregator/UnsignedIntSumAggregator.java | 43 + .../aggregator/UnsignedLongSumAggregator.java | 44 + .../function/AggregateFunction.java | 54 + .../function/ArrayIndexFunction.java | 88 ++ .../function/ArrayLengthFunction.java | 75 ++ .../function/AvgAggregateFunction.java | 62 +- .../function/CeilDateExpression.java | 77 ++ .../function/CeilDecimalExpression.java | 77 ++ .../expression/function/CeilFunction.java | 57 ++ .../function/CeilTimestampExpression.java | 64 +- .../expression/function/CoalesceFunction.java | 100 ++ .../function/CompositeAggregateFunction.java | 47 + .../function/CountAggregateFunction.java | 66 +- .../function/CurrentDateFunction.java | 69 ++ .../function/CurrentTimeFunction.java | 69 ++ ...egateConstantToCountAggregateFunction.java | 75 ++ .../DistinctCountAggregateFunction.java | 66 +- ...stinctValueWithCountAggregateFunction.java | 50 + .../function/FloorDateExpression.java | 56 +- .../function/FloorDecimalExpression.java | 77 ++ .../expression/function/FloorFunction.java | 56 ++ .../function/FunctionArgumentType.java | 4 +- .../function/FunctionExpression.java | 71 ++ .../function/IndexStateNameFunction.java | 81 ++ .../expression/function/InvertFunction.java | 54 +- .../expression/function/LTrimFunction.java | 64 +- .../expression/function/LengthFunction.java | 96 ++ .../expression/function/LowerFunction.java | 10 +- .../expression/function/MD5Function.java | 100 ++ .../function/MaxAggregateFunction.java | 75 ++ .../function/MinAggregateFunction.java | 89 ++ .../PercentRankAggregateFunction.java | 74 ++ .../PercentileContAggregateFunction.java | 75 ++ .../PercentileDiscAggregateFunction.java | 72 ++ .../expression/function/PrefixFunction.java | 14 +- .../expression/function/RTrimFunction.java | 70 +- .../function/RegexpReplaceFunction.java | 64 +- .../function/RegexpSubstrFunction.java | 62 +- .../expression/function/ReverseFunction.java | 16 +- .../function/RoundDateExpression.java | 68 +- .../function/RoundDecimalExpression.java | 60 +- .../expression/function/RoundFunction.java | 57 ++ .../function/RoundTimestampExpression.java | 64 +- .../function/SQLTableTypeFunction.java | 80 ++ .../function/SQLViewTypeFunction.java | 80 ++ .../expression/function/ScalarFunction.java | 72 ++ .../function/SingleAggregateFunction.java | 60 +- .../function/SqlTypeNameFunction.java | 86 ++ .../function/StddevPopFunction.java | 78 ++ .../function/StddevSampFunction.java | 78 ++ .../expression/function/SubstrFunction.java | 64 +- .../function/SumAggregateFunction.java | 72 +- .../phoenix/expression/function/TimeUnit.java | 50 + .../expression/function/ToCharFunction.java | 60 +- .../expression/function/ToDateFunction.java | 62 +- .../expression/function/ToNumberFunction.java | 62 +- .../expression/function/TrimFunction.java | 108 ++ .../expression/function/TruncFunction.java | 65 ++ .../expression/function/UpperFunction.java | 10 +- .../visitor/BaseExpressionVisitor.java | 94 +- .../expression/visitor/ExpressionVisitor.java | 94 +- .../visitor/KeyValueExpressionVisitor.java | 38 + .../SingleAggregateFunctionVisitor.java | 40 + .../visitor/TraverseAllExpressionVisitor.java | 57 ++ .../visitor/TraverseNoExpressionVisitor.java | 35 + .../filter/BooleanExpressionFilter.java | 56 +- .../filter/EvaluateOnCompletionVisitor.java | 83 ++ .../MultiCFCQKeyValueComparisonFilter.java | 44 +- .../MultiCQKeyValueComparisonFilter.java | 70 ++ .../filter/MultiKeyValueComparisonFilter.java | 54 +- .../filter/RowKeyComparisonFilter.java | 46 +- .../SingleCFCQKeyValueComparisonFilter.java | 51 + .../SingleCQKeyValueComparisonFilter.java | 49 + .../SingleKeyValueComparisonFilter.java | 48 +- .../phoenix/filter/SkipScanFilter.java | 56 +- .../apache/phoenix/index/BaseIndexCodec.java | 61 ++ .../phoenix/index/IndexMaintainer.java | 82 +- .../index/IndexMetaDataCacheClient.java | 56 +- .../index/IndexMetaDataCacheFactory.java | 66 ++ .../phoenix/index/PhoenixIndexBuilder.java | 48 +- .../phoenix/index/PhoenixIndexCodec.java | 70 +- .../index/PhoenixIndexFailurePolicy.java | 52 +- .../iterate/AggregatingResultIterator.java | 40 + .../phoenix/iterate/BaseResultIterator.java | 43 + .../phoenix/iterate/ConcatResultIterator.java | 91 ++ ...DefaultParallelIteratorRegionSplitter.java | 68 +- .../iterate/DelegateResultIterator.java | 50 + .../DistinctAggregatingResultIterator.java | 56 +- .../apache}/phoenix/iterate/ExplainTable.java | 68 +- .../FilterAggregatingResultIterator.java | 80 ++ .../phoenix/iterate/FilterResultIterator.java | 78 ++ .../GroupedAggregatingResultIterator.java | 62 +- .../iterate/LimitingResultIterator.java | 57 ++ .../iterate/LookAheadResultIterator.java | 53 + .../iterate/MappedByteBufferSortedQueue.java | 54 +- .../iterate/MaterializedResultIterator.java | 50 +- .../iterate/MergeSortResultIterator.java | 52 +- .../MergeSortRowKeyResultIterator.java | 61 ++ .../iterate/MergeSortTopNResultIterator.java | 54 +- .../OrderedAggregatingResultIterator.java | 63 ++ .../iterate/OrderedResultIterator.java | 56 +- .../ParallelIteratorRegionSplitter.java | 36 + ...ParallelIteratorRegionSplitterFactory.java | 40 + .../phoenix/iterate/ParallelIterators.java | 91 +- .../iterate/PeekingResultIterator.java | 63 ++ .../iterate/RegionScannerResultIterator.java | 65 ++ .../phoenix/iterate/ResultIterator.java | 54 + .../phoenix/iterate/ResultIterators.java | 29 + .../iterate/ScanningResultIterator.java | 61 ++ .../iterate/SequenceResultIterator.java | 59 ++ ...ipRangeParallelIteratorRegionSplitter.java | 60 +- .../iterate/SpoolTooBigToDiskException.java | 4 +- .../iterate/SpoolingResultIterator.java | 64 +- .../phoenix/iterate/TableResultIterator.java | 86 ++ .../UngroupedAggregatingResultIterator.java | 56 ++ .../org/apache/phoenix/jdbc/Jdbc7Shim.java | 66 ++ .../phoenix/jdbc/PhoenixConnection.java | 98 +- .../phoenix/jdbc/PhoenixDatabaseMetaData.java | 108 +- .../apache}/phoenix/jdbc/PhoenixDriver.java | 52 +- .../phoenix/jdbc/PhoenixEmbeddedDriver.java | 62 +- .../jdbc/PhoenixParameterMetaData.java | 62 +- .../jdbc/PhoenixPreparedStatement.java | 52 +- .../phoenix/jdbc/PhoenixResultSet.java | 70 +- .../jdbc/PhoenixResultSetMetaData.java | 60 +- .../phoenix/jdbc/PhoenixStatement.java | 186 ++-- .../phoenix/jdbc/PhoenixStatementFactory.java | 24 + .../phoenix/job/AbstractRoundRobinQueue.java | 48 +- .../apache}/phoenix/job/JobManager.java | 48 +- .../apache}/phoenix/join/HashCacheClient.java | 76 +- .../phoenix/join/HashCacheFactory.java | 66 +- .../apache}/phoenix/join/HashJoinInfo.java | 66 +- .../MaxServerCacheSizeExceededException.java | 49 + .../apache}/phoenix/join/ScanProjector.java | 68 +- .../phoenix/map/reduce/CSVBulkLoader.java | 58 +- .../phoenix/map/reduce/MapReduceJob.java | 54 +- .../phoenix/map/reduce/util/ConfigReader.java | 48 +- .../phoenix/memory/ChildMemoryManager.java | 48 +- .../memory/DelegatingMemoryManager.java | 61 ++ .../phoenix/memory/GlobalMemoryManager.java | 48 +- .../memory/InsufficientMemoryException.java | 47 + .../apache}/phoenix/memory/MemoryManager.java | 48 +- .../phoenix/optimize/QueryOptimizer.java | 40 +- .../phoenix/parse/AddColumnStatement.java | 51 + .../apache/phoenix/parse/AddParseNode.java | 49 + .../parse/AggregateFunctionParseNode.java | 39 + .../org/apache/phoenix/parse/AliasedNode.java | 53 + .../phoenix/parse/AlterIndexStatement.java | 53 + .../phoenix/parse/AlterTableStatement.java | 35 + .../apache/phoenix/parse/AndParseNode.java | 51 + .../phoenix/parse/ArithmeticParseNode.java | 30 + .../phoenix/parse/ArrayConstructorNode.java | 44 + .../phoenix/parse/AvgAggregateParseNode.java | 48 + .../phoenix/parse/BaseParseNodeVisitor.java | 70 ++ .../phoenix/parse/BetweenParseNode.java | 54 + .../apache/phoenix/parse/BinaryParseNode.java | 44 + .../apache/phoenix/parse/BindParseNode.java | 61 ++ .../apache/phoenix/parse/BindTableNode.java | 44 + .../phoenix/parse/BindableStatement.java | 25 + .../apache/phoenix/parse/CaseParseNode.java | 49 + .../apache/phoenix/parse/CastParseNode.java | 80 ++ .../apache/phoenix/parse/CeilParseNode.java | 82 ++ .../apache}/phoenix/parse/ColumnDef.java | 58 +- .../apache/phoenix/parse/ColumnFamilyDef.java | 57 ++ .../apache}/phoenix/parse/ColumnName.java | 50 +- .../phoenix/parse/ColumnParseNode.java | 38 +- .../phoenix/parse/ComparisonParseNode.java | 59 ++ .../phoenix/parse/CompoundParseNode.java | 75 ++ .../phoenix/parse/ConcreteTableNode.java | 43 + .../phoenix/parse/CreateIndexStatement.java | 48 +- .../parse/CreateSequenceStatement.java | 64 ++ .../phoenix/parse/CreateTableStatement.java | 52 +- .../phoenix/parse/CurrentDateParseNode.java | 41 + .../phoenix/parse/CurrentTimeParseNode.java | 41 + .../DelegateConstantToCountParseNode.java | 48 + .../apache/phoenix/parse/DeleteStatement.java | 69 ++ .../phoenix/parse/DerivedTableNode.java | 51 + .../phoenix/parse/DistinctCountParseNode.java | 46 + .../apache/phoenix/parse/DivideParseNode.java | 49 + .../phoenix/parse/DropColumnStatement.java | 43 + .../phoenix/parse/DropIndexStatement.java | 50 + .../phoenix/parse/DropSequenceStatement.java | 46 + .../phoenix/parse/DropTableStatement.java | 51 + .../apache/phoenix/parse/EqualParseNode.java | 47 + .../apache/phoenix/parse/ExistsParseNode.java | 55 + .../phoenix/parse/ExplainStatement.java | 37 + .../parse/FamilyWildcardParseNode.java | 55 + .../phoenix/parse/FilterableStatement.java | 31 + .../apache/phoenix/parse/FloorParseNode.java | 81 ++ .../phoenix/parse/FunctionParseNode.java | 66 +- .../parse/GreaterThanOrEqualParseNode.java | 49 + .../phoenix/parse/GreaterThanParseNode.java | 48 + .../apache}/phoenix/parse/HintNode.java | 50 +- .../apache/phoenix/parse/InListParseNode.java | 66 ++ .../org/apache/phoenix/parse/InParseNode.java | 55 + .../phoenix/parse/IndexKeyConstraint.java | 39 + .../apache/phoenix/parse/IsNullParseNode.java | 55 + .../apache/phoenix/parse/JoinTableNode.java | 64 ++ .../parse/LessThanOrEqualParseNode.java | 48 + .../phoenix/parse/LessThanParseNode.java | 48 + .../apache/phoenix/parse/LikeParseNode.java | 55 + .../org/apache/phoenix/parse/LimitNode.java | 40 + .../phoenix/parse/LiteralParseNode.java | 77 ++ .../phoenix/parse/MaxAggregateParseNode.java | 41 + .../phoenix/parse/MinAggregateParseNode.java | 41 + .../phoenix/parse/MultiplyParseNode.java | 49 + .../apache}/phoenix/parse/NamedNode.java | 4 +- .../apache/phoenix/parse/NamedParseNode.java | 53 + .../apache/phoenix/parse/NamedTableNode.java | 64 ++ .../phoenix/parse/NotEqualParseNode.java | 48 + .../apache/phoenix/parse/NotParseNode.java | 49 + .../org/apache/phoenix/parse/OrParseNode.java | 49 + .../org/apache/phoenix/parse/OrderByNode.java | 57 ++ .../phoenix/parse/OuterJoinParseNode.java | 49 + .../apache/phoenix/parse/ParseContext.java | 60 ++ .../apache/phoenix/parse/ParseException.java | 47 + .../org/apache/phoenix/parse/ParseNode.java | 52 + .../phoenix/parse/ParseNodeFactory.java | 84 +- .../phoenix/parse/ParseNodeRewriter.java | 54 +- .../phoenix/parse/ParseNodeVisitor.java | 48 +- .../phoenix/parse/PrimaryKeyConstraint.java | 69 ++ .../apache}/phoenix/parse/PropertyName.java | 4 +- .../apache/phoenix/parse/RoundParseNode.java | 83 ++ .../parse/RowValueConstructorParseNode.java | 48 + .../apache}/phoenix/parse/SQLParser.java | 50 +- .../phoenix/parse/SelectStatement.java | 54 +- .../parse/SelectStatementRewriter.java | 48 +- .../phoenix/parse/SequenceValueParseNode.java | 2 +- .../parse/SingleTableSQLStatement.java | 39 + .../StatelessTraverseAllParseNodeVisitor.java | 2 +- .../phoenix/parse/StringConcatParseNode.java | 51 + .../phoenix/parse/SubqueryParseNode.java | 49 + .../phoenix/parse/SubtractParseNode.java | 48 + .../phoenix/parse/SumAggregateParseNode.java | 41 + .../org/apache/phoenix/parse/TableName.java | 89 ++ .../org/apache/phoenix/parse/TableNode.java | 45 + .../phoenix/parse/TableNodeVisitor.java | 37 + .../phoenix/parse/TerminalParseNode.java | 37 + .../apache/phoenix/parse/ToCharParseNode.java | 67 ++ .../apache/phoenix/parse/ToDateParseNode.java | 51 + .../phoenix/parse/ToNumberParseNode.java | 16 +- .../parse/TraverseAllParseNodeVisitor.java | 48 +- .../parse/TraverseNoParseNodeVisitor.java | 48 +- .../apache/phoenix/parse/UnaryParseNode.java | 35 + .../parse/UnsupportedAllParseNodeVisitor.java | 48 +- .../apache/phoenix/parse/UpsertStatement.java | 54 + .../phoenix/parse/WildcardParseNode.java | 56 ++ .../phoenix/query/BaseQueryServicesImpl.java | 80 ++ .../phoenix/query/ChildQueryServices.java | 47 + .../phoenix/query/ConfigurationFactory.java | 46 + .../query/ConnectionQueryServices.java | 67 +- .../query/ConnectionQueryServicesImpl.java | 143 ++- .../ConnectionlessQueryServicesImpl.java | 111 +- .../DelegateConnectionQueryServices.java | 73 +- .../phoenix/query/DelegateQueryServices.java | 74 ++ .../phoenix/query/HBaseFactoryProvider.java | 57 ++ .../phoenix/query/HConnectionFactory.java | 51 + .../apache/phoenix/query/HTableFactory.java | 56 ++ .../apache}/phoenix/query/KeyRange.java | 52 +- .../apache/phoenix/query/MetaDataMutated.java | 42 + .../apache}/phoenix/query/QueryConstants.java | 160 ++- .../apache}/phoenix/query/QueryServices.java | 58 +- .../phoenix/query/QueryServicesImpl.java | 38 + .../phoenix/query/QueryServicesOptions.java | 120 ++- .../apache/phoenix/query/StatsManager.java | 59 ++ .../phoenix/query/StatsManagerImpl.java | 54 +- .../schema/AmbiguousColumnException.java | 52 + .../schema/AmbiguousTableException.java | 52 + .../schema/ArgumentTypeMismatchException.java | 44 + .../schema/ColumnAlreadyExistsException.java | 62 ++ .../schema/ColumnFamilyNotFoundException.java | 46 + .../phoenix/schema/ColumnModifier.java | 48 +- .../schema/ColumnNotFoundException.java | 65 ++ .../apache}/phoenix/schema/ColumnRef.java | 62 +- .../ConcurrentTableMutationException.java | 48 + .../schema/ConstraintViolationException.java | 48 + .../apache/phoenix/schema/DelegateColumn.java | 64 ++ .../apache/phoenix/schema/DelegateDatum.java | 62 ++ .../schema/EmptySequenceCacheException.java | 6 +- .../ExecuteQueryNotApplicableException.java | 39 + .../ExecuteUpdateNotApplicableException.java | 38 + .../phoenix/schema/IllegalDataException.java | 47 + .../phoenix/schema/KeyValueSchema.java | 54 +- .../phoenix/schema/MetaDataClient.java | 190 ++-- .../MetaDataEntityNotFoundException.java | 30 + .../phoenix/schema/MetaDataSplitPolicy.java | 51 + .../NewerTableAlreadyExistsException.java | 29 + .../phoenix/schema/PArrayDataType.java | 46 +- .../apache/phoenix/schema/PBaseColumn.java | 52 + .../org/apache/phoenix/schema/PColumn.java | 46 + .../apache/phoenix/schema/PColumnFamily.java | 54 + .../phoenix/schema/PColumnFamilyImpl.java | 48 +- .../apache}/phoenix/schema/PColumnImpl.java | 52 +- .../apache}/phoenix/schema/PDataType.java | 54 +- .../apache/phoenix/schema/PDateColumn.java | 27 + .../org/apache/phoenix/schema/PDatum.java | 54 + .../apache}/phoenix/schema/PIndexState.java | 48 +- .../apache/phoenix/schema/PIntegerColumn.java | 35 + .../apache/phoenix/schema/PLongColumn.java | 35 + .../org/apache/phoenix/schema/PMetaData.java | 30 + .../apache}/phoenix/schema/PMetaDataImpl.java | 48 +- .../java/org/apache/phoenix/schema/PName.java | 96 ++ .../apache}/phoenix/schema/PNameFactory.java | 4 +- .../apache}/phoenix/schema/PNameImpl.java | 4 +- .../phoenix/schema/PNormalizedName.java | 53 + .../java/org/apache/phoenix/schema/PRow.java | 75 ++ .../apache/phoenix/schema/PStringColumn.java | 36 + .../apache}/phoenix/schema/PTable.java | 58 +- .../apache}/phoenix/schema/PTableImpl.java | 80 +- .../apache}/phoenix/schema/PTableType.java | 48 +- .../apache}/phoenix/schema/PhoenixArray.java | 44 +- .../schema/ReadOnlyTableException.java | 57 ++ .../apache}/phoenix/schema/RowKeySchema.java | 52 +- .../phoenix/schema/RowKeyValueAccessor.java | 52 +- .../apache}/phoenix/schema/SaltingUtil.java | 56 +- .../apache}/phoenix/schema/Sequence.java | 28 +- .../SequenceAlreadyExistsException.java | 48 + .../apache}/phoenix/schema/SequenceKey.java | 48 +- .../schema/SequenceNotFoundException.java | 50 + .../schema/TableAlreadyExistsException.java | 55 + .../schema/TableNotFoundException.java | 73 ++ .../org/apache/phoenix/schema/TableRef.java | 82 ++ .../phoenix/schema/TypeMismatchException.java | 60 ++ .../apache}/phoenix/schema/ValueBitSet.java | 50 +- .../phoenix/schema/ValueRangeExcpetion.java | 40 + .../apache}/phoenix/schema/ValueSchema.java | 48 +- .../phoenix/schema/stat/PTableStats.java | 47 + .../phoenix/schema/stat/PTableStatsImpl.java | 70 ++ .../schema/tuple/MultiKeyValueTuple.java | 85 ++ .../phoenix/schema/tuple/ResultTuple.java | 50 +- .../schema/tuple/SingleKeyValueTuple.java | 48 +- .../apache}/phoenix/schema/tuple/Tuple.java | 48 +- .../apache/phoenix/util/BigDecimalUtil.java | 70 ++ .../apache}/phoenix/util/BitSet.java | 2 +- .../apache}/phoenix/util/ByteUtil.java | 56 +- .../apache}/phoenix/util/CSVLoader.java | 56 +- .../apache}/phoenix/util/Closeables.java | 48 +- .../apache}/phoenix/util/ColumnInfo.java | 2 +- .../apache}/phoenix/util/DateUtil.java | 52 +- .../apache}/phoenix/util/IndexUtil.java | 76 +- .../phoenix/util/InstanceResolver.java | 42 +- .../apache}/phoenix/util/JDBCUtil.java | 56 +- .../apache}/phoenix/util/KeyValueUtil.java | 48 +- .../apache}/phoenix/util/MetaDataUtil.java | 62 +- .../org/apache/phoenix/util/NumberUtil.java | 54 + .../apache}/phoenix/util/PhoenixRuntime.java | 54 +- .../apache}/phoenix/util/QueryUtil.java | 2 +- .../apache}/phoenix/util/ReadOnlyProps.java | 2 +- .../apache}/phoenix/util/ResultUtil.java | 48 +- .../org/apache/phoenix/util/SQLCloseable.java | 34 + .../apache}/phoenix/util/SQLCloseables.java | 48 +- .../apache}/phoenix/util/ScanUtil.java | 90 +- .../apache}/phoenix/util/SchemaUtil.java | 94 +- .../apache}/phoenix/util/ServerUtil.java | 52 +- .../apache}/phoenix/util/SizedUtil.java | 48 +- .../apache}/phoenix/util/StringUtil.java | 50 +- .../util/TrustedByteArrayOutputStream.java | 56 ++ .../apache}/phoenix/util/TupleUtil.java | 60 +- .../src/main/resources/java.sql.Driver | 2 +- phoenix-core/src/site/bin/merge.jar | Bin 0 -> 1347 bytes phoenix-core/src/site/bin/merge.sh | 10 + .../language_reference_source/datatypes.html | 493 +++++++++ .../language_reference_source/functions.html | 740 ++++++++++++++ .../site/language_reference_source/index.html | 947 ++++++++++++++++++ .../markdown/Phoenix-in-15-minutes-or-less.md | 80 ++ phoenix-core/src/site/markdown/building.md | 20 + phoenix-core/src/site/markdown/download.md | 84 ++ .../src/site/markdown/dynamic_columns.md | 17 + phoenix-core/src/site/markdown/faq.md | 279 ++++++ phoenix-core/src/site/markdown/flume.md | 42 + phoenix-core/src/site/markdown/index.md | 69 ++ phoenix-core/src/site/markdown/issues.md | 9 + .../src/site/markdown/mailing_list.md | 14 + phoenix-core/src/site/markdown/mr_dataload.md | 63 ++ phoenix-core/src/site/markdown/paged.md | 31 + phoenix-core/src/site/markdown/performance.md | 86 ++ .../src/site/markdown/phoenix_on_emr.md | 43 + phoenix-core/src/site/markdown/recent.md | 18 + phoenix-core/src/site/markdown/roadmap.md | 35 + phoenix-core/src/site/markdown/salted.md | 25 + .../src/site/markdown/secondary_indexing.md | 152 +++ phoenix-core/src/site/markdown/sequences.md | 47 + phoenix-core/src/site/markdown/skip_scan.md | 22 + phoenix-core/src/site/markdown/source.md | 9 + phoenix-core/src/site/markdown/tuning.md | 128 +++ phoenix-core/src/site/resources/css/site.css | 65 ++ phoenix-core/src/site/resources/favicon.ico | Bin 0 -> 318 bytes .../site/resources/images/PhoenixVsHive.png | Bin 0 -> 30363 bytes .../site/resources/images/PhoenixVsImpala.png | Bin 0 -> 19219 bytes .../resources/images/PhoenixVsOpenTSDB.png | Bin 0 -> 10039 bytes .../src/site/resources/images/logo.png | Bin 0 -> 17729 bytes .../src/site/resources/images/perf-esscf.png | Bin 0 -> 8081 bytes .../resources/images/perf-salted-read.png | Bin 0 -> 8086 bytes .../resources/images/perf-salted-write.png | Bin 0 -> 8379 bytes .../site/resources/images/perf-skipscan.png | Bin 0 -> 7526 bytes .../src/site/resources/images/perf-topn.png | Bin 0 -> 7807 bytes .../src/site/resources/images/psql.png | Bin 0 -> 25997 bytes .../src/site/resources/images/sqlline.png | Bin 0 -> 57490 bytes .../src/site/resources/images/squirrel.png | Bin 0 -> 64649 bytes .../resources/images/topbar-logo-small.png | Bin 0 -> 4931 bytes .../src/site/resources/images/topbar-logo.png | Bin 0 -> 7939 bytes .../site/resources/language/images/div-d.png | Bin 0 -> 8289 bytes .../site/resources/language/images/div-ke.png | Bin 0 -> 763 bytes .../site/resources/language/images/div-ks.png | Bin 0 -> 759 bytes .../site/resources/language/images/div-le.png | Bin 0 -> 387 bytes .../site/resources/language/images/div-ls.png | Bin 0 -> 396 bytes .../site/resources/language/images/div-te.png | Bin 0 -> 739 bytes .../site/resources/language/images/div-ts.png | Bin 0 -> 727 bytes .../site/resources/language/stylesheet.css | 139 +++ phoenix-core/src/site/site.xml | 96 ++ .../src/site/xhtml/language/datatypes.xhtml | 5 + .../src/site/xhtml/language/functions.xhtml | 5 + .../src/site/xhtml/language/index.xhtml | 5 + phoenix-core/src/site/xhtml/team.xhtml | 115 +++ .../salesforce/hbase/index/StubAbortable.java | 51 - .../com/salesforce/hbase/index/TableName.java | 55 - .../covered/CoveredIndexCodecForTesting.java | 81 -- .../index/covered/TestCoveredColumns.java | 55 - .../covered/example/TestColumnTracker.java | 71 -- .../TestEndtoEndIndexingWithCompression.java | 59 -- .../filter/TestNewerTimestampFilter.java | 57 -- .../index/parallel/TestThreadPoolBuilder.java | 73 -- .../index/write/TestCachingHTableFactory.java | 68 -- .../phoenix/compile/JoinQueryCompileTest.java | 73 -- .../end2end/BaseClientManagedTimeTest.java | 51 - .../end2end/BaseHBaseManagedTimeTest.java | 51 - .../phoenix/end2end/CoalesceFunctionTest.java | 67 -- .../phoenix/end2end/InMemoryOrderByTest.java | 50 - .../phoenix/end2end/IsNullTest.java | 75 -- .../end2end/QueryExecWithoutSCNTest.java | 59 -- .../phoenix/end2end/ServerExceptionTest.java | 77 -- .../phoenix/end2end/SpooledOrderByTest.java | 48 - .../expression/LikeExpressionTest.java | 52 - .../iterate/SpoolingResultIteratorTest.java | 81 -- .../phoenix/jdbc/PhoenixTestDriver.java | 90 -- .../query/BaseConnectionlessQueryTest.java | 113 --- .../query/HBaseFactoryProviderTest.java | 52 - .../phoenix/schema/SchemaUtilTest.java | 67 -- .../salesforce/phoenix/util/ByteUtilTest.java | 78 -- .../salesforce/phoenix/util/DateUtilTest.java | 72 -- .../phoenix/util/LikeExpressionTest.java | 50 - .../phoenix/util/MetaDataUtilTest.java | 54 - .../hbase/index/IndexTestingUtils.java | 48 +- .../hadoop/hbase/index/StubAbortable.java | 43 + .../apache/hadoop/hbase/index/TableName.java | 47 + .../TestFailForUnsupportedHBaseVersions.java | 54 +- .../covered/CoveredIndexCodecForTesting.java | 73 ++ .../index/covered/TestCoveredColumns.java | 47 + ...estEndToEndCoveredColumnsIndexBuilder.java | 58 +- .../index/covered/TestLocalTableState.java | 56 +- .../index/covered/data/TestIndexMemStore.java | 48 +- .../covered/example/TestColumnTracker.java | 63 ++ .../example/TestCoveredColumnIndexCodec.java | 60 +- .../TestCoveredIndexSpecifierBuilder.java | 48 +- .../example/TestEndToEndCoveredIndexing.java | 54 +- .../TestEndtoEndIndexingWithCompression.java | 51 + .../example/TestFailWithoutRetries.java | 60 +- .../TestApplyAndFilterDeletesFilter.java | 50 +- .../covered/filter/TestFamilyOnlyFilter.java | 48 +- .../filter/TestNewerTimestampFilter.java | 49 + .../update/TestIndexUpdateManager.java | 50 +- .../index/parallel/TestThreadPoolBuilder.java | 65 ++ .../index/parallel/TestThreadPoolManager.java | 50 +- .../index/util/TestIndexManagementUtil.java | 48 +- .../hbase/index/write/FakeTableFactory.java | 6 +- .../index/write/TestCachingHTableFactory.java | 60 ++ .../hbase/index/write/TestIndexWriter.java | 58 +- .../index/write/TestParalleIndexWriter.java | 56 +- .../TestParalleWriterIndexCommitter.java | 56 +- .../index/write/TestWALRecoveryCaching.java | 70 +- .../TestPerRegionIndexWriteCache.java | 54 +- .../wal/TestReadWriteKeyValuesWithCodec.java | 4 +- ...ReplayWithIndexWritesAndCompressedWAL.java | 12 +- ...WritesAndUncompressedWALInHBase_094_9.java | 2 +- .../arithmetic/ArithmeticOperationTest.java | 54 +- .../phoenix/client/TestClientKeyValue.java | 48 +- .../client/TestClientKeyValueLocal.java | 4 +- .../phoenix/compile/HavingClauseTest.java | 80 +- .../phoenix/compile/JoinQueryCompileTest.java | 65 ++ .../phoenix/compile/LimitClauseTest.java | 68 +- .../phoenix/compile/QueryCompileTest.java | 84 +- .../phoenix/compile/QueryMetaDataTest.java | 54 +- .../phoenix/compile/QueryOptimizerTest.java | 62 +- .../phoenix/compile/ScanRangesTest.java | 60 +- .../compile/SelectStatementRewriterTest.java | 70 +- .../StatementHintsCompilationTest.java | 62 +- .../phoenix/compile/ViewCompileTest.java | 64 +- .../compile/WhereClauseCompileTest.java | 102 +- .../compile/WhereClauseOptimizerTest.java | 84 +- .../phoenix/end2end/AlterTableTest.java | 64 +- .../phoenix/end2end/ArithmeticQueryTest.java | 52 +- .../apache}/phoenix/end2end/ArrayTest.java | 64 +- .../phoenix/end2end/AutoCommitTest.java | 50 +- .../end2end/BaseClientManagedTimeTest.java | 43 + .../end2end/BaseConnectedQueryTest.java | 132 ++- .../end2end/BaseHBaseManagedTimeTest.java | 43 + .../end2end/BaseTenantSpecificTablesTest.java | 50 +- .../phoenix/end2end/BinaryRowKeyTest.java | 50 +- .../phoenix/end2end/CSVLoaderTest.java | 56 +- .../phoenix/end2end/CoalesceFunctionTest.java | 59 ++ .../end2end/CompareDecimalToLongTest.java | 52 +- .../ConnectionQueryServicesTestImpl.java | 54 +- .../phoenix/end2end/CreateTableTest.java | 56 +- .../phoenix/end2end/CustomEntityDataTest.java | 52 +- ...ltParallelIteratorsRegionSplitterTest.java | 88 +- .../apache}/phoenix/end2end/DeleteTest.java | 52 +- .../end2end/DescColumnSortOrderTest.java | 50 +- .../phoenix/end2end/DistinctCountTest.java | 54 +- .../phoenix/end2end/DynamicColumnTest.java | 58 +- .../phoenix/end2end/DynamicFamilyTest.java | 56 +- .../phoenix/end2end/DynamicUpsertTest.java | 48 +- .../end2end/ExecuteStatementsTest.java | 70 +- .../end2end/ExtendedQueryExecTest.java | 56 +- .../phoenix/end2end/FunkyNamesTest.java | 54 +- .../phoenix/end2end/GroupByCaseTest.java | 58 +- .../apache}/phoenix/end2end/HashJoinTest.java | 66 +- .../phoenix/end2end/InMemoryOrderByTest.java | 42 + .../apache/phoenix/end2end/IsNullTest.java | 67 ++ .../apache}/phoenix/end2end/KeyOnlyTest.java | 56 +- .../phoenix/end2end/MD5FunctionTest.java | 48 +- .../phoenix/end2end/MultiCfQueryExecTest.java | 54 +- .../phoenix/end2end/NativeHBaseTypesTest.java | 68 +- .../apache}/phoenix/end2end/OrderByTest.java | 104 +- .../phoenix/end2end/PercentileTest.java | 56 +- .../phoenix/end2end/ProductMetricsTest.java | 70 +- .../end2end/QueryDatabaseMetaDataTest.java | 112 +-- .../end2end/QueryExecWithoutSCNTest.java | 51 + .../phoenix/end2end/QueryPlanTest.java | 56 +- .../apache}/phoenix/end2end/QueryTest.java | 102 +- .../end2end/ReadIsolationLevelTest.java | 52 +- .../phoenix/end2end/ReverseFunctionTest.java | 48 +- .../RoundFloorCeilFunctionsEnd2EndTest.java | 58 +- .../end2end/RowValueConstructorTest.java | 96 +- .../apache}/phoenix/end2end/SequenceTest.java | 18 +- .../phoenix/end2end/ServerExceptionTest.java | 69 ++ ...ngeParallelIteratorRegionSplitterTest.java | 90 +- .../phoenix/end2end/SkipScanQueryTest.java | 50 +- .../phoenix/end2end/SpillableGroupByTest.java | 60 +- .../phoenix/end2end/SpooledOrderByTest.java | 40 + .../phoenix/end2end/StatementHintsTest.java | 44 +- .../apache}/phoenix/end2end/StddevTest.java | 56 +- .../end2end/TenantSpecificTablesDDLTest.java | 90 +- .../end2end/TenantSpecificTablesDMLTest.java | 54 +- .../phoenix/end2end/ToCharFunctionTest.java | 54 +- .../phoenix/end2end/ToNumberFunctionTest.java | 56 +- .../apache}/phoenix/end2end/TopNTest.java | 72 +- .../phoenix/end2end/UpsertBigValuesTest.java | 50 +- .../end2end/UpsertSelectAutoCommitTest.java | 54 +- .../phoenix/end2end/UpsertSelectTest.java | 80 +- .../phoenix/end2end/UpsertValuesTest.java | 62 +- .../phoenix/end2end/VariableLengthPKTest.java | 62 +- .../apache}/phoenix/end2end/ViewTest.java | 50 +- .../end2end/index/BaseMutableIndexTest.java | 56 +- .../phoenix/end2end/index/DropViewTest.java | 60 +- .../end2end/index/ImmutableIndexTest.java | 68 +- .../end2end/index/IndexMetadataTest.java | 76 +- .../phoenix/end2end/index/IndexTestUtil.java | 88 +- .../index/MutableIndexFailureTest.java | 62 +- .../end2end/index/MutableIndexTest.java | 56 +- .../end2end/index/MutableSaltedIndexTest.java | 56 +- .../end2end/salted/SaltedTableTest.java | 60 +- .../salted/SaltedTableUpsertSelectTest.java | 6 +- .../SaltedTableVarLengthRowKeyTest.java | 6 +- .../expression/CoerceExpressionTest.java | 50 +- .../expression/ColumnExpressionTest.java | 56 +- .../DescColumnSortOrderExpressionTest.java | 84 +- .../expression/LikeExpressionTest.java | 44 + .../RoundFloorCeilExpressionsUnitTests.java | 68 +- .../filter/SkipScanFilterIntersectTest.java | 60 +- .../phoenix/filter/SkipScanFilterTest.java | 16 +- .../phoenix/index/IndexMaintainerTest.java | 26 +- .../iterate/AggregateResultScannerTest.java | 92 +- .../iterate/ConcatResultIteratorTest.java | 60 +- .../iterate/MergeSortResultIteratorTest.java | 58 +- .../iterate/SpoolingResultIteratorTest.java | 73 ++ .../jdbc/PhoenixEmbeddedDriverTest.java | 6 +- .../phoenix/jdbc/PhoenixTestDriver.java | 82 ++ .../phoenix/logging/PerformanceLog.java | 48 +- .../phoenix/memory/MemoryManagerTest.java | 50 +- .../phoenix/parse/QueryParserTest.java | 52 +- .../query/BaseConnectionlessQueryTest.java | 105 ++ .../apache}/phoenix/query/BaseTest.java | 104 +- .../query/ConnectionlessUpsertTest.java | 62 +- .../query/HBaseFactoryProviderTest.java | 44 + .../phoenix/query/KeyRangeCoalesceTests.java | 8 +- .../phoenix/query/KeyRangeIntersectTests.java | 8 +- .../phoenix/query/KeyRangeUnionTests.java | 8 +- .../phoenix/query/QueryServicesTestImpl.java | 52 +- .../schema/PDataTypeForArraysTest.java | 42 +- .../apache}/phoenix/schema/PDataTypeTest.java | 46 +- .../phoenix/schema/RowKeySchemaTest.java | 10 +- .../schema/RowKeyValueAccessorTest.java | 10 +- .../apache/phoenix/schema/SchemaUtilTest.java | 59 ++ .../phoenix/schema/ValueBitSetTest.java | 50 +- .../apache}/phoenix/util/AssertResults.java | 52 +- .../org/apache/phoenix/util/ByteUtilTest.java | 70 ++ .../org/apache/phoenix/util/DateUtilTest.java | 64 ++ .../phoenix/util/GeneratePerformanceData.java | 48 +- .../phoenix/util/LikeExpressionTest.java | 42 + .../apache/phoenix/util/MetaDataUtilTest.java | 46 + .../apache}/phoenix/util/ScanUtilTest.java | 64 +- .../apache}/phoenix/util/TestUtil.java | 90 +- phoenix-flume/pom.xml | 10 +- .../phoenix/flume/DefaultKeyGenerator.java | 79 -- .../phoenix/flume/KeyGenerator.java | 34 - .../phoenix/flume/SchemaHandler.java | 57 -- .../flume/serializer/EventSerializer.java | 52 - .../flume/serializer/EventSerializers.java | 46 - .../phoenix/flume/DefaultKeyGenerator.java | 71 ++ .../apache}/phoenix/flume/FlumeConstants.java | 48 +- .../apache/phoenix/flume/KeyGenerator.java | 26 + .../apache/phoenix/flume/SchemaHandler.java | 49 + .../flume/serializer/BaseEventSerializer.java | 76 +- .../flume/serializer/EventSerializer.java | 44 + .../flume/serializer/EventSerializers.java | 38 + .../serializer/RegexEventSerializer.java | 58 +- .../phoenix/flume/sink/PhoenixSink.java | 54 +- .../phoenix/flume/TestPhoenixSink.java | 58 +- .../flume/TestRegexEventSerializer.java | 58 +- phoenix-hadoop-compat/pom.xml | 4 +- phoenix-hadoop1-compat/pom.xml | 6 +- phoenix-hadoop2-compat/pom.xml | 4 +- phoenix-pig/pom.xml | 6 +- .../phoenix/pig/hadoop/PhoenixRecord.java | 99 -- .../pig/hadoop/PhoenixRecordWriter.java | 93 -- .../phoenix/pig/PhoenixHBaseStorage.java | 54 +- .../phoenix/pig/PhoenixPigConfiguration.java | 54 +- .../apache}/phoenix/pig/TypeUtil.java | 50 +- .../pig/hadoop/PhoenixOutputCommitter.java | 50 +- .../pig/hadoop/PhoenixOutputFormat.java | 50 +- .../phoenix/pig/hadoop/PhoenixRecord.java | 91 ++ .../pig/hadoop/PhoenixRecordWriter.java | 85 ++ pom.xml | 76 +- 1170 files changed, 34249 insertions(+), 35455 deletions(-) create mode 100644 LICENSE.txt create mode 100644 NOTICE.txt delete mode 100644 README.md delete mode 100644 license.txt delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/CapturingAbortable.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/ValueGetter.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/builder/IndexBuildingFailureException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/covered/Batch.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/covered/CoveredColumns.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/covered/IndexUpdate.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/covered/KeyValueStore.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/LazyValueGetter.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/LocalHBaseState.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/ColumnTrackingNextLargestTimestampFilter.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/MaxTimestampFilter.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/IndexedColumnGroup.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/exception/IndexWriteException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/exception/MultiIndexWriteFailureException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/exception/SingleIndexWriteFailureException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/EarlyExitFailure.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/QuickFailingTaskRunner.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/Task.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/TaskBatch.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/WaitForCompletionTaskRunner.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/scanner/FilteredKeyValueScanner.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexCommitter.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexFailurePolicy.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/write/KillServerOnFailurePolicy.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/hbase/index/write/recovery/PerRegionIndexWriteCache.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/cache/HashCache.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/cache/TenantCache.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/client/ClientKeyValueBuilder.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/compile/AggregationManager.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/compile/BindManager.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/compile/ColumnProjector.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/compile/ColumnResolver.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/compile/CreateIndexCompiler.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/compile/DropSequenceCompiler.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExplainPlan.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExpressionManager.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExpressionProjector.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/compile/MutationPlan.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/compile/QueryPlan.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/compile/StatementPlan.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/BaseRegionScanner.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/BaseScannerRegionObserver.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/GroupByCache.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/MetaDataRegionObserver.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ServerCachingEndpointImpl.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ServerCachingProtocol.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/exception/PhoenixIOException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/exception/UnknownFunctionException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/exception/ValueTypeIncompatibleException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/execute/CommitException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/execute/DegenerateQueryPlan.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/execute/ScanPlan.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/AddExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/AndExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/ArithmeticExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseAddSubtractExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseSingleExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseTerminalExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/CurrentDateTimeFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/DateAddExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/DateSubtractExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/DecimalDivideExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/DecimalMultiplyExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/DoubleAddExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/DoubleDivideExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/DoubleMultiplyExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/DoubleSubtractExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/Expression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/LongAddExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/LongDivideExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/LongMultiplyExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/LongSubtractExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/NotExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/OrExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/SubtractExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/Aggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/BaseAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/ClientAggregators.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/CountAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DecimalStddevPopAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DecimalStddevSampAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DecimalSumAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DistinctCountClientAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DoubleSumAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/IntSumAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/LongSumAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/MaxAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/StddevPopAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/StddevSampAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/UnsignedIntSumAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/UnsignedLongSumAggregator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/AggregateFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ArrayIndexFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ArrayLengthFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilDateExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilDecimalExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CoalesceFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CompositeAggregateFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CurrentDateFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CurrentTimeFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/DelegateConstantToCountAggregateFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/DistinctValueWithCountAggregateFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FloorDecimalExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FloorFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FunctionExpression.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/IndexStateNameFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/LengthFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/MD5Function.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/MaxAggregateFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/MinAggregateFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PercentRankAggregateFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PercentileContAggregateFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PercentileDiscAggregateFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RoundFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SQLTableTypeFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SQLViewTypeFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ScalarFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SqlTypeNameFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/StddevPopFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/StddevSampFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/TimeUnit.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/TrimFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/TruncFunction.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/KeyValueExpressionVisitor.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/SingleAggregateFunctionVisitor.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/TraverseAllExpressionVisitor.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/TraverseNoExpressionVisitor.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/filter/EvaluateOnCompletionVisitor.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/filter/MultiCQKeyValueComparisonFilter.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/filter/SingleCFCQKeyValueComparisonFilter.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/filter/SingleCQKeyValueComparisonFilter.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/index/BaseIndexCodec.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/index/IndexMetaDataCacheFactory.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/AggregatingResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/BaseResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ConcatResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/DelegateResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/FilterAggregatingResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/FilterResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/LimitingResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/LookAheadResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MergeSortRowKeyResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/OrderedAggregatingResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ParallelIteratorRegionSplitter.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ParallelIteratorRegionSplitterFactory.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/PeekingResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/RegionScannerResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ResultIterators.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ScanningResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/SequenceResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/TableResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/iterate/UngroupedAggregatingResultIterator.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/Jdbc7Shim.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixStatementFactory.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/join/MaxServerCacheSizeExceededException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/memory/DelegatingMemoryManager.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/memory/InsufficientMemoryException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/AddColumnStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/AddParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/AggregateFunctionParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/AliasedNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/AlterIndexStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/AlterTableStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/AndParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/ArithmeticParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/ArrayConstructorNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/AvgAggregateParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/BaseParseNodeVisitor.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/BetweenParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/BinaryParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/BindParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/BindTableNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/BindableStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/CaseParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/CastParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/CeilParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/ColumnFamilyDef.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/ComparisonParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/CompoundParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/ConcreteTableNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/CreateSequenceStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/CurrentDateParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/CurrentTimeParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/DelegateConstantToCountParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/DeleteStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/DerivedTableNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/DistinctCountParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/DivideParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropColumnStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropIndexStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropSequenceStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropTableStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/EqualParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/ExistsParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/ExplainStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/FamilyWildcardParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/FilterableStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/FloorParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/GreaterThanOrEqualParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/GreaterThanParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/InListParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/InParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/IndexKeyConstraint.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/IsNullParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/JoinTableNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/LessThanOrEqualParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/LessThanParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/LikeParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/LimitNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/LiteralParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/MaxAggregateParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/MinAggregateParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/MultiplyParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/NamedParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/NamedTableNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/NotEqualParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/NotParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/OrParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/OrderByNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/OuterJoinParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseContext.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/PrimaryKeyConstraint.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/RoundParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/RowValueConstructorParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/SingleTableSQLStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/StringConcatParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/SubqueryParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/SubtractParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/SumAggregateParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/TableName.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/TableNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/TableNodeVisitor.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/TerminalParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/ToCharParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/ToDateParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/UnaryParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/UpsertStatement.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/parse/WildcardParseNode.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/query/BaseQueryServicesImpl.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/query/ChildQueryServices.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/query/ConfigurationFactory.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/query/DelegateQueryServices.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/query/HBaseFactoryProvider.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/query/HConnectionFactory.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/query/HTableFactory.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/query/MetaDataMutated.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/query/QueryServicesImpl.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/query/StatsManager.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/AmbiguousColumnException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/AmbiguousTableException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/ArgumentTypeMismatchException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnAlreadyExistsException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnFamilyNotFoundException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnNotFoundException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/ConcurrentTableMutationException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/ConstraintViolationException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/DelegateColumn.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/DelegateDatum.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/ExecuteQueryNotApplicableException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/ExecuteUpdateNotApplicableException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/IllegalDataException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/MetaDataEntityNotFoundException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/MetaDataSplitPolicy.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/NewerTableAlreadyExistsException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/PBaseColumn.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumn.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumnFamily.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/PDateColumn.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/PDatum.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/PIntegerColumn.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/PLongColumn.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/PMetaData.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/PName.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/PNormalizedName.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/PRow.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/PStringColumn.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/ReadOnlyTableException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/SequenceAlreadyExistsException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/SequenceNotFoundException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/TableAlreadyExistsException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/TableNotFoundException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/TableRef.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/TypeMismatchException.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/ValueRangeExcpetion.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/stat/PTableStats.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/stat/PTableStatsImpl.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/schema/tuple/MultiKeyValueTuple.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/util/BigDecimalUtil.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/util/NumberUtil.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/util/SQLCloseable.java delete mode 100644 phoenix-core/src/main/java/com/salesforce/phoenix/util/TrustedByteArrayOutputStream.java create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/CapturingAbortable.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/IndexLogRollSynchronizer.java (65%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/Indexer.java (90%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/ValueGetter.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/builder/BaseIndexBuilder.java (55%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/builder/IndexBuildManager.java (77%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/builder/IndexBuilder.java (76%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/builder/IndexBuildingFailureException.java create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/Batch.java create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/CoveredColumns.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/CoveredColumnsIndexBuilder.java (90%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/IndexCodec.java (69%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/IndexUpdate.java create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/KeyValueStore.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/LocalTableState.java (74%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/TableState.java (94%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/data/IndexMemStore.java (84%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/LazyValueGetter.java create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/LocalHBaseState.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/data/LocalTable.java (50%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/example/ColumnGroup.java (97%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/example/CoveredColumn.java (95%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/example/CoveredColumnIndexCodec.java (98%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/example/CoveredColumnIndexSpecifierBuilder.java (95%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/example/CoveredColumnIndexer.java (95%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java (84%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/ColumnTrackingNextLargestTimestampFilter.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/filter/FamilyOnlyFilter.java (97%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/MaxTimestampFilter.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/filter/NewerTimestampFilter.java (95%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/update/ColumnReference.java (69%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/update/ColumnTracker.java (59%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/update/IndexUpdateManager.java (79%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/IndexedColumnGroup.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/update/SortedCollection.java (56%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/exception/IndexWriteException.java create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/exception/MultiIndexWriteFailureException.java create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/exception/SingleIndexWriteFailureException.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/parallel/BaseTaskRunner.java (69%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/EarlyExitFailure.java create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/QuickFailingTaskRunner.java create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/Task.java create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/TaskBatch.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/parallel/TaskRunner.java (51%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/parallel/ThreadPoolBuilder.java (55%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/parallel/ThreadPoolManager.java (74%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/WaitForCompletionTaskRunner.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/scanner/EmptyScanner.java (91%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/scanner/FilteredKeyValueScanner.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/scanner/Scanner.java (96%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/scanner/ScannerBuilder.java (91%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/table/CachingHTableFactory.java (61%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/table/CoprocessorHTableFactory.java (91%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/table/HTableFactory.java (68%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/table/HTableInterfaceReference.java (90%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/util/ImmutableBytesPtr.java (58%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/util/IndexManagementUtil.java (82%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/wal/IndexedKeyValue.java (98%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/wal/KeyValueCodec.java (98%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexCommitter.java create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexFailurePolicy.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/write/IndexWriter.java (79%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/write/IndexWriterUtils.java (58%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/KillServerOnFailurePolicy.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/write/ParallelWriterIndexCommitter.java (76%) create mode 100644 phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/recovery/PerRegionIndexWriteCache.java rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/write/recovery/StoreFailuresInCachePolicy.java (89%) rename phoenix-core/src/main/java/{com/salesforce => org/apache/hadoop}/hbase/index/write/recovery/TrackingParallelWriterIndexCommitter.java (74%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/cache/GlobalCache.java (62%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/cache/HashCache.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/cache/IndexMetaDataCache.java (64%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/cache/ServerCacheClient.java (81%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCache.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/cache/TenantCacheImpl.java (54%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/cache/aggcache/SpillFile.java (99%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/cache/aggcache/SpillManager.java (80%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/cache/aggcache/SpillMap.java (99%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/cache/aggcache/SpillableGroupByCache.java (92%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/client/ClientKeyValue.java (99%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/client/ClientKeyValueBuilder.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/client/GenericKeyValueBuilder.java (51%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/client/KeyValueBuilder.java (66%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/compile/AggregationManager.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/compile/BindManager.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/compile/ColumnProjector.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/compile/ColumnResolver.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/compile/CreateIndexCompiler.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/CreateSequenceCompiler.java (72%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/CreateTableCompiler.java (71%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/DeleteCompiler.java (79%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/compile/DropSequenceCompiler.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/compile/ExplainPlan.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/ExpressionCompiler.java (91%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionManager.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionProjector.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/FromCompiler.java (84%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/GroupByCompiler.java (80%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/HavingCompiler.java (69%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/IndexStatementRewriter.java (86%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/JoinCompiler.java (91%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/KeyPart.java (50%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/LimitCompiler.java (60%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/MutatingParallelIteratorFactory.java (51%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/OrderByCompiler.java (63%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/PostDDLCompiler.java (77%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/PostIndexDDLCompiler.java (66%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/ProjectionCompiler.java (82%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/QueryCompiler.java (79%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/RowProjector.java (66%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/ScanRanges.java (73%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/SequenceManager.java (72%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/StatementContext.java (74%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/StatementNormalizer.java (58%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/compile/StatementPlan.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/TrackOrderPreservingExpressionCompiler.java (85%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/UpsertCompiler.java (90%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/WhereCompiler.java (68%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/compile/WhereOptimizer.java (93%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseRegionScanner.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupByCache.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/coprocessor/GroupedAggregateRegionObserver.java (87%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/coprocessor/HashJoinRegionScanner.java (78%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/coprocessor/MetaDataEndpointImpl.java (92%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/coprocessor/MetaDataProtocol.java (81%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/coprocessor/ScanProjector.java (80%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/coprocessor/ScanRegionObserver.java (81%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/coprocessor/SequenceRegionObserver.java (96%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ServerCachingEndpointImpl.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ServerCachingProtocol.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/coprocessor/UngroupedAggregateRegionObserver.java (83%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/exception/PhoenixIOException.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/exception/PhoenixParserException.java (68%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/exception/SQLExceptionCode.java (85%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/exception/SQLExceptionInfo.java (68%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/exception/UnknownFunctionException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/exception/ValueTypeIncompatibleException.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/execute/AggregatePlan.java (59%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/execute/BasicQueryPlan.java (65%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/execute/CommitException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/execute/DegenerateQueryPlan.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/execute/HashJoinPlan.java (63%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/execute/MutationState.java (87%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/AddExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/AndExpression.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/AndOrExpression.java (54%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/ArithmeticExpression.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/ArrayConstructorExpression.java (55%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/BaseAddSubtractExpression.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/BaseCompoundExpression.java (65%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/BaseDecimalAddSubtractExpression.java (54%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/BaseExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/BaseSingleExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/BaseTerminalExpression.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/CaseExpression.java (77%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/CoerceExpression.java (66%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/ColumnExpression.java (67%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/ComparisonExpression.java (67%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/CurrentDateTimeFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/DateAddExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/DateSubtractExpression.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/DecimalAddExpression.java (52%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalDivideExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalMultiplyExpression.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/DecimalSubtractExpression.java (58%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/DivideExpression.java (52%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/DoubleAddExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/DoubleDivideExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/DoubleMultiplyExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/DoubleSubtractExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/Expression.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/ExpressionType.java (53%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/InListExpression.java (82%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/IndexKeyValueColumnExpression.java (79%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/IsNullExpression.java (50%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/KeyValueColumnExpression.java (52%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/LikeExpression.java (82%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/LiteralExpression.java (82%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/LongAddExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/LongDivideExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/LongMultiplyExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/LongSubtractExpression.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/MultiplyExpression.java (51%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/NotExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/OrExpression.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/OrderByExpression.java (98%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/ProjectedColumnExpression.java (58%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/RowKeyColumnExpression.java (66%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/RowKeyExpression.java (77%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/RowValueConstructorExpression.java (85%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/StringConcatExpression.java (50%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/SubtractExpression.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/TimestampAddExpression.java (52%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/TimestampSubtractExpression.java (53%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/Aggregator.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/aggregator/Aggregators.java (59%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseAggregator.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/aggregator/BaseDecimalStddevAggregator.java (62%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/aggregator/BaseStddevAggregator.java (50%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/ClientAggregators.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/CountAggregator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DecimalStddevPopAggregator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DecimalStddevSampAggregator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DecimalSumAggregator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DistinctCountClientAggregator.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/aggregator/DistinctValueWithCountClientAggregator.java (65%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/aggregator/DistinctValueWithCountServerAggregator.java (75%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DoubleSumAggregator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/IntSumAggregator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/LongSumAggregator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/MaxAggregator.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/aggregator/MinAggregator.java (53%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/aggregator/NumberSumAggregator.java (51%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/aggregator/PercentRankClientAggregator.java (53%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/aggregator/PercentileClientAggregator.java (58%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/aggregator/PercentileDiscClientAggregator.java (56%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/aggregator/ServerAggregators.java (69%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/StddevPopAggregator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/StddevSampAggregator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/UnsignedIntSumAggregator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/UnsignedLongSumAggregator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/AggregateFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/ArrayIndexFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/ArrayLengthFunction.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/AvgAggregateFunction.java (57%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilDateExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilDecimalExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilFunction.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/CeilTimestampExpression.java (59%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/CoalesceFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/CompositeAggregateFunction.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/CountAggregateFunction.java (51%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/CurrentDateFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/CurrentTimeFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/DelegateConstantToCountAggregateFunction.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/DistinctCountAggregateFunction.java (56%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/DistinctValueWithCountAggregateFunction.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/FloorDateExpression.java (52%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/FloorDecimalExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/FloorFunction.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/FunctionArgumentType.java (89%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/FunctionExpression.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/IndexStateNameFunction.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/InvertFunction.java (53%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/LTrimFunction.java (53%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/LengthFunction.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/LowerFunction.java (83%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/MD5Function.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/MaxAggregateFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/MinAggregateFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/PercentRankAggregateFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/PercentileContAggregateFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/PercentileDiscAggregateFunction.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/PrefixFunction.java (88%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/RTrimFunction.java (63%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/RegexpReplaceFunction.java (58%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/RegexpSubstrFunction.java (69%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/ReverseFunction.java (79%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/RoundDateExpression.java (78%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/RoundDecimalExpression.java (61%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/RoundFunction.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/RoundTimestampExpression.java (59%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/SQLTableTypeFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/SQLViewTypeFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/ScalarFunction.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/SingleAggregateFunction.java (70%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/SqlTypeNameFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/StddevPopFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/StddevSampFunction.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/SubstrFunction.java (75%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/SumAggregateFunction.java (59%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/TimeUnit.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/ToCharFunction.java (61%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/ToDateFunction.java (60%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/ToNumberFunction.java (69%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/TrimFunction.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/function/TruncFunction.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/function/UpperFunction.java (83%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/visitor/BaseExpressionVisitor.java (59%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/expression/visitor/ExpressionVisitor.java (54%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/KeyValueExpressionVisitor.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/SingleAggregateFunctionVisitor.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/TraverseAllExpressionVisitor.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/TraverseNoExpressionVisitor.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/filter/BooleanExpressionFilter.java (56%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/filter/EvaluateOnCompletionVisitor.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/filter/MultiCFCQKeyValueComparisonFilter.java (68%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/filter/MultiCQKeyValueComparisonFilter.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/filter/MultiKeyValueComparisonFilter.java (80%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/filter/RowKeyComparisonFilter.java (67%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/filter/SingleCFCQKeyValueComparisonFilter.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/filter/SingleCQKeyValueComparisonFilter.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/filter/SingleKeyValueComparisonFilter.java (69%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/filter/SkipScanFilter.java (90%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/index/BaseIndexCodec.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/index/IndexMaintainer.java (92%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/index/IndexMetaDataCacheClient.java (56%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/index/IndexMetaDataCacheFactory.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/index/PhoenixIndexBuilder.java (59%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/index/PhoenixIndexCodec.java (71%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/index/PhoenixIndexFailurePolicy.java (60%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/AggregatingResultIterator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/ConcatResultIterator.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/iterate/DefaultParallelIteratorRegionSplitter.java (81%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/DelegateResultIterator.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/iterate/DistinctAggregatingResultIterator.java (67%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/iterate/ExplainTable.java (80%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/FilterAggregatingResultIterator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/FilterResultIterator.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/iterate/GroupedAggregatingResultIterator.java (52%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/LimitingResultIterator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/LookAheadResultIterator.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/iterate/MappedByteBufferSortedQueue.java (87%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/iterate/MaterializedResultIterator.java (53%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/iterate/MergeSortResultIterator.java (52%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortRowKeyResultIterator.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/iterate/MergeSortTopNResultIterator.java (55%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/OrderedAggregatingResultIterator.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/iterate/OrderedResultIterator.java (81%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIteratorRegionSplitter.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIteratorRegionSplitterFactory.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/iterate/ParallelIterators.java (76%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/PeekingResultIterator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/RegionScannerResultIterator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/ResultIterator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/ResultIterators.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/SequenceResultIterator.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/iterate/SkipRangeParallelIteratorRegionSplitter.java (56%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/iterate/SpoolTooBigToDiskException.java (70%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/iterate/SpoolingResultIterator.java (81%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/TableResultIterator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/iterate/UngroupedAggregatingResultIterator.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/jdbc/Jdbc7Shim.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/jdbc/PhoenixConnection.java (87%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/jdbc/PhoenixDatabaseMetaData.java (93%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/jdbc/PhoenixDriver.java (60%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/jdbc/PhoenixEmbeddedDriver.java (84%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/jdbc/PhoenixParameterMetaData.java (67%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/jdbc/PhoenixPreparedStatement.java (87%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/jdbc/PhoenixResultSet.java (94%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/jdbc/PhoenixResultSetMetaData.java (75%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/jdbc/PhoenixStatement.java (88%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatementFactory.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/job/AbstractRoundRobinQueue.java (84%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/job/JobManager.java (66%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/join/HashCacheClient.java (65%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/join/HashCacheFactory.java (64%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/join/HashJoinInfo.java (76%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/join/MaxServerCacheSizeExceededException.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/join/ScanProjector.java (77%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/map/reduce/CSVBulkLoader.java (86%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/map/reduce/MapReduceJob.java (76%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/map/reduce/util/ConfigReader.java (54%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/memory/ChildMemoryManager.java (67%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/memory/DelegatingMemoryManager.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/memory/GlobalMemoryManager.java (76%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/memory/InsufficientMemoryException.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/memory/MemoryManager.java (58%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/optimize/QueryOptimizer.java (91%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/AddColumnStatement.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/AddParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/AggregateFunctionParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/AliasedNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/AlterIndexStatement.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/AlterTableStatement.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/AndParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/ArithmeticParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/ArrayConstructorNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/AvgAggregateParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/BaseParseNodeVisitor.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/BetweenParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/BinaryParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/BindParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/BindTableNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/BindableStatement.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/CaseParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/CastParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/CeilParseNode.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/ColumnDef.java (75%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnFamilyDef.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/ColumnName.java (57%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/ColumnParseNode.java (50%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/ComparisonParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/CompoundParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/ConcreteTableNode.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/CreateIndexStatement.java (50%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/CreateSequenceStatement.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/CreateTableStatement.java (58%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentDateParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentTimeParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/DelegateConstantToCountParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/DeleteStatement.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/DerivedTableNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/DistinctCountParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/DivideParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/DropColumnStatement.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/DropIndexStatement.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/DropSequenceStatement.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/DropTableStatement.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/EqualParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/ExistsParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/ExplainStatement.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/FamilyWildcardParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/FilterableStatement.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/FloorParseNode.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/FunctionParseNode.java (87%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/GreaterThanOrEqualParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/GreaterThanParseNode.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/HintNode.java (72%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/InListParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/InParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/IndexKeyConstraint.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/IsNullParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/JoinTableNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/LessThanOrEqualParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/LessThanParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/LikeParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/LimitNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/LiteralParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/MaxAggregateParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/MinAggregateParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/MultiplyParseNode.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/NamedNode.java (92%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/NamedParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/NamedTableNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/NotEqualParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/NotParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/OrParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/OrderByNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/OuterJoinParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/ParseContext.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/ParseException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNode.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/ParseNodeFactory.java (87%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/ParseNodeRewriter.java (91%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/ParseNodeVisitor.java (69%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/PrimaryKeyConstraint.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/PropertyName.java (87%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/RoundParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/RowValueConstructorParseNode.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/SQLParser.java (77%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/SelectStatement.java (73%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/SelectStatementRewriter.java (76%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/SequenceValueParseNode.java (94%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/SingleTableSQLStatement.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/StatelessTraverseAllParseNodeVisitor.java (98%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/StringConcatParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/SubqueryParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/SubtractParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/SumAggregateParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/TableName.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/TableNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/TableNodeVisitor.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/TerminalParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/ToCharParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/ToDateParseNode.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/ToNumberParseNode.java (77%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/TraverseAllParseNodeVisitor.java (63%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/TraverseNoParseNodeVisitor.java (74%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/UnaryParseNode.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/parse/UnsupportedAllParseNodeVisitor.java (78%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/UpsertStatement.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/parse/WildcardParseNode.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/query/BaseQueryServicesImpl.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/query/ChildQueryServices.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/query/ConfigurationFactory.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/query/ConnectionQueryServices.java (64%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/query/ConnectionQueryServicesImpl.java (93%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/query/ConnectionlessQueryServicesImpl.java (78%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/query/DelegateConnectionQueryServices.java (75%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/query/DelegateQueryServices.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/query/HBaseFactoryProvider.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/query/HConnectionFactory.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/query/HTableFactory.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/query/KeyRange.java (91%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/query/MetaDataMutated.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/query/QueryConstants.java (51%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/query/QueryServices.java (70%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesImpl.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/query/QueryServicesOptions.java (75%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/query/StatsManager.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/query/StatsManagerImpl.java (79%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/AmbiguousColumnException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/AmbiguousTableException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/ArgumentTypeMismatchException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnAlreadyExistsException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnFamilyNotFoundException.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/ColumnModifier.java (72%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnNotFoundException.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/ColumnRef.java (60%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/ConcurrentTableMutationException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/ConstraintViolationException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateColumn.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateDatum.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/EmptySequenceCacheException.java (79%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/ExecuteQueryNotApplicableException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/ExecuteUpdateNotApplicableException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/IllegalDataException.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/KeyValueSchema.java (79%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/MetaDataClient.java (93%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataEntityNotFoundException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataSplitPolicy.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/NewerTableAlreadyExistsException.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/PArrayDataType.java (87%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/PBaseColumn.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/PColumn.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnFamily.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/PColumnFamilyImpl.java (50%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/PColumnImpl.java (76%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/PDataType.java (99%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/PDateColumn.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/PDatum.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/PIndexState.java (56%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/PIntegerColumn.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/PLongColumn.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaData.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/PMetaDataImpl.java (80%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/PName.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/PNameFactory.java (87%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/PNameImpl.java (96%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/PNormalizedName.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/PRow.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/PStringColumn.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/PTable.java (77%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/PTableImpl.java (93%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/PTableType.java (63%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/PhoenixArray.java (86%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/ReadOnlyTableException.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/RowKeySchema.java (82%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/RowKeyValueAccessor.java (77%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/SaltingUtil.java (76%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/Sequence.java (95%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceAlreadyExistsException.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/SequenceKey.java (50%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceNotFoundException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/TableAlreadyExistsException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/TableNotFoundException.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/TypeMismatchException.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/ValueBitSet.java (77%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/ValueRangeExcpetion.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/ValueSchema.java (85%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/stat/PTableStats.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/stat/PTableStatsImpl.java create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/MultiKeyValueTuple.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/tuple/ResultTuple.java (51%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/tuple/SingleKeyValueTuple.java (59%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/schema/tuple/Tuple.java (56%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/util/BigDecimalUtil.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/BitSet.java (98%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/ByteUtil.java (90%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/CSVLoader.java (80%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/Closeables.java (66%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/ColumnInfo.java (91%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/DateUtil.java (71%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/IndexUtil.java (76%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/InstanceResolver.java (50%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/JDBCUtil.java (51%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/KeyValueUtil.java (74%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/MetaDataUtil.java (82%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/util/NumberUtil.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/PhoenixRuntime.java (86%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/QueryUtil.java (98%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/ReadOnlyProps.java (99%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/ResultUtil.java (77%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/util/SQLCloseable.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/SQLCloseables.java (68%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/ScanUtil.java (88%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/SchemaUtil.java (89%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/ServerUtil.java (69%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/SizedUtil.java (54%) rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/StringUtil.java (82%) create mode 100644 phoenix-core/src/main/java/org/apache/phoenix/util/TrustedByteArrayOutputStream.java rename phoenix-core/src/main/java/{com/salesforce => org/apache}/phoenix/util/TupleUtil.java (71%) create mode 100644 phoenix-core/src/site/bin/merge.jar create mode 100755 phoenix-core/src/site/bin/merge.sh create mode 100644 phoenix-core/src/site/language_reference_source/datatypes.html create mode 100644 phoenix-core/src/site/language_reference_source/functions.html create mode 100644 phoenix-core/src/site/language_reference_source/index.html create mode 100644 phoenix-core/src/site/markdown/Phoenix-in-15-minutes-or-less.md create mode 100644 phoenix-core/src/site/markdown/building.md create mode 100644 phoenix-core/src/site/markdown/download.md create mode 100644 phoenix-core/src/site/markdown/dynamic_columns.md create mode 100644 phoenix-core/src/site/markdown/faq.md create mode 100644 phoenix-core/src/site/markdown/flume.md create mode 100644 phoenix-core/src/site/markdown/index.md create mode 100644 phoenix-core/src/site/markdown/issues.md create mode 100644 phoenix-core/src/site/markdown/mailing_list.md create mode 100644 phoenix-core/src/site/markdown/mr_dataload.md create mode 100644 phoenix-core/src/site/markdown/paged.md create mode 100644 phoenix-core/src/site/markdown/performance.md create mode 100644 phoenix-core/src/site/markdown/phoenix_on_emr.md create mode 100644 phoenix-core/src/site/markdown/recent.md create mode 100644 phoenix-core/src/site/markdown/roadmap.md create mode 100644 phoenix-core/src/site/markdown/salted.md create mode 100644 phoenix-core/src/site/markdown/secondary_indexing.md create mode 100644 phoenix-core/src/site/markdown/sequences.md create mode 100644 phoenix-core/src/site/markdown/skip_scan.md create mode 100644 phoenix-core/src/site/markdown/source.md create mode 100644 phoenix-core/src/site/markdown/tuning.md create mode 100644 phoenix-core/src/site/resources/css/site.css create mode 100644 phoenix-core/src/site/resources/favicon.ico create mode 100644 phoenix-core/src/site/resources/images/PhoenixVsHive.png create mode 100644 phoenix-core/src/site/resources/images/PhoenixVsImpala.png create mode 100644 phoenix-core/src/site/resources/images/PhoenixVsOpenTSDB.png create mode 100644 phoenix-core/src/site/resources/images/logo.png create mode 100644 phoenix-core/src/site/resources/images/perf-esscf.png create mode 100644 phoenix-core/src/site/resources/images/perf-salted-read.png create mode 100644 phoenix-core/src/site/resources/images/perf-salted-write.png create mode 100644 phoenix-core/src/site/resources/images/perf-skipscan.png create mode 100644 phoenix-core/src/site/resources/images/perf-topn.png create mode 100644 phoenix-core/src/site/resources/images/psql.png create mode 100644 phoenix-core/src/site/resources/images/sqlline.png create mode 100644 phoenix-core/src/site/resources/images/squirrel.png create mode 100644 phoenix-core/src/site/resources/images/topbar-logo-small.png create mode 100644 phoenix-core/src/site/resources/images/topbar-logo.png create mode 100644 phoenix-core/src/site/resources/language/images/div-d.png create mode 100644 phoenix-core/src/site/resources/language/images/div-ke.png create mode 100644 phoenix-core/src/site/resources/language/images/div-ks.png create mode 100644 phoenix-core/src/site/resources/language/images/div-le.png create mode 100644 phoenix-core/src/site/resources/language/images/div-ls.png create mode 100644 phoenix-core/src/site/resources/language/images/div-te.png create mode 100644 phoenix-core/src/site/resources/language/images/div-ts.png create mode 100644 phoenix-core/src/site/resources/language/stylesheet.css create mode 100644 phoenix-core/src/site/site.xml create mode 100644 phoenix-core/src/site/xhtml/language/datatypes.xhtml create mode 100644 phoenix-core/src/site/xhtml/language/functions.xhtml create mode 100644 phoenix-core/src/site/xhtml/language/index.xhtml create mode 100644 phoenix-core/src/site/xhtml/team.xhtml delete mode 100644 phoenix-core/src/test/java/com/salesforce/hbase/index/StubAbortable.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/hbase/index/TableName.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/hbase/index/covered/CoveredIndexCodecForTesting.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/hbase/index/covered/TestCoveredColumns.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/hbase/index/covered/example/TestColumnTracker.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/hbase/index/covered/example/TestEndtoEndIndexingWithCompression.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/hbase/index/covered/filter/TestNewerTimestampFilter.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/hbase/index/parallel/TestThreadPoolBuilder.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/hbase/index/write/TestCachingHTableFactory.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/compile/JoinQueryCompileTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/end2end/BaseClientManagedTimeTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/end2end/BaseHBaseManagedTimeTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/end2end/CoalesceFunctionTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/end2end/InMemoryOrderByTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/end2end/IsNullTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/end2end/QueryExecWithoutSCNTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/end2end/ServerExceptionTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/end2end/SpooledOrderByTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/expression/LikeExpressionTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/iterate/SpoolingResultIteratorTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/jdbc/PhoenixTestDriver.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/query/BaseConnectionlessQueryTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/query/HBaseFactoryProviderTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/schema/SchemaUtilTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/util/ByteUtilTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/util/DateUtilTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/util/LikeExpressionTest.java delete mode 100644 phoenix-core/src/test/java/com/salesforce/phoenix/util/MetaDataUtilTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/IndexTestingUtils.java (62%) create mode 100644 phoenix-core/src/test/java/org/apache/hadoop/hbase/index/StubAbortable.java create mode 100644 phoenix-core/src/test/java/org/apache/hadoop/hbase/index/TableName.java rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/TestFailForUnsupportedHBaseVersions.java (73%) create mode 100644 phoenix-core/src/test/java/org/apache/hadoop/hbase/index/covered/CoveredIndexCodecForTesting.java create mode 100644 phoenix-core/src/test/java/org/apache/hadoop/hbase/index/covered/TestCoveredColumns.java rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/TestEndToEndCoveredColumnsIndexBuilder.java (84%) rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/TestLocalTableState.java (77%) rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/data/TestIndexMemStore.java (63%) create mode 100644 phoenix-core/src/test/java/org/apache/hadoop/hbase/index/covered/example/TestColumnTracker.java rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/example/TestCoveredColumnIndexCodec.java (80%) rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/example/TestCoveredIndexSpecifierBuilder.java (55%) rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/example/TestEndToEndCoveredIndexing.java (94%) create mode 100644 phoenix-core/src/test/java/org/apache/hadoop/hbase/index/covered/example/TestEndtoEndIndexingWithCompression.java rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/example/TestFailWithoutRetries.java (67%) rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/filter/TestApplyAndFilterDeletesFilter.java (81%) rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/filter/TestFamilyOnlyFilter.java (62%) create mode 100644 phoenix-core/src/test/java/org/apache/hadoop/hbase/index/covered/filter/TestNewerTimestampFilter.java rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/covered/update/TestIndexUpdateManager.java (71%) create mode 100644 phoenix-core/src/test/java/org/apache/hadoop/hbase/index/parallel/TestThreadPoolBuilder.java rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/parallel/TestThreadPoolManager.java (63%) rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/util/TestIndexManagementUtil.java (51%) rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/write/FakeTableFactory.java (81%) create mode 100644 phoenix-core/src/test/java/org/apache/hadoop/hbase/index/write/TestCachingHTableFactory.java rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/write/TestIndexWriter.java (84%) rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/write/TestParalleIndexWriter.java (66%) rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/write/TestParalleWriterIndexCommitter.java (66%) rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/write/TestWALRecoveryCaching.java (84%) rename phoenix-core/src/test/java/{com/salesforce => org/apache/hadoop}/hbase/index/write/recovery/TestPerRegionIndexWriteCache.java (74%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/arithmetic/ArithmeticOperationTest.java (87%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/client/TestClientKeyValue.java (76%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/client/TestClientKeyValueLocal.java (99%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/compile/HavingClauseTest.java (74%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/compile/JoinQueryCompileTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/compile/LimitClauseTest.java (71%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/compile/QueryCompileTest.java (95%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/compile/QueryMetaDataTest.java (92%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/compile/QueryOptimizerTest.java (87%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/compile/ScanRangesTest.java (92%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/compile/SelectStatementRewriterTest.java (63%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/compile/StatementHintsCompilationTest.java (67%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/compile/ViewCompileTest.java (65%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/compile/WhereClauseCompileTest.java (91%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/compile/WhereClauseOptimizerTest.java (96%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/AlterTableTest.java (93%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/ArithmeticQueryTest.java (93%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/ArrayTest.java (93%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/AutoCommitTest.java (52%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/end2end/BaseClientManagedTimeTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/BaseConnectedQueryTest.java (85%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/BaseTenantSpecificTablesTest.java (60%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/BinaryRowKeyTest.java (71%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/CSVLoaderTest.java (86%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/end2end/CoalesceFunctionTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/CompareDecimalToLongTest.java (82%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/ConnectionQueryServicesTestImpl.java (53%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/CreateTableTest.java (65%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/CustomEntityDataTest.java (79%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/DefaultParallelIteratorsRegionSplitterTest.java (82%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/DeleteTest.java (87%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/DescColumnSortOrderTest.java (93%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/DistinctCountTest.java (88%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/DynamicColumnTest.java (76%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/DynamicFamilyTest.java (87%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/DynamicUpsertTest.java (79%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/ExecuteStatementsTest.java (84%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/ExtendedQueryExecTest.java (75%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/FunkyNamesTest.java (70%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/GroupByCaseTest.java (76%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/HashJoinTest.java (96%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/end2end/InMemoryOrderByTest.java create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/end2end/IsNullTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/KeyOnlyTest.java (68%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/MD5FunctionTest.java (59%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/MultiCfQueryExecTest.java (81%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/NativeHBaseTypesTest.java (83%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/OrderByTest.java (55%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/PercentileTest.java (92%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/ProductMetricsTest.java (97%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/QueryDatabaseMetaDataTest.java (92%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/end2end/QueryExecWithoutSCNTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/QueryPlanTest.java (84%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/QueryTest.java (97%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/ReadIsolationLevelTest.java (73%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/ReverseFunctionTest.java (64%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/RoundFloorCeilFunctionsEnd2EndTest.java (88%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/RowValueConstructorTest.java (92%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/SequenceTest.java (97%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/end2end/ServerExceptionTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/SkipRangeParallelIteratorRegionSplitterTest.java (84%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/SkipScanQueryTest.java (80%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/SpillableGroupByTest.java (64%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/end2end/SpooledOrderByTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/StatementHintsTest.java (72%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/StddevTest.java (69%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/TenantSpecificTablesDDLTest.java (86%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/TenantSpecificTablesDMLTest.java (89%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/ToCharFunctionTest.java (81%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/ToNumberFunctionTest.java (83%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/TopNTest.java (66%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/UpsertBigValuesTest.java (89%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/UpsertSelectAutoCommitTest.java (54%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/UpsertSelectTest.java (91%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/UpsertValuesTest.java (87%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/VariableLengthPKTest.java (97%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/ViewTest.java (75%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/index/BaseMutableIndexTest.java (70%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/index/DropViewTest.java (59%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/index/ImmutableIndexTest.java (89%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/index/IndexMetadataTest.java (88%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/index/IndexTestUtil.java (67%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/index/MutableIndexFailureTest.java (64%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/index/MutableIndexTest.java (93%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/index/MutableSaltedIndexTest.java (78%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/salted/SaltedTableTest.java (90%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/salted/SaltedTableUpsertSelectTest.java (97%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/end2end/salted/SaltedTableVarLengthRowKeyTest.java (91%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/expression/CoerceExpressionTest.java (67%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/expression/ColumnExpressionTest.java (66%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/expression/DescColumnSortOrderExpressionTest.java (82%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/expression/LikeExpressionTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/expression/RoundFloorCeilExpressionsUnitTests.java (77%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/filter/SkipScanFilterIntersectTest.java (92%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/filter/SkipScanFilterTest.java (97%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/index/IndexMaintainerTest.java (94%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/iterate/AggregateResultScannerTest.java (57%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/iterate/ConcatResultIteratorTest.java (68%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/iterate/MergeSortResultIteratorTest.java (53%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/iterate/SpoolingResultIteratorTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/jdbc/PhoenixEmbeddedDriverTest.java (96%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/logging/PerformanceLog.java (60%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/memory/MemoryManagerTest.java (83%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/parse/QueryParserTest.java (93%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/query/BaseConnectionlessQueryTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/query/BaseTest.java (84%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/query/ConnectionlessUpsertTest.java (75%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/query/HBaseFactoryProviderTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/query/KeyRangeCoalesceTests.java (96%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/query/KeyRangeIntersectTests.java (92%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/query/KeyRangeUnionTests.java (92%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/query/QueryServicesTestImpl.java (61%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/schema/PDataTypeForArraysTest.java (90%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/schema/PDataTypeTest.java (97%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/schema/RowKeySchemaTest.java (95%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/schema/RowKeyValueAccessorTest.java (92%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/schema/SchemaUtilTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/schema/ValueBitSetTest.java (70%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/util/AssertResults.java (64%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/util/ByteUtilTest.java create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/util/DateUtilTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/util/GeneratePerformanceData.java (50%) create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/util/LikeExpressionTest.java create mode 100644 phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/util/ScanUtilTest.java (87%) rename phoenix-core/src/test/java/{com/salesforce => org/apache}/phoenix/util/TestUtil.java (80%) delete mode 100644 phoenix-flume/src/main/java/com/salesforce/phoenix/flume/DefaultKeyGenerator.java delete mode 100644 phoenix-flume/src/main/java/com/salesforce/phoenix/flume/KeyGenerator.java delete mode 100644 phoenix-flume/src/main/java/com/salesforce/phoenix/flume/SchemaHandler.java delete mode 100644 phoenix-flume/src/main/java/com/salesforce/phoenix/flume/serializer/EventSerializer.java delete mode 100644 phoenix-flume/src/main/java/com/salesforce/phoenix/flume/serializer/EventSerializers.java create mode 100644 phoenix-flume/src/main/java/org/apache/phoenix/flume/DefaultKeyGenerator.java rename phoenix-flume/src/main/java/{com/salesforce => org/apache}/phoenix/flume/FlumeConstants.java (53%) create mode 100644 phoenix-flume/src/main/java/org/apache/phoenix/flume/KeyGenerator.java create mode 100644 phoenix-flume/src/main/java/org/apache/phoenix/flume/SchemaHandler.java rename phoenix-flume/src/main/java/{com/salesforce => org/apache}/phoenix/flume/serializer/BaseEventSerializer.java (75%) create mode 100644 phoenix-flume/src/main/java/org/apache/phoenix/flume/serializer/EventSerializer.java create mode 100644 phoenix-flume/src/main/java/org/apache/phoenix/flume/serializer/EventSerializers.java rename phoenix-flume/src/main/java/{com/salesforce => org/apache}/phoenix/flume/serializer/RegexEventSerializer.java (67%) rename phoenix-flume/src/main/java/{com/salesforce => org/apache}/phoenix/flume/sink/PhoenixSink.java (78%) rename phoenix-flume/src/test/java/{com/salesforce => org/apache}/phoenix/flume/TestPhoenixSink.java (77%) rename phoenix-flume/src/test/java/{com/salesforce => org/apache}/phoenix/flume/TestRegexEventSerializer.java (87%) delete mode 100644 phoenix-pig/src/main/java/com/salesforce/phoenix/pig/hadoop/PhoenixRecord.java delete mode 100644 phoenix-pig/src/main/java/com/salesforce/phoenix/pig/hadoop/PhoenixRecordWriter.java rename phoenix-pig/src/main/java/{com/salesforce => org/apache}/phoenix/pig/PhoenixHBaseStorage.java (72%) rename phoenix-pig/src/main/java/{com/salesforce => org/apache}/phoenix/pig/PhoenixPigConfiguration.java (67%) rename phoenix-pig/src/main/java/{com/salesforce => org/apache}/phoenix/pig/TypeUtil.java (71%) rename phoenix-pig/src/main/java/{com/salesforce => org/apache}/phoenix/pig/hadoop/PhoenixOutputCommitter.java (57%) rename phoenix-pig/src/main/java/{com/salesforce => org/apache}/phoenix/pig/hadoop/PhoenixOutputFormat.java (54%) create mode 100644 phoenix-pig/src/main/java/org/apache/phoenix/pig/hadoop/PhoenixRecord.java create mode 100644 phoenix-pig/src/main/java/org/apache/phoenix/pig/hadoop/PhoenixRecordWriter.java diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/NOTICE.txt b/NOTICE.txt new file mode 100644 index 00000000..08364793 --- /dev/null +++ b/NOTICE.txt @@ -0,0 +1,25 @@ +This product includes software developed by The Apache Software +Foundation (http://www.apache.org/). + +It includes software from other Apache Software Foundation projects, +including, but not limited to: + - Apache HBase + - Apache Hadoop + - Apache Commons + +In addition, this product includes/uses software developed by: + +JLine (http://jline.sourceforge.net/), +Copyright (c) 2002-2006, Marc Prud'hommeaux . + +SQLLine ((http://jline.sourceforge.net/), +Copyright (c) 2002-2006, Marc Prud'hommeaux . + +SLF4J (http://www.slf4j.org/), +Copyright (c) 2004-2008 QOS.ch + +ANTLR (http://www.antlr.org/), +Copyright (c) 2003-2008, Terrence Parr. + +JUnit (http://www.junit.org/) included under the Common Public License v1.0. +See the full text here: http://junit.sourceforge.net/cpl-v10.html diff --git a/README.md b/README.md deleted file mode 100644 index cb1ade73..00000000 --- a/README.md +++ /dev/null @@ -1,136 +0,0 @@ -![logo](http://forcedotcom.github.com/phoenix/images/logo.jpg) - -Phoenix is a SQL skin over HBase, delivered as a client-embedded JDBC driver, powering the HBase use cases at Salesforce.com. Phoenix targets low-latency queries (milliseconds), as opposed to batch operation via map/reduce. To see what's supported, go to our [language reference guide](http://forcedotcom.github.com/phoenix/), read more on our [wiki](https://github.com/forcedotcom/phoenix/wiki), and download it [here](https://github.com/forcedotcom/phoenix/wiki/Download). -## Mission -Become the standard means of accessing HBase data through a well-defined, industry standard API. - -## Quick Start -Tired of reading already and just want to get started? Listen to the Phoenix talks from [Hadoop Summit 2013](http://www.youtube.com/watch?v=YHsHdQ08trg) and [HBaseConn 2013](http://www.cloudera.com/content/cloudera/en/resources/library/hbasecon/hbasecon-2013--how-and-why-phoenix-puts-the-sql-back-into-nosql-video.html), check out our [FAQs](https://github.com/forcedotcom/phoenix/wiki/F.A.Q.), and jump over to our quick start guide [here](https://github.com/forcedotcom/phoenix/wiki/Phoenix-in-15-minutes-or-less) or map to your existing HBase tables as described [here](https://github.com/forcedotcom/phoenix/wiki/Phoenix-Introduction#mapping-to-an-existing-hbase-table) and start querying now. - -## How It Works ## - -The Phoenix query engine transforms your [SQL query](http://forcedotcom.github.com/phoenix/#select) into one or more HBase scans, and orchestrates their execution to produce standard JDBC result sets. Direct use of the HBase API, along with coprocessors and custom filters, results in [performance](https://github.com/forcedotcom/phoenix/wiki/Performance) on the order of milliseconds for small queries, or seconds for tens of millions of rows. - -Tables are created and altered through [DDL statements](http://forcedotcom.github.com/phoenix/#create), and their schema is stored and versioned on the server in an HBase table. Columns are defined as either being part of a multi-part row key, or as key/value cells. You can also map Phoenix on to existing tables (see the [wiki](https://github.com/forcedotcom/phoenix/wiki) for more details). - -Applications interact with Phoenix through a standard JDBC interface; all the usual interfaces are supported, including `Connection`, `Statement`, `PreparedStatement`, and `ResultSet`. The driver class is `com.salesforce.phoenix.jdbc.PhoenixDriver`, JDK 1.5+ automatically registers JDBC driver on classpath, and the [connection url](https://github.com/forcedotcom/phoenix/wiki/Phoenix-Introduction#wiki-connStr) is `jdbc:phoenix:` followed by the zookeeper quorum hostname specification plus optionally the port number and/or root node. For example: - - Connection conn = DriverManager.getConnection("jdbc:phoenix:localhost"); - -For detailed documentation on the current level of SQL support, see our [language reference guide](http://forcedotcom.github.com/phoenix/). For details about how Phoenix handles schema, transactions, and more, see the [wiki](https://github.com/forcedotcom/phoenix/wiki). - -## System Requirements ## -* HBase v0.94.4+ (0.96 is not yet supported) -* JDK 6 or higher - -## Build Requirements ## -* All the system requirements -* Maven 3.X (https://maven.apache.org/) - - -## Installation ## -To install a pre-built phoenix, use these directions: - -* Download and expand the latest phoenix-[version]-install.tar from [download page](https://github.com/forcedotcom/phoenix/wiki/Download) -* Remove prior phoenix-[version].jar from every HBase region server. -* Add the phoenix-[version].jar to the classpath of every HBase region server. An easy way to do this is to copy it into the HBase lib directory. -* Restart all region servers. -* Remove prior phoenix-[version]-client.jar from the classpath of any Phoenix client. -* Add the phoenix-[version]-client.jar to the classpath of any Phoenix client. - -Alternatively, you can build it yourself using maven by following these [build instructions](https://github.com/forcedotcom/phoenix/wiki/Building-Project). - - -## Getting Started ## -Wanted to get started quickly? Take a look at our [FAQs](https://github.com/forcedotcom/phoenix/wiki/F.A.Q.) and take our quick start guide [here](https://github.com/forcedotcom/phoenix/wiki/Phoenix-in-15-minutes-or-less). - -

Command Line

- -A terminal interface to execute SQL from the command line is now bundled with Phoenix v 1.2. To -start it, execute the following from the bin directory: - - $ sqlline.sh localhost - -To execute SQL scripts from the command line, you can include a SQL file argument like this: - - $ sqlline.sh localhost ../examples/stock_symbol.sql - -![sqlline](http://forcedotcom.github.com/phoenix/images/sqlline.png) - -For more information, see the [manual](http://www.hydromatic.net/sqlline/manual.html). - -
Loading Data
- -In addition, you can use the bin/psql.sh to load CSV data or execute SQL scripts. For example: - - $ psql.sh localhost ../examples/web_stat.sql ../examples/web_stat.csv ../examples/web_stat_queries.sql - -Other alternatives include: -* Using our [map-reduce based CSV loader](https://github.com/forcedotcom/phoenix/wiki/Bulk-CSV-loading-through-map-reduce) for bigger data sets -* [Mapping an existing HBase table to a Phoenix table](https://github.com/forcedotcom/phoenix/wiki/Phoenix-Introduction#mapping-to-an-existing-hbase-table) and using the [UPSERT SELECT](http://forcedotcom.github.io/phoenix/#upsert_select) command to populate a new table. -* Populating the table through our [UPSERT VALUES](http://forcedotcom.github.io/phoenix/#upsert_values) command. - -

SQL Client

- -If you'd rather use a client GUI to interact with Phoenix, download and install [SQuirrel](http://squirrel-sql.sourceforge.net/). Since Phoenix is a JDBC driver, integration with tools such as this are seamless. Here are the setup steps necessary: - -1. Remove prior phoenix-[version]-client.jar from the lib directory of SQuirrel -2. Copy the phoenix-[version]-client.jar into the lib directory of SQuirrel (Note that on a Mac, this is the *internal* lib directory). -3. Start SQuirrel and add new driver to SQuirrel (Drivers -> New Driver) -4. In Add Driver dialog box, set Name to Phoenix -5. Enter com.salesforce.phoenix.jdbc.PhoenixDriver in the Class Name textbox. Press OK to close this dialog. -6. Switch to Alias tab and create the new Alias (Aliases -> New Aliases) -7. In the dialog box, Name: _any name_, Driver: Phoenix, User Name: _anything_, Password: _anything_ -8. Construct URL as follows: jdbc:phoenix: _zookeeper quorum server_. For example, to connect to a local HBase use: jdbc:phoenix:localhost -9. Press Test (which should succeed if everything is setup correctly) and press OK to close. -10. Now double click on your newly created Phoenix alias and click Connect. -11. Navigate to File --> New Session Properties --> Tab SQL and uncheck the "Remove multi line comment (/.../) from SQL before sending it to database" so that hints you include in queries are not stripped. -11. Now you are ready to run SQL queries against Phoenix. - -Through SQuirrel, you can issue SQL statements in the SQL tab (create tables, insert data, run queries), and inspect table metadata in the Object tab (i.e. list tables, their columns, primary keys, and types). - -![squirrel](http://forcedotcom.github.com/phoenix/images/squirrel.png) - -## Maven ## - -Currently, Phoenix hosts its own maven repository in github. This is done for convience and will later be moved to a 'real' maven repository. You can add it to your mavenized project by adding the following to your pom: -``` - - ... - - phoenix-github - Phoenix Github Maven - https://raw.github.com/forcedotcom/phoenix/maven-artifacts/releases - - true - - - true - - - ... - - - - ... - - com.salesforce - phoenix - 2.2.1 - - ... - -``` -## Samples ## -The best place to see samples are in our unit tests under src/test/java. The ones in the endToEnd package are tests demonstrating how to use all aspects of the Phoenix JDBC driver. We also have some examples in the examples directory. - -##Mailing List## -Join one or both of our Google groups: - -* [Phoenix HBase User](https://groups.google.com/forum/#!forum/phoenix-hbase-user) for users of Phoenix. -* [Phoenix HBase Dev](https://groups.google.com/forum/#!forum/phoenix-hbase-dev) for developers of Phoenix. - -and follow the Phoenix blog [here](http://phoenix-hbase.blogspot.com/). - -[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/8438f3b844208e09a811699265666a8d "githalytics.com")](http://githalytics.com/forcedotcom/phoenix.git) - diff --git a/bin/csv-bulk-loader.sh b/bin/csv-bulk-loader.sh index d19f6104..ded249e8 100755 --- a/bin/csv-bulk-loader.sh +++ b/bin/csv-bulk-loader.sh @@ -1,30 +1,24 @@ #!/bin/bash ############################################################################ -# Copyright (c) 2013, Salesforce.com, Inc. -# All rights reserved. # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: +# Copyright 2010 The Apache Software Foundation # -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# Neither the name of Salesforce.com nor the names of its contributors may -# be used to endorse or promote products derived from this software without -# specific prior written permission. +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ############################################################################ # Phoenix client jar. To generate new jars: $ mvn package -DskipTests @@ -43,4 +37,4 @@ # -help Print all options (optional) phoenix_client_jar=$(find ../phoenix-assembly/target/phoenix-*-client.jar) -java -cp "$phoenix_client_jar" com.salesforce.phoenix.map.reduce.CSVBulkLoader "$@" +java -cp "$phoenix_client_jar" org.apache.phoenix.map.reduce.CSVBulkLoader "$@" diff --git a/bin/performance.sh b/bin/performance.sh index 05708656..43ebaaba 100755 --- a/bin/performance.sh +++ b/bin/performance.sh @@ -1,30 +1,24 @@ #!/bin/bash ############################################################################ -# Copyright (c) 2013, Salesforce.com, Inc. -# All rights reserved. # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: +# Copyright 2010 The Apache Software Foundation # -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# Neither the name of Salesforce.com nor the names of its contributors may -# be used to endorse or promote products derived from this software without -# specific prior written permission. +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ############################################################################ # Note: This script is tested on Linux environment only. It should work on any Unix platform but is not tested. @@ -45,12 +39,12 @@ statements="" current_dir=$(cd $(dirname $0);pwd) phoenix_jar_path="$current_dir/../phoenix-assembly/target" phoenix_client_jar=$(find $phoenix_jar_path/phoenix-*-client.jar) -testjar="$phoenix_jar_path/phoenix-*-tests.jar" +testjar="$current_dir/../phoenix-core/target/phoenix-*-tests.jar" # HBase configuration folder path (where hbase-site.xml reside) for HBase/Phoenix client side property override hbase_config_path="$current_dir" -execute="java -cp "$hbase_config_path:$phoenix_client_jar" -Dlog4j.configuration=file:$current_dir/log4j.properties com.salesforce.phoenix.util.PhoenixRuntime -t $table $zookeeper " +execute="java -cp "$hbase_config_path:$phoenix_client_jar" -Dlog4j.configuration=file:$current_dir/log4j.properties org.apache.phoenix.util.PhoenixRuntime -t $table $zookeeper " function usage { echo "Performance script arguments not specified. Usage: performance.sh " echo "Example: performance.sh localhost 100000" diff --git a/bin/psql.sh b/bin/psql.sh index 24ac1937..c17f7c33 100755 --- a/bin/psql.sh +++ b/bin/psql.sh @@ -1,30 +1,24 @@ #!/bin/bash ############################################################################ -# Copyright (c) 2013, Salesforce.com, Inc. -# All rights reserved. # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: +# Copyright 2010 The Apache Software Foundation # -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# Neither the name of Salesforce.com nor the names of its contributors may -# be used to endorse or promote products derived from this software without -# specific prior written permission. +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ############################################################################ # Phoenix client jar. To generate new jars: $ mvn package -DskipTests @@ -35,4 +29,4 @@ phoenix_client_jar=$(find $phoenix_jar_path/phoenix-*-client.jar) # HBase configuration folder path (where hbase-site.xml reside) for HBase/Phoenix client side property override hbase_config_path="$current_dir" -java -cp "$hbase_config_path:$phoenix_client_jar" -Dlog4j.configuration=file:$current_dir/log4j.properties com.salesforce.phoenix.util.PhoenixRuntime "$@" +java -cp "$hbase_config_path:$phoenix_client_jar" -Dlog4j.configuration=file:$current_dir/log4j.properties org.apache.phoenix.util.PhoenixRuntime "$@" diff --git a/bin/sqlline.sh b/bin/sqlline.sh index 77eba84e..066f3842 100755 --- a/bin/sqlline.sh +++ b/bin/sqlline.sh @@ -1,30 +1,24 @@ #!/bin/bash ############################################################################ -# Copyright (c) 2013, Salesforce.com, Inc. -# All rights reserved. # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: +# Copyright 2010 The Apache Software Foundation # -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# Neither the name of Salesforce.com nor the names of its contributors may -# be used to endorse or promote products derived from this software without -# specific prior written permission. +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ############################################################################ # Phoenix client jar. To generate new jars: $ mvn package -DskipTests @@ -42,4 +36,4 @@ if [ "$2" ] then sqlfile="--run=$2"; fi -java -cp ".:$phoenix_client_jar" -Dlog4j.configuration=file:$current_dir/log4j.properties sqlline.SqlLine -d com.salesforce.phoenix.jdbc.PhoenixDriver -u jdbc:phoenix:$1 -n none -p none --color=true --fastConnect=false --verbose=true --isolation=TRANSACTION_READ_COMMITTED $sqlfile +java -cp ".:$phoenix_client_jar" -Dlog4j.configuration=file:$current_dir/log4j.properties sqlline.SqlLine -d org.apache.phoenix.jdbc.PhoenixDriver -u jdbc:phoenix:$1 -n none -p none --color=true --fastConnect=false --verbose=true --isolation=TRANSACTION_READ_COMMITTED $sqlfile diff --git a/bin/upgradeTo2.sh b/bin/upgradeTo2.sh index 0e3f9aaa..c2a4a0dd 100755 --- a/bin/upgradeTo2.sh +++ b/bin/upgradeTo2.sh @@ -1,30 +1,24 @@ #!/bin/bash ############################################################################ -# Copyright (c) 2013, Salesforce.com, Inc. -# All rights reserved. # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: +# Copyright 2010 The Apache Software Foundation # -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# Neither the name of Salesforce.com nor the names of its contributors may -# be used to endorse or promote products derived from this software without -# specific prior written permission. +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ############################################################################ # Phoenix client jar. To generate new jars: $ mvn package -DskipTests @@ -35,4 +29,4 @@ phoenix_client_jar=$(find $phoenix_jar_path/phoenix-*-client.jar) # HBase configuration folder path (where hbase-site.xml reside) for HBase/Phoenix client side property override hbase_config_path="$current_dir" -java -cp "$hbase_config_path:$phoenix_client_jar" -Dlog4j.configuration=file:$current_dir/log4j.properties com.salesforce.phoenix.util.PhoenixRuntime -u "$@" +java -cp "$hbase_config_path:$phoenix_client_jar" -Dlog4j.configuration=file:$current_dir/log4j.properties org.apache.phoenix.util.PhoenixRuntime -u "$@" diff --git a/build.txt b/build.txt index 6dc841f4..ca3304dc 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,28 @@ -# Building Phoenix -================ +############################################################################ +# +# Copyright 2010 The Apache Software Foundation +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################ + + +# Building Apache Phoenix +========================= Phoenix uses Maven (3.X) to build all its necessary resources. @@ -36,3 +59,9 @@ Use the m2e eclipse plugin and do Import->Maven Project and just pick the root ' Findbugs report is generated in /target/site $ mvn site + +## Generate Apache Web Site +=========================== + $ mvn -pl phoenix-core site -Ddependency.locations.enabled=false + +Note: site is generated in phoenix-core/target/site diff --git a/config/apache-access-logs.properties b/config/apache-access-logs.properties index 78077cdf..2733cba6 100644 --- a/config/apache-access-logs.properties +++ b/config/apache-access-logs.properties @@ -21,7 +21,7 @@ agent.sources.spooling-source.interceptors=i1 agent.sources.spooling-source.interceptors.i1.type=host agent.sources.spooling-source.interceptors.i1.hostHeader=f_host # configurationforsink -agent.sinks.phoenix-sink.type=com.salesforce.phoenix.flume.sink.PhoenixSink +agent.sinks.phoenix-sink.type=org.apache.phoenix.flume.sink.PhoenixSink agent.sinks.phoenix-sink.channel=memoryChannel agent.sinks.phoenix-sink.batchSize=100 agent.sinks.phoenix-sink.table=APACHE_LOGS diff --git a/dev/eclipse_prefs_phoenix.epf b/dev/eclipse_prefs_phoenix.epf index b6e6f15c..fb8df40f 100644 --- a/dev/eclipse_prefs_phoenix.epf +++ b/dev/eclipse_prefs_phoenix.epf @@ -800,7 +800,7 @@ file_export_version=3.0 /instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.packages.linktoeditor=true /instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.staticondemandthreshold=99 /instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.code_templates_migrated=true -/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.custom_code_templates= +/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.custom_code_templates= /instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.custom_templates= /instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.templates_migrated=true /instance/org.eclipse.jdt.ui/proposalOrderMigrated=true diff --git a/examples/pig/test.pig b/examples/pig/test.pig index 670c3e3c..aba5b1ba 100644 --- a/examples/pig/test.pig +++ b/examples/pig/test.pig @@ -1,2 +1,2 @@ A = load 'examples/pig/testdata' as (a:chararray, b:chararray, c:int, d:chararray, e: datetime) ; -STORE A into 'hbase://TESTPHX' using com.salesforce.phoenix.pig.PhoenixHBaseStorage('localhost','-batchSize 1000'); +STORE A into 'hbase://TESTPHX' using org.apache.phoenix.pig.PhoenixHBaseStorage('localhost','-batchSize 1000'); diff --git a/license.txt b/license.txt deleted file mode 100644 index e21b6dc3..00000000 --- a/license.txt +++ /dev/null @@ -1,26 +0,0 @@ -Copyright (c) 2013, Salesforce.com, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - Neither the name of Salesforce.com nor the names of its contributors may - be used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/phoenix-assembly/pom.xml b/phoenix-assembly/pom.xml index e6c32574..9a89206a 100644 --- a/phoenix-assembly/pom.xml +++ b/phoenix-assembly/pom.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.salesforce + org.apache phoenix 3.0.0-SNAPSHOT @@ -29,7 +29,7 @@ true true - com.salesforce.phoenix.util.PhoenixRuntime + org.apache.phoenix.util.PhoenixRuntime true true @@ -92,24 +92,24 @@ - com.salesforce + org.apache phoenix-core - com.salesforce + org.apache phoenix-hadoop-compat - com.salesforce + org.apache ${compat.module} - com.salesforce + org.apache phoenix-flume - com.salesforce + org.apache phoenix-pig - \ No newline at end of file + diff --git a/phoenix-core/pom.xml b/phoenix-core/pom.xml index 0be278c3..0e2b8e59 100644 --- a/phoenix-core/pom.xml +++ b/phoenix-core/pom.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.salesforce + org.apache phoenix 3.0.0-SNAPSHOT @@ -10,6 +10,20 @@ Phoenix Core Core Phoenix codebase + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + Apache Software Foundation + http://www.apache.org + + @@ -23,6 +37,54 @@ + + org.apache.maven.plugins + maven-site-plugin + 3.2 + + + org.apache.maven.doxia + doxia-module-markdown + 1.3 + + + lt.velykis.maven.skins + reflow-velocity-tools + 1.0.0 + + + org.apache.velocity + velocity + 1.7 + + + + + + org.codehaus.mojo + findbugs-maven-plugin + 2.5.2 + + + + + + exec-maven-plugin + org.codehaus.mojo + 1.2.1 + + + Merge Language Reference + site + + exec + + + ${basedir}/src/site/bin/merge.sh + + + + org.codehaus.mojo build-helper-maven-plugin @@ -56,7 +118,7 @@ - ${antlr-output.dir}/com/salesforce/phoenix/parse + ${antlr-output.dir}/org/apache/phoenix/parse - com.salesforce + org.apache phoenix-hadoop-compat - com.salesforce + org.apache phoenix-hadoop-compat tests test @@ -254,4 +316,4 @@ - \ No newline at end of file + diff --git a/phoenix-core/src/main/antlr3/PhoenixSQL.g b/phoenix-core/src/main/antlr3/PhoenixSQL.g index a22fc783..5dcfe813 100644 --- a/phoenix-core/src/main/antlr3/PhoenixSQL.g +++ b/phoenix-core/src/main/antlr3/PhoenixSQL.g @@ -1,30 +1,22 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ +/** + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ grammar PhoenixSQL; tokens @@ -111,34 +103,26 @@ tokens @parser::header { -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/** + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; ///CLOVER:OFF import com.google.common.collect.ImmutableMap; @@ -150,45 +134,37 @@ import java.util.Arrays; import java.util.Collections; import java.util.Stack; import java.sql.SQLException; -import com.salesforce.phoenix.expression.function.CountAggregateFunction; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.IllegalDataException; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PIndexState; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.expression.function.CountAggregateFunction; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.IllegalDataException; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.util.SchemaUtil; } @lexer::header { -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/** + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; ///CLOVER:OFF } diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/CapturingAbortable.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/CapturingAbortable.java deleted file mode 100644 index 5493d7fa..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/CapturingAbortable.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index; - -import org.apache.hadoop.hbase.Abortable; - -/** - * {@link Abortable} that can rethrow the cause of the abort. - */ -public class CapturingAbortable implements Abortable { - - private Abortable delegate; - private Throwable cause; - private String why; - - public CapturingAbortable(Abortable delegate) { - this.delegate = delegate; - } - - @Override - public void abort(String why, Throwable e) { - if (delegate.isAborted()) { - return; - } - this.why = why; - this.cause = e; - delegate.abort(why, e); - - } - - @Override - public boolean isAborted() { - return delegate.isAborted(); - } - - /** - * Throw the cause of the abort, if this was aborted. If there was an exception causing - * the abort, re-throws that. Otherwise, just throws a generic {@link Exception} with the reason - * why the abort was caused. - * @throws Throwable the cause of the abort. - */ - public void throwCauseIfAborted() throws Throwable { - if (!this.isAborted()) { - return; - } - if (cause == null) { - throw new Exception(why); - } - throw cause; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/ValueGetter.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/ValueGetter.java deleted file mode 100644 index 0cf05886..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/ValueGetter.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index; - -import java.io.IOException; - -import com.salesforce.hbase.index.covered.update.ColumnReference; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; - -public interface ValueGetter { - - /** - * Get the most recent (largest timestamp) for the given column reference - * @param ref to match against an underlying key value. Uses the passed object to match the - * keyValue via {@link ColumnReference#matches} - * @return the stored value for the given {@link ColumnReference}, or null if no value is - * present. - * @throws IOException if there is an error accessing the underlying data storage - */ - public ImmutableBytesPtr getLatestValue(ColumnReference ref) throws IOException; -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/builder/IndexBuildingFailureException.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/builder/IndexBuildingFailureException.java deleted file mode 100644 index 92f58682..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/builder/IndexBuildingFailureException.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.builder; - -import java.io.IOException; - -import org.apache.hadoop.hbase.DoNotRetryIOException; - -/** - * Unexpected failure while building index updates that wasn't caused by an {@link IOException}. - * This should be used if there is some basic issue with indexing - and no matter of retries will - * fix it. - */ -@SuppressWarnings("serial") -public class IndexBuildingFailureException extends DoNotRetryIOException { - - /** - * Constructor for over the wire propagation. Generally, shouldn't be used since index failure - * should have an underlying cause to propagate. - * @param msg reason for the failure - */ - public IndexBuildingFailureException(String msg) { - super(msg); - } - - /** - * @param msg reason - * @param cause underlying cause for the failure - */ - public IndexBuildingFailureException(String msg, Throwable cause) { - super(msg, cause); - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/Batch.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/Batch.java deleted file mode 100644 index 14647e43..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/Batch.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.hadoop.hbase.KeyValue; - -/** - * A collection of {@link KeyValue KeyValues} to the primary table - */ -public class Batch { - - private static final long pointDeleteCode = KeyValue.Type.Delete.getCode(); - private final long timestamp; - private List batch = new ArrayList(); - private boolean allPointDeletes = true; - - /** - * @param ts - */ - public Batch(long ts) { - this.timestamp = ts; - } - - public void add(KeyValue kv){ - if (pointDeleteCode != kv.getType()) { - allPointDeletes = false; - } - batch.add(kv); - } - - public boolean isAllPointDeletes() { - return allPointDeletes; - } - - public long getTimestamp() { - return this.timestamp; - } - - public List getKvs() { - return this.batch; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/CoveredColumns.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/CoveredColumns.java deleted file mode 100644 index 439c4aab..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/CoveredColumns.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import com.salesforce.hbase.index.covered.update.ColumnReference; - -/** - * Manage a set of {@link ColumnReference}s for the {@link LocalTableState}. - */ -public class CoveredColumns { - - Set columns = new HashSet(); - - public Collection findNonCoveredColumns( - Collection columns2) { - List uncovered = new ArrayList(); - for (ColumnReference column : columns2) { - if (!columns.contains(column)) { - uncovered.add(column); - } - } - return uncovered; - } - - public void addColumn(ColumnReference column) { - this.columns.add(column); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/IndexUpdate.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/IndexUpdate.java deleted file mode 100644 index c50c0932..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/IndexUpdate.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered; - -import org.apache.hadoop.hbase.client.Mutation; -import org.apache.hadoop.hbase.client.Put; -import org.apache.hadoop.hbase.util.Bytes; - -import com.salesforce.hbase.index.covered.update.ColumnTracker; - -/** - * Update to make to the index table. - */ -public class IndexUpdate { - Mutation update; - byte[] tableName; - ColumnTracker columns; - - IndexUpdate(ColumnTracker tracker) { - this.columns = tracker; - } - - public void setUpdate(Mutation p) { - this.update = p; - } - - public void setTable(byte[] tableName) { - this.tableName = tableName; - } - - public Mutation getUpdate() { - return update; - } - - public byte[] getTableName() { - return tableName; - } - - public ColumnTracker getIndexedColumns() { - return columns; - } - - @Override - public String toString() { - return "IndexUpdate: \n\ttable - " + Bytes.toString(tableName) + "\n\tupdate: " + update - + "\n\tcolumns: " + columns; - } - - public static IndexUpdate createIndexUpdateForTesting(ColumnTracker tracker, byte[] table, Put p) { - IndexUpdate update = new IndexUpdate(tracker); - update.setTable(table); - update.setUpdate(p); - return update; - } - - /** - * @return true if the necessary state for a valid index update has been set. - */ - public boolean isValid() { - return this.tableName != null && this.update != null; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/KeyValueStore.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/KeyValueStore.java deleted file mode 100644 index 88a99cce..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/KeyValueStore.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered; - -import org.apache.hadoop.hbase.KeyValue; -import org.apache.hadoop.hbase.regionserver.KeyValueScanner; - -/** - * Store a collection of KeyValues in memory. - */ -public interface KeyValueStore { - - public void add(KeyValue kv, boolean overwrite); - - public KeyValueScanner getScanner(); - - public void rollback(KeyValue kv); -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/LazyValueGetter.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/LazyValueGetter.java deleted file mode 100644 index 2f380370..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/LazyValueGetter.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered.data; - -import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.apache.hadoop.hbase.KeyValue; - -import com.salesforce.hbase.index.ValueGetter; -import com.salesforce.hbase.index.covered.update.ColumnReference; -import com.salesforce.hbase.index.scanner.Scanner; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; - -/** - * {@link ValueGetter} that uses lazy initialization to get the value for the given - * {@link ColumnReference}. Once stored, the mapping for that reference is retained. - */ -public class LazyValueGetter implements ValueGetter { - - private Scanner scan; - private volatile Map values; - private byte[] row; - - /** - * Back the getter with a {@link Scanner} to actually access the local data. - * @param scan backing scanner - * @param currentRow row key for the row to seek in the scanner - */ - public LazyValueGetter(Scanner scan, byte[] currentRow) { - this.scan = scan; - this.row = currentRow; - } - - @Override - public ImmutableBytesPtr getLatestValue(ColumnReference ref) throws IOException { - // ensure we have a backing map - if (values == null) { - synchronized (this) { - values = Collections.synchronizedMap(new HashMap()); - } - } - - // check the value in the map - ImmutableBytesPtr value = values.get(ref); - if (value == null) { - value = get(ref); - values.put(ref, value); - } - - return value; - } - - /** - * @param ref - * @return the first value on the scanner for the given column - */ - private ImmutableBytesPtr get(ColumnReference ref) throws IOException { - KeyValue first = ref.getFirstKeyValueForRow(row); - if (!scan.seek(first)) { - return null; - } - // there is a next value - we only care about the current value, so we can just snag that - KeyValue next = scan.next(); - if (ref.matches(next)) { - return new ImmutableBytesPtr(next.getBuffer(), next.getValueOffset(), next.getValueLength()); - } - return null; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/LocalHBaseState.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/LocalHBaseState.java deleted file mode 100644 index 4e4f8062..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/LocalHBaseState.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered.data; - -import java.io.IOException; -import java.util.Collection; - -import org.apache.hadoop.hbase.KeyValue; -import org.apache.hadoop.hbase.client.Mutation; -import org.apache.hadoop.hbase.client.Result; - -import com.salesforce.hbase.index.covered.update.ColumnReference; - -/** - * Access the current state of the row in the local HBase table, given a mutation - */ -public interface LocalHBaseState { - - /** - * @param m mutation for which we should get the current table state - * @param toCover all the columns the current row state needs to cover; hint the underlying lookup - * to save getting all the columns for the row - * @return the full state of the given row. Includes all current versions (even if they are not - * usually visible to the client (unless they are also doing a raw scan)). Never returns a - * null {@link Result} - instead, when there is not data for the row, returns a - * {@link Result} with no stored {@link KeyValue}s. - * @throws IOException if there is an issue reading the row - */ - public Result getCurrentRowState(Mutation m, Collection toCover) - throws IOException; - -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/ColumnTrackingNextLargestTimestampFilter.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/ColumnTrackingNextLargestTimestampFilter.java deleted file mode 100644 index 21abc63a..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/ColumnTrackingNextLargestTimestampFilter.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered.filter; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.hadoop.hbase.KeyValue; -import org.apache.hadoop.hbase.filter.FilterBase; - -import com.salesforce.hbase.index.covered.update.ColumnTracker; - -/** - * Similar to the {@link MaxTimestampFilter}, but also updates the 'next largest' timestamp seen - * that is not skipped by the below criteria. Note that it isn't as quick as the - * {@link MaxTimestampFilter} as we can't just seek ahead to a key with the matching timestamp, but - * have to iterate each kv until we find the right one with an allowed timestamp. - *

- * Inclusively filter on the maximum timestamp allowed. Excludes all elements greater than (but not - * equal to) the given timestamp, so given ts = 5, a {@link KeyValue} with ts 6 is excluded, but not - * one with ts = 5. - *

- * This filter generally doesn't make sense on its own - it should follow a per-column filter and - * possible a per-delete filter to only track the most recent (but not exposed to the user) - * timestamp. - */ -public class ColumnTrackingNextLargestTimestampFilter extends FilterBase { - - private long ts; - private ColumnTracker column; - - public ColumnTrackingNextLargestTimestampFilter(long maxTime, ColumnTracker toTrack) { - this.ts = maxTime; - this.column = toTrack; - } - - @Override - public ReturnCode filterKeyValue(KeyValue v) { - long timestamp = v.getTimestamp(); - if (timestamp > ts) { - this.column.setTs(timestamp); - return ReturnCode.SKIP; - } - return ReturnCode.INCLUDE; - } - - @Override - public void write(DataOutput out) throws IOException { - throw new UnsupportedOperationException("Server-side only filter, cannot be serialized!"); - } - - @Override - public void readFields(DataInput in) throws IOException { - throw new UnsupportedOperationException("Server-side only filter, cannot be deserialized!"); - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/MaxTimestampFilter.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/MaxTimestampFilter.java deleted file mode 100644 index 89c74aeb..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/MaxTimestampFilter.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered.filter; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.hadoop.hbase.KeyValue; -import org.apache.hadoop.hbase.filter.FilterBase; -import org.apache.hadoop.hbase.util.Bytes; - -/** - * Inclusive filter on the maximum timestamp allowed. Excludes all elements greater than (but not - * equal to) the given timestamp, so given ts = 5, a {@link KeyValue} with ts 6 is excluded, but not - * one with ts = 5. - */ -public class MaxTimestampFilter extends FilterBase { - - private long ts; - - public MaxTimestampFilter(long maxTime) { - this.ts = maxTime; - } - - @Override - public KeyValue getNextKeyHint(KeyValue currentKV) { - // this might be a little excessive right now - better safe than sorry though, so we don't mess - // with other filters too much. - KeyValue kv = currentKV.deepCopy(); - int offset =kv.getTimestampOffset(); - //set the timestamp in the buffer - byte[] buffer = kv.getBuffer(); - byte[] ts = Bytes.toBytes(this.ts); - System.arraycopy(ts, 0, buffer, offset, ts.length); - - return kv; - } - - @Override - public ReturnCode filterKeyValue(KeyValue v) { - long timestamp = v.getTimestamp(); - if (timestamp > ts) { - return ReturnCode.SEEK_NEXT_USING_HINT; - } - return ReturnCode.INCLUDE; - } - - @Override - public void write(DataOutput out) throws IOException { - throw new UnsupportedOperationException("Server-side only filter, cannot be serialized!"); - - } - - @Override - public void readFields(DataInput in) throws IOException { - throw new UnsupportedOperationException("Server-side only filter, cannot be deserialized!"); - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/IndexedColumnGroup.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/IndexedColumnGroup.java deleted file mode 100644 index 97c0d3fd..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/IndexedColumnGroup.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered.update; - -import java.util.List; - -/** - * Group of columns that were requested to build an index - */ -public interface IndexedColumnGroup { - - public List getColumns(); -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/exception/IndexWriteException.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/exception/IndexWriteException.java deleted file mode 100644 index 35f48b57..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/exception/IndexWriteException.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.exception; - -import org.apache.hadoop.hbase.HBaseIOException; - -/** - * Generic {@link Exception} that an index write has failed - */ -@SuppressWarnings("serial") -public class IndexWriteException extends HBaseIOException { - - public IndexWriteException() { - super(); - } - - public IndexWriteException(String message, Throwable cause) { - super(message, cause); - } - - public IndexWriteException(String message) { - super(message); - } - - public IndexWriteException(Throwable cause) { - super(cause); - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/exception/MultiIndexWriteFailureException.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/exception/MultiIndexWriteFailureException.java deleted file mode 100644 index 6c57750e..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/exception/MultiIndexWriteFailureException.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.exception; - -import java.util.List; - -import com.salesforce.hbase.index.table.HTableInterfaceReference; - -/** - * Indicate a failure to write to multiple index tables. - */ -@SuppressWarnings("serial") -public class MultiIndexWriteFailureException extends IndexWriteException { - - private List failures; - - /** - * @param failures the tables to which the index write did not succeed - */ - public MultiIndexWriteFailureException(List failures) { - super("Failed to write to multiple index tables"); - this.failures = failures; - - } - - public List getFailedTables() { - return this.failures; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/exception/SingleIndexWriteFailureException.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/exception/SingleIndexWriteFailureException.java deleted file mode 100644 index 66aefe9f..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/exception/SingleIndexWriteFailureException.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.exception; - -import java.util.List; - -import org.apache.hadoop.hbase.client.Mutation; - -/** - * Exception thrown if we cannot successfully write to an index table. - */ -@SuppressWarnings("serial") -public class SingleIndexWriteFailureException extends IndexWriteException { - - private String table; - - /** - * Cannot reach the index, but not sure of the table or the mutations that caused the failure - * @param msg more description of what happened - * @param cause original cause - */ - public SingleIndexWriteFailureException(String msg, Throwable cause) { - super(msg, cause); - } - - /** - * Failed to write the passed mutations to an index table for some reason. - * @param targetTableName index table to which we attempted to write - * @param mutations mutations that were attempted - * @param cause underlying reason for the failure - */ - public SingleIndexWriteFailureException(String targetTableName, List mutations, - Exception cause) { - super("Failed to make index update:\n\t table: " + targetTableName + "\n\t edits: " + mutations - + "\n\tcause: " + cause == null ? "UNKNOWN" : cause.getMessage(), cause); - this.table = targetTableName; - } - - /** - * @return The table to which we failed to write the index updates. If unknown, returns - * null - */ - public String getTableName() { - return this.table; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/EarlyExitFailure.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/EarlyExitFailure.java deleted file mode 100644 index 0f08393e..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/EarlyExitFailure.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.parallel; - -import java.io.IOException; - -/** - * Exception denoting a need to early-exit a task (or group of tasks) due to external notification - */ -@SuppressWarnings("serial") -public class EarlyExitFailure extends IOException { - - /** - * @param msg reason for the early exit - */ - public EarlyExitFailure(String msg) { - super(msg); - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/QuickFailingTaskRunner.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/QuickFailingTaskRunner.java deleted file mode 100644 index 25dbd343..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/QuickFailingTaskRunner.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.parallel; - -import java.util.List; -import java.util.concurrent.ExecutorService; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * {@link TaskRunner} that attempts to run all tasks passed, but quits early if any {@link Task} - * fails, not waiting for the remaining {@link Task}s to complete. - */ -public class QuickFailingTaskRunner extends BaseTaskRunner { - - static final Log LOG = LogFactory.getLog(QuickFailingTaskRunner.class); - - /** - * @param service thread pool to which {@link Task}s are submitted. This service is then 'owned' - * by this and will be shutdown on calls to {@link #stop(String)}. - */ - public QuickFailingTaskRunner(ExecutorService service) { - super(service); - } - - @Override - protected ListenableFuture> submitTasks(List> futures) { - return Futures.allAsList(futures); - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/Task.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/Task.java deleted file mode 100644 index c86d2953..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/Task.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.parallel; - -import java.util.concurrent.Callable; - -import org.apache.hadoop.hbase.Abortable; - -/** - * Like a {@link Callable}, but supports an internal {@link Abortable} that can be checked - * periodically to determine if the batch should abort - * @param expected result of the task - */ -public abstract class Task implements Callable { - - private Abortable batch; - - void setBatchMonitor(Abortable abort) { - this.batch = abort; - } - - protected boolean isBatchFailed() { - return this.batch.isAborted(); - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/TaskBatch.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/TaskBatch.java deleted file mode 100644 index d732b15c..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/TaskBatch.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.parallel; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.hbase.Abortable; - -/** - * A group of {@link Task}s. The tasks are all bound together using the same {@link Abortable} ( - * this) to ensure that all tasks are aware when any of the other tasks fails. - * @param expected result type from all the tasks - */ -public class TaskBatch implements Abortable { - private static final Log LOG = LogFactory.getLog(TaskBatch.class); - private AtomicBoolean aborted = new AtomicBoolean(); - private List> tasks; - - /** - * @param size expected number of tasks - */ - public TaskBatch(int size) { - this.tasks = new ArrayList>(size); - } - - public void add(Task task) { - this.tasks.add(task); - task.setBatchMonitor(this); - } - - public Collection> getTasks() { - return this.tasks; - } - - @Override - public void abort(String why, Throwable e) { - if (this.aborted.getAndSet(true)) { - return; - } - LOG.info("Aborting batch of tasks because " + why); - } - - @Override - public boolean isAborted() { - return this.aborted.get(); - } - - /** - * @return the number of tasks assigned to this batch - */ - public int size() { - return this.tasks.size(); - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/WaitForCompletionTaskRunner.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/WaitForCompletionTaskRunner.java deleted file mode 100644 index b3ffaa66..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/WaitForCompletionTaskRunner.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.parallel; - -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; - -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * A {@link TaskRunner} that ensures that all the tasks have been attempted before we return, even - * if some of the tasks cause failures. - *

- * Because we wait until the entire batch is complete to see the failure, checking for failure of - * the {@link TaskBatch} on the submitted tasks will not help - they will never see the failure of - * the other tasks. You will need to provide an external mechanism to propagate the error. - *

- * Does not throw an {@link ExecutionException} if any of the tasks fail. - */ -public class WaitForCompletionTaskRunner extends BaseTaskRunner { - - /** - * @param service thread pool to which {@link Task}s are submitted. This service is then 'owned' - * by this and will be shutdown on calls to {@link #stop(String)}. - */ - public WaitForCompletionTaskRunner(ExecutorService service) { - super(service); - } - - @Override - public ListenableFuture> submitTasks(List> futures) { - return Futures.successfulAsList(futures); - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/scanner/FilteredKeyValueScanner.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/scanner/FilteredKeyValueScanner.java deleted file mode 100644 index c90319fd..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/scanner/FilteredKeyValueScanner.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.salesforce.hbase.index.scanner; - -import java.io.IOException; -import java.util.SortedSet; - -import org.apache.hadoop.hbase.KeyValue; -import org.apache.hadoop.hbase.client.Scan; -import org.apache.hadoop.hbase.filter.Filter; -import org.apache.hadoop.hbase.filter.Filter.ReturnCode; -import org.apache.hadoop.hbase.regionserver.KeyValueScanner; - -import com.salesforce.hbase.index.covered.KeyValueStore; - -/** - * Combine a simplified version of the logic in the ScanQueryMatcher and the KeyValueScanner. We can - * get away with this here because we are only concerned with a single MemStore for the index; we - * don't need to worry about multiple column families or minimizing seeking through file - we just - * want to iterate the kvs quickly, in-memory. - */ -public class FilteredKeyValueScanner implements KeyValueScanner { - - private KeyValueScanner delegate; - private Filter filter; - - public FilteredKeyValueScanner(Filter filter, KeyValueStore store) { - this(filter, store.getScanner()); - } - - private FilteredKeyValueScanner(Filter filter, KeyValueScanner delegate) { - this.delegate = delegate; - this.filter = filter; - } - - @Override - public KeyValue peek() { - return delegate.peek(); - } - - /** - * Same a {@link KeyValueScanner#next()} except that we filter out the next {@link KeyValue} until - * we find one that passes the filter. - * @return the next {@link KeyValue} or null if no next {@link KeyValue} is present and - * passes all the filters. - */ - @Override - public KeyValue next() throws IOException { - seekToNextUnfilteredKeyValue(); - return delegate.next(); - } - - @Override - public boolean seek(KeyValue key) throws IOException { - if(filter.filterAllRemaining()){ - return false; - } - // see if we can seek to the next key - if (!delegate.seek(key)) { - return false; - } - - return seekToNextUnfilteredKeyValue(); - } - - private boolean seekToNextUnfilteredKeyValue() throws IOException { - while (true) { - KeyValue peeked = delegate.peek(); - // no more key values, so we are done - if (peeked == null) { - return false; - } - - // filter the peeked value to see if it should be served - ReturnCode code = filter.filterKeyValue(peeked); - switch (code) { - // included, so we are done - case INCLUDE: - case INCLUDE_AND_NEXT_COL: - return true; - // not included, so we need to go to the next row - case SKIP: - case NEXT_COL: - case NEXT_ROW: - delegate.next(); - break; - // use a seek hint to find out where we should go - case SEEK_NEXT_USING_HINT: - delegate.seek(filter.getNextKeyHint(peeked)); - } - } - } - - @Override - public boolean reseek(KeyValue key) throws IOException { - this.delegate.reseek(key); - return this.seekToNextUnfilteredKeyValue(); - } - - @Override - public boolean requestSeek(KeyValue kv, boolean forward, boolean useBloom) throws IOException { - return this.reseek(kv); - } - - @Override - public boolean isFileScanner() { - return false; - } - - @Override - public long getSequenceID() { - return this.delegate.getSequenceID(); - } - - @Override - public boolean shouldUseScanner(Scan scan, SortedSet columns, long oldestUnexpiredTS) { - throw new UnsupportedOperationException(this.getClass().getName() - + " doesn't support checking to see if it should use a scanner!"); - } - - - @Override - public boolean realSeekDone() { - return this.delegate.realSeekDone(); - } - - @Override - public void enforceSeek() throws IOException { - this.delegate.enforceSeek(); - } - - @Override - public void close() { - this.delegate.close(); - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexCommitter.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexCommitter.java deleted file mode 100644 index 0f17b982..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexCommitter.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.write; - -import org.apache.hadoop.hbase.Stoppable; -import org.apache.hadoop.hbase.client.Mutation; -import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; - -import com.google.common.collect.Multimap; -import com.salesforce.hbase.index.exception.IndexWriteException; -import com.salesforce.hbase.index.table.HTableInterfaceReference; - -/** - * Write the index updates to the index tables - */ -public interface IndexCommitter extends Stoppable { - - void setup(IndexWriter parent, RegionCoprocessorEnvironment env, String name); - - public void write(Multimap toWrite) - throws IndexWriteException; -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexFailurePolicy.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexFailurePolicy.java deleted file mode 100644 index e539aa68..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexFailurePolicy.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.write; - -import java.io.IOException; - -import org.apache.hadoop.hbase.Stoppable; -import org.apache.hadoop.hbase.client.Mutation; -import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; - -import com.google.common.collect.Multimap; -import com.salesforce.hbase.index.table.HTableInterfaceReference; - -/** - * Handle failures to write to the index tables. - */ -public interface IndexFailurePolicy extends Stoppable { - - public void setup(Stoppable parent, RegionCoprocessorEnvironment env); - - /** - * Handle the failure of the attempted index updates - * @param attempted map of index table -> mutations to apply - * @param cause reason why there was a failure - * @throws IOException - */ - public void - handleFailure(Multimap attempted, Exception cause) throws IOException; -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/KillServerOnFailurePolicy.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/write/KillServerOnFailurePolicy.java deleted file mode 100644 index c54e96e7..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/KillServerOnFailurePolicy.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.write; - -import java.io.IOException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.hbase.Abortable; -import org.apache.hadoop.hbase.Stoppable; -import org.apache.hadoop.hbase.client.Mutation; -import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; - -import com.google.common.collect.Multimap; -import com.salesforce.hbase.index.table.HTableInterfaceReference; - -/** - * Naive failure policy - kills the server on which it resides - */ -public class KillServerOnFailurePolicy implements IndexFailurePolicy { - - private static final Log LOG = LogFactory.getLog(KillServerOnFailurePolicy.class); - private Abortable abortable; - private Stoppable stoppable; - - @Override - public void setup(Stoppable parent, RegionCoprocessorEnvironment env) { - setup(parent, env.getRegionServerServices()); - } - - public void setup(Stoppable parent, Abortable abort) { - this.stoppable = parent; - this.abortable = abort; - } - - @Override - public void stop(String why) { - // noop - } - - @Override - public boolean isStopped() { - return this.stoppable.isStopped(); - } - - @Override - public void - handleFailure(Multimap attempted, Exception cause) throws IOException { - // cleanup resources - this.stop("Killing ourselves because of an error:" + cause); - // notify the regionserver of the failure - String msg = - "Could not update the index table, killing server region because couldn't write to an index table"; - LOG.error(msg, cause); - try { - this.abortable.abort(msg, cause); - } catch (Exception e) { - LOG.fatal("Couldn't abort this server to preserve index writes, " - + "attempting to hard kill the server"); - System.exit(1); - } - - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/recovery/PerRegionIndexWriteCache.java b/phoenix-core/src/main/java/com/salesforce/hbase/index/write/recovery/PerRegionIndexWriteCache.java deleted file mode 100644 index 18b4c2f1..00000000 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/recovery/PerRegionIndexWriteCache.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.write.recovery; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.apache.hadoop.hbase.client.Mutation; -import org.apache.hadoop.hbase.regionserver.HRegion; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; -import com.salesforce.hbase.index.table.HTableInterfaceReference; - - -public class PerRegionIndexWriteCache { - - private Map> cache = - new HashMap>(); - - - /** - * Get the edits for the current region. Removes the edits from the cache. To add them back, call - * {@link #addEdits(HRegion, HTableInterfaceReference, Collection)}. - * @param region - * @return Get the edits for the given region. Returns null if there are no pending edits - * for the region - */ - public Multimap getEdits(HRegion region) { - return cache.remove(region); - } - - /** - * @param region - * @param table - * @param collection - */ - public void addEdits(HRegion region, HTableInterfaceReference table, - Collection collection) { - Multimap edits = cache.get(region); - if (edits == null) { - edits = ArrayListMultimap. create(); - cache.put(region, edits); - } - edits.putAll(table, collection); - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/HashCache.java b/phoenix-core/src/main/java/com/salesforce/phoenix/cache/HashCache.java deleted file mode 100644 index 6b7ebe96..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/HashCache.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.cache; - -import java.io.Closeable; -import java.util.List; - -import org.apache.http.annotation.Immutable; - -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * Encapsulate deserialized hash cache from bytes into Map. - * The Map uses the row key as the key and the row as the value. - * @author jtaylor - * @since 0.1 - */ -@Immutable -public interface HashCache extends Closeable { - public List get(ImmutableBytesPtr hashKey); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/TenantCache.java b/phoenix-core/src/main/java/com/salesforce/phoenix/cache/TenantCache.java deleted file mode 100644 index 75c49e04..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/TenantCache.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.cache; - -import java.io.Closeable; -import java.sql.SQLException; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.coprocessor.ServerCachingProtocol.ServerCacheFactory; -import com.salesforce.phoenix.memory.MemoryManager; - - -/** - * - * Inteface to set and set cached values for a tenant - * - * @author jtaylor - * @since 0.1 - */ -public interface TenantCache { - MemoryManager getMemoryManager(); - Closeable getServerCache(ImmutableBytesPtr cacheId); - Closeable addServerCache(ImmutableBytesPtr cacheId, ImmutableBytesWritable cachePtr, ServerCacheFactory cacheFactory) throws SQLException; - void removeServerCache(ImmutableBytesPtr cacheId) throws SQLException; -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/client/ClientKeyValueBuilder.java b/phoenix-core/src/main/java/com/salesforce/phoenix/client/ClientKeyValueBuilder.java deleted file mode 100644 index 22b53e4c..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/client/ClientKeyValueBuilder.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.client; - -import org.apache.hadoop.hbase.KeyValue; -import org.apache.hadoop.hbase.KeyValue.Type; -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData; - -/** - * A {@link KeyValueBuilder} that builds {@link ClientKeyValue}, eliminating the extra byte copies - * inherent in the standard {@link KeyValue} implementation. - *

- * This {@link KeyValueBuilder} is only supported in HBase 0.94.14+ ( - * {@link PhoenixDatabaseMetaData#CLIENT_KEY_VALUE_BUILDER_THRESHOLD}), with the addition of - * HBASE-9834. - */ -public class ClientKeyValueBuilder extends KeyValueBuilder { - - public static final KeyValueBuilder INSTANCE = new ClientKeyValueBuilder(); - - private ClientKeyValueBuilder() { - // private ctor for singleton - } - - @Override - public KeyValue buildPut(ImmutableBytesWritable row, ImmutableBytesWritable family, - ImmutableBytesWritable qualifier, long ts, ImmutableBytesWritable value) { - return new ClientKeyValue(row, family, qualifier, ts, Type.Put, value); - } - - @Override - public KeyValue buildDeleteFamily(ImmutableBytesWritable row, ImmutableBytesWritable family, - ImmutableBytesWritable qualifier, long ts) { - return new ClientKeyValue(row, family, qualifier, ts, Type.DeleteFamily, null); - } - - @Override - public KeyValue buildDeleteColumns(ImmutableBytesWritable row, ImmutableBytesWritable family, - ImmutableBytesWritable qualifier, long ts) { - return new ClientKeyValue(row, family, qualifier, ts, Type.DeleteColumn, null); - } - - @Override - public KeyValue buildDeleteColumn(ImmutableBytesWritable row, ImmutableBytesWritable family, - ImmutableBytesWritable qualifier, long ts) { - return new ClientKeyValue(row, family, qualifier, ts, Type.Delete, null); - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/AggregationManager.java b/phoenix-core/src/main/java/com/salesforce/phoenix/compile/AggregationManager.java deleted file mode 100644 index 0149886b..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/AggregationManager.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; - -import com.salesforce.phoenix.expression.aggregator.ClientAggregators; - -/** - * - * Class that manages aggregations during query compilation - * - * @author jtaylor - * @since 0.1 - */ -public class AggregationManager { - private ClientAggregators aggregators; - private int position = 0; - - public AggregationManager() { - } - - public ClientAggregators getAggregators() { - return aggregators; - } - - /** - * @return allocate the next available zero-based positional index - * for the client-side aggregate function. - */ - protected int nextPosition() { - return position++; - } - - public void setAggregators(ClientAggregators clientAggregator) { - this.aggregators = clientAggregator; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/BindManager.java b/phoenix-core/src/main/java/com/salesforce/phoenix/compile/BindManager.java deleted file mode 100644 index 8206597d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/BindManager.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; - -import java.sql.ParameterMetaData; -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.jdbc.PhoenixParameterMetaData; -import com.salesforce.phoenix.parse.BindParseNode; -import com.salesforce.phoenix.schema.PDatum; - - -/** - * - * Class that manages binding parameters and checking type matching. There are - * two main usages: - * - * 1) the standard query case where we have the values for the binds. - * 2) the retrieve param metadata case where we don't have the bind values. - * - * In both cases, during query compilation we figure out what type the bind variable - * "should" be, based on how it's used in the query. For example foo < ? would expect - * that the bind variable type matches or can be coerced to the type of foo. For (1), - * we check that the bind value has the correct type and for (2) we set the param - * metadata type. - * - * @author jtaylor - * @since 0.1 - */ -public class BindManager { - public static final Object UNBOUND_PARAMETER = new Object(); - - private final List binds; - private final PhoenixParameterMetaData bindMetaData; - - public BindManager(List binds) { - this.binds = binds; - this.bindMetaData = new PhoenixParameterMetaData(binds.size()); - } - - public ParameterMetaData getParameterMetaData() { - return bindMetaData; - } - - public Object getBindValue(BindParseNode node) throws SQLException { - int index = node.getIndex(); - if (index < 0 || index >= binds.size()) { - throw new SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_INDEX_OUT_OF_BOUND) - .setMessage("binds size: " + binds.size() + "; index: " + index).build().buildException(); - } - Object value = binds.get(index); - if (value == UNBOUND_PARAMETER) { - throw new SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_VALUE_UNBOUND) - .setMessage(node.toString()).build().buildException(); - } - return value; - } - - public void addParamMetaData(BindParseNode bind, PDatum column) throws SQLException { - bindMetaData.addParam(bind,column); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ColumnProjector.java b/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ColumnProjector.java deleted file mode 100644 index 0c155fb6..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ColumnProjector.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; - -import java.sql.SQLException; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - - - -/** - * - * Interface used to access the value of a projected column. - * - * @author jtaylor - * @since 0.1 - */ -public interface ColumnProjector { - /** - * Get the column name as it was referenced in the query - * @return the database column name - */ - String getName(); - - /** - * Get the expression - * @return the expression for the column projector - */ - public Expression getExpression(); - - // TODO: An expression may contain references to multiple tables. - /** - * Get the name of the hbase table containing the column - * @return the hbase table name - */ - String getTableName(); - - /** - * Get the value of the column, coercing it if necessary to the specified type - * @param tuple the row containing the column - * @param type the type to which to coerce the binary value - * @param ptr used to retrieve the value - * @return the object representation of the column value. - * @throws SQLException - */ - Object getValue(Tuple tuple, PDataType type, ImmutableBytesWritable ptr) throws SQLException; - - boolean isCaseSensitive(); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ColumnResolver.java b/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ColumnResolver.java deleted file mode 100644 index 93ef389d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ColumnResolver.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.schema.ColumnRef; -import com.salesforce.phoenix.schema.TableRef; - - - -/** - * - * Interface used to resolve column references occurring - * in the select statement. - * - * @author jtaylor - * @since 0.1 - */ -public interface ColumnResolver { - - /** - * Returns the collection of resolved tables in the FROM clause. - */ - public List getTables(); - - /** - * Resolves column using name and alias. - * @param schemaName TODO - * @param tableName TODO - * @param colName TODO - * @return the resolved ColumnRef - * @throws ColumnNotFoundException if the column could not be resolved - * @throws AmbiguousColumnException if the column name is ambiguous - */ - public ColumnRef resolveColumn(String schemaName, String tableName, String colName) throws SQLException; -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/CreateIndexCompiler.java b/phoenix-core/src/main/java/com/salesforce/phoenix/compile/CreateIndexCompiler.java deleted file mode 100644 index d5d5ceff..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/CreateIndexCompiler.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; - -import java.sql.ParameterMetaData; -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - -import org.apache.hadoop.hbase.client.Scan; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixStatement; -import com.salesforce.phoenix.parse.CreateIndexStatement; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.schema.MetaDataClient; - -public class CreateIndexCompiler { - private final PhoenixStatement statement; - - public CreateIndexCompiler(PhoenixStatement statement) { - this.statement = statement; - } - - public MutationPlan compile(final CreateIndexStatement create) throws SQLException { - final PhoenixConnection connection = statement.getConnection(); - final ColumnResolver resolver = FromCompiler.getResolver(create, connection); - Scan scan = new Scan(); - final StatementContext context = new StatementContext(statement, resolver, statement.getParameters(), scan); - ExpressionCompiler expressionCompiler = new ExpressionCompiler(context); - List splitNodes = create.getSplitNodes(); - final byte[][] splits = new byte[splitNodes.size()][]; - for (int i = 0; i < splits.length; i++) { - ParseNode node = splitNodes.get(i); - if (!node.isStateless()) { - throw new SQLExceptionInfo.Builder(SQLExceptionCode.SPLIT_POINT_NOT_CONSTANT) - .setMessage("Node: " + node).build().buildException(); - } - LiteralExpression expression = (LiteralExpression)node.accept(expressionCompiler); - splits[i] = expression.getBytes(); - } - final MetaDataClient client = new MetaDataClient(connection); - - return new MutationPlan() { - - @Override - public ParameterMetaData getParameterMetaData() { - return context.getBindManager().getParameterMetaData(); - } - - @Override - public PhoenixConnection getConnection() { - return connection; - } - - @Override - public MutationState execute() throws SQLException { - return client.createIndex(create, splits); - } - - @Override - public ExplainPlan getExplainPlan() throws SQLException { - return new ExplainPlan(Collections.singletonList("CREATE INDEX")); - } - }; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/DropSequenceCompiler.java b/phoenix-core/src/main/java/com/salesforce/phoenix/compile/DropSequenceCompiler.java deleted file mode 100644 index 568712e0..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/DropSequenceCompiler.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; - -import java.sql.ParameterMetaData; -import java.sql.SQLException; -import java.util.Collections; - -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixParameterMetaData; -import com.salesforce.phoenix.jdbc.PhoenixStatement; -import com.salesforce.phoenix.parse.DropSequenceStatement; -import com.salesforce.phoenix.schema.MetaDataClient; - - -public class DropSequenceCompiler { - private final PhoenixStatement statement; - - public DropSequenceCompiler(PhoenixStatement statement) { - this.statement = statement; - } - - - public MutationPlan compile(final DropSequenceStatement sequence) throws SQLException { - final PhoenixConnection connection = statement.getConnection(); - final MetaDataClient client = new MetaDataClient(connection); - return new MutationPlan() { - - @Override - public MutationState execute() throws SQLException { - return client.dropSequence(sequence); - } - - @Override - public ExplainPlan getExplainPlan() throws SQLException { - return new ExplainPlan(Collections.singletonList("DROP SEQUENCE")); - } - - @Override - public PhoenixConnection getConnection() { - return connection; - } - - @Override - public ParameterMetaData getParameterMetaData() { - return PhoenixParameterMetaData.EMPTY_PARAMETER_META_DATA; - } - - }; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExplainPlan.java b/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExplainPlan.java deleted file mode 100644 index a9900d51..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExplainPlan.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; - -import java.util.Collections; -import java.util.List; - -import com.google.common.collect.ImmutableList; - -public class ExplainPlan { - public static final ExplainPlan EMPTY_PLAN = new ExplainPlan(Collections.emptyList()); - - private final List planSteps; - - public ExplainPlan(List planSteps) { - this.planSteps = ImmutableList.copyOf(planSteps); - } - - public List getPlanSteps() { - return planSteps; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExpressionManager.java b/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExpressionManager.java deleted file mode 100644 index 4a923fbe..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExpressionManager.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; - -import java.util.Iterator; -import java.util.Map; - - -import com.google.common.collect.Maps; -import com.salesforce.phoenix.expression.Expression; - -/** - * - * Class to manage list of expressions inside of a select statement by - * deduping them. - * - * @author jtaylor - * @since 0.1 - */ -public class ExpressionManager { - // Use a Map instead of a Set because we need to get and return - // the existing Expression - private final Map expressionMap; - - public ExpressionManager() { - expressionMap = Maps.newHashMap(); - } - - /** - * Add the expression to the set of known expressions for the select - * clause. If the expression is already in the set, then the new one - * passed in is ignored. - * @param expression the new expression to add - * @return the new expression if not already present in the set and - * the existing one otherwise. - */ - public Expression addIfAbsent(Expression expression) { - Expression existingExpression = expressionMap.get(expression); - if (existingExpression == null) { - expressionMap.put(expression, expression); - return expression; - } - return existingExpression; - } - - public int getExpressionCount() { - return expressionMap.size(); - } - - public Iterator getExpressions() { - return expressionMap.keySet().iterator(); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExpressionProjector.java b/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExpressionProjector.java deleted file mode 100644 index 384787bb..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExpressionProjector.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; - - -import java.sql.SQLException; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - - - -/** - * - * Projector for getting value from a select statement for an expression - * - * @author jtaylor - * @since 0.1 - */ -public class ExpressionProjector implements ColumnProjector { - private final String name; - private final Expression expression; - private final String tableName; - private final boolean isCaseSensitive; - - public ExpressionProjector(String name, String tableName, Expression expression, boolean isCaseSensitive) { - this.name = name; - this.expression = expression; - this.tableName = tableName; - this.isCaseSensitive = isCaseSensitive; - } - - @Override - public String getTableName() { - return tableName; - } - - @Override - public Expression getExpression() { - return expression; - } - - @Override - public String getName() { - return name; - } - - @Override - public final Object getValue(Tuple tuple, PDataType type, ImmutableBytesWritable ptr) throws SQLException { - try { - Expression expression = getExpression(); - if (!expression.evaluate(tuple, ptr)) { - return null; - } - if (ptr.getLength() == 0) { - return null; - } - return type.toObject(ptr, expression.getDataType(), expression.getColumnModifier()); - } catch (RuntimeException e) { - // FIXME: Expression.evaluate does not throw SQLException - // so this will unwrap throws from that. - if (e.getCause() instanceof SQLException) { - throw (SQLException) e.getCause(); - } - throw e; - } - } - - @Override - public boolean isCaseSensitive() { - return isCaseSensitive; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/MutationPlan.java b/phoenix-core/src/main/java/com/salesforce/phoenix/compile/MutationPlan.java deleted file mode 100644 index 36d9dc16..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/MutationPlan.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; - -import java.sql.SQLException; - -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.jdbc.PhoenixConnection; - - -public interface MutationPlan extends StatementPlan { - public PhoenixConnection getConnection(); - public MutationState execute() throws SQLException; -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/QueryPlan.java b/phoenix-core/src/main/java/com/salesforce/phoenix/compile/QueryPlan.java deleted file mode 100644 index 11e0cf22..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/QueryPlan.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.compile.OrderByCompiler.OrderBy; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.parse.FilterableStatement; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.schema.TableRef; - - - -/** - * - * Interface for an executable query plan - * - * @author jtaylor - * @since 0.1 - */ -public interface QueryPlan extends StatementPlan { - /** - * Get a result iterator to iterate over the results - * @return result iterator for iterating over the results - * @throws SQLException - */ - public ResultIterator iterator() throws SQLException; - - public long getEstimatedSize(); - - // TODO: change once joins are supported - TableRef getTableRef(); - /** - * Returns projector used to formulate resultSet row - */ - RowProjector getProjector(); - - Integer getLimit(); - - OrderBy getOrderBy(); - - GroupBy getGroupBy(); - - List getSplits(); - - StatementContext getContext(); - - FilterableStatement getStatement(); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/StatementPlan.java b/phoenix-core/src/main/java/com/salesforce/phoenix/compile/StatementPlan.java deleted file mode 100644 index b04eeb77..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/StatementPlan.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; - -import java.sql.ParameterMetaData; -import java.sql.SQLException; - -import com.salesforce.phoenix.jdbc.PhoenixParameterMetaData; - - -public interface StatementPlan { - public final StatementPlan EMPTY_PLAN = new StatementPlan() { - @Override - public ParameterMetaData getParameterMetaData() { - return new PhoenixParameterMetaData(0); - } - - @Override - public ExplainPlan getExplainPlan() throws SQLException { - return ExplainPlan.EMPTY_PLAN; - } - }; - - /** - * Returns the ParameterMetaData for the statement - */ - ParameterMetaData getParameterMetaData(); - - ExplainPlan getExplainPlan() throws SQLException; -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/BaseRegionScanner.java b/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/BaseRegionScanner.java deleted file mode 100644 index ff9c1f25..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/BaseRegionScanner.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.coprocessor; - -import java.io.IOException; -import java.util.List; - -import org.apache.hadoop.hbase.DoNotRetryIOException; -import org.apache.hadoop.hbase.KeyValue; -import org.apache.hadoop.hbase.regionserver.RegionScanner; - -public abstract class BaseRegionScanner implements RegionScanner { - - @Override - public boolean isFilterDone() { - return false; - } - - @Override - public boolean next(List results, String metric) throws IOException { - return next(results); - } - - @Override - public boolean next(List result, int limit, String metric) throws IOException { - return next(result); - } - @Override - public boolean next(List result, int limit) throws IOException { - return next(result); - } - - @Override - public boolean reseek(byte[] row) throws IOException { - throw new DoNotRetryIOException("Unsupported"); - } - - @Override - public long getMvccReadPoint() { - return Long.MAX_VALUE; - } - - @Override - public boolean nextRaw(List result, String metric) throws IOException { - return next(result, metric); - } - - @Override - public boolean nextRaw(List result, int limit, String metric) throws IOException { - return next(result, limit, metric); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/BaseScannerRegionObserver.java b/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/BaseScannerRegionObserver.java deleted file mode 100644 index 8e718ba7..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/BaseScannerRegionObserver.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.coprocessor; - -import java.io.IOException; - -import org.apache.hadoop.hbase.client.Scan; -import org.apache.hadoop.hbase.coprocessor.*; -import org.apache.hadoop.hbase.regionserver.RegionScanner; - -import com.salesforce.phoenix.util.ServerUtil; - - -abstract public class BaseScannerRegionObserver extends BaseRegionObserver { - - /** - * Used by logger to identify coprocessor - */ - @Override - public String toString() { - return this.getClass().getName(); - } - - abstract protected RegionScanner doPostScannerOpen(final ObserverContext c, final Scan scan, final RegionScanner s) throws Throwable; - - /** - * Wrapper for {@link #postScannerOpen(ObserverContext, Scan, RegionScanner)} that ensures no non IOException is thrown, - * to prevent the coprocessor from becoming blacklisted. - * - */ - @Override - public final RegionScanner postScannerOpen(final ObserverContext c, final Scan scan, final RegionScanner s) throws IOException { - try { - return doPostScannerOpen(c, scan, s); - } catch (Throwable t) { - ServerUtil.throwIOException(c.getEnvironment().getRegion().getRegionNameAsString(), t); - return null; // impossible - } - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/GroupByCache.java b/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/GroupByCache.java deleted file mode 100644 index 7107f3bd..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/GroupByCache.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source - * and binary forms, with or without modification, are permitted provided that the following - * conditions are met: Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. Redistributions in binary form must reproduce - * the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of - * Salesforce.com nor the names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED - * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.coprocessor; - -import java.io.Closeable; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import org.apache.hadoop.hbase.regionserver.RegionScanner; - -import com.salesforce.phoenix.expression.aggregator.Aggregator; - -/** - * - * Interface to abstract the way in which distinct group by - * elements are cached - * - * @author jtaylor - * @since 3.0.0 - */ -public interface GroupByCache extends Closeable { - int size(); - Aggregator[] cache(ImmutableBytesWritable key); - RegionScanner getScanner(RegionScanner s); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/MetaDataRegionObserver.java b/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/MetaDataRegionObserver.java deleted file mode 100644 index 23013385..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/MetaDataRegionObserver.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.coprocessor; - -import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver; -import org.apache.hadoop.hbase.coprocessor.ObserverContext; -import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; - -import com.salesforce.phoenix.cache.GlobalCache; - - -/** - * Coprocessor for metadata related operations. This coprocessor would only be registered - * to SYSTEM.TABLE. - */ -public class MetaDataRegionObserver extends BaseRegionObserver { - - @Override - public void preClose(final ObserverContext c, - boolean abortRequested) { - GlobalCache.getInstance(c.getEnvironment()).getMetaDataCache().clear(); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ServerCachingEndpointImpl.java b/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ServerCachingEndpointImpl.java deleted file mode 100644 index a000bae4..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ServerCachingEndpointImpl.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.coprocessor; - -import java.sql.SQLException; - -import org.apache.hadoop.hbase.coprocessor.BaseEndpointCoprocessor; -import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.cache.GlobalCache; -import com.salesforce.phoenix.cache.TenantCache; - - - - -/** - * - * Server-side implementation of {@link ServerCachingProtocol} - * - * @author jtaylor - * @since 0.1 - */ -public class ServerCachingEndpointImpl extends BaseEndpointCoprocessor implements ServerCachingProtocol { - - @Override - public boolean addServerCache(byte[] tenantId, byte[] cacheId, ImmutableBytesWritable cachePtr, ServerCacheFactory cacheFactory) throws SQLException { - TenantCache tenantCache = GlobalCache.getTenantCache((RegionCoprocessorEnvironment)this.getEnvironment(), tenantId == null ? null : new ImmutableBytesPtr(tenantId)); - tenantCache.addServerCache(new ImmutableBytesPtr(cacheId), cachePtr, cacheFactory); - return true; - } - - @Override - public boolean removeServerCache(byte[] tenantId, byte[] cacheId) throws SQLException { - TenantCache tenantCache = GlobalCache.getTenantCache((RegionCoprocessorEnvironment)this.getEnvironment(), tenantId == null ? null : new ImmutableBytesPtr(tenantId)); - tenantCache.removeServerCache(new ImmutableBytesPtr(cacheId)); - return true; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ServerCachingProtocol.java b/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ServerCachingProtocol.java deleted file mode 100644 index ddcf31cd..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ServerCachingProtocol.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.coprocessor; - -import java.io.Closeable; -import java.sql.SQLException; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; -import org.apache.hadoop.io.Writable; - -import com.salesforce.phoenix.memory.MemoryManager.MemoryChunk; - -/** - * - * EndPoint coprocessor to send a cache to a region server. - * Used for: - * a) hash joins, to send the smaller side of the join to each region server - * b) secondary indexes, to send the necessary meta data to each region server - * @author jtaylor - * @since 0.1 - */ -public interface ServerCachingProtocol extends CoprocessorProtocol { - public static interface ServerCacheFactory extends Writable { - public Closeable newCache(ImmutableBytesWritable cachePtr, MemoryChunk chunk) throws SQLException; - } - /** - * Add the cache to the region server cache. - * @param tenantId the tenantId or null if not applicable - * @param cacheId unique identifier of the cache - * @param cachePtr pointer to the byte array of the cache - * @param cacheFactory factory that converts from byte array to object representation on the server side - * @return true on success and otherwise throws - * @throws SQLException - */ - public boolean addServerCache(byte[] tenantId, byte[] cacheId, ImmutableBytesWritable cachePtr, ServerCacheFactory cacheFactory) throws SQLException; - /** - * Remove the cache from the region server cache. Called upon completion of - * the operation when cache is no longer needed. - * @param tenantId the tenantId or null if not applicable - * @param cacheId unique identifier of the cache - * @return true on success and otherwise throws - * @throws SQLException - */ - public boolean removeServerCache(byte[] tenantId, byte[] cacheId) throws SQLException; -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/exception/PhoenixIOException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/exception/PhoenixIOException.java deleted file mode 100644 index 5fd9049a..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/exception/PhoenixIOException.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.exception; - -import java.sql.SQLException; - - -public class PhoenixIOException extends SQLException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.IO_EXCEPTION; - - public PhoenixIOException(Throwable e) { - super(e.getMessage(), code.getSQLState(), code.getErrorCode(), e); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/exception/UnknownFunctionException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/exception/UnknownFunctionException.java deleted file mode 100644 index 4bf57b8f..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/exception/UnknownFunctionException.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.exception; - -/** - * Thrown by ParseNodeFactory when it could not identify a node as a valid function. - */ -public class UnknownFunctionException extends RuntimeException { - private static final long serialVersionUID = 1L; - private final String funcName; - - public UnknownFunctionException(String funcName) { - super(); - this.funcName = funcName; - } - - public String getFuncName() { - return funcName; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/exception/ValueTypeIncompatibleException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/exception/ValueTypeIncompatibleException.java deleted file mode 100644 index 1412ce8d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/exception/ValueTypeIncompatibleException.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.exception; - -import com.salesforce.phoenix.schema.IllegalDataException; -import com.salesforce.phoenix.schema.PDataType; - - -public class ValueTypeIncompatibleException extends IllegalDataException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.DATA_INCOMPATIBLE_WITH_TYPE; - - public ValueTypeIncompatibleException(PDataType type, Integer precision, Integer scale) { - super(new SQLExceptionInfo.Builder(code).setMessage(getTypeDisplayString(type, precision, scale)) - .build().toString()); - } - - private static String getTypeDisplayString(PDataType type, Integer precision, Integer scale) { - return type.toString() + "(" + precision + "," + scale + ")"; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/CommitException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/execute/CommitException.java deleted file mode 100644 index 2ade76d7..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/CommitException.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.execute; - -import java.sql.SQLException; - -public class CommitException extends SQLException { - private static final long serialVersionUID = 1L; - private final MutationState uncommittedState; - private final MutationState committedState; - - public CommitException(Exception e, MutationState uncommittedState, MutationState committedState) { - super(e); - this.uncommittedState = uncommittedState; - this.committedState = committedState; - } - - public MutationState getUncommittedState() { - return uncommittedState; - } - - public MutationState getCommittedState() { - return committedState; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/DegenerateQueryPlan.java b/phoenix-core/src/main/java/com/salesforce/phoenix/execute/DegenerateQueryPlan.java deleted file mode 100644 index 8c6877e3..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/DegenerateQueryPlan.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.execute; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.compile.OrderByCompiler.OrderBy; -import com.salesforce.phoenix.compile.*; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.jdbc.PhoenixParameterMetaData; -import com.salesforce.phoenix.parse.FilterableStatement; -import com.salesforce.phoenix.query.*; -import com.salesforce.phoenix.schema.TableRef; - -public class DegenerateQueryPlan extends BasicQueryPlan { - - public DegenerateQueryPlan(StatementContext context, FilterableStatement statement, TableRef table) { - super(context, statement, table, RowProjector.EMPTY_PROJECTOR, PhoenixParameterMetaData.EMPTY_PARAMETER_META_DATA, null, OrderBy.EMPTY_ORDER_BY, GroupBy.EMPTY_GROUP_BY, null); - context.setScanRanges(ScanRanges.NOTHING); - } - - @Override - public List getSplits() { - return Collections.emptyList(); - } - - @Override - protected ResultIterator newIterator() throws SQLException { - return null; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/ScanPlan.java b/phoenix-core/src/main/java/com/salesforce/phoenix/execute/ScanPlan.java deleted file mode 100644 index 4a0fc1ad..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/ScanPlan.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.execute; - - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.compile.OrderByCompiler.OrderBy; -import com.salesforce.phoenix.compile.RowProjector; -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.coprocessor.ScanRegionObserver; -import com.salesforce.phoenix.iterate.ConcatResultIterator; -import com.salesforce.phoenix.iterate.LimitingResultIterator; -import com.salesforce.phoenix.iterate.MergeSortRowKeyResultIterator; -import com.salesforce.phoenix.iterate.MergeSortTopNResultIterator; -import com.salesforce.phoenix.iterate.ParallelIterators; -import com.salesforce.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.iterate.SequenceResultIterator; -import com.salesforce.phoenix.iterate.SpoolingResultIterator; -import com.salesforce.phoenix.parse.FilterableStatement; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.SaltingUtil; -import com.salesforce.phoenix.schema.TableRef; - - - -/** - * - * Query plan for a basic table scan - * - * @author jtaylor - * @since 0.1 - */ -public class ScanPlan extends BasicQueryPlan { - private List splits; - - public ScanPlan(StatementContext context, FilterableStatement statement, TableRef table, RowProjector projector, Integer limit, OrderBy orderBy, ParallelIteratorFactory parallelIteratorFactory) { - super(context, statement, table, projector, context.getBindManager().getParameterMetaData(), limit, orderBy, null, parallelIteratorFactory == null ? new SpoolingResultIterator.SpoolingResultIteratorFactory(context.getConnection().getQueryServices()) : parallelIteratorFactory); - if (!orderBy.getOrderByExpressions().isEmpty()) { // TopN - int thresholdBytes = context.getConnection().getQueryServices().getProps().getInt( - QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB, QueryServicesOptions.DEFAULT_SPOOL_THRESHOLD_BYTES); - ScanRegionObserver.serializeIntoScan(context.getScan(), thresholdBytes, limit == null ? -1 : limit, orderBy.getOrderByExpressions(), projector.getEstimatedRowByteSize()); - } - } - - @Override - public List getSplits() { - return splits; - } - - @Override - protected ResultIterator newIterator() throws SQLException { - // Set any scan attributes before creating the scanner, as it will be too late afterwards - context.getScan().setAttribute(ScanRegionObserver.NON_AGGREGATE_QUERY, QueryConstants.TRUE); - ResultIterator scanner; - TableRef tableRef = this.getTableRef(); - PTable table = tableRef.getTable(); - boolean isSalted = table.getBucketNum() != null; - /* If no limit or topN, use parallel iterator so that we get results faster. Otherwise, if - * limit is provided, run query serially. - */ - boolean isOrdered = !orderBy.getOrderByExpressions().isEmpty(); - ParallelIterators iterators = new ParallelIterators(context, tableRef, statement, projection, GroupBy.EMPTY_GROUP_BY, isOrdered ? null : limit, parallelIteratorFactory); - splits = iterators.getSplits(); - if (isOrdered) { - scanner = new MergeSortTopNResultIterator(iterators, limit, orderBy.getOrderByExpressions()); - } else { - if (isSalted && - (getConnectionQueryServices(context.getConnection().getQueryServices()).getProps().getBoolean( - QueryServices.ROW_KEY_ORDER_SALTED_TABLE_ATTRIB, - QueryServicesOptions.DEFAULT_ROW_KEY_ORDER_SALTED_TABLE) || - orderBy == OrderBy.ROW_KEY_ORDER_BY)) { // ORDER BY was optimized out b/c query is in row key order - scanner = new MergeSortRowKeyResultIterator(iterators, SaltingUtil.NUM_SALTING_BYTES); - } else { - scanner = new ConcatResultIterator(iterators); - } - if (limit != null) { - scanner = new LimitingResultIterator(scanner, limit); - } - } - - if (context.getSequenceManager().getSequenceCount() > 0) { - scanner = new SequenceResultIterator(scanner, context.getSequenceManager()); - } - return scanner; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/AddExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/AddExpression.java deleted file mode 100644 index 749f6588..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/AddExpression.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.util.List; - -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; - - -/** - * - * Subtract expression implementation - * - * @author jtaylor - * @since 0.1 - */ -public abstract class AddExpression extends BaseAddSubtractExpression { - public AddExpression() { - } - - public AddExpression(List children) { - super(children); - } - - @Override - public final T accept(ExpressionVisitor visitor) { - List l = acceptChildren(visitor, visitor.visitEnter(this)); - T t = visitor.visitLeave(this, l); - if (t == null) { - t = visitor.defaultReturn(this, l); - } - return t; - } - - @Override - public String getOperatorString() { - return " + "; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/AndExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/AndExpression.java deleted file mode 100644 index 47fea8d9..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/AndExpression.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.util.List; - -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; - - -/** - * - * AND expression implementation - * - * @author jtaylor - * @since 0.1 - */ -public class AndExpression extends AndOrExpression { - private static final String AND = "AND"; - - public static String combine(String expression1, String expression2) { - if (expression1 == null) { - return expression2; - } - if (expression2 == null) { - return expression1; - } - return "(" + expression1 + ") " + AND + " (" + expression2 + ")"; - } - - public AndExpression() { - } - - public AndExpression(List children) { - super(children); - } - - @Override - protected boolean getStopValue() { - return Boolean.FALSE; - } - - @Override - public String toString() { - StringBuilder buf = new StringBuilder("("); - for (int i = 0; i < children.size() - 1; i++) { - buf.append(children.get(i) + " " + AND + " "); - } - buf.append(children.get(children.size()-1)); - buf.append(')'); - return buf.toString(); - } - - @Override - public final T accept(ExpressionVisitor visitor) { - List l = acceptChildren(visitor, visitor.visitEnter(this)); - T t = visitor.visitLeave(this, l); - if (t == null) { - t = visitor.defaultReturn(this, l); - } - return t; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/ArithmeticExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/ArithmeticExpression.java deleted file mode 100644 index 1721c623..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/ArithmeticExpression.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.util.List; - -public abstract class ArithmeticExpression extends BaseCompoundExpression { - - public ArithmeticExpression() { - } - - public ArithmeticExpression(List children) { - super(children); - } - - @Override - public String toString() { - StringBuilder buf = new StringBuilder("("); - for (int i = 0; i < children.size() - 1; i++) { - buf.append(children.get(i) + getOperatorString()); - } - buf.append(children.get(children.size()-1)); - buf.append(')'); - return buf.toString(); - } - - abstract protected String getOperatorString(); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseAddSubtractExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseAddSubtractExpression.java deleted file mode 100644 index 1bd0d8f0..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseAddSubtractExpression.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.util.List; - -import com.salesforce.phoenix.schema.PDataType; - - -abstract public class BaseAddSubtractExpression extends ArithmeticExpression { - public BaseAddSubtractExpression() { - } - - public BaseAddSubtractExpression(List children) { - super(children); - } - - protected static Integer getPrecision(Integer lp, Integer rp, Integer ls, Integer rs) { - if (ls == null || rs == null) { - return PDataType.MAX_PRECISION; - } - int val = getScale(lp, rp, ls, rs) + Math.max(lp - ls, rp - rs) + 1; - return Math.min(PDataType.MAX_PRECISION, val); - } - - protected static Integer getScale(Integer lp, Integer rp, Integer ls, Integer rs) { - // If we are adding a decimal with scale and precision to a decimal - // with no precision nor scale, the scale system does not apply. - if (ls == null || rs == null) { - return null; - } - int val = Math.max(ls, rs); - return Math.min(PDataType.MAX_PRECISION, val); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseExpression.java deleted file mode 100644 index 5d3ff48c..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseExpression.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.schema.ColumnModifier; - - - -/** - * - * Base class for Expression hierarchy that provides common - * default implementations for most methods - * - * @author jtaylor - * @since 0.1 - */ -public abstract class BaseExpression implements Expression { - @Override - public boolean isNullable() { - return false; - } - - @Override - public Integer getByteSize() { - return getDataType().isFixedWidth() ? getDataType().getByteSize() : null; - } - - @Override - public Integer getMaxLength() { - return null; - } - - @Override - public Integer getScale() { - return null; - } - - @Override - public ColumnModifier getColumnModifier() { - return null; - } - - @Override - public void readFields(DataInput input) throws IOException { - } - - @Override - public void write(DataOutput output) throws IOException { - } - - @Override - public void reset() { - } - - protected final List acceptChildren(ExpressionVisitor visitor, Iterator iterator) { - if (iterator == null) { - iterator = visitor.defaultIterator(this); - } - List l = Collections.emptyList(); - while (iterator.hasNext()) { - Expression child = iterator.next(); - T t = child.accept(visitor); - if (t != null) { - if (l.isEmpty()) { - l = new ArrayList(getChildren().size()); - } - l.add(t); - } - } - return l; - } - - @Override - public boolean isDeterministic() { - return true; - } - - @Override - public boolean isStateless() { - return false; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseSingleExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseSingleExpression.java deleted file mode 100644 index 43dc8a38..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseSingleExpression.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.List; - -import org.apache.hadoop.io.WritableUtils; - -import com.google.common.collect.ImmutableList; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; - - -/** - * - * Base class for expressions which have a single child expression - * - * @author jtaylor - * @since 0.1 - */ -public abstract class BaseSingleExpression extends BaseExpression { - - protected List children; - - public BaseSingleExpression() { - } - - public BaseSingleExpression(Expression expression) { - this.children = ImmutableList.of(expression); - } - - @Override - public List getChildren() { - return children; - } - - @Override - public void readFields(DataInput input) throws IOException { - Expression expression = ExpressionType.values()[WritableUtils.readVInt(input)].newInstance(); - expression.readFields(input); - children = ImmutableList.of(expression); - } - - @Override - public void write(DataOutput output) throws IOException { - WritableUtils.writeVInt(output, ExpressionType.valueOf(children.get(0)).ordinal()); - children.get(0).write(output); - } - - @Override - public boolean isNullable() { - return children.get(0).isNullable(); - } - - @Override - public void reset() { - children.get(0).reset(); - } - - @Override - public T accept(ExpressionVisitor visitor) { - List l = acceptChildren(visitor, null); - if (l.isEmpty()) { - return visitor.defaultReturn(this, l); - } - return l.get(0); - } - - public Expression getChild() { - return children.get(0); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseTerminalExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseTerminalExpression.java deleted file mode 100644 index e19ea68d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseTerminalExpression.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.util.Collections; -import java.util.List; - -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; - - - -/** - * - * Grouping class for expression that have no expression children - * - * @author jtaylor - * @since 0.1 - */ -public abstract class BaseTerminalExpression extends BaseExpression { - @Override - public List getChildren() { - return Collections.emptyList(); - } - - @Override - public T accept(ExpressionVisitor visitor) { - return null; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/CurrentDateTimeFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/CurrentDateTimeFunction.java deleted file mode 100644 index f363af71..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/CurrentDateTimeFunction.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.util.List; - -import com.salesforce.phoenix.expression.function.ScalarFunction; - -public abstract class CurrentDateTimeFunction extends ScalarFunction { - - public CurrentDateTimeFunction() { - } - - public CurrentDateTimeFunction(List children) { - super(children); - } - - @Override - public boolean isStateless() { - return true; - } - - @Override - public boolean isDeterministic() { - return false; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/DateAddExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/DateAddExpression.java deleted file mode 100644 index 9b8827f8..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/DateAddExpression.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.math.BigDecimal; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -public class DateAddExpression extends AddExpression { - static private final BigDecimal BD_MILLIS_IN_DAY = BigDecimal.valueOf(QueryConstants.MILLIS_IN_DAY); - - public DateAddExpression() { - } - - public DateAddExpression(List children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - long finalResult=0; - - for(int i=0;i children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - long finalResult=0; - - for(int i=0;i children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - BigDecimal result = null; - for (int i=0; i children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - BigDecimal result = null; - for (int i=0; i children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - double result = 0.0; - for (int i = 0; i < children.size(); i++) { - Expression child = children.get(i); - if (!child.evaluate(tuple, ptr)) { - return false; - } - if (ptr.getLength() == 0) { - return true; - } - double childvalue = child.getDataType().getCodec() - .decodeDouble(ptr, child.getColumnModifier()); - if (!Double.isNaN(childvalue) - && childvalue != Double.NEGATIVE_INFINITY - && childvalue != Double.POSITIVE_INFINITY) { - result += childvalue; - } else { - return false; - } - } - byte[] resultPtr = new byte[getDataType().getByteSize()]; - ptr.set(resultPtr); - getDataType().getCodec().encodeDouble(result, ptr); - return true; - } - - @Override - public PDataType getDataType() { - return PDataType.DOUBLE; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/DoubleDivideExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/DoubleDivideExpression.java deleted file mode 100644 index 668e48c5..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/DoubleDivideExpression.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - -public class DoubleDivideExpression extends DivideExpression { - - public DoubleDivideExpression() { - } - - public DoubleDivideExpression(List children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - double result = 0.0; - for (int i = 0; i < children.size(); i++) { - Expression child = children.get(i); - if (!child.evaluate(tuple, ptr)) { - return false; - } - if (ptr.getLength() == 0) { - return true; - } - double childvalue = child.getDataType().getCodec() - .decodeDouble(ptr, child.getColumnModifier()); - if (!Double.isNaN(childvalue) - && childvalue != Double.NEGATIVE_INFINITY - && childvalue != Double.POSITIVE_INFINITY) { - if (i == 0) { - result = childvalue; - } else { - result /= childvalue; - } - } else { - return false; - } - } - byte[] resultPtr = new byte[getDataType().getByteSize()]; - ptr.set(resultPtr); - getDataType().getCodec().encodeDouble(result, ptr); - return true; - } - - @Override - public PDataType getDataType() { - return PDataType.DOUBLE; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/DoubleMultiplyExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/DoubleMultiplyExpression.java deleted file mode 100644 index 0a9f9468..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/DoubleMultiplyExpression.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - -public class DoubleMultiplyExpression extends MultiplyExpression { - - public DoubleMultiplyExpression() { - } - - public DoubleMultiplyExpression(List children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - double result = 1.0; - for (int i = 0; i < children.size(); i++) { - Expression child = children.get(i); - if (!child.evaluate(tuple, ptr)) { - return false; - } - if (ptr.getLength() == 0) { - return true; - } - double childvalue = child.getDataType().getCodec() - .decodeDouble(ptr, child.getColumnModifier()); - if (!Double.isNaN(childvalue) - && childvalue != Double.NEGATIVE_INFINITY - && childvalue != Double.POSITIVE_INFINITY) { - result *= childvalue; - } else { - return false; - } - } - byte[] resultPtr = new byte[getDataType().getByteSize()]; - ptr.set(resultPtr); - getDataType().getCodec().encodeDouble(result, ptr); - return true; - } - - @Override - public PDataType getDataType() { - return PDataType.DOUBLE; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/DoubleSubtractExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/DoubleSubtractExpression.java deleted file mode 100644 index e25b3f74..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/DoubleSubtractExpression.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - -public class DoubleSubtractExpression extends SubtractExpression { - - public DoubleSubtractExpression() { - } - - public DoubleSubtractExpression(List children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - double result = 0.0; - for (int i = 0; i < children.size(); i++) { - Expression child = children.get(i); - if (!child.evaluate(tuple, ptr)) { - return false; - } - if (ptr.getLength() == 0) { - return true; - } - double childvalue = child.getDataType().getCodec() - .decodeDouble(ptr, child.getColumnModifier()); - if (!Double.isNaN(childvalue) - && childvalue != Double.NEGATIVE_INFINITY - && childvalue != Double.POSITIVE_INFINITY) { - if (i == 0) { - result = childvalue; - } else { - result -= childvalue; - } - } else { - return false; - } - } - byte[] resultPtr = new byte[getDataType().getByteSize()]; - ptr.set(resultPtr); - getDataType().getCodec().encodeDouble(result, ptr); - return true; - } - - @Override - public PDataType getDataType() { - return PDataType.DOUBLE; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/Expression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/Expression.java deleted file mode 100644 index 1138ecfd..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/Expression.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import org.apache.hadoop.io.Writable; - -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.schema.PDatum; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Interface for general expression evaluation - * - * @author jtaylor - * @since 0.1 - */ -public interface Expression extends PDatum, Writable { - /** - * Access the value by setting a pointer to it (as opposed to making - * a copy of it which can be expensive) - * @param tuple Single row result during scan iteration - * @param ptr Pointer to byte value being accessed - * @return true if the expression could be evaluated (i.e. ptr was set) - * and false otherwise - */ - boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr); - - /** - * Means of traversing expression tree through visitor. - * @param visitor - */ - T accept(ExpressionVisitor visitor); - - /** - * @return the child expressions - */ - List getChildren(); - - /** - * Resets the state of a expression back to its initial state and - * enables the expession to be evaluated incrementally (which - * occurs during filter evaluation where we see one key value at - * a time; it's possible to evaluate immediately rather than - * wait until all key values have been seen). Note that when - * evaluating incrementally, you must call this method before - * processing a new row. - */ - void reset(); - - /** - * @return true if the expression can be evaluated without - * requiring a row Tuple and false otherwise. - */ - boolean isStateless(); - /** - * @return true if the expression returns the same output every - * time given the same input. - */ - boolean isDeterministic(); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/LongAddExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/LongAddExpression.java deleted file mode 100644 index 2e2fe9bd..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/LongAddExpression.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -public class LongAddExpression extends AddExpression { - - public LongAddExpression() { - } - - public LongAddExpression(List children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - long finalResult=0; - - for(int i=0;i children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - long finalResult=0; - - for(int i=0;i children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - long finalResult=1; - - for(int i=0;i children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - long finalResult=0; - - for(int i=0;i T accept(ExpressionVisitor visitor) { - List l = acceptChildren(visitor, visitor.visitEnter(this)); - T t = visitor.visitLeave(this, l); - if (t == null) { - t = visitor.defaultReturn(this, l); - } - return t; - } - - @Override - public String toString() { - StringBuilder buf = new StringBuilder("NOT ("); - buf.append(children.get(0).toString()); - buf.append(")"); - return buf.toString(); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/OrExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/OrExpression.java deleted file mode 100644 index ed2faf80..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/OrExpression.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.util.List; - -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; - - -/** - * - * OR expression implementation - * - * @author jtaylor - * @since 0.1 - */ -public class OrExpression extends AndOrExpression { - public OrExpression() { - } - - public OrExpression(List children) { - super(children); - } - - @Override - protected boolean getStopValue() { - return Boolean.TRUE; - } - - @Override - public String toString() { - StringBuilder buf = new StringBuilder("("); - for (int i = 0; i < children.size() - 1; i++) { - buf.append(children.get(i) + " OR "); - } - buf.append(children.get(children.size()-1)); - buf.append(')'); - return buf.toString(); - } - - @Override - public final T accept(ExpressionVisitor visitor) { - List l = acceptChildren(visitor, visitor.visitEnter(this)); - T t = visitor.visitLeave(this, l); - if (t == null) { - t = visitor.defaultReturn(this, l); - } - return t; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/SubtractExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/SubtractExpression.java deleted file mode 100644 index 169290a6..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/SubtractExpression.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; - -import java.math.BigDecimal; -import java.util.List; - -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.query.QueryConstants; - - -/** - * - * Subtract expression implementation - * - * @author kmahadik - * @since 0.1 - */ -public abstract class SubtractExpression extends BaseAddSubtractExpression { - protected static final BigDecimal BD_MILLIS_IN_DAY = BigDecimal.valueOf(QueryConstants.MILLIS_IN_DAY); - - public SubtractExpression() { - } - - public SubtractExpression(List children) { - super(children); - } - - @Override - public final T accept(ExpressionVisitor visitor) { - List l = acceptChildren(visitor, visitor.visitEnter(this)); - T t = visitor.visitLeave(this, l); - if (t == null) { - t = visitor.defaultReturn(this, l); - } - return t; - } - - @Override - public String getOperatorString() { - return " - "; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/Aggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/Aggregator.java deleted file mode 100644 index 82a96b7e..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/Aggregator.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Interface to abstract the incremental calculation of an aggregated value. - * - * @author jtaylor - * @since 0.1 - */ -public interface Aggregator extends Expression { - - /** - * Incrementally aggregate the value with the current row - * @param tuple the result containing all the key values of the row - * @param ptr the bytes pointer to the underlying result - */ - public void aggregate(Tuple tuple, ImmutableBytesWritable ptr); - - /** - * Get the size in bytes - */ - public int getSize(); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/BaseAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/BaseAggregator.java deleted file mode 100644 index 3862b63f..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/BaseAggregator.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.BaseTerminalExpression; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.util.SizedUtil; - -/** - * Base class for Aggregator implementations - * - * @author jtaylor - * @since 0.1 - */ -public abstract class BaseAggregator extends BaseTerminalExpression implements Aggregator { - - protected final ColumnModifier columnModifier; - - public BaseAggregator(ColumnModifier columnModifier) { - this.columnModifier = columnModifier; - } - - @Override - public boolean isNullable() { - return true; - } - - @Override - public int getSize() { - return SizedUtil.OBJECT_SIZE; - } - - ImmutableBytesWritable evalClientAggs(Aggregator clientAgg) { - CountAggregator ca = (CountAggregator)clientAgg; - ImmutableBytesWritable ptr = new ImmutableBytesWritable(); - ca.evaluate(null, ptr); - return ptr; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/ClientAggregators.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/ClientAggregators.java deleted file mode 100644 index 01fc9768..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/ClientAggregators.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import java.util.List; - -import com.salesforce.phoenix.expression.function.SingleAggregateFunction; -import com.salesforce.phoenix.schema.ValueBitSet; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.TupleUtil; - - - -/** - * - * Aggregators that execute on the client-side - * - * @author jtaylor - * @since 0.1 - */ -public class ClientAggregators extends Aggregators { - private final ValueBitSet tempValueSet; - - private static Aggregator[] getAggregators(List aggFuncs) { - Aggregator[] aggregators = new Aggregator[aggFuncs.size()]; - for (int i = 0; i < aggregators.length; i++) { - aggregators[i] = aggFuncs.get(i).getAggregator(); - } - return aggregators; - } - - public ClientAggregators(List functions, int minNullableIndex) { - super(functions.toArray(new SingleAggregateFunction[functions.size()]), getAggregators(functions), minNullableIndex); - this.tempValueSet = ValueBitSet.newInstance(schema); - } - - @Override - public void aggregate(Aggregator[] aggregators, Tuple result) { - TupleUtil.getAggregateValue(result, ptr); - tempValueSet.clear(); - tempValueSet.or(ptr); - - int i = 0, maxOffset = ptr.getOffset() + ptr.getLength(); - Boolean hasValue; - schema.iterator(ptr); - while ((hasValue=schema.next(ptr, i, maxOffset, tempValueSet)) != null) { - if (hasValue) { - aggregators[i].aggregate(result, ptr); - } - i++; - } - } - - @Override - public Aggregator[] newAggregators() { - Aggregator[] aggregators = new Aggregator[functions.length]; - for (int i = 0; i < functions.length; i++) { - aggregators[i] = functions[i].newClientAggregator(); - } - return aggregators; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/CountAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/CountAggregator.java deleted file mode 100644 index 849944d4..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/CountAggregator.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.SizedUtil; - -/** - * - * Aggregator for COUNT aggregations - * - * @author jtaylor - * @since 0.1 - */ -public class CountAggregator extends BaseAggregator { - - private long count = 0; - private byte[] buffer = null; - - public CountAggregator() { - super(null); - } - - public CountAggregator(LongSumAggregator clientAgg) { - this(); - count = clientAgg.getSum(); - } - - @Override - public void aggregate(Tuple tuple, ImmutableBytesWritable ptr) { - count++; - } - - @Override - public boolean isNullable() { - return false; - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - if (buffer == null) { - buffer = new byte[getDataType().getByteSize()]; - } - getDataType().getCodec().encodeLong(count, buffer, 0); - ptr.set(buffer); - return true; - } - - @Override - public final PDataType getDataType() { - return PDataType.LONG; - } - - @Override - public void reset() { - count = 0; - buffer = null; - super.reset(); - } - - @Override - public String toString() { - return "COUNT [count=" + count + "]"; - } - - @Override - public int getSize() { - return super.getSize() + SizedUtil.LONG_SIZE + SizedUtil.ARRAY_SIZE - + getDataType().getByteSize(); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DecimalStddevPopAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DecimalStddevPopAggregator.java deleted file mode 100644 index 65ee2d36..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DecimalStddevPopAggregator.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import java.util.List; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.ColumnModifier; - -/** - * Client side Aggregator for STDDEV_POP aggregations for DECIMAL data type. - * - * @author anoopsjohn - * @since 1.2.1 - */ -public class DecimalStddevPopAggregator extends BaseDecimalStddevAggregator { - - public DecimalStddevPopAggregator(List exps, ColumnModifier columnModifier) { - super(exps, columnModifier); - } - - @Override - protected long getDataPointsCount() { - return totalCount; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DecimalStddevSampAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DecimalStddevSampAggregator.java deleted file mode 100644 index ddedc5c3..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DecimalStddevSampAggregator.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import java.util.List; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.ColumnModifier; - -/** - * Client side Aggregator for STDDEV_SAMP aggregations for DECIMAL data type. - * - * @author anoopsjohn - * @since 1.2.1 - */ -public class DecimalStddevSampAggregator extends BaseDecimalStddevAggregator { - - public DecimalStddevSampAggregator(List exps, ColumnModifier columnModifier) { - super(exps, columnModifier); - } - - @Override - protected long getDataPointsCount() { - return totalCount - 1; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DecimalSumAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DecimalSumAggregator.java deleted file mode 100644 index 1b4786b1..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DecimalSumAggregator.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import java.math.BigDecimal; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.SizedUtil; - - -/** - * - * Aggregator that sums BigDecimal values - * - * @author jtaylor - * @since 0.1 - */ -public class DecimalSumAggregator extends BaseAggregator { - private BigDecimal sum = BigDecimal.ZERO; - private byte[] sumBuffer; - - public DecimalSumAggregator(ColumnModifier columnModifier, ImmutableBytesWritable ptr) { - super(columnModifier); - if (ptr != null) { - initBuffer(); - sum = (BigDecimal)PDataType.DECIMAL.toObject(ptr); - } - } - - private PDataType getInputDataType() { - return PDataType.DECIMAL; - } - - private int getBufferLength() { - return getDataType().getByteSize(); - } - - private void initBuffer() { - sumBuffer = new byte[getBufferLength()]; - } - - @Override - public void aggregate(Tuple tuple, ImmutableBytesWritable ptr) { - BigDecimal value = (BigDecimal)getDataType().toObject(ptr, getInputDataType(), columnModifier); - sum = sum.add(value); - if (sumBuffer == null) { - sumBuffer = new byte[getDataType().getByteSize()]; - } - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - if (sumBuffer == null) { - return false; - } - int len = getDataType().toBytes(sum, sumBuffer, 0); - ptr.set(sumBuffer, 0, len); - return true; - } - - @Override - public final PDataType getDataType() { - return PDataType.DECIMAL; - } - - @Override - public void reset() { - sum = BigDecimal.ZERO; - sumBuffer = null; - super.reset(); - } - - @Override - public String toString() { - return "DECIMAL SUM [sum=" + sum + "]"; - } - - @Override - public int getSize() { - return super.getSize() + SizedUtil.BIG_DECIMAL_SIZE + SizedUtil.ARRAY_SIZE + getDataType().getByteSize(); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DistinctCountClientAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DistinctCountClientAggregator.java deleted file mode 100644 index e2142454..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DistinctCountClientAggregator.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - -/** - * Client side Aggregator for DISTINCT COUNT aggregations - * - * @author anoopsjohn - * @since 1.2.1 - */ -public class DistinctCountClientAggregator extends DistinctValueWithCountClientAggregator { - - public DistinctCountClientAggregator(ColumnModifier columnModifier) { - super(columnModifier); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - if (buffer == null) { - initBuffer(); - } - long value = this.valueVsCount.size(); - buffer = PDataType.LONG.toBytes(value); - ptr.set(buffer); - return true; - } - - @Override - protected int getBufferLength() { - return PDataType.LONG.getByteSize(); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DoubleSumAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DoubleSumAggregator.java deleted file mode 100644 index b1cf70e0..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DoubleSumAggregator.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.SizedUtil; - -public class DoubleSumAggregator extends BaseAggregator { - - private double sum = 0; - private byte[] buffer; - - public DoubleSumAggregator(ColumnModifier columnModifier, ImmutableBytesWritable ptr) { - super(columnModifier); - if (ptr != null) { - initBuffer(); - sum = PDataType.DOUBLE.getCodec().decodeDouble(ptr, columnModifier); - } - } - - protected PDataType getInputDataType() { - return PDataType.DOUBLE; - } - - private void initBuffer() { - buffer = new byte[getDataType().getByteSize()]; - } - - @Override - public void aggregate(Tuple tuple, ImmutableBytesWritable ptr) { - double value = getInputDataType().getCodec().decodeDouble(ptr, columnModifier); - sum += value; - if (buffer == null) { - initBuffer(); - } - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - if (buffer == null) { - if (isNullable()) { - return false; - } - initBuffer(); - } - ptr.set(buffer); - getDataType().getCodec().encodeDouble(sum, ptr); - return true; - } - - @Override - public PDataType getDataType() { - return PDataType.DOUBLE; - } - - @Override - public String toString() { - return "SUM [sum=" + sum + "]"; - } - - @Override - public void reset() { - sum = 0; - buffer = null; - super.reset(); - } - - @Override - public int getSize() { - return super.getSize() + SizedUtil.LONG_SIZE + SizedUtil.ARRAY_SIZE + getDataType().getByteSize(); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/IntSumAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/IntSumAggregator.java deleted file mode 100644 index 41292958..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/IntSumAggregator.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; - -/** - * - * Aggregator that sums integer values - * - * @author jtaylor - * @since 0.1 - */ -public class IntSumAggregator extends NumberSumAggregator { - - public IntSumAggregator(ColumnModifier columnModifier) { - super(columnModifier); - } - - @Override - protected PDataType getInputDataType() { - return PDataType.INTEGER; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/LongSumAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/LongSumAggregator.java deleted file mode 100644 index deb1837d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/LongSumAggregator.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; - -/** - * - * Aggregator that sums long values - * - * @author jtaylor - * @since 0.1 - */ -public class LongSumAggregator extends NumberSumAggregator { - - public LongSumAggregator(ColumnModifier columnModifier) { - super(columnModifier); - } - - @Override - protected PDataType getInputDataType() { - return PDataType.LONG; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/MaxAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/MaxAggregator.java deleted file mode 100644 index 04c05b95..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/MaxAggregator.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import org.apache.hadoop.hbase.util.Bytes; - -import com.salesforce.phoenix.schema.ColumnModifier; - - -/** - * Aggregator that finds the max of values. Inverse of {@link MinAggregator}. - * - * @author syyang - * @since 0.1 - */ -abstract public class MaxAggregator extends MinAggregator { - - public MaxAggregator(ColumnModifier columnModifier) { - super(columnModifier); - } - - @Override - protected boolean keepFirst(ImmutableBytesWritable ibw1, ImmutableBytesWritable ibw2) { - return !super.keepFirst(ibw1, ibw2); - } - - @Override - public String toString() { - return "MAX [value=" + Bytes.toStringBinary(value.get(),value.getOffset(),value.getLength()) + "]"; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/StddevPopAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/StddevPopAggregator.java deleted file mode 100644 index 7c232501..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/StddevPopAggregator.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import java.util.List; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.ColumnModifier; - -/** - * Client side Aggregator for STDDEV_POP aggregations - * - * @author anoopsjohn - * @since 1.2.1 - */ -public class StddevPopAggregator extends BaseStddevAggregator { - - public StddevPopAggregator(List exps, ColumnModifier columnModifier) { - super(exps, columnModifier); - } - - @Override - protected long getDataPointsCount() { - return totalCount; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/StddevSampAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/StddevSampAggregator.java deleted file mode 100644 index a4af51d5..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/StddevSampAggregator.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import java.util.List; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.ColumnModifier; - -/** - * Client side Aggregator for STDDEV_SAMP aggregations - * - * @author anoopsjohn - * @since 1.2.1 - */ -public class StddevSampAggregator extends BaseStddevAggregator { - - public StddevSampAggregator(List exps, ColumnModifier columnModifier) { - super(exps, columnModifier); - } - - @Override - protected long getDataPointsCount() { - return totalCount - 1; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/UnsignedIntSumAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/UnsignedIntSumAggregator.java deleted file mode 100644 index c0ddb92d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/UnsignedIntSumAggregator.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; - -/** - * - * Aggregator that sums unsigned integer values - * - * @author jtaylor - * @since 0.12 - */ -public class UnsignedIntSumAggregator extends NumberSumAggregator { - - public UnsignedIntSumAggregator(ColumnModifier columnModifier) { - super(columnModifier); - } - - @Override - protected PDataType getInputDataType() { - return PDataType.UNSIGNED_INT; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/UnsignedLongSumAggregator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/UnsignedLongSumAggregator.java deleted file mode 100644 index 55e161f5..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/UnsignedLongSumAggregator.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; - -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; - -/** - * - * Aggregator that sums unsigned long values - * TODO: create these classes dynamically based on the type passed through - * - * @author jtaylor - * @since 0.12 - */ -public class UnsignedLongSumAggregator extends NumberSumAggregator { - - public UnsignedLongSumAggregator(ColumnModifier columnModifier) { - super(columnModifier); - } - - @Override - protected PDataType getInputDataType() { - return PDataType.UNSIGNED_LONG; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/AggregateFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/AggregateFunction.java deleted file mode 100644 index 5d1c8493..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/AggregateFunction.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import com.salesforce.phoenix.expression.Expression; - - - - -/** - * - * Compiled representation of a built-in aggregate function - * - * @author jtaylor - * @since 0.1 - */ -abstract public class AggregateFunction extends FunctionExpression { - - public AggregateFunction() { - } - - public AggregateFunction(List children) { - super(children); - } - - @Override - public boolean isStateless() { - return false; - } - - @Override - public boolean isDeterministic() { - return false; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ArrayIndexFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ArrayIndexFunction.java deleted file mode 100644 index a3c082c3..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ArrayIndexFunction.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.sql.Types; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.parse.ParseException; -import com.salesforce.phoenix.schema.PArrayDataType; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - -@BuiltInFunction(name = ArrayIndexFunction.NAME, args = { - @Argument(allowedTypes = { PDataType.BINARY_ARRAY, - PDataType.VARBINARY_ARRAY }), - @Argument(allowedTypes = { PDataType.INTEGER }) }) -public class ArrayIndexFunction extends ScalarFunction { - - public static final String NAME = "ARRAY_ELEM"; - - public ArrayIndexFunction() { - } - - public ArrayIndexFunction(List children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - Expression indexExpr = children.get(1); - if (!indexExpr.evaluate(tuple, ptr)) { - return false; - } else if (ptr.getLength() == 0) { - return true; - } - // Use Codec to prevent Integer object allocation - int index = PDataType.INTEGER.getCodec().decodeInt(ptr, indexExpr.getColumnModifier()); - if(index < 0) { - throw new ParseException("Index cannot be negative :" + index); - } - Expression arrayExpr = children.get(0); - if (!arrayExpr.evaluate(tuple, ptr)) { - return false; - } else if (ptr.getLength() == 0) { - return true; - } - - // Given a ptr to the entire array, set ptr to point to a particular element within that array - // given the type of an array element (see comments in PDataTypeForArray) - PArrayDataType.positionAtArrayElement(ptr, index, getDataType()); - return true; - - } - - @Override - public PDataType getDataType() { - return PDataType.fromTypeId(children.get(0).getDataType().getSqlType() - - Types.ARRAY); - } - - @Override - public String getName() { - return NAME; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ArrayLengthFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ArrayLengthFunction.java deleted file mode 100644 index 530468c8..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ArrayLengthFunction.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.sql.Types; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PArrayDataType; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - -@BuiltInFunction(name = ArrayLengthFunction.NAME, args = { @Argument(allowedTypes = { - PDataType.BINARY_ARRAY, PDataType.VARBINARY_ARRAY }) }) -public class ArrayLengthFunction extends ScalarFunction { - public static final String NAME = "ARRAY_LENGTH"; - - public ArrayLengthFunction() { - } - - public ArrayLengthFunction(List children) { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - Expression arrayExpr = children.get(0); - if (!arrayExpr.evaluate(tuple, ptr)) { - return false; - } else if (ptr.getLength() == 0) { - return true; - } - PDataType baseType = PDataType.fromTypeId(children.get(0).getDataType() - .getSqlType() - - Types.ARRAY); - int length = PArrayDataType.getArrayLength(ptr, baseType); - byte[] lengthBuf = new byte[PDataType.INTEGER.getByteSize()]; - PDataType.INTEGER.getCodec().encodeInt(length, lengthBuf, 0); - ptr.set(lengthBuf); - return true; - } - - @Override - public PDataType getDataType() { - // Array length will return an Integer - return PDataType.INTEGER; - } - - @Override - public String getName() { - return NAME; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilDateExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilDateExpression.java deleted file mode 100644 index 11d6a4e3..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilDateExpression.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.sql.SQLException; -import java.util.List; - -import com.google.common.collect.Lists; -import com.salesforce.phoenix.expression.Expression; - -/** - * - * Class encapsulating ceil operation on {@link com.salesforce.phoenix.schema.PDataType#DATE}. - * - * @author samarth.jain - * @since 3.0.0 - */ -public class CeilDateExpression extends RoundDateExpression { - - public CeilDateExpression() {} - - /** - * @param timeUnit - unit of time to round up to. - * Creates a {@link CeilDateExpression} with default multiplier of 1. - */ - public static Expression create(Expression expr, TimeUnit timeUnit) throws SQLException { - return create(expr, timeUnit, 1); - } - - /** - * @param timeUnit - unit of time to round up to - * @param multiplier - determines the roll up window size. - * Create a {@link CeilDateExpression}. - */ - public static Expression create(Expression expr, TimeUnit timeUnit, int multiplier) throws SQLException { - Expression timeUnitExpr = getTimeUnitExpr(timeUnit); - Expression defaultMultiplierExpr = getMultiplierExpr(multiplier); - List expressions = Lists.newArrayList(expr, timeUnitExpr, defaultMultiplierExpr); - return CeilDateExpression.create(expressions); - } - - public static Expression create(List children) throws SQLException { - return new CeilDateExpression(children); - } - - CeilDateExpression(List children) { - super(children); - } - - @Override - protected long getRoundUpAmount() { - return divBy - 1; - } - - @Override - public String getName() { - return CeilFunction.NAME; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilDecimalExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilDecimalExpression.java deleted file mode 100644 index 9bf0c05e..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilDecimalExpression.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.math.RoundingMode; -import java.sql.SQLException; -import java.util.List; - -import com.google.common.collect.Lists; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.schema.PDataType; - -/** - * - * Class encapsulating the CEIL operation on a {@link com.salesforce.phoenix.schema.PDataType#DECIMAL} - * - * @author samarth.jain - * @since 3.0.0 - */ -public class CeilDecimalExpression extends RoundDecimalExpression { - - public CeilDecimalExpression() {} - - public CeilDecimalExpression(List children) { - super(children); - } - - /** - * Creates a {@link CeilDecimalExpression} with rounding scale given by @param scale. - * - */ - public static Expression create(Expression expr, int scale) throws SQLException { - if (expr.getDataType().isCoercibleTo(PDataType.LONG)) { - return expr; - } - Expression scaleExpr = LiteralExpression.newConstant(scale, PDataType.INTEGER, true); - List expressions = Lists.newArrayList(expr, scaleExpr); - return new CeilDecimalExpression(expressions); - } - - /** - * Creates a {@link CeilDecimalExpression} with a default scale of 0 used for rounding. - * - */ - public static Expression create(Expression expr) throws SQLException { - return create(expr, 0); - } - - @Override - protected RoundingMode getRoundingMode() { - return RoundingMode.CEILING; - } - - @Override - public String getName() { - return CeilFunction.NAME; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilFunction.java deleted file mode 100644 index 4678ca54..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilFunction.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.CeilParseNode; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -/** - * - * Base class for built-in CEIL function. - * - * @author samarth.jain - * @since 3.0.0 - */ -@BuiltInFunction(name = CeilFunction.NAME, - nodeClass = CeilParseNode.class, - args = { - @Argument(allowedTypes={PDataType.TIMESTAMP, PDataType.DECIMAL}), - @Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValue = "null", isConstant=true), - @Argument(allowedTypes={PDataType.INTEGER}, defaultValue="1", isConstant=true) - } - ) -public abstract class CeilFunction extends ScalarFunction { - - public static final String NAME = "CEIL"; - - public CeilFunction(List children) { - super(children); - } - - @Override - public String getName() { - return NAME; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CoalesceFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CoalesceFunction.java deleted file mode 100644 index 7846a0aa..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CoalesceFunction.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.sql.SQLException; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Function used to provide an alternative value when the first argument is null. - * Usage: - * COALESCE(expr1,expr2) - * If expr1 is not null, then it is returned, otherwise expr2 is returned. - * - * TODO: better bind parameter type matching, since arg2 must be coercible - * to arg1. consider allowing a common base type? - * @author jtaylor - * @since 0.1 - */ -@BuiltInFunction(name=CoalesceFunction.NAME, args= { - @Argument(), - @Argument()} ) -public class CoalesceFunction extends ScalarFunction { - public static final String NAME = "COALESCE"; - - public CoalesceFunction() { - } - - public CoalesceFunction(List children) throws SQLException { - super(children); - if (!children.get(1).getDataType().isCoercibleTo(children.get(0).getDataType())) { - throw new SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_CONVERT_TYPE) - .setMessage(getName() + " expected " + children.get(0).getDataType() + ", but got " + children.get(1).getDataType()) - .build().buildException(); - } - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - if (children.get(0).evaluate(tuple, ptr)) { - return true; - } - return children.get(1).evaluate(tuple, ptr); - } - - @Override - public PDataType getDataType() { - return children.get(0).getDataType(); - } - - @Override - public Integer getByteSize() { - Integer maxByteSize1 = children.get(0).getByteSize(); - if (maxByteSize1 != null) { - Integer maxByteSize2 = children.get(1).getByteSize(); - if (maxByteSize2 != null) { - return maxByteSize1 > maxByteSize2 ? maxByteSize1 : maxByteSize2; - } - } - return null; - } - - @Override - public boolean isNullable() { - return children.get(0).isNullable() && children.get(1).isNullable(); - } - - @Override - public String getName() { - return NAME; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CompositeAggregateFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CompositeAggregateFunction.java deleted file mode 100644 index 86248bc1..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CompositeAggregateFunction.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; - - -/** - * - * Base class for aggregation functions which are composed of other - * aggregation functions (for example, AVG is modeled as a SUM aggregate - * function and a COUNT aggregate function). - * - * @author jtaylor - * @since 0.1 - */ -abstract public class CompositeAggregateFunction extends AggregateFunction { - - public CompositeAggregateFunction(List children) { - super(children); - } - - @Override - public final T accept(ExpressionVisitor visitor) { - return null; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CurrentDateFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CurrentDateFunction.java deleted file mode 100644 index 22140455..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CurrentDateFunction.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.CurrentDateTimeFunction; -import com.salesforce.phoenix.parse.CurrentDateParseNode; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Function that returns the current date accurate to the millisecond. Note that this - * function is never evaluated on the server-side, instead the server side date is - * retrieved (piggy-backed on the call to check that the metadata is up-to-date) and - * passed into this function at create time. - * - * @author jtaylor - * @since 0.1 - */ -@BuiltInFunction(name=CurrentDateFunction.NAME, nodeClass=CurrentDateParseNode.class, args= {} ) -public class CurrentDateFunction extends CurrentDateTimeFunction { - public static final String NAME = "CURRENT_DATE"; - private final ImmutableBytesWritable currentDate = new ImmutableBytesWritable(new byte[PDataType.DATE.getByteSize()]); - - public CurrentDateFunction() { - this(System.currentTimeMillis()); - } - - public CurrentDateFunction(long timeStamp) { - getDataType().getCodec().encodeLong(timeStamp, currentDate); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - ptr.set(currentDate.get(), 0, PDataType.DATE.getByteSize()); - return true; - } - - @Override - public final PDataType getDataType() { - return PDataType.DATE; - } - - @Override - public String getName() { - return NAME; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CurrentTimeFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CurrentTimeFunction.java deleted file mode 100644 index e23bf86c..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CurrentTimeFunction.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.CurrentDateTimeFunction; -import com.salesforce.phoenix.parse.CurrentTimeParseNode; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Function that returns the current date accurate to the millisecond. Note that this - * function is never evaluated on the server-side, instead the server side date is - * retrieved (piggy-backed on the call to check that the metadata is up-to-date) and - * passed into this function at create time. - * - * @author jtaylor - * @since 0.1 - */ -@BuiltInFunction(name=CurrentTimeFunction.NAME, nodeClass=CurrentTimeParseNode.class, args={} ) -public class CurrentTimeFunction extends CurrentDateTimeFunction { - public static final String NAME = "CURRENT_TIME"; - private final ImmutableBytesWritable currentDate = new ImmutableBytesWritable(new byte[PDataType.TIME.getByteSize()]); - - public CurrentTimeFunction() { - this(System.currentTimeMillis()); - } - - public CurrentTimeFunction(long timeStamp) { - getDataType().getCodec().encodeLong(timeStamp, currentDate); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - ptr.set(currentDate.get(), 0, PDataType.TIME.getByteSize()); - return true; - } - - @Override - public final PDataType getDataType() { - return PDataType.TIME; - } - - @Override - public String getName() { - return NAME; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/DelegateConstantToCountAggregateFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/DelegateConstantToCountAggregateFunction.java deleted file mode 100644 index e61a851e..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/DelegateConstantToCountAggregateFunction.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Base class for non composite aggregation functions that optimize aggregation by - * delegating to {@link CountAggregateFunction} when the child expression is a - * constant. - * - * @author jtaylor - * @since 0.1 - */ -abstract public class DelegateConstantToCountAggregateFunction extends SingleAggregateFunction { - private static final ImmutableBytesWritable ZERO = new ImmutableBytesWritable(PDataType.LONG.toBytes(0L)); - private CountAggregateFunction delegate; - - public DelegateConstantToCountAggregateFunction() { - } - - public DelegateConstantToCountAggregateFunction(List childExpressions, CountAggregateFunction delegate) { - super(childExpressions); - // Using a delegate here causes us to optimize the number of aggregators - // by sharing the CountAggregator across functions. On the server side, - // this will always be null, since if it had not been null on the client, - // the function would not have been transfered over (the delegate would - // have instead). - this.delegate = delegate; - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - if (delegate == null) { - return super.evaluate(tuple, ptr); - } - delegate.evaluate(tuple, ptr); - if (PDataType.LONG.compareTo(ptr,ZERO) == 0) { - return false; - } - return true; - } - - - @Override - protected SingleAggregateFunction getDelegate() { - return delegate != null ? delegate : super.getDelegate(); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/DistinctValueWithCountAggregateFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/DistinctValueWithCountAggregateFunction.java deleted file mode 100644 index 958431ee..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/DistinctValueWithCountAggregateFunction.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctValueWithCountClientAggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; - -public abstract class DistinctValueWithCountAggregateFunction extends SingleAggregateFunction { - - public DistinctValueWithCountAggregateFunction() { - } - - public DistinctValueWithCountAggregateFunction(List children) { - super(children); - } - - @Override - abstract public DistinctValueWithCountClientAggregator newClientAggregator(); - - @Override - public Aggregator newServerAggregator(Configuration config, ImmutableBytesWritable ptr) { - DistinctValueWithCountClientAggregator clientAgg = newClientAggregator(); - clientAgg.aggregate(null, ptr); - return new DistinctValueWithCountServerAggregator(config, clientAgg); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FloorDecimalExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FloorDecimalExpression.java deleted file mode 100644 index 75c12bce..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FloorDecimalExpression.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.math.RoundingMode; -import java.sql.SQLException; -import java.util.List; - -import com.google.common.collect.Lists; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.schema.PDataType; - -/** - * - * Class encapsulating the FLOOR operation on - * a column/literal of type {@link com.salesforce.phoenix.schema.PDataType#DECIMAL}. - * - * @author samarth.jain - * @since 3.0.0 - */ -public class FloorDecimalExpression extends RoundDecimalExpression { - - public FloorDecimalExpression() {} - - public FloorDecimalExpression(List children) { - super(children); - } - - /** - * Creates a {@link FloorDecimalExpression} with rounding scale given by @param scale. - * - */ - public static Expression create(Expression expr, int scale) throws SQLException { - if (expr.getDataType().isCoercibleTo(PDataType.LONG)) { - return expr; - } - Expression scaleExpr = LiteralExpression.newConstant(scale, PDataType.INTEGER, true); - List expressions = Lists.newArrayList(expr, scaleExpr); - return new FloorDecimalExpression(expressions); - } - - /** - * Creates a {@link FloorDecimalExpression} with a default scale of 0 used for rounding. - * - */ - public static Expression create(Expression expr) throws SQLException { - return create(expr, 0); - } - - @Override - protected RoundingMode getRoundingMode() { - return RoundingMode.FLOOR; - } - - @Override - public String getName() { - return FloorFunction.NAME; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FloorFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FloorFunction.java deleted file mode 100644 index 2b2309ed..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FloorFunction.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FloorParseNode; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -/** - * - * Base class for built-in FLOOR function. - * - * @author samarth.jain - * @since 3.0.0 - */ -@BuiltInFunction(name = FloorFunction.NAME, - nodeClass = FloorParseNode.class, - args = { - @Argument(allowedTypes={PDataType.TIMESTAMP, PDataType.DECIMAL}), - @Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValue = "null", isConstant=true), - @Argument(allowedTypes={PDataType.INTEGER}, defaultValue="1", isConstant=true) - } - ) -public abstract class FloorFunction extends ScalarFunction { - - public static final String NAME = "FLOOR"; - - public FloorFunction(List children) { - super(children); - } - - @Override - public String getName() { - return NAME; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FunctionExpression.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FunctionExpression.java deleted file mode 100644 index e315fad5..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FunctionExpression.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import com.salesforce.phoenix.expression.BaseCompoundExpression; -import com.salesforce.phoenix.expression.Expression; - -/** - * - * Compiled representation of a built-in function - * - * @author jtaylor - * @since 0.1 - */ -public abstract class FunctionExpression extends BaseCompoundExpression { - public enum OrderPreserving {NO, YES_IF_LAST, YES}; - public FunctionExpression() { - } - - public FunctionExpression(List children) { - super(children); - } - - /** - * Determines whether or not the result of the function invocation - * will be ordered in the same way as the input to the function. - * Returning YES enables an optimization to occur when a - * GROUP BY contains function invocations using the leading PK - * column(s). - * @return YES if the function invocation will always preserve order for - * the inputs versus the outputs and false otherwise, YES_IF_LAST if the - * function preserves order, but any further column reference would not - * continue to preserve order, and NO if the function does not preserve - * order. - */ - public OrderPreserving preservesOrder() { - return OrderPreserving.NO; - } - - abstract public String getName(); - - @Override - public final String toString() { - StringBuilder buf = new StringBuilder(getName() + "("); - for (int i = 0; i < children.size() - 1; i++) { - buf.append(children.get(i) + ", "); - } - buf.append(children.get(children.size()-1) + ")"); - return buf.toString(); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/IndexStateNameFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/IndexStateNameFunction.java deleted file mode 100644 index 1d819600..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/IndexStateNameFunction.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.sql.SQLException; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PIndexState; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Function used to get the index state name from the serialized byte value - * Usage: - * IndexStateName('a') - * will return 'ACTIVE' - * - * @author jtaylor - * @since 2.1 - */ -@BuiltInFunction(name=IndexStateNameFunction.NAME, args= { - @Argument(allowedTypes=PDataType.CHAR)} ) -public class IndexStateNameFunction extends ScalarFunction { - public static final String NAME = "IndexStateName"; - - public IndexStateNameFunction() { - } - - public IndexStateNameFunction(List children) throws SQLException { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - Expression child = children.get(0); - if (!child.evaluate(tuple, ptr)) { - return false; - } - if (ptr.getLength() == 0) { - return true; - } - byte serializedByte = ptr.get()[ptr.getOffset()]; - PIndexState indexState = PIndexState.fromSerializedValue(serializedByte); - ptr.set(indexState.toBytes()); - return true; - } - - @Override - public PDataType getDataType() { - return PDataType.VARCHAR; - } - - @Override - public String getName() { - return NAME; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/LengthFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/LengthFunction.java deleted file mode 100644 index 21dc6f5f..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/LengthFunction.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.io.UnsupportedEncodingException; -import java.sql.SQLException; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.StringUtil; - - -/** - * - * Implementation of the LENGTH() build-in function. is the string - * of characters we want to find the length of. If is NULL or empty, null - * is returned. - * - * @author zhuang - * @since 0.1 - */ -@BuiltInFunction(name=LengthFunction.NAME, args={ - @Argument(allowedTypes={PDataType.VARCHAR})} ) -public class LengthFunction extends ScalarFunction { - public static final String NAME = "LENGTH"; - - public LengthFunction() { } - - public LengthFunction(List children) throws SQLException { - super(children); - } - - private Expression getStringExpression() { - return children.get(0); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - Expression child = getStringExpression(); - if (!child.evaluate(tuple, ptr)) { - return false; - } - if (ptr.getLength() == 0) { - ptr.set(ByteUtil.EMPTY_BYTE_ARRAY); - return true; - } - int len; - if (child.getDataType() == PDataType.CHAR) { - // Only single-byte characters allowed in CHAR - len = ptr.getLength(); - } else { - try { - len = StringUtil.calculateUTF8Length(ptr.get(), ptr.getOffset(), ptr.getLength(), child.getColumnModifier()); - } catch (UnsupportedEncodingException e) { - return false; - } - } - ptr.set(PDataType.INTEGER.toBytes(len)); - return true; - } - - @Override - public PDataType getDataType() { - return PDataType.INTEGER; - } - - @Override - public String getName() { - return NAME; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/MD5Function.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/MD5Function.java deleted file mode 100644 index 9688ed85..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/MD5Function.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.sql.SQLException; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - -@BuiltInFunction(name = MD5Function.NAME, args={@Argument()}) -public class MD5Function extends ScalarFunction { - public static final String NAME = "MD5"; - public static final Integer LENGTH = 16; - - private final MessageDigest messageDigest; - - public MD5Function() throws SQLException { - try { - messageDigest = MessageDigest.getInstance("MD5"); - } catch (NoSuchAlgorithmException e) { - throw new SQLException(e); - } - } - - public MD5Function(List children) throws SQLException { - super(children); - try { - messageDigest = MessageDigest.getInstance("MD5"); - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException(e); - } - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - if (!getChildExpression().evaluate(tuple, ptr)) { - return false; - } - - // Update the digest value - messageDigest.update(ptr.get(), ptr.getOffset(), ptr.getLength()); - // Get the digest bytes (note this resets the messageDigest as well) - ptr.set(messageDigest.digest()); - return true; - } - - @Override - public PDataType getDataType() { - return PDataType.BINARY; - } - - @Override - public Integer getMaxLength() { - return LENGTH; - } - - @Override - public Integer getByteSize() { - return LENGTH; - } - - @Override - public boolean isNullable() { - return getChildExpression().isNullable(); - } - - @Override - public String getName() { - return NAME; - } - - private Expression getChildExpression() { - return children.get(0); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/MaxAggregateFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/MaxAggregateFunction.java deleted file mode 100644 index b55301ba..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/MaxAggregateFunction.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import org.apache.hadoop.conf.Configuration; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.MaxAggregator; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.parse.MaxAggregateParseNode; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; - - - -/** - * Built-in function for finding MAX. - * - * @author syyang - * @since 0.1 - */ -@BuiltInFunction(name=MaxAggregateFunction.NAME, nodeClass=MaxAggregateParseNode.class, args= {@Argument()} ) -public class MaxAggregateFunction extends MinAggregateFunction { - public static final String NAME = "MAX"; - - public MaxAggregateFunction() { - } - - public MaxAggregateFunction(List childExpressions, CountAggregateFunction delegate) { - super(childExpressions, delegate); - } - - @Override - public Aggregator newServerAggregator(Configuration conf) { - final PDataType type = getAggregatorExpression().getDataType(); - ColumnModifier columnModifier = getAggregatorExpression().getColumnModifier(); - return new MaxAggregator(columnModifier) { - @Override - public PDataType getDataType() { - return type; - } - }; - } - - @Override - public String getName() { - return NAME; - } - - @Override - public ColumnModifier getColumnModifier() { - return getAggregatorExpression().getColumnModifier(); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/MinAggregateFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/MinAggregateFunction.java deleted file mode 100644 index a4acee60..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/MinAggregateFunction.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.MinAggregator; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.parse.MinAggregateParseNode; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - - - -/** - * Built-in function for finding MIN. - * - * @author syyang - * @since 0.1 - */ -@BuiltInFunction(name=MinAggregateFunction.NAME, nodeClass=MinAggregateParseNode.class, args= {@Argument()} ) -public class MinAggregateFunction extends DelegateConstantToCountAggregateFunction { - public static final String NAME = "MIN"; - - public MinAggregateFunction() { - } - - public MinAggregateFunction(List childExpressions, CountAggregateFunction delegate) { - super(childExpressions, delegate); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - boolean wasEvaluated = super.evaluate(tuple, ptr); - if (!wasEvaluated) { - return false; - } - if (isConstantExpression()) { - getAggregatorExpression().evaluate(tuple, ptr); - } - return true; - } - - @Override - public Aggregator newServerAggregator(Configuration conf) { - final PDataType type = getAggregatorExpression().getDataType(); - ColumnModifier columnModifier = getAggregatorExpression().getColumnModifier(); - return new MinAggregator(columnModifier) { - @Override - public PDataType getDataType() { - return type; - } - }; - } - - @Override - public ColumnModifier getColumnModifier() { - return getAggregatorExpression().getColumnModifier(); - } - - @Override - public String getName() { - return NAME; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PercentRankAggregateFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PercentRankAggregateFunction.java deleted file mode 100644 index 384f85f1..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PercentRankAggregateFunction.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import org.apache.hadoop.conf.Configuration; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctValueWithCountClientAggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; -import com.salesforce.phoenix.expression.aggregator.PercentRankClientAggregator; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; - -/** - * - * PERCENT_RANK([,]) WITHIN GROUP (ORDER BY [,] ASC/DESC) aggregate function - * - * @author anoopsjohn - * @since 1.2.1 - */ -@BuiltInFunction(name = PercentRankAggregateFunction.NAME, args = { @Argument(), - @Argument(allowedTypes = { PDataType.BOOLEAN }, isConstant = true), @Argument(isConstant = true) }) -public class PercentRankAggregateFunction extends DistinctValueWithCountAggregateFunction { - public static final String NAME = "PERCENT_RANK"; - - public PercentRankAggregateFunction() { - - } - - public PercentRankAggregateFunction(List childern) { - super(childern); - } - - @Override - public Aggregator newServerAggregator(Configuration conf) { - return new DistinctValueWithCountServerAggregator(conf); - } - - @Override - public DistinctValueWithCountClientAggregator newClientAggregator() { - return new PercentRankClientAggregator(children, getAggregatorExpression().getColumnModifier()); - } - - @Override - public String getName() { - return NAME; - } - - @Override - public PDataType getDataType() { - return PDataType.DECIMAL; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PercentileContAggregateFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PercentileContAggregateFunction.java deleted file mode 100644 index ff50c66a..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PercentileContAggregateFunction.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import org.apache.hadoop.conf.Configuration; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctValueWithCountClientAggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; -import com.salesforce.phoenix.expression.aggregator.PercentileClientAggregator; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; - -/** - * - * Built-in function for PERCENTILE_CONT() WITHIN GROUP (ORDER BY ASC/DESC) aggregate function - * - * @author anoopsjohn - * @since 1.2.1 - */ -@BuiltInFunction(name = PercentileContAggregateFunction.NAME, args = { @Argument(allowedTypes = { PDataType.DECIMAL }), - @Argument(allowedTypes = { PDataType.BOOLEAN }, isConstant = true), - @Argument(allowedTypes = { PDataType.DECIMAL }, isConstant = true, minValue = "0", maxValue = "1") }) -public class PercentileContAggregateFunction extends DistinctValueWithCountAggregateFunction { - public static final String NAME = "PERCENTILE_CONT"; - - public PercentileContAggregateFunction() { - - } - - public PercentileContAggregateFunction(List childern) { - super(childern); - } - - @Override - public Aggregator newServerAggregator(Configuration conf) { - return new DistinctValueWithCountServerAggregator(conf); - } - - @Override - public DistinctValueWithCountClientAggregator newClientAggregator() { - return new PercentileClientAggregator(children, getAggregatorExpression().getColumnModifier()); - } - - @Override - public String getName() { - return NAME; - } - - @Override - public PDataType getDataType() { - return PDataType.DECIMAL; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PercentileDiscAggregateFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PercentileDiscAggregateFunction.java deleted file mode 100644 index 1fdec4dc..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PercentileDiscAggregateFunction.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import org.apache.hadoop.conf.Configuration; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctValueWithCountClientAggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; -import com.salesforce.phoenix.expression.aggregator.PercentileDiscClientAggregator; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; - - -/** - * - * Built-in function for PERCENTILE_DISC() WITHIN GROUP (ORDER BY ASC/DESC) aggregate function - * - * @author ramkrishna - * @since 1.2.1 - */ -@BuiltInFunction(name = PercentileDiscAggregateFunction.NAME, args = { @Argument(allowedTypes = { PDataType.DECIMAL }), - @Argument(allowedTypes = { PDataType.BOOLEAN }, isConstant = true), - @Argument(allowedTypes = { PDataType.DECIMAL }, isConstant = true, minValue = "0", maxValue = "1") }) -public class PercentileDiscAggregateFunction extends DistinctValueWithCountAggregateFunction { - - public static final String NAME = "PERCENTILE_DISC"; - - public PercentileDiscAggregateFunction() { - } - - public PercentileDiscAggregateFunction(List childern) { - super(childern); - } - - @Override - public Aggregator newServerAggregator(Configuration conf) { - return new DistinctValueWithCountServerAggregator(conf); - } - - @Override - public DistinctValueWithCountClientAggregator newClientAggregator() { - return new PercentileDiscClientAggregator(children, getAggregatorExpression().getColumnModifier()); - } - - @Override - public String getName() { - return NAME; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RoundFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RoundFunction.java deleted file mode 100644 index c0ce5000..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RoundFunction.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.parse.RoundParseNode; -import com.salesforce.phoenix.schema.PDataType; - - -/** - * Base class for RoundFunction. - * - * @author jtaylor, samarth.jain - * @since 0.1 - */ -@BuiltInFunction(name = RoundFunction.NAME, - nodeClass = RoundParseNode.class, - args = { - @Argument(allowedTypes={PDataType.TIMESTAMP, PDataType.DECIMAL}), - @Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValue = "null", isConstant=true), - @Argument(allowedTypes={PDataType.INTEGER}, defaultValue="1", isConstant=true) - } - ) -public abstract class RoundFunction extends ScalarFunction { - - public static final String NAME = "ROUND"; - - public RoundFunction(List children) { - super(children); - } - - @Override - public String getName() { - return NAME; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SQLTableTypeFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SQLTableTypeFunction.java deleted file mode 100644 index f7405d06..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SQLTableTypeFunction.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.sql.SQLException; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Function used to get the SQL table type name from the serialized table type. - * Usage: - * SqlTableType('v') will return 'VIEW' based on - * {@link java.sql.DatabaseMetaData#getTableTypes()} - * - * @author jtaylor - * @since 2.2 - */ -@BuiltInFunction(name=SQLTableTypeFunction.NAME, args= { - @Argument(allowedTypes=PDataType.CHAR)} ) -public class SQLTableTypeFunction extends ScalarFunction { - public static final String NAME = "SQLTableType"; - - public SQLTableTypeFunction() { - } - - public SQLTableTypeFunction(List children) throws SQLException { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - Expression child = children.get(0); - if (!child.evaluate(tuple, ptr)) { - return false; - } - if (ptr.getLength() == 0) { - return true; - } - PTableType tableType = PTableType.fromSerializedValue(ptr.get()[ptr.getOffset()]); - ptr.set(tableType.getValue().getBytes()); - return true; - } - - @Override - public PDataType getDataType() { - return PDataType.VARCHAR; - } - - @Override - public String getName() { - return NAME; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SQLViewTypeFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SQLViewTypeFunction.java deleted file mode 100644 index 022b533d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SQLViewTypeFunction.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.sql.SQLException; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PTable.ViewType; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Function used to get the SQL view type name from the serialized view type. - * Usage: - * SQLViewType('v') will return 'VIEW' based on - * {@link java.sql.DatabaseMetaData#getTableTypes()} - * - * @author jtaylor - * @since 2.2 - */ -@BuiltInFunction(name=SQLViewTypeFunction.NAME, args= { - @Argument(allowedTypes=PDataType.UNSIGNED_TINYINT)} ) -public class SQLViewTypeFunction extends ScalarFunction { - public static final String NAME = "SQLViewType"; - - public SQLViewTypeFunction() { - } - - public SQLViewTypeFunction(List children) throws SQLException { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - Expression child = children.get(0); - if (!child.evaluate(tuple, ptr)) { - return false; - } - if (ptr.getLength() == 0) { - return true; - } - ViewType viewType = ViewType.fromSerializedValue(ptr.get()[ptr.getOffset()]); - ptr.set(viewType.getBytes()); - return true; - } - - @Override - public PDataType getDataType() { - return PDataType.VARCHAR; - } - - @Override - public String getName() { - return NAME; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ScalarFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ScalarFunction.java deleted file mode 100644 index 69ae6e64..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ScalarFunction.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import com.salesforce.phoenix.compile.KeyPart; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; - - -public abstract class ScalarFunction extends FunctionExpression { - public static final int NO_TRAVERSAL = -1; - - public ScalarFunction() { - } - - public ScalarFunction(List children) { - super(children); - } - - @Override - public final T accept(ExpressionVisitor visitor) { - List l = acceptChildren(visitor, visitor.visitEnter(this)); - T t = visitor.visitLeave(this, l); - if (t == null) { - t = visitor.defaultReturn(this, l); - } - return t; - } - - /** - * Determines whether or not a function may be used to form - * the start/stop key of a scan - * @return the zero-based position of the argument to traverse - * into to look for a primary key column reference, or - * {@value #NO_TRAVERSAL} if the function cannot be used to - * form the scan key. - */ - public int getKeyFormationTraversalIndex() { - return NO_TRAVERSAL; - } - - /** - * Manufactures a KeyPart used to construct the KeyRange given - * a constant and a comparison operator. - * @param childPart the KeyPart formulated for the child expression - * at the {@link #getKeyFormationTraversalIndex()} position. - * @return the KeyPart for constructing the KeyRange for this - * function. - */ - public KeyPart newKeyPart(KeyPart childPart) { - return null; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SqlTypeNameFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SqlTypeNameFunction.java deleted file mode 100644 index 37b935b5..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SqlTypeNameFunction.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.sql.SQLException; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.IllegalDataException; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; - - -/** - * - * Function used to get the SQL type name from the SQL type integer. - * Usage: - * SqlTypeName(12) - * will return 'VARCHAR' based on {@link java.sql.Types#VARCHAR} being 12 - * - * @author jtaylor - * @since 0.1 - */ -@BuiltInFunction(name=SqlTypeNameFunction.NAME, args= { - @Argument(allowedTypes=PDataType.INTEGER)} ) -public class SqlTypeNameFunction extends ScalarFunction { - public static final String NAME = "SqlTypeName"; - - public SqlTypeNameFunction() { - } - - public SqlTypeNameFunction(List children) throws SQLException { - super(children); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - Expression child = children.get(0); - if (!child.evaluate(tuple, ptr)) { - return false; - } - if (ptr.getLength() == 0) { - return true; - } - int sqlType = child.getDataType().getCodec().decodeInt(ptr, child.getColumnModifier()); - try { - byte[] sqlTypeNameBytes = PDataType.fromTypeId(sqlType).getSqlTypeNameBytes(); - ptr.set(sqlTypeNameBytes); - } catch (IllegalDataException e) { - ptr.set(ByteUtil.EMPTY_BYTE_ARRAY); - } - return true; - } - - @Override - public PDataType getDataType() { - return PDataType.VARCHAR; - } - - @Override - public String getName() { - return NAME; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/StddevPopFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/StddevPopFunction.java deleted file mode 100644 index c0647cca..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/StddevPopFunction.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import org.apache.hadoop.conf.Configuration; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.DecimalStddevPopAggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctValueWithCountClientAggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; -import com.salesforce.phoenix.expression.aggregator.StddevPopAggregator; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; - -/** - * - * Built-in function for STDDEV_POP() aggregate function - * - * @author anoopsjohn - * @since 1.2.1 - */ -@BuiltInFunction(name = StddevPopFunction.NAME, args = { @Argument(allowedTypes={PDataType.DECIMAL})}) -public class StddevPopFunction extends DistinctValueWithCountAggregateFunction { - public static final String NAME = "STDDEV_POP"; - - public StddevPopFunction() { - - } - - public StddevPopFunction(List childern) { - super(childern); - } - - @Override - public Aggregator newServerAggregator(Configuration conf) { - return new DistinctValueWithCountServerAggregator(conf); - } - - @Override - public DistinctValueWithCountClientAggregator newClientAggregator() { - if (children.get(0).getDataType() == PDataType.DECIMAL) { - // Special Aggregators for DECIMAL datatype for more precision than double - return new DecimalStddevPopAggregator(children, getAggregatorExpression().getColumnModifier()); - } - return new StddevPopAggregator(children, getAggregatorExpression().getColumnModifier()); - } - - @Override - public String getName() { - return NAME; - } - - @Override - public PDataType getDataType() { - return PDataType.DECIMAL; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/StddevSampFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/StddevSampFunction.java deleted file mode 100644 index 8635915f..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/StddevSampFunction.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.util.List; - -import org.apache.hadoop.conf.Configuration; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.DecimalStddevSampAggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctValueWithCountClientAggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; -import com.salesforce.phoenix.expression.aggregator.StddevSampAggregator; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; - -/** - * - * Built-in function for STDDEV_SAMP() aggregate function - * - * @author anoopsjohn - * @since 1.2.1 - */ -@BuiltInFunction(name = StddevSampFunction.NAME, args = { @Argument(allowedTypes={PDataType.DECIMAL})}) -public class StddevSampFunction extends DistinctValueWithCountAggregateFunction { - public static final String NAME = "STDDEV_SAMP"; - - public StddevSampFunction() { - - } - - public StddevSampFunction(List childern) { - super(childern); - } - - @Override - public Aggregator newServerAggregator(Configuration conf) { - return new DistinctValueWithCountServerAggregator(conf); - } - - @Override - public DistinctValueWithCountClientAggregator newClientAggregator() { - if (children.get(0).getDataType() == PDataType.DECIMAL) { - // Special Aggregators for DECIMAL datatype for more precision than double - return new DecimalStddevSampAggregator(children, getAggregatorExpression().getColumnModifier()); - } - return new StddevSampAggregator(children, getAggregatorExpression().getColumnModifier()); - } - - @Override - public String getName() { - return NAME; - } - - @Override - public PDataType getDataType() { - return PDataType.DECIMAL; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/TimeUnit.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/TimeUnit.java deleted file mode 100644 index 6b782b9b..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/TimeUnit.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import com.google.common.base.Joiner; - -public enum TimeUnit { - DAY("day"), - HOUR("hour"), - MINUTE("minute"), - SECOND("second"), - MILLISECOND("millisecond"); - - private String value; - - private TimeUnit(String value) { - this.value = value; - } - - public static final String VALID_VALUES = Joiner.on(", ").join(TimeUnit.values()); - - public static TimeUnit getTimeUnit(String timeUnit) { - if(timeUnit == null) { - throw new IllegalArgumentException("No time unit value specified. Only a time unit value that belongs to one of these : " + VALID_VALUES + " is allowed."); - } - for(TimeUnit tu : values()) { - if(timeUnit.equalsIgnoreCase(tu.value)) { - return tu; - } - } - throw new IllegalArgumentException("Invalid value of time unit " + timeUnit + ". Only a time unit value that belongs to one of these : " + VALID_VALUES + " is allowed."); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/TrimFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/TrimFunction.java deleted file mode 100644 index 6ae134c3..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/TrimFunction.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.sql.SQLException; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.StringUtil; - - -/** - * Implementation of the Trim() build-in function. It removes from both end of - * space character and other function bytes in single byte utf8 characters set. - * - * @author zhuang - * @since 0.1 - */ -@BuiltInFunction(name=TrimFunction.NAME, args={ - @Argument(allowedTypes={PDataType.VARCHAR})} ) -public class TrimFunction extends ScalarFunction { - public static final String NAME = "TRIM"; - - private Integer byteSize; - - public TrimFunction() { } - - public TrimFunction(List children) throws SQLException { - super(children); - if (getStringExpression().getDataType().isFixedWidth()) { - byteSize = getStringExpression().getByteSize(); - } - } - - private Expression getStringExpression() { - return children.get(0); - } - - @Override - public ColumnModifier getColumnModifier() { - return children.get(0).getColumnModifier(); - } - - @Override - public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { - if (!getStringExpression().evaluate(tuple, ptr)) { - return false; - } - if (ptr.getLength() == 0) { - ptr.set(ByteUtil.EMPTY_BYTE_ARRAY); - return true; - } - byte[] string = ptr.get(); - int offset = ptr.getOffset(); - int length = ptr.getLength(); - - ColumnModifier columnModifier = getColumnModifier(); - int end = StringUtil.getFirstNonBlankCharIdxFromEnd(string, offset, length, columnModifier); - if (end == offset - 1) { - ptr.set(ByteUtil.EMPTY_BYTE_ARRAY); - return true; - } - int head = StringUtil.getFirstNonBlankCharIdxFromStart(string, offset, length, columnModifier); - ptr.set(string, head, end - head + 1); - return true; - } - - @Override - public Integer getByteSize() { - return byteSize; - } - - @Override - public PDataType getDataType() { - return PDataType.VARCHAR; - } - - @Override - public String getName() { - return NAME; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/TruncFunction.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/TruncFunction.java deleted file mode 100644 index 9a6ee50b..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/TruncFunction.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FloorParseNode; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; - - -/** - * - * Function used to bucketize date/time values by truncating them to - * an even increment. Usage: - * TRUNC(,<'day'|'hour'|'minute'|'second'|'millisecond'>,[]) - * The integer multiplier is optional and is used to do rollups to a partial time unit (i.e. 10 minute rollup) - * The function returns a {@link com.salesforce.phoenix.schema.PDataType#DATE} - * - * @author jtaylor - * @since 0.1 - */ -@BuiltInFunction(name = TruncFunction.NAME, -nodeClass = FloorParseNode.class, -args = { - @Argument(allowedTypes={PDataType.TIMESTAMP, PDataType.DECIMAL}), - @Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValue = "null", isConstant=true), - @Argument(allowedTypes={PDataType.INTEGER}, defaultValue="1", isConstant=true) - } -) -public abstract class TruncFunction extends ScalarFunction { - - public static final String NAME = "TRUNC"; - - public TruncFunction(List children) throws SQLException { - super(children); - } - - @Override - public String getName() { - return NAME; - } - - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/KeyValueExpressionVisitor.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/KeyValueExpressionVisitor.java deleted file mode 100644 index 925f55ff..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/KeyValueExpressionVisitor.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.visitor; - -import com.salesforce.phoenix.expression.KeyValueColumnExpression; - - - - -/** - * - * Implementation of ExpressionVisitor where only KeyValueDataAccessor - * is being visited - * - * @author jtaylor - * @since 0.1 - */ -public abstract class KeyValueExpressionVisitor extends TraverseAllExpressionVisitor { - @Override - abstract public Void visit(KeyValueColumnExpression node); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/SingleAggregateFunctionVisitor.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/SingleAggregateFunctionVisitor.java deleted file mode 100644 index cc58cf91..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/SingleAggregateFunctionVisitor.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.visitor; - -import java.util.Iterator; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.function.SingleAggregateFunction; - - - -/** - * - * Implementation of ExpressionVisitor where only SingleAggregateFunction - * instances are visited - * - * @author jtaylor - * @since 0.1 - */ -public abstract class SingleAggregateFunctionVisitor extends TraverseAllExpressionVisitor { - @Override - abstract public Iterator visitEnter(SingleAggregateFunction node); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/TraverseAllExpressionVisitor.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/TraverseAllExpressionVisitor.java deleted file mode 100644 index 0077e691..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/TraverseAllExpressionVisitor.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.visitor; - -import java.util.*; - -import com.salesforce.phoenix.expression.Expression; - - - - -public class TraverseAllExpressionVisitor extends BaseExpressionVisitor { - - @Override - public Iterator defaultIterator(Expression node) { - final List children = node.getChildren(); - return new Iterator() { - private int position; - - @Override - public final boolean hasNext() { - return position < children.size(); - } - - @Override - public final Expression next() { - if (!hasNext()) { - throw new NoSuchElementException(); - } - return children.get(position++); - } - - @Override - public final void remove() { - throw new UnsupportedOperationException(); - } - }; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/TraverseNoExpressionVisitor.java b/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/TraverseNoExpressionVisitor.java deleted file mode 100644 index afc08308..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/TraverseNoExpressionVisitor.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.visitor; - -import java.util.Iterator; - - -import com.google.common.collect.Iterators; -import com.salesforce.phoenix.expression.Expression; - -public class TraverseNoExpressionVisitor extends BaseExpressionVisitor { - - @Override - public Iterator defaultIterator(Expression node) { - return Iterators.emptyIterator(); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/EvaluateOnCompletionVisitor.java b/phoenix-core/src/main/java/com/salesforce/phoenix/filter/EvaluateOnCompletionVisitor.java deleted file mode 100644 index e93b8cfd..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/EvaluateOnCompletionVisitor.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.filter; - -import java.util.Iterator; - -import com.salesforce.phoenix.expression.ArrayConstructorExpression; -import com.salesforce.phoenix.expression.CaseExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.IsNullExpression; -import com.salesforce.phoenix.expression.RowKeyColumnExpression; -import com.salesforce.phoenix.expression.RowValueConstructorExpression; -import com.salesforce.phoenix.expression.visitor.TraverseAllExpressionVisitor; - - -/** - * - * Implementation of ExpressionVisitor for the expression used by the - * BooleanExpressionFilter that looks for expressions that need to be - * evaluated upon completion. Examples include: - * - CaseExpression with an else clause, since upon completion, the - * else clause would apply if the when clauses could not be evaluated - * due to the absense of a value. - * - IsNullExpression that's not negated, since upon completion, we - * know definitively that a column value was not found. - * - row key columns are used, since we may never have encountered a - * key value column of interest, but the expression may evaluate to true - * just based on the row key columns. - * @author jtaylor - * @since 0.1 - */ -public class EvaluateOnCompletionVisitor extends TraverseAllExpressionVisitor { - private boolean evaluateOnCompletion = false; - - public boolean evaluateOnCompletion() { - return evaluateOnCompletion; - } - - @Override - public Iterator visitEnter(IsNullExpression node) { - evaluateOnCompletion |= !node.isNegate(); - return null; - } - @Override - public Iterator visitEnter(CaseExpression node) { - evaluateOnCompletion |= node.hasElse(); - return null; - } - @Override - public Void visit(RowKeyColumnExpression node) { - evaluateOnCompletion = true; - return null; - } - @Override - public Iterator visitEnter(RowValueConstructorExpression node) { - evaluateOnCompletion = true; - return null; - } - - @Override - public Iterator visitEnter(ArrayConstructorExpression node) { - evaluateOnCompletion = true; - return null; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/MultiCQKeyValueComparisonFilter.java b/phoenix-core/src/main/java/com/salesforce/phoenix/filter/MultiCQKeyValueComparisonFilter.java deleted file mode 100644 index 215456cc..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/MultiCQKeyValueComparisonFilter.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.filter; - -import org.apache.hadoop.hbase.util.Bytes; - -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.expression.Expression; - -/** - * - * Filter that evaluates WHERE clause expression, used in the case where there - * are references to multiple column qualifiers over a single column family. - * - * @author jtaylor - * @since 0.1 - */ -public class MultiCQKeyValueComparisonFilter extends MultiKeyValueComparisonFilter { - private ImmutableBytesPtr ptr = new ImmutableBytesPtr(); - private byte[] cf; - - public MultiCQKeyValueComparisonFilter() { - } - - public MultiCQKeyValueComparisonFilter(Expression expression) { - super(expression); - } - - @Override - protected Object setColumnKey(byte[] cf, int cfOffset, int cfLength, byte[] cq, int cqOffset, - int cqLength) { - ptr.set(cq, cqOffset, cqLength); - return ptr; - } - - @Override - protected Object newColumnKey(byte[] cf, int cfOffset, int cfLength, byte[] cq, int cqOffset, - int cqLength) { - if (cfOffset == 0 && cf.length == cfLength) { - this.cf = cf; - } else { - this.cf = new byte[cfLength]; - System.arraycopy(cf, cfOffset, this.cf, 0, cfLength); - } - return new ImmutableBytesPtr(cq, cqOffset, cqLength); - } - - - @SuppressWarnings("all") // suppressing missing @Override since this doesn't exist for HBase 0.94.4 - public boolean isFamilyEssential(byte[] name) { - return Bytes.compareTo(cf, name) == 0; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/SingleCFCQKeyValueComparisonFilter.java b/phoenix-core/src/main/java/com/salesforce/phoenix/filter/SingleCFCQKeyValueComparisonFilter.java deleted file mode 100644 index 51f69f25..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/SingleCFCQKeyValueComparisonFilter.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.filter; - -import org.apache.hadoop.hbase.util.Bytes; - -import com.salesforce.phoenix.expression.Expression; - - -/** - * - * SingleKeyValueComparisonFilter that needs to compare both the column family and - * column qualifier parts of the key value to disambiguate with another similarly - * named column qualifier in a different column family. - * - * @author jtaylor - * @since 0.1 - */ -public class SingleCFCQKeyValueComparisonFilter extends SingleKeyValueComparisonFilter { - public SingleCFCQKeyValueComparisonFilter() { - } - - public SingleCFCQKeyValueComparisonFilter(Expression expression) { - super(expression); - } - - @Override - protected final int compare(byte[] cfBuf, int cfOffset, int cfLength, byte[] cqBuf, int cqOffset, int cqLength) { - int c = Bytes.compareTo(cf, 0, cf.length, cfBuf, cfOffset, cfLength); - if (c != 0) return c; - return Bytes.compareTo(cq, 0, cq.length, cqBuf, cqOffset, cqLength); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/SingleCQKeyValueComparisonFilter.java b/phoenix-core/src/main/java/com/salesforce/phoenix/filter/SingleCQKeyValueComparisonFilter.java deleted file mode 100644 index 0940ccae..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/SingleCQKeyValueComparisonFilter.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.filter; - -import org.apache.hadoop.hbase.util.Bytes; - -import com.salesforce.phoenix.expression.Expression; - - -/** - * - * SingleKeyValueComparisonFilter that needs to only compare the column qualifier - * part of the key value since the column qualifier is unique across all column - * families. - * - * @author jtaylor - * @since 0.1 - */ -public class SingleCQKeyValueComparisonFilter extends SingleKeyValueComparisonFilter { - public SingleCQKeyValueComparisonFilter() { - } - - public SingleCQKeyValueComparisonFilter(Expression expression) { - super(expression); - } - - @Override - protected final int compare(byte[] cfBuf, int cfOffset, int cfLength, byte[] cqBuf, int cqOffset, int cqLength) { - return Bytes.compareTo(cq, 0, cq.length, cqBuf, cqOffset, cqLength); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/index/BaseIndexCodec.java b/phoenix-core/src/main/java/com/salesforce/phoenix/index/BaseIndexCodec.java deleted file mode 100644 index 923f3c47..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/index/BaseIndexCodec.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.index; - -import java.io.IOException; - -import org.apache.hadoop.hbase.client.Mutation; -import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; - -import com.salesforce.hbase.index.covered.IndexCodec; - -/** - * - */ -public abstract class BaseIndexCodec implements IndexCodec { - - @Override - public void initialize(RegionCoprocessorEnvironment env) throws IOException { - // noop - } - - /** - * {@inheritDoc} - *

- * By default, the codec is always enabled. Subclasses should override this method if they want do - * decide to index on a per-mutation basis. - * @throws IOException - */ - @Override - public boolean isEnabled(Mutation m) throws IOException { - return true; - } - - /** - * {@inheritDoc} - *

- * Assumes each mutation is not in a batch. Subclasses that have different batching behavior - * should override this. - */ - @Override - public byte[] getBatchId(Mutation m) { - return null; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/index/IndexMetaDataCacheFactory.java b/phoenix-core/src/main/java/com/salesforce/phoenix/index/IndexMetaDataCacheFactory.java deleted file mode 100644 index b53eacbe..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/index/IndexMetaDataCacheFactory.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the following conditions are met: Redistributions of source code - * must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in - * binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of Salesforce.com nor the names - * of its contributors may be used to endorse or promote products derived from this software without specific prior - * written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.index; - -import java.io.Closeable; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.sql.SQLException; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.cache.IndexMetaDataCache; -import com.salesforce.phoenix.client.GenericKeyValueBuilder; -import com.salesforce.phoenix.coprocessor.ServerCachingProtocol.ServerCacheFactory; -import com.salesforce.phoenix.memory.MemoryManager.MemoryChunk; - -public class IndexMetaDataCacheFactory implements ServerCacheFactory { - public IndexMetaDataCacheFactory() { - } - - @Override - public void readFields(DataInput arg0) throws IOException { - } - - @Override - public void write(DataOutput arg0) throws IOException { - } - - @Override - public Closeable newCache (ImmutableBytesWritable cachePtr, final MemoryChunk chunk) throws SQLException { - // just use the standard keyvalue builder - this doesn't really need to be fast - final List maintainers = - IndexMaintainer.deserialize(cachePtr, GenericKeyValueBuilder.INSTANCE); - return new IndexMetaDataCache() { - - @Override - public void close() throws IOException { - chunk.close(); - } - - @Override - public List getIndexMaintainers() { - return maintainers; - } - }; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/AggregatingResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/AggregatingResultIterator.java deleted file mode 100644 index 01649b1c..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/AggregatingResultIterator.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Interface for scanners that either do aggregation - * or delegate to scanners that do aggregation. - * - * @author jtaylor - * @since 0.1 - */ -public interface AggregatingResultIterator extends ResultIterator { - /** - * Provides a means of re-aggregating a result row. For - * scanners that need to look ahead (i.e. {@link com.salesforce.phoenix.iterate.OrderedAggregatingResultIterator} - * @param result the row to re-aggregate - */ - void aggregate(Tuple result); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/BaseResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/BaseResultIterator.java deleted file mode 100644 index b3e71450..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/BaseResultIterator.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; -import java.util.List; - -/** - * - * Abstract base class for ResultIterator implementations that - * do nothing on close and have no explain plan steps - * - * @author jtaylor - * @since 1.2 - */ -public abstract class BaseResultIterator implements ResultIterator { - - @Override - public void close() throws SQLException { - } - - @Override - public void explain(List planSteps) { - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ConcatResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ConcatResultIterator.java deleted file mode 100644 index c47f5e71..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ConcatResultIterator.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Result iterator that concatenates a list of other iterators. - * - * @author jtaylor - * @since 0.1 - */ -public class ConcatResultIterator implements PeekingResultIterator { - private final ResultIterators resultIterators; - private List iterators; - private int index; - - public ConcatResultIterator(ResultIterators iterators) { - this.resultIterators = iterators; - } - - private List getIterators() throws SQLException { - if (iterators == null) { - iterators = resultIterators.getIterators(); - } - return iterators; - } - - @Override - public void close() throws SQLException { - if (iterators != null) { - for (;index < iterators.size(); index++) { - PeekingResultIterator iterator = iterators.get(index); - iterator.close(); - } - } - } - - - @Override - public void explain(List planSteps) { - resultIterators.explain(planSteps); - } - - private PeekingResultIterator currentIterator() throws SQLException { - List iterators = getIterators(); - while (index < iterators.size()) { - PeekingResultIterator iterator = iterators.get(index); - Tuple r = iterator.peek(); - if (r != null) { - return iterator; - } - iterator.close(); - index++; - } - return EMPTY_ITERATOR; - } - - @Override - public Tuple peek() throws SQLException { - return currentIterator().peek(); - } - - @Override - public Tuple next() throws SQLException { - return currentIterator().next(); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/DelegateResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/DelegateResultIterator.java deleted file mode 100644 index 44ad11db..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/DelegateResultIterator.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.schema.tuple.Tuple; - - -public class DelegateResultIterator implements ResultIterator { - private final ResultIterator delegate; - - public DelegateResultIterator(ResultIterator delegate) { - this.delegate = delegate; - } - - @Override - public void close() throws SQLException { - delegate.close(); - } - - @Override - public Tuple next() throws SQLException { - return delegate.next(); - } - - @Override - public void explain(List planSteps) { - delegate.explain(planSteps); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/FilterAggregatingResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/FilterAggregatingResultIterator.java deleted file mode 100644 index cced489d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/FilterAggregatingResultIterator.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Post aggregation filter for HAVING clause. Due to the way we cache aggregation values - * we cannot have a look ahead for this Iterator, because the expressions in the SELECT - * clause would return values for the peeked row instead of the current row. If we only - * use the Result argument in {@link com.salesforce.phoenix.expression.Expression} - * instead of our cached value in Aggregators, we could have a look ahead. - * - * @author jtaylor - * @since 0.1 - */ -public class FilterAggregatingResultIterator implements AggregatingResultIterator { - private final AggregatingResultIterator delegate; - private final Expression expression; - private final ImmutableBytesWritable ptr = new ImmutableBytesWritable(); - - public FilterAggregatingResultIterator(AggregatingResultIterator delegate, Expression expression) { - this.delegate = delegate; - this.expression = expression; - if (expression.getDataType() != PDataType.BOOLEAN) { - throw new IllegalArgumentException("FilterResultIterator requires a boolean expression, but got " + expression); - } - } - - @Override - public Tuple next() throws SQLException { - Tuple next; - do { - next = delegate.next(); - } while (next != null && expression.evaluate(next, ptr) && Boolean.FALSE.equals(expression.getDataType().toObject(ptr))); - return next; - } - - @Override - public void close() throws SQLException { - delegate.close(); - } - - @Override - public void aggregate(Tuple result) { - delegate.aggregate(result); - } - - @Override - public void explain(List planSteps) { - delegate.explain(planSteps); - planSteps.add("CLIENT FILTER BY " + expression.toString()); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/FilterResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/FilterResultIterator.java deleted file mode 100644 index fcc74319..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/FilterResultIterator.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; -import java.util.List; - -import org.apache.hadoop.hbase.io.ImmutableBytesWritable; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Result scanner that filters out rows based on the results of a boolean - * expression (i.e. filters out if {@link com.salesforce.phoenix.expression.Expression#evaluate(Tuple, ImmutableBytesWritable)} - * returns false or the ptr contains a FALSE value}). May not be used where - * the delegate provided is an {@link com.salesforce.phoenix.iterate.AggregatingResultIterator}. - * For these, the {@link com.salesforce.phoenix.iterate.FilterAggregatingResultIterator} should be used. - * - * @author jtaylor - * @since 0.1 - */ -public class FilterResultIterator extends LookAheadResultIterator { - private final ResultIterator delegate; - private final Expression expression; - private final ImmutableBytesWritable ptr = new ImmutableBytesWritable(); - - public FilterResultIterator(ResultIterator delegate, Expression expression) { - if (delegate instanceof AggregatingResultIterator) { - throw new IllegalArgumentException("FilterResultScanner may not be used with an aggregate delegate. Use phoenix.iterate.FilterAggregateResultScanner instead"); - } - this.delegate = delegate; - this.expression = expression; - if (expression.getDataType() != PDataType.BOOLEAN) { - throw new IllegalArgumentException("FilterResultIterator requires a boolean expression, but got " + expression); - } - } - - @Override - protected Tuple advance() throws SQLException { - Tuple next; - do { - next = delegate.next(); - } while (next != null && expression.evaluate(next, ptr) && Boolean.FALSE.equals(expression.getDataType().toObject(ptr))); - return next; - } - - @Override - public void close() throws SQLException { - delegate.close(); - } - - @Override - public void explain(List planSteps) { - delegate.explain(planSteps); - planSteps.add("CLIENT FILTER BY " + expression.toString()); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/LimitingResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/LimitingResultIterator.java deleted file mode 100644 index 7a76d427..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/LimitingResultIterator.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.schema.tuple.Tuple; - -/** - * - * Iterates through tuples up to a limit - * - * @author jtaylor - * @since 1.2 - */ -public class LimitingResultIterator extends DelegateResultIterator { - private int rowCount; - private final int limit; - - public LimitingResultIterator(ResultIterator delegate, int limit) { - super(delegate); - this.limit = limit; - } - - @Override - public Tuple next() throws SQLException { - if (rowCount++ >= limit) { - return null; - } - return super.next(); - } - - @Override - public void explain(List planSteps) { - super.explain(planSteps); - planSteps.add("CLIENT " + limit + " ROW LIMIT"); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/LookAheadResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/LookAheadResultIterator.java deleted file mode 100644 index 68e3c3f8..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/LookAheadResultIterator.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; - -import com.salesforce.phoenix.schema.tuple.ResultTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -abstract public class LookAheadResultIterator implements PeekingResultIterator { - private final static Tuple UNINITIALIZED = new ResultTuple(); - private Tuple next = UNINITIALIZED; - - abstract protected Tuple advance() throws SQLException; - - private void init() throws SQLException { - if (next == UNINITIALIZED) { - next = advance(); - } - } - - @Override - public Tuple next() throws SQLException { - init(); - Tuple next = this.next; - this.next = advance(); - return next; - } - - @Override - public Tuple peek() throws SQLException { - init(); - return next; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MergeSortRowKeyResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MergeSortRowKeyResultIterator.java deleted file mode 100644 index 93c9759f..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MergeSortRowKeyResultIterator.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.util.List; - -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.TupleUtil; - - -/** - * - * ResultIterator that does a merge sort on the list of iterators provided, - * returning the rows in row key ascending order. The iterators provided - * must be in row key ascending order. - * - * @author jtaylor - * @since 0.1 - */ -public class MergeSortRowKeyResultIterator extends MergeSortResultIterator { - private final int keyOffset; - - public MergeSortRowKeyResultIterator(ResultIterators iterators) { - this(iterators, 0); - } - - public MergeSortRowKeyResultIterator(ResultIterators iterators, int keyOffset) { - super(iterators); - this.keyOffset = keyOffset; - } - - @Override - protected int compare(Tuple t1, Tuple t2) { - return TupleUtil.compare(t1, t2, tempPtr, keyOffset); - } - - @Override - public void explain(List planSteps) { - resultIterators.explain(planSteps); - planSteps.add("CLIENT MERGE SORT"); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/OrderedAggregatingResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/OrderedAggregatingResultIterator.java deleted file mode 100644 index 3c2c57d7..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/OrderedAggregatingResultIterator.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.expression.OrderByExpression; -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * Result scanner that sorts aggregated rows by columns specified in the ORDER BY clause. - *

- * Note that currently the sort is entirely done in memory. - * - * @author syyang - * @since 0.1 - */ -public class OrderedAggregatingResultIterator extends OrderedResultIterator implements AggregatingResultIterator { - - public OrderedAggregatingResultIterator(AggregatingResultIterator delegate, - List orderByExpressions, - int thresholdBytes, Integer limit) throws SQLException { - super (delegate, orderByExpressions, thresholdBytes, limit); - } - - @Override - protected AggregatingResultIterator getDelegate() { - return (AggregatingResultIterator)super.getDelegate(); - } - - @Override - public Tuple next() throws SQLException { - Tuple tuple = super.next(); - if (tuple != null) { - aggregate(tuple); - } - return tuple; - } - - @Override - public void aggregate(Tuple result) { - getDelegate().aggregate(result); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ParallelIteratorRegionSplitter.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ParallelIteratorRegionSplitter.java deleted file mode 100644 index 8b2f0b73..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ParallelIteratorRegionSplitter.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.query.KeyRange; - - -/** - * Interface for strategies determining how to split regions in ParallelIterators. - * - * @author zhuang - */ -public interface ParallelIteratorRegionSplitter { - - public List getSplits() throws SQLException; -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ParallelIteratorRegionSplitterFactory.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ParallelIteratorRegionSplitterFactory.java deleted file mode 100644 index 9992bfc6..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ParallelIteratorRegionSplitterFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.parse.HintNode; -import com.salesforce.phoenix.schema.TableRef; - - -/** - * Factory class for the Region Splitter used by the project. - */ -public class ParallelIteratorRegionSplitterFactory { - - public static ParallelIteratorRegionSplitter getSplitter(StatementContext context, TableRef table, HintNode hintNode) throws SQLException { - if (context.getScanRanges().useSkipScanFilter()) { - return SkipRangeParallelIteratorRegionSplitter.getInstance(context, table, hintNode); - } - return DefaultParallelIteratorRegionSplitter.getInstance(context, table, hintNode); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/PeekingResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/PeekingResultIterator.java deleted file mode 100644 index 663bb52e..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/PeekingResultIterator.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.schema.tuple.Tuple; - - -/** - * - * Interface for iterating through results returned from a scan, adding the - * ability to peek at the next result. - * - * @author jtaylor - * @since 0.1 - */ -public interface PeekingResultIterator extends ResultIterator { - public static final PeekingResultIterator EMPTY_ITERATOR = new PeekingResultIterator() { - - @Override - public Tuple next() throws SQLException { - return null; - } - - @Override - public Tuple peek() { - return null; - } - - @Override - public void close() throws SQLException { - } - - @Override - public void explain(List planSteps) { - } - }; - - /** - * Returns the next result without advancing the iterator - * @throws SQLException - */ - public Tuple peek() throws SQLException; -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/RegionScannerResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/RegionScannerResultIterator.java deleted file mode 100644 index 0d0e3f09..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/RegionScannerResultIterator.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.io.IOException; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.hadoop.hbase.KeyValue; -import org.apache.hadoop.hbase.regionserver.MultiVersionConsistencyControl; -import org.apache.hadoop.hbase.regionserver.RegionScanner; - -import com.salesforce.phoenix.schema.tuple.MultiKeyValueTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ServerUtil; - - -public class RegionScannerResultIterator extends BaseResultIterator { - private final RegionScanner scanner; - - public RegionScannerResultIterator(RegionScanner scanner) { - this.scanner = scanner; - MultiVersionConsistencyControl.setThreadReadPoint(scanner.getMvccReadPoint()); - } - - @Override - public Tuple next() throws SQLException { - try { - // TODO: size - List results = new ArrayList(); - // Results are potentially returned even when the return value of s.next is false - // since this is an indication of whether or not there are more values after the - // ones returned - boolean hasMore = scanner.nextRaw(results, null); - if (!hasMore && results.isEmpty()) { - return null; - } - // We instantiate a new tuple because in all cases currently we hang on to it (i.e. - // to compute and hold onto the TopN). - MultiKeyValueTuple tuple = new MultiKeyValueTuple(); - tuple.setKeyValues(results); - return tuple; - } catch (IOException e) { - throw ServerUtil.parseServerException(e); - } - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ResultIterator.java deleted file mode 100644 index edf7a05b..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ResultIterator.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.SQLCloseable; - - -public interface ResultIterator extends SQLCloseable { - public static final ResultIterator EMPTY_ITERATOR = new ResultIterator() { - @Override - public void close() throws SQLException { - } - - @Override - public Tuple next() throws SQLException { - return null; - } - - @Override - public void explain(List planSteps) { - } - }; - - /** - * Grab the next row's worth of values. The iterator will return a Tuple. - * @return Tuple object if there is another row, null if the scanner is - * exhausted. - * @throws SQLException e - */ - public Tuple next() throws SQLException; - - public void explain(List planSteps); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ResultIterators.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ResultIterators.java deleted file mode 100644 index 72f39b84..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ResultIterators.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; -import java.util.List; - -public interface ResultIterators { - public List getIterators() throws SQLException; - public int size(); - public void explain(List planSteps); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ScanningResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ScanningResultIterator.java deleted file mode 100644 index 318bfeab..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ScanningResultIterator.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.io.IOException; -import java.sql.SQLException; -import java.util.List; - -import org.apache.hadoop.hbase.client.Result; -import org.apache.hadoop.hbase.client.ResultScanner; - -import com.salesforce.phoenix.schema.tuple.ResultTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ServerUtil; - - -public class ScanningResultIterator implements ResultIterator { - private final ResultScanner scanner; - - public ScanningResultIterator(ResultScanner scanner) { - this.scanner = scanner; - } - - @Override - public void close() throws SQLException { - scanner.close(); - } - - @Override - public Tuple next() throws SQLException { - try { - Result result = scanner.next(); - // TODO: use ResultTuple.setResult(result) - // Need to create a new one if holding on to it (i.e. OrderedResultIterator) - return result == null ? null : new ResultTuple(result); - } catch (IOException e) { - throw ServerUtil.parseServerException(e); - } - } - - @Override - public void explain(List planSteps) { - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/SequenceResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/SequenceResultIterator.java deleted file mode 100644 index 122428c8..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/SequenceResultIterator.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.SequenceManager; -import com.salesforce.phoenix.schema.tuple.Tuple; - -/** - * - * Iterates through tuples retrieving sequences from the server as needed - * - * @author jtaylor - * @since 3.0 - */ -public class SequenceResultIterator extends DelegateResultIterator { - private final SequenceManager sequenceManager; - - public SequenceResultIterator(ResultIterator delegate, SequenceManager sequenceManager) throws SQLException { - super(delegate); - sequenceManager.initSequences(); - this.sequenceManager = sequenceManager; - } - - @Override - public Tuple next() throws SQLException { - Tuple next = super.next(); - if (next == null) { - return null; - } - sequenceManager.incrementSequenceValues(); - return next; - } - - @Override - public void explain(List planSteps) { - super.explain(planSteps); - planSteps.add("CLIENT RESERVE " + sequenceManager.getSequenceCount() + " SEQUENCES"); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/TableResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/TableResultIterator.java deleted file mode 100644 index 1e2f1cf0..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/TableResultIterator.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import java.io.IOException; -import java.sql.SQLException; -import java.util.List; - -import org.apache.hadoop.hbase.client.HTableInterface; -import org.apache.hadoop.hbase.client.Scan; - -import com.google.common.io.Closeables; -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ServerUtil; - - -/** - * - * Wrapper for ResultScanner creation that closes HTableInterface - * when ResultScanner is closed. - * - * @author jtaylor - * @since 0.1 - */ -public class TableResultIterator extends ExplainTable implements ResultIterator { - private final HTableInterface htable; - private final ResultIterator delegate; - - public TableResultIterator(StatementContext context, TableRef tableRef) throws SQLException { - this(context, tableRef, context.getScan()); - } - - public TableResultIterator(StatementContext context, TableRef tableRef, Scan scan) throws SQLException { - super(context, tableRef); - htable = context.getConnection().getQueryServices().getTable(tableRef.getTable().getPhysicalName().getBytes()); - try { - delegate = new ScanningResultIterator(htable.getScanner(scan)); - } catch (IOException e) { - Closeables.closeQuietly(htable); - throw ServerUtil.parseServerException(e); - } - } - - @Override - public void close() throws SQLException { - try { - delegate.close(); - } finally { - try { - htable.close(); - } catch (IOException e) { - throw ServerUtil.parseServerException(e); - } - } - } - - @Override - public Tuple next() throws SQLException { - return delegate.next(); - } - - @Override - public void explain(List planSteps) { - StringBuilder buf = new StringBuilder(); - explain(buf.toString(),planSteps); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/UngroupedAggregatingResultIterator.java b/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/UngroupedAggregatingResultIterator.java deleted file mode 100644 index e6472c2d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/UngroupedAggregatingResultIterator.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; - -import static com.salesforce.phoenix.query.QueryConstants.*; - -import java.sql.SQLException; - -import com.salesforce.phoenix.expression.aggregator.Aggregators; -import com.salesforce.phoenix.schema.tuple.SingleKeyValueTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.KeyValueUtil; - - -public class UngroupedAggregatingResultIterator extends GroupedAggregatingResultIterator { - private boolean hasRows = false; - - public UngroupedAggregatingResultIterator( PeekingResultIterator resultIterator, Aggregators aggregators) { - super(resultIterator, aggregators); - } - - @Override - public Tuple next() throws SQLException { - Tuple result = super.next(); - // Ensure ungrouped aggregregation always returns a row, even if the underlying iterator doesn't. - if (result == null && !hasRows) { - // Generate value using unused ClientAggregators - byte[] value = aggregators.toBytes(aggregators.getAggregators()); - result = new SingleKeyValueTuple( - KeyValueUtil.newKeyValue(UNGROUPED_AGG_ROW_KEY, - SINGLE_COLUMN_FAMILY, - SINGLE_COLUMN, - AGG_TIMESTAMP, - value)); - } - hasRows = true; - return result; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/Jdbc7Shim.java b/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/Jdbc7Shim.java deleted file mode 100644 index 231e4671..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/Jdbc7Shim.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.jdbc; - -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.util.concurrent.Executor; -import java.util.logging.Logger; - -/** - * Interfaces to be implemented by classes that need to be "JDK7" compliant, - * but also run in JDK6 - */ -public final class Jdbc7Shim { - - public interface Statement { // Note: do not extend "regular" statement or else eclipse 3.7 complains - void closeOnCompletion() throws SQLException; - boolean isCloseOnCompletion() throws SQLException; - } - - public interface CallableStatement extends Statement { - public T getObject(int columnIndex, Class type) throws SQLException; - public T getObject(String columnLabel, Class type) throws SQLException; - } - - public interface Connection { - void setSchema(String schema) throws SQLException; - String getSchema() throws SQLException; - void abort(Executor executor) throws SQLException; - void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException; - int getNetworkTimeout() throws SQLException; - } - - public interface ResultSet { - public T getObject(int columnIndex, Class type) throws SQLException; - public T getObject(String columnLabel, Class type) throws SQLException; - } - - public interface DatabaseMetaData { - java.sql.ResultSet getPseudoColumns(String catalog, String schemaPattern, - String tableNamePattern, String columnNamePattern) - throws SQLException; - boolean generatedKeyAlwaysReturned() throws SQLException; - } - - public interface Driver { - public Logger getParentLogger() throws SQLFeatureNotSupportedException; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixStatementFactory.java b/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixStatementFactory.java deleted file mode 100644 index 3a0166a5..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixStatementFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.jdbc; - -public interface PhoenixStatementFactory { - public PhoenixStatement newStatement(PhoenixConnection connection); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/join/MaxServerCacheSizeExceededException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/join/MaxServerCacheSizeExceededException.java deleted file mode 100644 index b6da591c..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/join/MaxServerCacheSizeExceededException.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.join; - -/** - * - * Exception thrown when the size of the hash cache exceeds the - * maximum size as specified by the phoenix.query.maxHashCacheBytes - * parameter in the {@link org.apache.hadoop.conf.Configuration} - * - * @author jtaylor - * @since 0.1 - */ -public class MaxServerCacheSizeExceededException extends RuntimeException { - private static final long serialVersionUID = 1L; - - public MaxServerCacheSizeExceededException() { - } - - public MaxServerCacheSizeExceededException(String message) { - super(message); - } - - public MaxServerCacheSizeExceededException(Throwable cause) { - super(cause); - } - - public MaxServerCacheSizeExceededException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/memory/DelegatingMemoryManager.java b/phoenix-core/src/main/java/com/salesforce/phoenix/memory/DelegatingMemoryManager.java deleted file mode 100644 index 3bcccb60..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/memory/DelegatingMemoryManager.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.memory; - -/** - * - * Memory manager that delegates through to another memory manager. - * - * @author jtaylor - * @since 0.1 - */ -public class DelegatingMemoryManager implements MemoryManager { - private final MemoryManager parent; - - public DelegatingMemoryManager(MemoryManager globalMemoryManager){ - this.parent = globalMemoryManager; - } - - @Override - public long getAvailableMemory() { - return parent.getAvailableMemory(); - } - - @Override - public long getMaxMemory() { - return parent.getMaxMemory(); - } - - @Override - public MemoryChunk allocate(long minBytes, long reqBytes) { - return parent.allocate(minBytes, reqBytes); - } - - - @Override - public MemoryChunk allocate(long nBytes) { - return allocate(nBytes, nBytes); - } - - public MemoryManager getParent() { - return parent; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/memory/InsufficientMemoryException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/memory/InsufficientMemoryException.java deleted file mode 100644 index 2157f4a4..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/memory/InsufficientMemoryException.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.memory; - -/** - * - * Exception thrown by MemoryManager when insufficient memory is available - * - * @author jtaylor - * @since 0.1 - */ -public class InsufficientMemoryException extends RuntimeException { - private static final long serialVersionUID = 1L; - - public InsufficientMemoryException() { - } - - public InsufficientMemoryException(String message) { - super(message); - } - - public InsufficientMemoryException(Throwable cause) { - super(cause); - } - - public InsufficientMemoryException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AddColumnStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AddColumnStatement.java deleted file mode 100644 index 6007b0be..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AddColumnStatement.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import com.salesforce.phoenix.schema.PTableType; - -public class AddColumnStatement extends AlterTableStatement { - private final List columnDefs; - private final boolean ifNotExists; - private final Map props; - - protected AddColumnStatement(NamedTableNode table, PTableType tableType, List columnDefs, boolean ifNotExists, Map props) { - super(table, tableType); - this.columnDefs = columnDefs; - this.props = props == null ? Collections.emptyMap() : props; - this.ifNotExists = ifNotExists; - } - - public List getColumnDefs() { - return columnDefs; - } - - public boolean ifNotExists() { - return ifNotExists; - } - - public Map getProps() { - return props; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AddParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AddParseNode.java deleted file mode 100644 index 69f7ee86..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AddParseNode.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - -/** - * - * Node representing addition in a SQL expression - * - * @author jtaylor - * @since 0.1 - */ -public class AddParseNode extends ArithmeticParseNode { - - AddParseNode(List children) { - super(children); - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AggregateFunctionParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AggregateFunctionParseNode.java deleted file mode 100644 index e0a6d388..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AggregateFunctionParseNode.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.List; - - -public class AggregateFunctionParseNode extends FunctionParseNode { - - public AggregateFunctionParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - /** - * Aggregate function are not stateless, even though all the args may be stateless, - * for example, COUNT(1) - */ - @Override - public boolean isStateless() { - return false; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AliasedNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AliasedNode.java deleted file mode 100644 index 667be6b1..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AliasedNode.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import com.salesforce.phoenix.util.SchemaUtil; - -/** - * - * Node representing an aliased parse node in a SQL select clause - * - * @author jtaylor - * @since 0.1 - */ -public class AliasedNode { - private final String alias; - private final ParseNode node; - private final boolean isCaseSensitve; - - public AliasedNode(String alias, ParseNode node) { - this.isCaseSensitve = alias != null && SchemaUtil.isCaseSensitive(alias); - this.alias = alias == null ? null : SchemaUtil.normalizeIdentifier(alias); - this.node = node; - } - - public String getAlias() { - return alias; - } - - public ParseNode getNode() { - return node; - } - - public boolean isCaseSensitve() { - return isCaseSensitve; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AlterIndexStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AlterIndexStatement.java deleted file mode 100644 index 20765bfe..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AlterIndexStatement.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import com.salesforce.phoenix.schema.PIndexState; - -public class AlterIndexStatement extends SingleTableSQLStatement { - private final String dataTableName; - private final boolean ifExists; - private final PIndexState indexState; - - public AlterIndexStatement(NamedTableNode indexTableNode, String dataTableName, boolean ifExists, PIndexState indexState) { - super(indexTableNode,0); - this.dataTableName = dataTableName; - this.ifExists = ifExists; - this.indexState = indexState; - } - - public String getTableName() { - return dataTableName; - } - - @Override - public int getBindCount() { - return 0; - } - - public boolean ifExists() { - return ifExists; - } - - public PIndexState getIndexState() { - return indexState; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AlterTableStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AlterTableStatement.java deleted file mode 100644 index 2590bbf0..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AlterTableStatement.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import com.salesforce.phoenix.schema.PTableType; - -public abstract class AlterTableStatement extends SingleTableSQLStatement { - private final PTableType tableType; - - AlterTableStatement(NamedTableNode table, PTableType tableType) { - super(table, 0); - this.tableType = tableType; - } - - public PTableType getTableType() { - return tableType; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AndParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AndParseNode.java deleted file mode 100644 index ca2182f3..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AndParseNode.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - - -/** - * - * Node representing AND in a SQL expression - * - * @author jtaylor - * @since 0.1 - */ -public class AndParseNode extends CompoundParseNode { - - AndParseNode(List children) { - super(children); - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ArithmeticParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ArithmeticParseNode.java deleted file mode 100644 index 5609ab01..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ArithmeticParseNode.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.List; - -public abstract class ArithmeticParseNode extends CompoundParseNode { - - public ArithmeticParseNode(List children) { - super(children); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ArrayConstructorNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ArrayConstructorNode.java deleted file mode 100644 index f9ba8c2b..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ArrayConstructorNode.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - -/** - * Holds the list of array elements that will be used by the upsert stmt with ARRAY column - * - */ -public class ArrayConstructorNode extends CompoundParseNode { - - public ArrayConstructorNode(List children) { - super(children); - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AvgAggregateParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AvgAggregateParseNode.java deleted file mode 100644 index 19b35847..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/AvgAggregateParseNode.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.function.*; - - -public class AvgAggregateParseNode extends AggregateFunctionParseNode { - - public AvgAggregateParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - @Override - public FunctionExpression create(List children, StatementContext context) throws SQLException { - SumAggregateFunction sumFunc; - CountAggregateFunction countFunc = (CountAggregateFunction)context.getExpressionManager().addIfAbsent(new CountAggregateFunction(children)); - if (!countFunc.isConstantExpression()) { - sumFunc = (SumAggregateFunction)context.getExpressionManager().addIfAbsent(new SumAggregateFunction(countFunc.getChildren(),null)); - } else { - sumFunc = null; - } - - return new AvgAggregateFunction(children, countFunc, sumFunc); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BaseParseNodeVisitor.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BaseParseNodeVisitor.java deleted file mode 100644 index 31d51bb3..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BaseParseNodeVisitor.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.util.List; - - - -/** - * - * Base class for parse node visitors. - * - * @author jtaylor - * @since 0.1 - */ -public abstract class BaseParseNodeVisitor implements ParseNodeVisitor { - - /** - * Fall through visitEnter method. Anything coming through - * here means that a more specific method wasn't found - * and thus this CompoundNode is not yet supported. - */ - @Override - public boolean visitEnter(CompoundParseNode expressionNode) throws SQLException { - throw new SQLFeatureNotSupportedException(expressionNode.toString()); - } - - @Override - public E visitLeave(CompoundParseNode expressionNode, List l) throws SQLException { - throw new SQLFeatureNotSupportedException(expressionNode.toString()); - } - - /** - * Fall through visit method. Anything coming through - * here means that a more specific method wasn't found - * and thus this Node is not yet supported. - */ - @Override - public E visit(ParseNode expressionNode) throws SQLException { - throw new SQLFeatureNotSupportedException(expressionNode.toString()); - } - - @Override - public List newElementList(int size) { - return null; - } - - @Override - public void addElement(List l, E element) { - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BetweenParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BetweenParseNode.java deleted file mode 100644 index cd7d5ded..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BetweenParseNode.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.*; - - - -/** - * - * Node representing BETWEEN in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class BetweenParseNode extends CompoundParseNode { - private final boolean negate; - - BetweenParseNode(ParseNode l, ParseNode r1, ParseNode r2, boolean negate) { - super(Arrays.asList(l, r1, r2)); - this.negate = negate; - } - - public boolean isNegate() { - return negate; - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BinaryParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BinaryParseNode.java deleted file mode 100644 index 37bdf55a..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BinaryParseNode.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.Arrays; - -/** - * - * Abstract class for operators that operate on exactly two nodes - * - * @author jtaylor - * @since 0.1 - */ -public abstract class BinaryParseNode extends CompoundParseNode { - - BinaryParseNode(ParseNode lhs, ParseNode rhs) { - super(Arrays.asList(lhs, rhs)); - } - - public ParseNode getLHS() { - return getChildren().get(0); - } - - public ParseNode getRHS() { - return getChildren().get(1); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BindParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BindParseNode.java deleted file mode 100644 index 383bcde9..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BindParseNode.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; - - - -/** - * - * Node representing a bind variable in a SQL expression - * - * @author jtaylor - * @since 0.1 - */ -public class BindParseNode extends NamedParseNode { - private final int index; - - BindParseNode(String name) { - super(name); - index = Integer.parseInt(name); - } - - public int getIndex() { - return index-1; - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - return visitor.visit(this); - } - - - @Override - public boolean isStateless() { - return true; - } - - @Override - public String toString() { - return ":" + index; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BindTableNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BindTableNode.java deleted file mode 100644 index 3c7c8828..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BindTableNode.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; - - - -/** - * - * Node representing a TABLE bound using an ARRAY variable - * TODO: modify grammar to support this - * @author jtaylor - * @since 0.1 - */ -public class BindTableNode extends ConcreteTableNode { - - BindTableNode(String alias, TableName name) { - super(alias, name); - } - - @Override - public void accept(TableNodeVisitor visitor) throws SQLException { - visitor.visit(this); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BindableStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BindableStatement.java deleted file mode 100644 index 2ac82809..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/BindableStatement.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - - -public interface BindableStatement { - public int getBindCount(); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CaseParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CaseParseNode.java deleted file mode 100644 index 96870b6f..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CaseParseNode.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - -/** - * - * Node representing a CASE in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class CaseParseNode extends CompoundParseNode { - - CaseParseNode(List children) { - super(children); - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CastParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CastParseNode.java deleted file mode 100644 index 50ab939b..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CastParseNode.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.function.RoundDecimalExpression; -import com.salesforce.phoenix.expression.function.RoundTimestampExpression; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.TypeMismatchException; - -/** - * - * Node representing the CAST operator in SQL. - * - * @author samarth.jain - * @since 0.1 - * - */ -public class CastParseNode extends UnaryParseNode { - - private final PDataType dt; - - CastParseNode(ParseNode expr, String dataType) { - super(expr); - dt = PDataType.fromSqlTypeName(dataType); - } - - CastParseNode(ParseNode expr, PDataType dataType) { - super(expr); - dt = dataType; - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } - - public PDataType getDataType() { - return dt; - } - - public static Expression convertToRoundExpressionIfNeeded(PDataType fromDataType, PDataType targetDataType, List expressions) throws SQLException { - Expression firstChildExpr = expressions.get(0); - if(fromDataType == targetDataType) { - return firstChildExpr; - } else if(fromDataType == PDataType.DECIMAL && targetDataType.isCoercibleTo(PDataType.LONG)) { - return new RoundDecimalExpression(expressions); - } else if((fromDataType == PDataType.TIMESTAMP || fromDataType == PDataType.UNSIGNED_TIMESTAMP) && targetDataType.isCoercibleTo(PDataType.DATE)) { - return RoundTimestampExpression.create(expressions); - } else if(!fromDataType.isCoercibleTo(targetDataType)) { - throw TypeMismatchException.newException(fromDataType, targetDataType, firstChildExpr.toString()); - } - return firstChildExpr; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CeilParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CeilParseNode.java deleted file mode 100644 index e7f78b81..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CeilParseNode.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.function.CeilDateExpression; -import com.salesforce.phoenix.expression.function.CeilDecimalExpression; -import com.salesforce.phoenix.expression.function.CeilFunction; -import com.salesforce.phoenix.expression.function.CeilTimestampExpression; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.TypeMismatchException; - -/** - * Parse node corresponding to {@link CeilFunction}. - * It also acts as a factory for creating the right kind of - * ceil expression according to the data type of the - * first child. - * - * @author samarth.jain - * @since 3.0.0 - */ -public class CeilParseNode extends FunctionParseNode { - - CeilParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - @Override - public Expression create(List children, StatementContext context) throws SQLException { - return getCeilExpression(children); - } - - public static Expression getCeilExpression(List children) throws SQLException { - final Expression firstChild = children.get(0); - final PDataType firstChildDataType = firstChild.getDataType(); - if(firstChildDataType.isCoercibleTo(PDataType.DATE)) { - return CeilDateExpression.create(children); - } else if (firstChildDataType == PDataType.TIMESTAMP || firstChildDataType == PDataType.UNSIGNED_TIMESTAMP) { - return CeilTimestampExpression.create(children); - } else if(firstChildDataType.isCoercibleTo(PDataType.DECIMAL)) { - return new CeilDecimalExpression(children); - } else { - throw TypeMismatchException.newException(firstChildDataType, "1"); - } - } - - /** - * When ceiling off decimals, user need not specify the scale. In such cases, - * we need to prevent the function from getting evaluated as null. This is really - * a hack. A better way would have been if {@link com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo} provided a - * way of associating default values for each permissible data type. - * Something like: @ Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValues = {"null", "1"} isConstant=true) - * Till then, this will have to do. - */ - @Override - public boolean evalToNullIfParamIsNull(StatementContext context, int index) throws SQLException { - return index == 0; - } - - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ColumnFamilyDef.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ColumnFamilyDef.java deleted file mode 100644 index 17ff7f86..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ColumnFamilyDef.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.*; - - -import com.google.common.collect.ImmutableList; -import com.salesforce.phoenix.util.SchemaUtil; - -/** - * - * Definition of a Column Family at DDL time - * - * @author jtaylor - * @since 0.1 - */ -public class ColumnFamilyDef { - private final String name; - private final List columnDefs; - private final Map props; - - ColumnFamilyDef(String name, List columnDefs, Map props) { - this.name = SchemaUtil.normalizeIdentifier(name); - this.columnDefs = ImmutableList.copyOf(columnDefs); - this.props = props == null ? Collections.emptyMap() : props; - } - - public String getName() { - return name; - } - - public List getColumnDefs() { - return columnDefs; - } - - public Map getProps() { - return props; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ComparisonParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ComparisonParseNode.java deleted file mode 100644 index c6973f72..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ComparisonParseNode.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - -import org.apache.hadoop.hbase.filter.CompareFilter; - -/** - * - * Common base class for =, >, >=, <, <=, != - * - * @author jtaylor - * @since 0.1 - */ -public abstract class ComparisonParseNode extends BinaryParseNode { - - ComparisonParseNode(ParseNode lhs, ParseNode rhs) { - super(lhs, rhs); - } - - @Override - public final T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } - - /** - * Return the comparison operator associated with the given comparison expression node - */ - public abstract CompareFilter.CompareOp getFilterOp(); - - /** - * Return the inverted operator for the CompareOp - */ - public abstract CompareFilter.CompareOp getInvertFilterOp(); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CompoundParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CompoundParseNode.java deleted file mode 100644 index d82fa936..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CompoundParseNode.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - -/** - * - * Abstract node representing an expression node that has children - * - * @author jtaylor - * @since 0.1 - */ -public abstract class CompoundParseNode extends ParseNode { - private final List children; - private final boolean isStateless; - - CompoundParseNode(List children) { - this.children = Collections.unmodifiableList(children); - boolean isStateless = true; - for (ParseNode child : children) { - isStateless &= child.isStateless(); - if (!isStateless) { - break; - } - } - this.isStateless = isStateless; - } - - @Override - public boolean isStateless() { - return isStateless; - } - - @Override - public final List getChildren() { - return children; - } - - - final List acceptChildren(ParseNodeVisitor visitor) throws SQLException { - List l = visitor.newElementList(children.size()); - for (int i = 0; i < children.size(); i++) { - T e = children.get(i).accept(visitor); - visitor.addElement(l, e); - } - return l; - } - - @Override - public String toString() { - return this.getClass().getName() + children.toString(); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ConcreteTableNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ConcreteTableNode.java deleted file mode 100644 index a741745b..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ConcreteTableNode.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import com.salesforce.phoenix.util.SchemaUtil; - -/** - * - * Abstract node representing a table reference in the FROM clause in SQL - * - * @author jtaylor - * @since 0.1 - */ -public abstract class ConcreteTableNode extends TableNode { - private final TableName name; - - ConcreteTableNode(String alias, TableName name) { - super(SchemaUtil.normalizeIdentifier(alias)); - this.name = name; - } - - public TableName getName() { - return name; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CreateSequenceStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CreateSequenceStatement.java deleted file mode 100644 index e26604e2..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CreateSequenceStatement.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -public class CreateSequenceStatement implements BindableStatement { - - private final TableName sequenceName; - private final ParseNode startWith; - private final ParseNode incrementBy; - private final ParseNode cacheSize; - private final boolean ifNotExists; - private final int bindCount; - - protected CreateSequenceStatement(TableName sequenceName, ParseNode startsWith, ParseNode incrementBy, ParseNode cacheSize, boolean ifNotExists, int bindCount) { - this.sequenceName = sequenceName; - this.startWith = startsWith == null ? LiteralParseNode.ONE : startsWith; - this.incrementBy = incrementBy == null ? LiteralParseNode.ONE : incrementBy; - this.cacheSize = cacheSize == null ? null : cacheSize; - this.ifNotExists = ifNotExists; - this.bindCount = bindCount; - } - - @Override - public int getBindCount() { - return this.bindCount; - } - - public ParseNode getIncrementBy() { - return incrementBy; - } - - public TableName getSequenceName() { - return sequenceName; - } - - public ParseNode getCacheSize() { - return cacheSize; - } - - public ParseNode getStartWith() { - return startWith; - } - - public boolean ifNotExists() { - return ifNotExists; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CurrentDateParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CurrentDateParseNode.java deleted file mode 100644 index 54e9a386..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CurrentDateParseNode.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.function.CurrentDateFunction; -import com.salesforce.phoenix.expression.function.FunctionExpression; - - -public class CurrentDateParseNode extends FunctionParseNode { - - public CurrentDateParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - @Override - public FunctionExpression create(List children, StatementContext context) throws SQLException { - return new CurrentDateFunction(context.getCurrentTime()); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CurrentTimeParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CurrentTimeParseNode.java deleted file mode 100644 index 3d169f76..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CurrentTimeParseNode.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.function.CurrentTimeFunction; -import com.salesforce.phoenix.expression.function.FunctionExpression; - - -public class CurrentTimeParseNode extends FunctionParseNode { - - public CurrentTimeParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - @Override - public FunctionExpression create(List children, StatementContext context) throws SQLException { - return new CurrentTimeFunction(context.getCurrentTime()); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DelegateConstantToCountParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DelegateConstantToCountParseNode.java deleted file mode 100644 index 265d1215..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DelegateConstantToCountParseNode.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.function.CountAggregateFunction; -import com.salesforce.phoenix.expression.function.FunctionExpression; - - -public abstract class DelegateConstantToCountParseNode extends AggregateFunctionParseNode { - - public DelegateConstantToCountParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - protected CountAggregateFunction getDelegateFunction(List children, StatementContext context) { - CountAggregateFunction countFunc = null; - if (getChildren().get(0).isStateless()) { - countFunc = (CountAggregateFunction)context.getExpressionManager().addIfAbsent(new CountAggregateFunction(children)); - } - return countFunc; - } - - @Override - public abstract FunctionExpression create(List children, StatementContext context) throws SQLException; - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DeleteStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DeleteStatement.java deleted file mode 100644 index 317a5cfe..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DeleteStatement.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.Collections; -import java.util.List; - -public class DeleteStatement extends SingleTableSQLStatement implements FilterableStatement { - private final ParseNode whereNode; - private final List orderBy; - private final LimitNode limit; - private final HintNode hint; - - public DeleteStatement(NamedTableNode table, HintNode hint, ParseNode whereNode, List orderBy, LimitNode limit, int bindCount) { - super(table, bindCount); - this.whereNode = whereNode; - this.orderBy = orderBy == null ? Collections.emptyList() : orderBy; - this.limit = limit; - this.hint = hint == null ? HintNode.EMPTY_HINT_NODE : hint; - } - - @Override - public ParseNode getWhere() { - return whereNode; - } - - @Override - public List getOrderBy() { - return orderBy; - } - - @Override - public LimitNode getLimit() { - return limit; - } - - @Override - public HintNode getHint() { - return hint; - } - - @Override - public boolean isDistinct() { - return false; - } - - @Override - public boolean isAggregate() { - return false; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DerivedTableNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DerivedTableNode.java deleted file mode 100644 index 5faba22a..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DerivedTableNode.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; - - - -/** - * - * Node representing a subselect in the FROM clause of SQL - * - * @author jtaylor - * @since 0.1 - */ -public class DerivedTableNode extends TableNode { - - private final SelectStatement select; - - DerivedTableNode(String alias, SelectStatement select) { - super(alias); - this.select = select; - } - - public SelectStatement getSelect() { - return select; - } - - @Override - public void accept(TableNodeVisitor visitor) throws SQLException { - visitor.visit(this); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DistinctCountParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DistinctCountParseNode.java deleted file mode 100644 index e7815e64..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DistinctCountParseNode.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.function.DistinctCountAggregateFunction; -import com.salesforce.phoenix.expression.function.FunctionExpression; - -/** - * - * @author anoopsjohn - * @since 1.2.1 - */ -public class DistinctCountParseNode extends DelegateConstantToCountParseNode { - - public DistinctCountParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - @Override - public FunctionExpression create(List children, StatementContext context) - throws SQLException { - return new DistinctCountAggregateFunction(children, getDelegateFunction(children, context)); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DivideParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DivideParseNode.java deleted file mode 100644 index 9270a3f8..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DivideParseNode.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - -/** - * - * Node representing division in a SQL expression - * - * @author jtaylor - * @since 0.1 - */ -public class DivideParseNode extends ArithmeticParseNode { - - DivideParseNode(List children) { - super(children); - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropColumnStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropColumnStatement.java deleted file mode 100644 index 18db5b50..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropColumnStatement.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.List; - -import com.salesforce.phoenix.schema.PTableType; - -public class DropColumnStatement extends AlterTableStatement { - private final List columnRefs; - private final boolean ifExists; - - protected DropColumnStatement(NamedTableNode table, PTableType tableType, List columnRefs, boolean ifExists) { - super(table, tableType); - this.columnRefs = columnRefs; - this.ifExists = ifExists; - } - - public List getColumnRefs() { - return columnRefs; - } - - public boolean ifExists() { - return ifExists; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropIndexStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropIndexStatement.java deleted file mode 100644 index bae21897..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropIndexStatement.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -public class DropIndexStatement implements BindableStatement { - private final TableName tableName; - private final NamedNode indexName; - private final boolean ifExists; - - public DropIndexStatement(NamedNode indexName, TableName tableName, boolean ifExists) { - this.indexName = indexName; - this.tableName = tableName; - this.ifExists = ifExists; - } - - public TableName getTableName() { - return tableName; - } - - public NamedNode getIndexName() { - return indexName; - } - - @Override - public int getBindCount() { - return 0; - } - - public boolean ifExists() { - return ifExists; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropSequenceStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropSequenceStatement.java deleted file mode 100644 index c1182b05..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropSequenceStatement.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -public class DropSequenceStatement implements BindableStatement { - - private final TableName sequenceName; - private final boolean ifExists; - private final int bindCount; - - protected DropSequenceStatement(TableName sequenceName, boolean ifExists, int bindCount) { - this.sequenceName = sequenceName; - this.ifExists = ifExists; - this.bindCount = bindCount; - } - - @Override - public int getBindCount() { - return bindCount; - } - - public TableName getSequenceName() { - return sequenceName; - } - - public boolean ifExists() { - return ifExists; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropTableStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropTableStatement.java deleted file mode 100644 index 4cac741b..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/DropTableStatement.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import com.salesforce.phoenix.schema.PTableType; - -public class DropTableStatement implements BindableStatement { - private final TableName tableName; - private final boolean ifExists; - private final PTableType tableType; - - protected DropTableStatement(TableName tableName, PTableType tableType, boolean ifExists) { - this.tableName = tableName; - this.tableType = tableType; - this.ifExists = ifExists; - } - - @Override - public int getBindCount() { - return 0; // No binds for DROP - } - - public TableName getTableName() { - return tableName; - } - - public PTableType getTableType() { - return tableType; - } - - public boolean ifExists() { - return ifExists; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/EqualParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/EqualParseNode.java deleted file mode 100644 index 62a76581..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/EqualParseNode.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; - - -/** - * - * Node representing the equal operator in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class EqualParseNode extends ComparisonParseNode { - - EqualParseNode(ParseNode lhs, ParseNode rhs) { - super(lhs, rhs); - } - - @Override - public CompareOp getFilterOp() { - return CompareOp.EQUAL; - } - - @Override - public CompareOp getInvertFilterOp() { - return CompareOp.EQUAL; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ExistsParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ExistsParseNode.java deleted file mode 100644 index 208f58f1..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ExistsParseNode.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - -/** - * - * Node representing EXISTS and NOT EXISTS expressions in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class ExistsParseNode extends BinaryParseNode { - private final boolean negate; - - ExistsParseNode(ParseNode l, ParseNode r, boolean negate) { - super(l, r); - this.negate = negate; - } - - public boolean isNegate() { - return negate; - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ExplainStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ExplainStatement.java deleted file mode 100644 index e3dcbff5..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ExplainStatement.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -public class ExplainStatement implements BindableStatement { - private final BindableStatement statement; - - public ExplainStatement(BindableStatement statement) { - this.statement = statement; - } - - public BindableStatement getStatement() { - return statement; - } - - @Override - public int getBindCount() { - return statement.getBindCount(); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/FamilyWildcardParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/FamilyWildcardParseNode.java deleted file mode 100644 index 36094efb..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/FamilyWildcardParseNode.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; - -/** - * - * Node representing the selection of all columns of a family (cf.*) in the SELECT clause of SQL - * - * @author nmaillard - * @since 1.2 - */ - -public class FamilyWildcardParseNode extends NamedParseNode { - private final boolean isRewrite; - - public FamilyWildcardParseNode(String familyName, boolean isRewrite){ - super(familyName); - this.isRewrite = isRewrite; - } - - public FamilyWildcardParseNode(FamilyWildcardParseNode familyName, boolean isRewrite){ - super(familyName); - this.isRewrite = isRewrite; - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - return visitor.visit(this); - } - - public boolean isRewrite() { - return isRewrite; - } -} - diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/FilterableStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/FilterableStatement.java deleted file mode 100644 index ff486239..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/FilterableStatement.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.List; - -public interface FilterableStatement extends BindableStatement { - public HintNode getHint(); - public ParseNode getWhere(); - public boolean isDistinct(); - public boolean isAggregate(); - public List getOrderBy(); - public LimitNode getLimit(); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/FloorParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/FloorParseNode.java deleted file mode 100644 index fe43d9a6..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/FloorParseNode.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.function.FloorDateExpression; -import com.salesforce.phoenix.expression.function.FloorDecimalExpression; -import com.salesforce.phoenix.expression.function.FloorFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.TypeMismatchException; - -/** - * Parse node corresponding to {@link FloorFunction}. - * It also acts as a factory for creating the right kind of - * floor expression according to the data type of the - * first child. - * - * @author samarth.jain - * @since 3.0.0 - */ -public class FloorParseNode extends FunctionParseNode { - - FloorParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - @Override - public Expression create(List children, StatementContext context) throws SQLException { - return getFloorExpression(children); - } - - public static Expression getFloorExpression(List children) throws SQLException { - final Expression firstChild = children.get(0); - final PDataType firstChildDataType = firstChild.getDataType(); - - //FLOOR on timestamp doesn't really care about the nanos part i.e. it just sets it to zero. - //Which is exactly what FloorDateExpression does too. - if(firstChildDataType.isCoercibleTo(PDataType.TIMESTAMP)) { - return FloorDateExpression.create(children); - } else if(firstChildDataType.isCoercibleTo(PDataType.DECIMAL)) { - return new FloorDecimalExpression(children); - } else { - throw TypeMismatchException.newException(firstChildDataType, "1"); - } - } - - /** - * When rounding off decimals, user need not specify the scale. In such cases, - * we need to prevent the function from getting evaluated as null. This is really - * a hack. A better way would have been if {@link com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo} provided a - * way of associating default values for each permissible data type. - * Something like: @ Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValues = {"null", "1"} isConstant=true) - * Till then, this will have to do. - */ - @Override - public boolean evalToNullIfParamIsNull(StatementContext context, int index) throws SQLException { - return index == 0; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/GreaterThanOrEqualParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/GreaterThanOrEqualParseNode.java deleted file mode 100644 index 5fcb4b31..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/GreaterThanOrEqualParseNode.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import org.apache.hadoop.hbase.filter.CompareFilter; -import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; - - -/** - * - * Node representing the greater than or equal to operator (>=) in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class GreaterThanOrEqualParseNode extends ComparisonParseNode { - - GreaterThanOrEqualParseNode(ParseNode lhs, ParseNode rhs) { - super(lhs, rhs); - } - - @Override - public CompareOp getFilterOp() { - return CompareFilter.CompareOp.GREATER_OR_EQUAL; - } - - - @Override - public CompareOp getInvertFilterOp() { - return CompareOp.LESS_OR_EQUAL; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/GreaterThanParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/GreaterThanParseNode.java deleted file mode 100644 index 2ec6848d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/GreaterThanParseNode.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import org.apache.hadoop.hbase.filter.CompareFilter; -import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; - - -/** - * - * Node representing the greater than operator (>) in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class GreaterThanParseNode extends ComparisonParseNode { - - GreaterThanParseNode(ParseNode lhs, ParseNode rhs) { - super(lhs, rhs); - } - - @Override - public CompareOp getFilterOp() { - return CompareFilter.CompareOp.GREATER; - } - - @Override - public CompareOp getInvertFilterOp() { - return CompareOp.LESS; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/InListParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/InListParseNode.java deleted file mode 100644 index 1ba1dbc0..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/InListParseNode.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - - - -/** - * - * Node representing the IN literal list expression in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class InListParseNode extends CompoundParseNode { - private final boolean negate; - - InListParseNode(List children, boolean negate) { - super(children); - // All values in the IN must be constant. First child is the LHS - for (int i = 1; i < children.size(); i++) { - ParseNode child = children.get(i); - if (!child.isStateless()) { - throw new ParseException(new SQLExceptionInfo.Builder(SQLExceptionCode.VALUE_IN_LIST_NOT_CONSTANT) - .build().buildException()); - } - } - this.negate = negate; - } - - public boolean isNegate() { - return negate; - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/InParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/InParseNode.java deleted file mode 100644 index 29b30f5d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/InParseNode.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - -/** - * - * Node representing IN subquery expression in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class InParseNode extends BinaryParseNode { - private final boolean negate; - - InParseNode(ParseNode l, ParseNode r, boolean negate) { - super(l, r); - this.negate = negate; - } - - public boolean isNegate() { - return negate; - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/IndexKeyConstraint.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/IndexKeyConstraint.java deleted file mode 100644 index 804a10f3..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/IndexKeyConstraint.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.List; - -import org.apache.hadoop.hbase.util.Pair; - -import com.google.common.collect.ImmutableList; -import com.salesforce.phoenix.schema.ColumnModifier; - -public class IndexKeyConstraint { - private final List> columnNameToModifier; - - IndexKeyConstraint(List> columnNameAndModifier) { - this.columnNameToModifier = ImmutableList.copyOf(columnNameAndModifier); - } - - public List> getColumns() { - return columnNameToModifier; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/IsNullParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/IsNullParseNode.java deleted file mode 100644 index 84815838..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/IsNullParseNode.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - -/** - * - * Node representing the IS NULL and IS NOT NULL expressions in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class IsNullParseNode extends UnaryParseNode { - private final boolean negate; - - IsNullParseNode(ParseNode expr, boolean negate) { - super(expr); - this.negate = negate; - } - - public boolean isNegate() { - return negate; - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/JoinTableNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/JoinTableNode.java deleted file mode 100644 index 32834ca3..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/JoinTableNode.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; - - - -/** - * - * Node representing the join specified in the FROM clause of SQL - * - * @author jtaylor - * @since 0.1 - */ -public class JoinTableNode extends TableNode { - public enum JoinType {Inner, Left, Right, Full}; - - private final JoinType type; - private final ParseNode on; - private final TableNode table; - - JoinTableNode(JoinType type, ParseNode on, TableNode table) { - super(table.getAlias()); - this.type = type; - this.on = on; - this.table = table; - } - - public JoinType getType() { - return type; - } - - public ParseNode getOnNode() { - return on; - } - - public TableNode getTable() { - return table; - } - - @Override - public void accept(TableNodeVisitor visitor) throws SQLException { - visitor.visit(this); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LessThanOrEqualParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LessThanOrEqualParseNode.java deleted file mode 100644 index 33fa577c..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LessThanOrEqualParseNode.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import org.apache.hadoop.hbase.filter.CompareFilter; -import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; - - -/** - * - * Node representing the less than or equal to operator (<=) in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class LessThanOrEqualParseNode extends ComparisonParseNode { - - LessThanOrEqualParseNode(ParseNode lhs, ParseNode rhs) { - super(lhs, rhs); - } - - @Override - public CompareOp getFilterOp() { - return CompareFilter.CompareOp.LESS_OR_EQUAL; - } - - @Override - public CompareOp getInvertFilterOp() { - return CompareOp.GREATER_OR_EQUAL; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LessThanParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LessThanParseNode.java deleted file mode 100644 index 8e112328..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LessThanParseNode.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import org.apache.hadoop.hbase.filter.CompareFilter; -import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; - - -/** - * - * Node representing the less than operator (<) in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class LessThanParseNode extends ComparisonParseNode { - - LessThanParseNode(ParseNode lhs, ParseNode rhs) { - super(lhs, rhs); - } - - @Override - public CompareOp getFilterOp() { - return CompareFilter.CompareOp.LESS; - } - - @Override - public CompareOp getInvertFilterOp() { - return CompareOp.GREATER; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LikeParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LikeParseNode.java deleted file mode 100644 index 200ec3ba..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LikeParseNode.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - -/** - * - * Node representing LIKE and NOT LIKE in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class LikeParseNode extends BinaryParseNode { - private final boolean negate; - - LikeParseNode(ParseNode lhs, ParseNode rhs, boolean negate) { - super(lhs, rhs); - this.negate = negate; - } - - public boolean isNegate() { - return negate; - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LimitNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LimitNode.java deleted file mode 100644 index 00fa46a7..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LimitNode.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - - -public class LimitNode { - private final BindParseNode bindNode; - private final LiteralParseNode limitNode; - - LimitNode(BindParseNode bindNode) { - this.bindNode = bindNode; - limitNode = null; - } - - LimitNode(LiteralParseNode limitNode) { - this.limitNode = limitNode; - this.bindNode = null; - } - - public ParseNode getLimitParseNode() { - return bindNode == null ? limitNode : bindNode; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LiteralParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LiteralParseNode.java deleted file mode 100644 index aa2648ea..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/LiteralParseNode.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - -import com.salesforce.phoenix.schema.PDataType; - - - -/** - * - * Node representing literal expressions such as 1,2.5,'foo', and NULL in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class LiteralParseNode extends TerminalParseNode { - public static final List STAR = Collections.singletonList(new LiteralParseNode(1)); - public static final ParseNode NULL = new LiteralParseNode(null); - public static final ParseNode ZERO = new LiteralParseNode(0); - public static final ParseNode ONE = new LiteralParseNode(1); - - private final Object value; - private final PDataType type; - - public LiteralParseNode(Object value) { - this.value = value; - this.type = PDataType.fromLiteral(value); - } - - public PDataType getType() { - return type; - } - - public Object getValue() { - return value; - } - - @Override - public boolean isStateless() { - return true; - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - return visitor.visit(this); - } - - public byte[] getBytes() { - return type == null ? null : type.toBytes(value); - } - - @Override - public String toString() { - return type == PDataType.VARCHAR ? ("'" + value.toString() + "'") : value == null ? "null" : value.toString(); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/MaxAggregateParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/MaxAggregateParseNode.java deleted file mode 100644 index 2859f121..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/MaxAggregateParseNode.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.function.FunctionExpression; -import com.salesforce.phoenix.expression.function.MaxAggregateFunction; - - -public class MaxAggregateParseNode extends DelegateConstantToCountParseNode { - - public MaxAggregateParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - @Override - public FunctionExpression create(List children, StatementContext context) throws SQLException { - return new MaxAggregateFunction(children, getDelegateFunction(children,context)); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/MinAggregateParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/MinAggregateParseNode.java deleted file mode 100644 index 5fc13ac1..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/MinAggregateParseNode.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.function.FunctionExpression; -import com.salesforce.phoenix.expression.function.MinAggregateFunction; - - -public class MinAggregateParseNode extends DelegateConstantToCountParseNode { - - public MinAggregateParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - @Override - public FunctionExpression create(List children, StatementContext context) throws SQLException { - return new MinAggregateFunction(children, getDelegateFunction(children,context)); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/MultiplyParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/MultiplyParseNode.java deleted file mode 100644 index 4d17a748..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/MultiplyParseNode.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - -/** - * - * Node representing multiplication in a SQL expression - * - * @author jtaylor - * @since 0.1 - */ -public class MultiplyParseNode extends ArithmeticParseNode { - - MultiplyParseNode(List children) { - super(children); - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NamedParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NamedParseNode.java deleted file mode 100644 index 66b5f02a..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NamedParseNode.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - - -/** - * - * Abstract node representing named nodes such as binds and column expressions in SQL - * - * @author jtaylor - * @since 0.1 - */ -public abstract class NamedParseNode extends TerminalParseNode{ - private final NamedNode namedNode; - - NamedParseNode(NamedParseNode node) { - this.namedNode = node.namedNode; - } - - NamedParseNode(String name) { - this.namedNode = new NamedNode(name); - } - - public String getName() { - return namedNode.getName(); - } - - public boolean isCaseSensitive() { - return namedNode.isCaseSensitive(); - } - - @Override - public String toString() { - return getName(); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NamedTableNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NamedTableNode.java deleted file mode 100644 index b53ed1c0..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NamedTableNode.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the following conditions are met: Redistributions of source code - * must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in - * binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of Salesforce.com nor the names - * of its contributors may be used to endorse or promote products derived from this software without specific prior - * written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * **************************************************************************** - */ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - -import com.google.common.collect.ImmutableList; - -/** - * Node representing an explicit table reference in the FROM clause of SQL - * - * @author jtaylor - * @since 0.1 - */ -public class NamedTableNode extends ConcreteTableNode { - - private final List dynColumns; - - public static NamedTableNode create (String alias, TableName name, List dynColumns) { - return new NamedTableNode(alias, name, dynColumns); - } - - NamedTableNode(String alias, TableName name) { - super(alias, name); - dynColumns = Collections. emptyList(); - } - - NamedTableNode(String alias, TableName name, List dynColumns) { - super(alias, name); - if (dynColumns != null) { - this.dynColumns = ImmutableList.copyOf(dynColumns); - } else { - this.dynColumns = Collections. emptyList(); - } - } - - @Override - public void accept(TableNodeVisitor visitor) throws SQLException { - visitor.visit(this); - } - - public List getDynamicColumns() { - return dynColumns; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NotEqualParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NotEqualParseNode.java deleted file mode 100644 index bb71cf65..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NotEqualParseNode.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; - - - -/** - * - * Node representing a not equal expression (!=,<>) in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class NotEqualParseNode extends ComparisonParseNode { - - NotEqualParseNode(ParseNode lhs, ParseNode rhs) { - super(lhs, rhs); - } - - @Override - public CompareOp getFilterOp() { - return CompareOp.NOT_EQUAL; - } - - @Override - public CompareOp getInvertFilterOp() { - return CompareOp.NOT_EQUAL; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NotParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NotParseNode.java deleted file mode 100644 index f14171c3..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NotParseNode.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - -/** - * - * Node representing the NOT in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class NotParseNode extends UnaryParseNode { - - NotParseNode(ParseNode expr) { - super(expr); - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/OrParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/OrParseNode.java deleted file mode 100644 index 9eab2285..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/OrParseNode.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - -/** - * - * Node representing an OR in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class OrParseNode extends CompoundParseNode { - - OrParseNode(List children) { - super(children); - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/OrderByNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/OrderByNode.java deleted file mode 100644 index 5fea466e..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/OrderByNode.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - - -/** - * - * Node representing an ORDER BY clause (including asc/desc and nulls first/last) in SQL - * - * @author jtaylor - * @since 0.1 - */ -public final class OrderByNode { - private final ParseNode child; - private final boolean nullsLast; - private final boolean orderAscending; - - OrderByNode(ParseNode child, boolean nullsLast, boolean orderAscending) { - this.child = child; - this.nullsLast = nullsLast; - this.orderAscending = orderAscending; - } - - public boolean isNullsLast() { - return nullsLast; - } - - public boolean isAscending() { - return orderAscending; - } - - public ParseNode getNode() { - return child; - } - - @Override - public String toString() { - return child.toString() + (orderAscending ? " asc" : " desc") + " nulls " + (nullsLast ? "last" : "first"); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/OuterJoinParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/OuterJoinParseNode.java deleted file mode 100644 index 7d98d135..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/OuterJoinParseNode.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - -/** - * - * Node representing an outer join qualifier (+) in SQL - * TODO: remove Oracle specific syntax - * - * @author jtaylor - * @since 0.1 - */ -public class OuterJoinParseNode extends UnaryParseNode{ - OuterJoinParseNode(ParseNode node) { - super(node); - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseContext.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseContext.java deleted file mode 100644 index 0c43174d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseContext.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.List; - -import com.google.common.collect.Lists; - -public class ParseContext { - private boolean isAggregate; - - public ParseContext() { - } - - public boolean isAggregate() { - return isAggregate; - } - - public void setAggregate(boolean isAggregate) { - this.isAggregate |= isAggregate; - } - - public static class Stack { - private final List stack = Lists.newArrayListWithExpectedSize(5); - - public void push(ParseContext context) { - stack.add(context); - } - - public ParseContext pop() { - return stack.remove(stack.size()-1); - } - - public ParseContext peek() { - return stack.get(stack.size()-1); - } - - public boolean isEmpty() { - return stack.isEmpty(); - } - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseException.java deleted file mode 100644 index 1d0d64d8..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseException.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -/** - * - * RuntimeException for exceptions occurring during parsing, - * since ANTLR doesn't handle typed exceptions well. - * - * @author jtaylor - * @since 2.0 - */ -public class ParseException extends RuntimeException { - - public ParseException() { - } - - public ParseException(String msg) { - super(msg); - } - - public ParseException(Throwable t) { - super(t); - } - - public ParseException(String msg, Throwable t) { - super(msg, t); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseNode.java deleted file mode 100644 index e9dc2bf9..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseNode.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.List; - - - - -/** - * - * Abstract base class for a parse node in SQL - * - * @author jtaylor - * @since 0.1 - */ -public abstract class ParseNode { - public abstract List getChildren(); - public abstract T accept(ParseNodeVisitor visitor) throws SQLException; - - public boolean isStateless() { - return false; - } - - /** - * Allows node to override what the alias is for a given node. - * Useful for a column reference, as JDBC says that the alias - * name for "a.b" should be "b" - * @return the alias to use for this node or null for no alias - */ - public String getAlias() { - return null; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/PrimaryKeyConstraint.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/PrimaryKeyConstraint.java deleted file mode 100644 index bd1a8063..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/PrimaryKeyConstraint.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - -import org.apache.hadoop.hbase.util.Pair; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Maps; -import com.salesforce.phoenix.schema.ColumnModifier; - -public class PrimaryKeyConstraint extends NamedNode { - public static final PrimaryKeyConstraint EMPTY = new PrimaryKeyConstraint(null, Collections.>emptyList()); - - private final List> columns; - private final HashMap> columnNameToModifier; - - PrimaryKeyConstraint(String name, List> columns) { - super(name); - this.columns = columns == null ? Collections.>emptyList() : ImmutableList.copyOf(columns); - this.columnNameToModifier = Maps.newHashMapWithExpectedSize(this.columns.size()); - for (Pair p : this.columns) { - this.columnNameToModifier.put(p.getFirst(), p); - } - } - - public List> getColumnNames() { - return columns; - } - - public Pair getColumn(ColumnName columnName) { - return columnNameToModifier.get(columnName); - } - - public boolean contains(ColumnName columnName) { - return columnNameToModifier.containsKey(columnName); - } - - @Override - public int hashCode() { - return super.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return super.equals(obj); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/RoundParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/RoundParseNode.java deleted file mode 100644 index df692e2d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/RoundParseNode.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.function.RoundDateExpression; -import com.salesforce.phoenix.expression.function.RoundDecimalExpression; -import com.salesforce.phoenix.expression.function.RoundFunction; -import com.salesforce.phoenix.expression.function.RoundTimestampExpression; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.TypeMismatchException; - -/** - * - * Parse node corresponding to {@link RoundFunction}. - * It also acts as a factory for creating the right kind of - * round expression according to the data type of the - * first child. - * - * @author samarth.jain - * @since 3.0.0 - */ -public class RoundParseNode extends FunctionParseNode { - - RoundParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - @Override - public Expression create(List children, StatementContext context) throws SQLException { - return getRoundExpression(children); - } - - public static Expression getRoundExpression(List children) throws SQLException { - final Expression firstChild = children.get(0); - final PDataType firstChildDataType = firstChild.getDataType(); - - if(firstChildDataType.isCoercibleTo(PDataType.DATE)) { - return RoundDateExpression.create(children); // FIXME: remove cast - } else if (firstChildDataType.isCoercibleTo(PDataType.TIMESTAMP)) { - return RoundTimestampExpression.create(children); // FIXME: remove cast - } else if(firstChildDataType.isCoercibleTo(PDataType.DECIMAL)) { - return new RoundDecimalExpression(children); - } else { - throw TypeMismatchException.newException(firstChildDataType, "1"); - } - } - - /** - * When rounding off decimals, user need not specify the scale. In such cases, - * we need to prevent the function from getting evaluated as null. This is really - * a hack. A better way would have been if {@link com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo} provided a - * way of associating default values for each permissible data type. - * Something like: @ Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValues = {"null", "1"} isConstant=true) - * Till then, this will have to do. - */ - @Override - public boolean evalToNullIfParamIsNull(StatementContext context, int index) throws SQLException { - return index == 0; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/RowValueConstructorParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/RowValueConstructorParseNode.java deleted file mode 100644 index f616466a..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/RowValueConstructorParseNode.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - -/** - * - * Node representing a row value constructor in SQL. - * - * @author samarth.jain - * @since 0.1 - */ -public class RowValueConstructorParseNode extends CompoundParseNode { - - public RowValueConstructorParseNode(List l) { - super(l); - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SingleTableSQLStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SingleTableSQLStatement.java deleted file mode 100644 index 381b16ba..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SingleTableSQLStatement.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -public abstract class SingleTableSQLStatement implements BindableStatement { - private final NamedTableNode table; - private final int bindCount; - - public SingleTableSQLStatement(NamedTableNode table, int bindCount) { - this.table = table; - this.bindCount = bindCount; - } - - public NamedTableNode getTable() { - return table; - } - - @Override - public int getBindCount() { - return bindCount; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/StringConcatParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/StringConcatParseNode.java deleted file mode 100644 index 5308da10..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/StringConcatParseNode.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - - -/** - * - * Node representing || String concatenation in a SQL expression - * - * @author kmahadik - * @since 0.1 - */ -public class StringConcatParseNode extends CompoundParseNode { - - StringConcatParseNode(List children) { - super(children); - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SubqueryParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SubqueryParseNode.java deleted file mode 100644 index 12c14ad0..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SubqueryParseNode.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; - - - -/** - * - * Node representing a subquery in SQL - * - * @author jtaylor - * @since 0.1 - */ -public class SubqueryParseNode extends TerminalParseNode { - private final SelectStatement select; - - SubqueryParseNode(SelectStatement select) { - this.select = select; - } - - public SelectStatement getSelectNode() { - return select; - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - return visitor.visit(this); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SubtractParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SubtractParseNode.java deleted file mode 100644 index 8a66dec9..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SubtractParseNode.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.List; - - - -/** - * - * Node representing subtraction in a SQL expression - * - * @author jtaylor - * @since 0.1 - */ -public class SubtractParseNode extends ArithmeticParseNode { - SubtractParseNode(List children) { - super(children); - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - List l = Collections.emptyList(); - if (visitor.visitEnter(this)) { - l = acceptChildren(visitor); - } - return visitor.visitLeave(this, l); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SumAggregateParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SumAggregateParseNode.java deleted file mode 100644 index d653d22d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SumAggregateParseNode.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.function.FunctionExpression; -import com.salesforce.phoenix.expression.function.SumAggregateFunction; - - -public class SumAggregateParseNode extends DelegateConstantToCountParseNode { - - public SumAggregateParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - @Override - public FunctionExpression create(List children, StatementContext context) throws SQLException { - return new SumAggregateFunction(children, getDelegateFunction(children,context)); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TableName.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TableName.java deleted file mode 100644 index 67c05a95..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TableName.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.util.SchemaUtil; - -public class TableName { - private final String tableName; - private final String schemaName; - - public static TableName createNormalized(String schemaName, String tableName) { - schemaName = schemaName == null ? null : SchemaUtil.normalizeIdentifier(schemaName); - tableName = SchemaUtil.normalizeIdentifier(tableName); - return new TableName(schemaName, tableName); - } - - public static TableName create(String schemaName, String tableName) { - return new TableName(schemaName,tableName); - } - - private TableName(String schemaName, String tableName) { - this.schemaName = schemaName; - this.tableName = tableName; - } - - public String getTableName() { - return tableName; - } - - public String getSchemaName() { - return schemaName; - } - - @Override - public String toString() { - return (schemaName == null ? "" : schemaName + QueryConstants.NAME_SEPARATOR) + tableName; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((schemaName == null) ? 0 : schemaName.hashCode()); - result = prime * result - + ((tableName == null) ? 0 : tableName.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - TableName other = (TableName) obj; - if (schemaName == null) { - if (other.schemaName != null) - return false; - } else if (!schemaName.equals(other.schemaName)) - return false; - if (tableName == null) { - if (other.tableName != null) - return false; - } else if (!tableName.equals(other.tableName)) - return false; - return true; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TableNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TableNode.java deleted file mode 100644 index f38a7e29..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TableNode.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; - - - -/** - * - * Abstract base class for FROM clause data sources - * - * @author jtaylor - * @since 0.1 - */ -public abstract class TableNode { - private final String alias; - - TableNode(String alias) { - this.alias = alias; - } - - public String getAlias() { - return alias; - } - - public abstract void accept(TableNodeVisitor visitor) throws SQLException; -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TableNodeVisitor.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TableNodeVisitor.java deleted file mode 100644 index 5fb616a0..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TableNodeVisitor.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; - - -/** - * - * Visitor for nodes in the FROM clause - * - * @author jtaylor - * @since 0.1 - */ -public interface TableNodeVisitor { - void visit(BindTableNode boundTableNode) throws SQLException; - void visit(JoinTableNode joinNode) throws SQLException; - void visit(NamedTableNode namedTableNode) throws SQLException; - void visit(DerivedTableNode subselectNode) throws SQLException; -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TerminalParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TerminalParseNode.java deleted file mode 100644 index 84faae19..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TerminalParseNode.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.Collections; -import java.util.List; - -/** - * - * Abstract node for expressions that have no children - * - * @author jtaylor - * @since 0.1 - */ -public abstract class TerminalParseNode extends ParseNode { - @Override - public final List getChildren() { - return Collections.emptyList(); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ToCharParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ToCharParseNode.java deleted file mode 100644 index bffb96bc..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ToCharParseNode.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.text.Format; -import java.util.List; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.expression.function.FunctionArgumentType; -import com.salesforce.phoenix.expression.function.FunctionExpression; -import com.salesforce.phoenix.expression.function.ToCharFunction; -import com.salesforce.phoenix.schema.PDataType; - - -public class ToCharParseNode extends FunctionParseNode { - - public ToCharParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - @Override - public FunctionExpression create(List children, StatementContext context) throws SQLException { - PDataType dataType = children.get(0).getDataType(); - String formatString = (String)((LiteralExpression)children.get(1)).getValue(); // either date or number format string - Format formatter; - FunctionArgumentType type; - if (dataType.isCoercibleTo(PDataType.TIMESTAMP)) { - if (formatString == null) { - formatString = context.getDateFormat(); - formatter = context.getDateFormatter(); - } else { - formatter = FunctionArgumentType.TEMPORAL.getFormatter(formatString); - } - type = FunctionArgumentType.TEMPORAL; - } - else if (dataType.isCoercibleTo(PDataType.DECIMAL)) { - if (formatString == null) - formatString = context.getNumberFormat(); - formatter = FunctionArgumentType.NUMERIC.getFormatter(formatString); - type = FunctionArgumentType.NUMERIC; - } - else { - throw new SQLException(dataType + " type is unsupported for TO_CHAR(). Numeric and temporal types are supported."); - } - return new ToCharFunction(children, type, formatString, formatter); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ToDateParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ToDateParseNode.java deleted file mode 100644 index e5040dc6..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ToDateParseNode.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; -import java.text.Format; -import java.util.List; - -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.expression.function.FunctionExpression; -import com.salesforce.phoenix.expression.function.ToDateFunction; -import com.salesforce.phoenix.util.DateUtil; - - -public class ToDateParseNode extends FunctionParseNode { - public ToDateParseNode(String name, List children, BuiltInFunctionInfo info) { - super(name, children, info); - } - - @Override - public FunctionExpression create(List children, StatementContext context) throws SQLException { - Format dateParser; - String dateFormat = (String)((LiteralExpression)children.get(1)).getValue(); - if (dateFormat == null) { - dateFormat = context.getDateFormat(); - dateParser = context.getDateParser(); - } else { - dateParser = DateUtil.getDateParser(dateFormat); - } - return new ToDateFunction(children, dateFormat, dateParser); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/UnaryParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/UnaryParseNode.java deleted file mode 100644 index 124ae4f3..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/UnaryParseNode.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.Collections; - -/** - * - * Abstract node representing an expression that has a single child in SQL - * - * @author jtaylor - * @since 0.1 - */ -public abstract class UnaryParseNode extends CompoundParseNode { - UnaryParseNode(ParseNode expr) { - super(Collections.singletonList(expr)); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/UpsertStatement.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/UpsertStatement.java deleted file mode 100644 index a7479d3d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/UpsertStatement.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.util.Collections; -import java.util.List; - -public class UpsertStatement extends SingleTableSQLStatement { - private final List columns; - private final List values; - private final SelectStatement select; - private final HintNode hint; - - public UpsertStatement(NamedTableNode table, HintNode hint, List columns, List values, SelectStatement select, int bindCount) { - super(table, bindCount); - this.columns = columns == null ? Collections.emptyList() : columns; - this.values = values; - this.select = select; - this.hint = hint == null ? HintNode.EMPTY_HINT_NODE : hint; - } - - public List getColumns() { - return columns; - } - - public List getValues() { - return values; - } - - public SelectStatement getSelect() { - return select; - } - - public HintNode getHint() { - return hint; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/WildcardParseNode.java b/phoenix-core/src/main/java/com/salesforce/phoenix/parse/WildcardParseNode.java deleted file mode 100644 index dc165079..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/WildcardParseNode.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; - -import java.sql.SQLException; - - - -/** - * - * Node representing the selection of all columns (*) in the SELECT clause of SQL - * - * @author jtaylor - * @since 0.1 - */ -public class WildcardParseNode extends TerminalParseNode { - private final boolean isRewrite; - public static final WildcardParseNode INSTANCE = new WildcardParseNode(false); - public static final WildcardParseNode REWRITE_INSTANCE = new WildcardParseNode(true); - - private WildcardParseNode(boolean isRewrite) { - this.isRewrite = isRewrite; - } - - @Override - public T accept(ParseNodeVisitor visitor) throws SQLException { - return visitor.visit(this); - } - - @Override - public String toString() { - return "*"; - } - - public boolean isRewrite() { - return isRewrite; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/BaseQueryServicesImpl.java b/phoenix-core/src/main/java/com/salesforce/phoenix/query/BaseQueryServicesImpl.java deleted file mode 100644 index 2d715af5..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/BaseQueryServicesImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; - -import java.util.concurrent.ExecutorService; - -import com.salesforce.phoenix.job.JobManager; -import com.salesforce.phoenix.memory.GlobalMemoryManager; -import com.salesforce.phoenix.memory.MemoryManager; -import com.salesforce.phoenix.optimize.QueryOptimizer; -import com.salesforce.phoenix.util.ReadOnlyProps; - - - -/** - * - * Base class for QueryService implementors. - * - * @author jtaylor - * @since 0.1 - */ -public abstract class BaseQueryServicesImpl implements QueryServices { - private final ExecutorService executor; - private final MemoryManager memoryManager; - private final ReadOnlyProps props; - private final QueryOptimizer queryOptimizer; - - public BaseQueryServicesImpl(QueryServicesOptions options) { - this.executor = JobManager.createThreadPoolExec( - options.getKeepAliveMs(), - options.getThreadPoolSize(), - options.getQueueSize()); - this.memoryManager = new GlobalMemoryManager( - Runtime.getRuntime().totalMemory() * options.getMaxMemoryPerc() / 100, - options.getMaxMemoryWaitMs()); - this.props = options.getProps(); - this.queryOptimizer = new QueryOptimizer(this); - } - - @Override - public ExecutorService getExecutor() { - return executor; - } - - @Override - public MemoryManager getMemoryManager() { - return memoryManager; - } - - @Override - public final ReadOnlyProps getProps() { - return props; - } - - @Override - public void close() { - } - - @Override - public QueryOptimizer getOptimizer() { - return queryOptimizer; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/ChildQueryServices.java b/phoenix-core/src/main/java/com/salesforce/phoenix/query/ChildQueryServices.java deleted file mode 100644 index 67950bb3..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/ChildQueryServices.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; - -import com.salesforce.phoenix.memory.ChildMemoryManager; -import com.salesforce.phoenix.memory.MemoryManager; - -/** - * - * Child QueryServices that delegates through to global QueryService. - * Used to track memory used by each org to allow a max percentage threshold. - * - * @author jtaylor - * @since 0.1 - */ -public class ChildQueryServices extends DelegateConnectionQueryServices { - private final MemoryManager memoryManager; - private static final int DEFAULT_MAX_ORG_MEMORY_PERC = 30; - - public ChildQueryServices(ConnectionQueryServices services) { - super(services); - int maxOrgMemPerc = getProps().getInt(MAX_TENANT_MEMORY_PERC_ATTRIB, DEFAULT_MAX_ORG_MEMORY_PERC); - this.memoryManager = new ChildMemoryManager(services.getMemoryManager(), maxOrgMemPerc); - } - - @Override - public MemoryManager getMemoryManager() { - return memoryManager; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/ConfigurationFactory.java b/phoenix-core/src/main/java/com/salesforce/phoenix/query/ConfigurationFactory.java deleted file mode 100644 index bd95fadd..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/ConfigurationFactory.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseConfiguration; - -/** - * Creates {@link Configuration} instances that contain HBase/Hadoop settings. - * - * @author aaraujo - * @since 2.0 - */ -public interface ConfigurationFactory { - /** - * @return Configuration containing HBase/Hadoop settings - */ - Configuration getConfiguration(); - - /** - * Default implementation uses {@link org.apache.hadoop.hbase.HBaseConfiguration#create()}. - */ - static class ConfigurationFactoryImpl implements ConfigurationFactory { - @Override - public Configuration getConfiguration() { - return HBaseConfiguration.create(); - } - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/DelegateQueryServices.java b/phoenix-core/src/main/java/com/salesforce/phoenix/query/DelegateQueryServices.java deleted file mode 100644 index 706e90bf..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/DelegateQueryServices.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; - -import java.sql.SQLException; -import java.util.concurrent.ExecutorService; - -import com.salesforce.phoenix.memory.MemoryManager; -import com.salesforce.phoenix.optimize.QueryOptimizer; -import com.salesforce.phoenix.util.ReadOnlyProps; - - - -/** - * - * Class that delegates QueryService calls through to - * a parent QueryService. - * - * @author jtaylor - * @since 0.1 - */ -public class DelegateQueryServices implements QueryServices { - private final QueryServices parent; - - public DelegateQueryServices(QueryServices queryServices) { - parent = queryServices; - } - - protected QueryServices getDelegate() { - return parent; - } - - @Override - public ExecutorService getExecutor() { - return parent.getExecutor(); - } - - @Override - public MemoryManager getMemoryManager() { - return parent.getMemoryManager(); - } - - @Override - public void close() throws SQLException { - parent.close(); - } - - @Override - public ReadOnlyProps getProps() { - return parent.getProps(); - } - - @Override - public QueryOptimizer getOptimizer() { - return parent.getOptimizer(); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/HBaseFactoryProvider.java b/phoenix-core/src/main/java/com/salesforce/phoenix/query/HBaseFactoryProvider.java deleted file mode 100644 index 60e0b052..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/HBaseFactoryProvider.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; - -import com.salesforce.phoenix.util.InstanceResolver; - -/** - * Manages factories that provide extension points for HBase. - *

- * Dependent modules may register their own implementations of the following using {@link java.util.ServiceLoader}: - *

    - *
  • {@link ConfigurationFactory}
  • - *
  • {@link HTableFactory}
  • - *
  • {@link HConnectionFactory}
  • - *
- * - * If a custom implementation is not registered, the default implementations will be used. - * - * @author aaraujo - * @since 0.2 - */ -public class HBaseFactoryProvider { - - private static final HTableFactory DEFAULT_HTABLE_FACTORY = new HTableFactory.HTableFactoryImpl(); - private static final HConnectionFactory DEFAULT_HCONNECTION_FACTORY = - new HConnectionFactory.HConnectionFactoryImpl(); - private static final ConfigurationFactory DEFAULT_CONFIGURATION_FACTORY = new ConfigurationFactory.ConfigurationFactoryImpl(); - - public static HTableFactory getHTableFactory() { - return InstanceResolver.getSingleton(HTableFactory.class, DEFAULT_HTABLE_FACTORY); - } - - public static HConnectionFactory getHConnectionFactory() { - return InstanceResolver.getSingleton(HConnectionFactory.class, DEFAULT_HCONNECTION_FACTORY); - } - - public static ConfigurationFactory getConfigurationFactory() { - return InstanceResolver.getSingleton(ConfigurationFactory.class, DEFAULT_CONFIGURATION_FACTORY); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/HConnectionFactory.java b/phoenix-core/src/main/java/com/salesforce/phoenix/query/HConnectionFactory.java deleted file mode 100644 index 9541a011..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/HConnectionFactory.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.ZooKeeperConnectionException; -import org.apache.hadoop.hbase.client.HConnection; -import org.apache.hadoop.hbase.client.HConnectionManager; - -/** - * Factory for creating {@link HConnection} - * - * @author ukuchibhotla - */ -public interface HConnectionFactory { - - /** - * Creates HConnection to access HBase clusters. - * - * @param configuration object - * @return A HConnection instance - */ - HConnection createConnection(Configuration conf) throws ZooKeeperConnectionException; - - /** - * Default implementation. Uses standard HBase HConnections. - */ - static class HConnectionFactoryImpl implements HConnectionFactory { - @Override - public HConnection createConnection(Configuration conf) throws ZooKeeperConnectionException { - return HConnectionManager.createConnection(conf); - } - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/HTableFactory.java b/phoenix-core/src/main/java/com/salesforce/phoenix/query/HTableFactory.java deleted file mode 100644 index f6089c3d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/HTableFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; - -import java.io.IOException; -import java.util.concurrent.ExecutorService; - -import org.apache.hadoop.hbase.client.HConnection; -import org.apache.hadoop.hbase.client.HTable; -import org.apache.hadoop.hbase.client.HTableInterface; - -/** - * Creates clients to access HBase tables. - * - * @author aaraujo - * @since 0.2 - */ -public interface HTableFactory { - /** - * Creates an HBase client using an externally managed HConnection and Thread pool. - * - * @param tableName Name of the table. - * @param connection HConnection to use. - * @param pool ExecutorService to use. - * @return An client to access an HBase table. - * @throws IOException if a server or network exception occurs - */ - HTableInterface getTable(byte[] tableName, HConnection connection, ExecutorService pool) throws IOException; - - /** - * Default implementation. Uses standard HBase HTables. - */ - static class HTableFactoryImpl implements HTableFactory { - @Override - public HTableInterface getTable(byte[] tableName, HConnection connection, ExecutorService pool) throws IOException { - return new HTable(tableName, connection, pool); - } - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/MetaDataMutated.java b/phoenix-core/src/main/java/com/salesforce/phoenix/query/MetaDataMutated.java deleted file mode 100644 index e5b47581..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/MetaDataMutated.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; - -import java.sql.SQLException; -import java.util.List; - -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PMetaData; -import com.salesforce.phoenix.schema.PTable; - - -/** - * - * Interface for applying schema mutations to our client-side schema cache - * - * @author jtaylor - * @since 0.1 - */ -public interface MetaDataMutated { - PMetaData addTable(PTable table) throws SQLException; - PMetaData removeTable(String tableName) throws SQLException; - PMetaData addColumn(String tableName, List columns, long tableTimeStamp, long tableSeqNum, boolean isImmutableRows) throws SQLException; - PMetaData removeColumn(String tableName, String familyName, String columnName, long tableTimeStamp, long tableSeqNum) throws SQLException; -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/QueryServicesImpl.java b/phoenix-core/src/main/java/com/salesforce/phoenix/query/QueryServicesImpl.java deleted file mode 100644 index 04f5e562..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/QueryServicesImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; - - - - - -/** - * - * Real implementation of QueryServices for use in runtime and perf testing - * - * @author jtaylor - * @since 0.1 - */ -public final class QueryServicesImpl extends BaseQueryServicesImpl { - - public QueryServicesImpl() { - super(QueryServicesOptions.withDefaults()); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/StatsManager.java b/phoenix-core/src/main/java/com/salesforce/phoenix/query/StatsManager.java deleted file mode 100644 index 44f10647..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/StatsManager.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; - -import java.sql.SQLException; - -import com.salesforce.phoenix.schema.TableRef; - - -/** - * - * Interface for managing and caching table statistics. - * The frequency of updating the table statistics are controlled - * by {@link com.salesforce.phoenix.query.QueryServices#STATS_UPDATE_FREQ_MS_ATTRIB}. - * Table stats may also be manually updated through {@link #updateStats(TableRef)}. - * - * - * @author jtaylor - * @since 0.1 - */ -public interface StatsManager { - /** - * Get the minimum key for the given table - * @param table the table - * @return the minimum key or null if unknown - */ - byte[] getMinKey(TableRef table); - - /** - * Get the maximum key for the given table - * @param table the table - * @return the maximum key or null if unknown - */ - byte[] getMaxKey(TableRef table); - - /** - * Manually update the cached table statistics - * @param table the table - * @throws SQLException - */ - void updateStats(TableRef table) throws SQLException; -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/AmbiguousColumnException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/AmbiguousColumnException.java deleted file mode 100644 index 53d08d34..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/AmbiguousColumnException.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.sql.SQLException; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - -/** - * - * Exception thrown when a column name is used without being qualified with an alias - * and more than one table contains that column. - * - * @author jtaylor - * @since 0.1 - */ -public class AmbiguousColumnException extends SQLException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.AMBIGUOUS_COLUMN; - - public AmbiguousColumnException() { - super(new SQLExceptionInfo.Builder(code).build().toString(), code.getSQLState(), code.getErrorCode()); - } - - public AmbiguousColumnException(String columnName) { - super(new SQLExceptionInfo.Builder(code).setColumnName(columnName).build().toString(), - code.getSQLState(), code.getErrorCode()); - } - - public AmbiguousColumnException(String columnName, Throwable cause) { - super(new SQLExceptionInfo.Builder(code).setColumnName(columnName).build().toString(), - code.getSQLState(), code.getErrorCode(), cause); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/AmbiguousTableException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/AmbiguousTableException.java deleted file mode 100644 index 98f1d8d7..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/AmbiguousTableException.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.sql.SQLException; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - -/** - * - * Exception thrown when a table name is used without being qualified with an alias - * and more than one schema contains that table. - * - * @author jtaylor - * @since 0.1 - */ -public class AmbiguousTableException extends SQLException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.AMBIGUOUS_TABLE; - - public AmbiguousTableException() { - super(new SQLExceptionInfo.Builder(code).build().toString(), code.getSQLState(), code.getErrorCode(), null); - } - - public AmbiguousTableException(String tableName) { - super(new SQLExceptionInfo.Builder(code).setTableName(tableName).toString(), - code.getSQLState(), code.getErrorCode(), null); - } - - public AmbiguousTableException(String tableName, Throwable cause) { - super(new SQLExceptionInfo.Builder(code).setTableName(tableName).toString(), - code.getSQLState(), code.getErrorCode(), cause); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ArgumentTypeMismatchException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ArgumentTypeMismatchException.java deleted file mode 100644 index a3b5aaeb..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ArgumentTypeMismatchException.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.sql.SQLException; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - -/** - * Exception thrown when we try to use use an argument that has the wrong type. - * - * @author zhuang - * @since 1.0 - */ -public class ArgumentTypeMismatchException extends SQLException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.TYPE_MISMATCH; - - public ArgumentTypeMismatchException(PDataType expected, PDataType actual, String location) { - super(new SQLExceptionInfo.Builder(code).setMessage("expected: " + expected + " but was: " + actual + " at " + location).build().toString(), code.getSQLState(), code.getErrorCode()); - } - - public ArgumentTypeMismatchException(String expected, String actual, String location) { - super(new SQLExceptionInfo.Builder(code).setMessage("expected: " + expected + " but was: " + actual + " at " + location).build().toString(), code.getSQLState(), code.getErrorCode()); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnAlreadyExistsException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnAlreadyExistsException.java deleted file mode 100644 index 4521f0c7..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnAlreadyExistsException.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.sql.SQLException; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - - -/** - * - * Exception thrown when a column already exists. - * - * @author jtaylor - * @since 0.1 - */ -public class ColumnAlreadyExistsException extends SQLException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.COLUMN_EXIST_IN_DEF; - private final String schemaName; - private final String tableName; - private final String columnName; - - public ColumnAlreadyExistsException(String schemaName, String tableName, String columnName) { - super(new SQLExceptionInfo.Builder(code).setColumnName(columnName) - .setSchemaName(schemaName).setTableName(tableName).build().toString(), - code.getSQLState(), code.getErrorCode(), null); - this.schemaName = schemaName; - this.tableName = tableName; - this.columnName = columnName; - } - - public String getTableName() { - return tableName; - } - - public String getSchemaName() { - return schemaName; - } - - public String getColumnName() { - return columnName; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnFamilyNotFoundException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnFamilyNotFoundException.java deleted file mode 100644 index 9c049e15..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnFamilyNotFoundException.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - -/** - * - * Exception thrown when a family name could not be found in the schema - * - * @author jtaylor - * @since 0.1 - */ -public class ColumnFamilyNotFoundException extends MetaDataEntityNotFoundException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.COLUMN_FAMILY_NOT_FOUND; - private final String familyName; - - public ColumnFamilyNotFoundException(String familyName) { - super(new SQLExceptionInfo.Builder(code).setFamilyName(familyName).build().toString(), - code.getSQLState(), code.getErrorCode(), null); - this.familyName = familyName; - } - - public String getFamilyName() { - return familyName; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnNotFoundException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnNotFoundException.java deleted file mode 100644 index 661bdc9d..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnNotFoundException.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - - -/** - * - * Exception thrown when a column name referenced in a select - * statement cannot be found in any table. - * - * @author jtaylor - * @since 0.1 - */ -public class ColumnNotFoundException extends MetaDataEntityNotFoundException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.COLUMN_NOT_FOUND; - private final String schemaName; - private final String tableName; - private final String columnName; - - public ColumnNotFoundException(String columnName) { - this(null, null, null, columnName); - } - - public ColumnNotFoundException(String schemaName, String tableName, String familyName, String columnName) { - super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName) - .setFamilyName(familyName).setColumnName(columnName).build().toString(), - code.getSQLState(), code.getErrorCode(), null); - this.schemaName = schemaName; - this.tableName = tableName; - this.columnName = columnName; - } - - public String getTableName() { - return tableName; - } - - public String getSchemaName() { - return schemaName; - } - - public String getColumnName() { - return columnName; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ConcurrentTableMutationException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ConcurrentTableMutationException.java deleted file mode 100644 index 511aa5d1..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ConcurrentTableMutationException.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.sql.SQLException; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - - -public class ConcurrentTableMutationException extends SQLException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.CONCURRENT_TABLE_MUTATION; - private final String schemaName; - private final String tableName; - - public ConcurrentTableMutationException(String schemaName, String tableName) { - super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).build().toString(), - code.getSQLState(), code.getErrorCode()); - this.schemaName = schemaName; - this.tableName = tableName; - } - - public String getTableName() { - return tableName; - } - - public String getSchemaName() { - return schemaName; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ConstraintViolationException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ConstraintViolationException.java deleted file mode 100644 index 121ecaa2..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ConstraintViolationException.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -/** - * - * Exception thrown when a schema constraint is violated at the - * time of data insertion. - * - * @author jtaylor - * @since 180 - */ -public class ConstraintViolationException extends RuntimeException { - private static final long serialVersionUID = 1L; - - public ConstraintViolationException() { - } - - public ConstraintViolationException(String message) { - super(message); - } - - public ConstraintViolationException(Throwable cause) { - super(cause); - } - - public ConstraintViolationException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/DelegateColumn.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/DelegateColumn.java deleted file mode 100644 index 5bbec9ac..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/DelegateColumn.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.io.*; - -public class DelegateColumn extends DelegateDatum implements PColumn { - - public DelegateColumn(PColumn delegate) { - super(delegate); - } - - @Override - protected PColumn getDelegate() { - return (PColumn)super.getDelegate(); - } - - @Override - public PName getName() { - return getDelegate().getName(); - } - - @Override - public ColumnModifier getColumnModifier() { - return getDelegate().getColumnModifier(); - } - - @Override - public PName getFamilyName() { - return getDelegate().getFamilyName(); - } - - @Override - public void readFields(DataInput input) throws IOException { - getDelegate().readFields(input); - } - - @Override - public void write(DataOutput output) throws IOException { - getDelegate().write(output); - } - - @Override - public int getPosition() { - return getDelegate().getPosition(); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/DelegateDatum.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/DelegateDatum.java deleted file mode 100644 index d628efbd..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/DelegateDatum.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -public class DelegateDatum implements PDatum { - private final PDatum delegate; - - public DelegateDatum(PDatum delegate) { - this.delegate = delegate; - } - - @Override - public boolean isNullable() { - return delegate.isNullable(); - } - - @Override - public PDataType getDataType() { - return delegate.getDataType(); - } - - @Override - public Integer getByteSize() { - return delegate.getByteSize(); - } - - @Override - public Integer getMaxLength() { - return delegate.getByteSize(); - } - - @Override - public Integer getScale() { - return delegate.getScale(); - } - - @Override - public ColumnModifier getColumnModifier() { - return delegate.getColumnModifier(); - } - - protected PDatum getDelegate() { - return delegate; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ExecuteQueryNotApplicableException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ExecuteQueryNotApplicableException.java deleted file mode 100644 index 0096753a..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ExecuteQueryNotApplicableException.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.sql.SQLException; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - -public class ExecuteQueryNotApplicableException extends SQLException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.EXECUTE_QUERY_NOT_APPLICABLE; - - public ExecuteQueryNotApplicableException(String query) { - super(new SQLExceptionInfo.Builder(code).setMessage("Query: " + query).build().toString(), code.getSQLState(), code.getErrorCode()); - } - - public ExecuteQueryNotApplicableException(String command, String statement) { - super(new SQLExceptionInfo.Builder(code).setMessage("Command: " + command + ". Statement: " + statement).build().toString(), code.getSQLState(), code.getErrorCode()); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ExecuteUpdateNotApplicableException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ExecuteUpdateNotApplicableException.java deleted file mode 100644 index dfcb3efa..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ExecuteUpdateNotApplicableException.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.sql.SQLException; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - -public class ExecuteUpdateNotApplicableException extends SQLException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.EXECUTE_QUERY_NOT_APPLICABLE; - - public ExecuteUpdateNotApplicableException(String query) { - super(new SQLExceptionInfo.Builder(code).setMessage("Query: " + query).build().toString(), code.getSQLState(), code.getErrorCode()); - } - - public ExecuteUpdateNotApplicableException(String command, String statement) { - super(new SQLExceptionInfo.Builder(code).setMessage("Command: " + command + ". Statement: " + statement).build().toString(), code.getSQLState(), code.getErrorCode()); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/IllegalDataException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/IllegalDataException.java deleted file mode 100644 index 8074de72..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/IllegalDataException.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -/** - * - * Exception thrown when an invalid or illegal data value is found - * - * @author jtaylor - * @since 0.1 - */ -public class IllegalDataException extends ConstraintViolationException { - private static final long serialVersionUID = 1L; - - public IllegalDataException() { - } - - public IllegalDataException(String message) { - super(message); - } - - public IllegalDataException(Throwable cause) { - super(cause); - } - - public IllegalDataException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/MetaDataEntityNotFoundException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/MetaDataEntityNotFoundException.java deleted file mode 100644 index fbffc0dc..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/MetaDataEntityNotFoundException.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.sql.SQLException; - -public abstract class MetaDataEntityNotFoundException extends SQLException { - private static final long serialVersionUID = 1L; - - public MetaDataEntityNotFoundException(String reason, String sqlState, int code, Throwable cause) { - super(reason, sqlState, code, cause); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/MetaDataSplitPolicy.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/MetaDataSplitPolicy.java deleted file mode 100644 index 0b459f13..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/MetaDataSplitPolicy.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import org.apache.hadoop.hbase.regionserver.ConstantSizeRegionSplitPolicy; - -import com.salesforce.phoenix.util.SchemaUtil; - - -public class MetaDataSplitPolicy extends ConstantSizeRegionSplitPolicy { - - @Override - protected byte[] getSplitPoint() { - byte[] splitPoint = super.getSplitPoint(); - int offset = SchemaUtil.getVarCharLength(splitPoint, 0, splitPoint.length); - // Split only on Phoenix schema name, so this is ok b/c we won't be splitting - // in the middle of a Phoenix table. - if (offset == splitPoint.length) { - return splitPoint; - } -// offset = SchemaUtil.getVarCharLength(splitPoint, offset+1, splitPoint.length-offset-1); -// // Split only on Phoenix schema and table name, so this is ok b/c we won't be splitting -// // in the middle of a Phoenix table. -// if (offset == splitPoint.length) { -// return splitPoint; -// } - // Otherwise, an attempt is being made to split in the middle of a table. - // Just return a split point at the schema boundary instead - byte[] newSplitPoint = new byte[offset + 1]; - System.arraycopy(splitPoint, 0, newSplitPoint, 0, offset+1); - return newSplitPoint; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/NewerTableAlreadyExistsException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/NewerTableAlreadyExistsException.java deleted file mode 100644 index 545345d9..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/NewerTableAlreadyExistsException.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -public class NewerTableAlreadyExistsException extends TableAlreadyExistsException { - private static final long serialVersionUID = 1L; - - public NewerTableAlreadyExistsException(String schemaName, String tableName) { - super(schemaName, tableName); - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PBaseColumn.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PBaseColumn.java deleted file mode 100644 index 119a5220..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PBaseColumn.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - - -/** - * - * Base class for PColumn implementors that provides - * some reasonable default implementations. - * - * @author jtaylor - * @since 0.1 - */ -public abstract class PBaseColumn implements PColumn { - - @Override - public final Integer getByteSize() { - return getDataType().getByteSize(); - } - - @Override - public final Integer getMaxLength() { - return null; - } - - @Override - public final Integer getScale() { - return null; - } - - @Override - public boolean isNullable() { - return false; - } - } diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumn.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumn.java deleted file mode 100644 index ad8bd934..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumn.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import org.apache.hadoop.io.Writable; - -/** - * Definition of a Phoenix column - * - * @author wmacklem,jtaylor - * @since 0.1 - */ -public interface PColumn extends PDatum, Writable { - - /** - * @return the name of the column qualifier - */ - PName getName(); - - /** - * @return the name of the column family - */ - PName getFamilyName(); - - /** - * @return the zero-based ordinal position of the column - */ - int getPosition(); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumnFamily.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumnFamily.java deleted file mode 100644 index 1ef61174..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumnFamily.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.util.Collection; - -/** - * - * Definition of a Phoenix Column Family - * - * @author jtaylor - * @since 0.1 - */ -public interface PColumnFamily { - - /** - * @return The column family name. - */ - PName getName(); - - /** - * @return All the PColumns in this column family. - */ - Collection getColumns(); - - /** - * @return The PColumn for the specified column qualifier. - * @throws ColumnNotFoundException if the column cannot be found - */ - PColumn getColumn(byte[] qualifier) throws ColumnNotFoundException; - - /** - * @return The PColumn for the specified column qualifier. - * @throws ColumnNotFoundException if the column cannot be found - */ - PColumn getColumn(String name) throws ColumnNotFoundException; -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PDateColumn.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PDateColumn.java deleted file mode 100644 index ba9c314b..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PDateColumn.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -abstract public class PDateColumn extends PBaseColumn { - @Override - public PDataType getDataType() { - return PDataType.DATE; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PDatum.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PDatum.java deleted file mode 100644 index bd9131b3..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PDatum.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - - -public interface PDatum { - /** - * @return is this column nullable? - */ - boolean isNullable(); - - /** - * @return data type of the column - */ - PDataType getDataType(); - - /** - * @return maximum byte length of the column - */ - Integer getByteSize(); - - /** - * @return the actual length of the column. For decimal, it would be its precision. For char or - * varchar, it would be the maximum length as specified during schema definition. - */ - Integer getMaxLength(); - - /** - * @return scale of a decimal number. - */ - Integer getScale(); - - /** - * @return The modifier for this column or null if it doesn't have a modifier - */ - ColumnModifier getColumnModifier(); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PIntegerColumn.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PIntegerColumn.java deleted file mode 100644 index eb8fdc81..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PIntegerColumn.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - - -/** - * - * Base class for PColumn implementors of type Integer. - * - * @author jtaylor - * @since 0.1 - */ -public abstract class PIntegerColumn extends PBaseColumn { - @Override - public final PDataType getDataType() { - return PDataType.INTEGER; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PLongColumn.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PLongColumn.java deleted file mode 100644 index 62a3a7da..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PLongColumn.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - - -/** - * - * Base class for PColumn implementors of type Long. - * - * @author jtaylor - * @since 0.1 - */ -public abstract class PLongColumn extends PBaseColumn { - @Override - public final PDataType getDataType() { - return PDataType.LONG; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PMetaData.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PMetaData.java deleted file mode 100644 index f47dccc0..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PMetaData.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.util.Map; - -import com.salesforce.phoenix.query.MetaDataMutated; - - -public interface PMetaData extends MetaDataMutated { - public PTable getTable(String name) throws TableNotFoundException; - public Map getTables(); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PName.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PName.java deleted file mode 100644 index a0876a18..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PName.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.util.ByteUtil; - - -/** - * - * Interface to encapsulate both the client-side name - * together with the server-side name for a named object - * - * @author jtaylor - * @since 0.1 - */ -public interface PName { - public static PName EMPTY_NAME = new PName() { - @Override - public String getString() { - return ""; - } - - @Override - public byte[] getBytes() { - return ByteUtil.EMPTY_BYTE_ARRAY; - } - - @Override - public String toString() { - return getString(); - } - - @Override - public ImmutableBytesPtr getBytesPtr() { - return ByteUtil.EMPTY_BYTE_ARRAY_PTR; - } - }; - public static PName EMPTY_COLUMN_NAME = new PName() { - @Override - public String getString() { - return QueryConstants.EMPTY_COLUMN_NAME; - } - - @Override - public byte[] getBytes() { - return QueryConstants.EMPTY_COLUMN_BYTES; - } - - @Override - public String toString() { - return getString(); - } - - @Override - public ImmutableBytesPtr getBytesPtr() { - return QueryConstants.EMPTY_COLUMN_BYTES_PTR; - } - }; - /** - * Get the client-side, normalized name as referenced - * in a SQL statement. - * @return the normalized string name - */ - String getString(); - - /** - * Get the server-side name as referenced in HBase-related - * APIs such as Scan, Filter, etc. - * @return the name as a byte array - */ - byte[] getBytes(); - - /** - * @return a pointer to the underlying bytes - */ - ImmutableBytesPtr getBytesPtr(); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PNormalizedName.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PNormalizedName.java deleted file mode 100644 index 08686b8c..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PNormalizedName.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import org.apache.http.annotation.Immutable; - -import com.salesforce.phoenix.util.SchemaUtil; - - -@Immutable -public class PNormalizedName extends PNameImpl { - - public PNormalizedName(String nonNormalizedName) { - super(SchemaUtil.normalizeIdentifier(nonNormalizedName)); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + getString().hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - PNormalizedName other = (PNormalizedName)obj; - // Compare normalized stringName for equality, since bytesName - // may differ since it remains case sensitive. - if (!getString().equals(other.getString())) return false; - return true; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PRow.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PRow.java deleted file mode 100644 index 9e2a05ab..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PRow.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.util.List; -import java.util.Map; - -import org.apache.hadoop.hbase.client.Mutation; - -import com.google.common.collect.ImmutableMap; - -/** - * - * Provide a client API for updating rows. The updates are processed in - * the calling order. Calling setValue after calling delete will cause the - * delete to be canceled. Conversely, calling delete after calling - * setValue will cause all prior setValue calls to be canceled. - * - * @author jtaylor - * @since 0.1 - */ -public interface PRow { - Map DELETE_MARKER = ImmutableMap.of(); - - /** - * Get the list of {@link org.apache.hadoop.hbase.client.Mutation} used to - * update an HTable after all mutations through calls to - * {@link #setValue(PColumn, Object)} or {@link #delete()}. - * @return the list of mutations representing all changes made to a row - * @throws ConstraintViolationException if row data violates schema - * constraint - */ - public List toRowMutations(); - - /** - * Set a column value in the row - * @param col the column for which the value is being set - * @param value the value - * @throws ConstraintViolationException if row data violates schema - * constraint - */ - public void setValue(PColumn col, Object value); - - /** - * Set a column value in the row - * @param col the column for which the value is being set - * @param value the value - * @throws ConstraintViolationException if row data violates schema - * constraint - */ - public void setValue(PColumn col, byte[] value); - - /** - * Delete the row. Note that a delete take precedence over any - * values that may have been set before or after the delete call. - */ - public void delete(); -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PStringColumn.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PStringColumn.java deleted file mode 100644 index c41bc850..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PStringColumn.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -/** - * - * Abstract class for columns of type {@link com.salesforce.phoenix.schema.PDataType#VARCHAR} - * - * @author jtaylor - * @since 0.1 - */ -public abstract class PStringColumn extends PBaseColumn { - - @Override - public PDataType getDataType() { - return PDataType.VARCHAR; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ReadOnlyTableException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ReadOnlyTableException.java deleted file mode 100644 index 7ed6e3b7..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ReadOnlyTableException.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.sql.SQLException; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - -/** - * - * Exception thrown when an attempt is made to modify or write to a read-only table. - * - * @author jtaylor - * @since 0.1 - */ -public class ReadOnlyTableException extends SQLException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.READ_ONLY_TABLE; - - public ReadOnlyTableException(String schemaName, String tableName) { - super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).toString(), - code.getSQLState(), code.getErrorCode()); - } - - public ReadOnlyTableException(String message, String schemaName, String tableName) { - super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).setMessage(message).toString(), - code.getSQLState(), code.getErrorCode()); - } - - public ReadOnlyTableException(String message, String schemaName, String tableName, Throwable cause) { - super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).setRootCause(cause).setMessage(message).toString(), - code.getSQLState(), code.getErrorCode(), cause); - } - - public ReadOnlyTableException(String message, String schemaName, String tableName, String familyName) { - super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).setFamilyName(familyName).setMessage(message).toString(), - code.getSQLState(), code.getErrorCode()); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/SequenceAlreadyExistsException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/SequenceAlreadyExistsException.java deleted file mode 100644 index 4612c4da..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/SequenceAlreadyExistsException.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.sql.SQLException; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - - -public class SequenceAlreadyExistsException extends SQLException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.SEQUENCE_ALREADY_EXIST; - private final String schemaName; - private final String sequenceName; - - - public SequenceAlreadyExistsException(String schemaName, String sequenceName) { - super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(sequenceName).build().toString(), - code.getSQLState(), code.getErrorCode()); - this.schemaName = schemaName; - this.sequenceName = sequenceName; - } - - public String getSequenceName() { - return sequenceName; - } - - public String getSchemaName() { - return schemaName; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/SequenceNotFoundException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/SequenceNotFoundException.java deleted file mode 100644 index 56f11fc5..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/SequenceNotFoundException.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - - -public class SequenceNotFoundException extends MetaDataEntityNotFoundException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.SEQUENCE_UNDEFINED; - private final String schemaName; - private final String tableName; - - public SequenceNotFoundException(String tableName) { - this(null, tableName); - } - - public SequenceNotFoundException(String schemaName, String tableName) { - super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).build().toString(), - code.getSQLState(), code.getErrorCode(), null); - this.tableName = tableName; - this.schemaName = schemaName; - } - - public String getTableName() { - return tableName; - } - - public String getSchemaName() { - return schemaName; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/TableAlreadyExistsException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/TableAlreadyExistsException.java deleted file mode 100644 index 7bcbe477..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/TableAlreadyExistsException.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.sql.SQLException; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - - -/** - * - * Exception thrown when a table name could not be found in the schema - * - * @author jtaylor - * @since 0.1 - */ -public class TableAlreadyExistsException extends SQLException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.TABLE_ALREADY_EXIST; - private final String schemaName; - private final String tableName; - - public TableAlreadyExistsException(String schemaName, String tableName) { - super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).build().toString(), - code.getSQLState(), code.getErrorCode()); - this.schemaName = schemaName; - this.tableName = tableName; - } - - public String getTableName() { - return tableName; - } - - public String getSchemaName() { - return schemaName; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/TableNotFoundException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/TableNotFoundException.java deleted file mode 100644 index ae604d7a..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/TableNotFoundException.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import org.apache.hadoop.hbase.HConstants; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - - -/** - * - * Exception thrown when a table name could not be found in the schema - * - * @author jtaylor - * @since 0.1 - */ -public class TableNotFoundException extends MetaDataEntityNotFoundException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.TABLE_UNDEFINED; - private final String schemaName; - private final String tableName; - private final long timestamp; - - public TableNotFoundException(TableNotFoundException e, long timestamp) { - this(e.schemaName,e.tableName, timestamp); - } - - public TableNotFoundException(String tableName) { - this(null, tableName); - } - - public TableNotFoundException(String schemaName, String tableName) { - this(schemaName, tableName, HConstants.LATEST_TIMESTAMP); - } - - public TableNotFoundException(String schemaName, String tableName, long timestamp) { - super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).build().toString(), - code.getSQLState(), code.getErrorCode(), null); - this.tableName = tableName; - this.schemaName = schemaName; - this.timestamp = timestamp; - } - - public String getTableName() { - return tableName; - } - - public String getSchemaName() { - return schemaName; - } - - public long getTimeStamp() { - return timestamp; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/TableRef.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/TableRef.java deleted file mode 100644 index b91c4a19..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/TableRef.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import org.apache.hadoop.hbase.HConstants; - - - -public final class TableRef { - private final PTable table; - private final String alias; - private final long timeStamp; - private final boolean hasDynamicCols; - - public TableRef(TableRef tableRef, long timeStamp) { - this(tableRef.alias, tableRef.table, timeStamp, tableRef.hasDynamicCols); - } - - public TableRef(PTable table) { - this(null, table, HConstants.LATEST_TIMESTAMP, false); - } - - public TableRef(String alias, PTable table, long timeStamp, boolean hasDynamicCols) { - this.alias = alias; - this.table = table; - this.timeStamp = timeStamp; - this.hasDynamicCols = hasDynamicCols; - } - - public PTable getTable() { - return table; - } - - public String getTableAlias() { - return alias; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = alias == null ? 0 : alias.hashCode(); - result = prime * result + this.table.getName().getString().hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - TableRef other = (TableRef)obj; - if ((alias == null && other.alias != null) || (alias != null && !alias.equals(other.alias))) return false; - if (!table.getName().getString().equals(other.table.getName().getString())) return false; - return true; - } - - public long getTimeStamp() { - return timeStamp; - } - - public boolean hasDynamicCols() { - return hasDynamicCols; - } - -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/TypeMismatchException.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/TypeMismatchException.java deleted file mode 100644 index 019776cd..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/TypeMismatchException.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.sql.SQLException; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - -/** - * Exception thrown when we try to convert one type into a different incompatible type. - * - * @author zhuang - * @since 1.0 - */ -public class TypeMismatchException extends SQLException { - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.TYPE_MISMATCH; - - public TypeMismatchException(String msg) { - super(new SQLExceptionInfo.Builder(code).setMessage(msg).build().toString(), code.getSQLState(), code.getErrorCode()); - } - - public static TypeMismatchException newException(PDataType lhs) { - return new TypeMismatchException(getMessage(lhs,null,null)); - } - - public static TypeMismatchException newException(PDataType lhs, String location) { - return new TypeMismatchException(getMessage(lhs,null,location)); - } - - public static TypeMismatchException newException(PDataType lhs, PDataType rhs) { - return new TypeMismatchException(getMessage(lhs,rhs,null)); - } - - public static TypeMismatchException newException(PDataType lhs, PDataType rhs, String location) { - return new TypeMismatchException(getMessage(lhs,rhs,location)); - } - - public static String getMessage(PDataType lhs, PDataType rhs, String location) { - return lhs + (rhs == null ? "" : " and " + rhs) + (location == null ? "" : " for " + location); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ValueRangeExcpetion.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ValueRangeExcpetion.java deleted file mode 100644 index 85a3c713..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ValueRangeExcpetion.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import java.sql.SQLException; - -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; - -/** - * Exception thrown when we try to use use an argument that has the wrong type. - * - * @author anoopsjohn - * @since 1.1.2 - */ -public class ValueRangeExcpetion extends SQLException{ - private static final long serialVersionUID = 1L; - private static SQLExceptionCode code = SQLExceptionCode.VALUE_OUTSIDE_RANGE; - - public ValueRangeExcpetion(Object minValue, Object maxValue, Object actualValue, String location){ - super(new SQLExceptionInfo.Builder(code).setMessage("expected: [" + minValue + " , " + maxValue + "] but was: " + actualValue + " at " + location).build().toString(), code.getSQLState(), code.getErrorCode()); - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/stat/PTableStats.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/stat/PTableStats.java deleted file mode 100644 index 80519d18..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/stat/PTableStats.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema.stat; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.hadoop.hbase.HRegionInfo; - - -/** - * Interface for Phoenix table statistics. Statistics is collected on the server - * side and can be used for various purpose like splitting region for scanning, etc. - * - * The table is defined on the client side, but it is populated on the server side. The client - * should not populate any data to the statistics object. - */ -public interface PTableStats { - - /** - * Given the region info, returns an array of bytes that is the current estimate of key - * distribution inside that region. The keys should split that region into equal chunks. - * - * @param region - * @return array of keys - */ - byte[][] getRegionGuidePosts(HRegionInfo region); - - void write(DataOutput output) throws IOException; -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/stat/PTableStatsImpl.java b/phoenix-core/src/main/java/com/salesforce/phoenix/schema/stat/PTableStatsImpl.java deleted file mode 100644 index 637c1cb9..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/stat/PTableStatsImpl.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema.stat; - -import java.io.DataOutput; -import java.io.IOException; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.hadoop.hbase.HRegionInfo; -import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.io.WritableUtils; - -import com.google.common.collect.ImmutableMap; - - -/** - * Implementation for PTableStats. - */ -public class PTableStatsImpl implements PTableStats { - - // The map for guide posts should be immutable. We only take the current snapshot from outside - // method call and store it. - private Map regionGuidePosts; - - public PTableStatsImpl() { } - - public PTableStatsImpl(Map stats) { - regionGuidePosts = ImmutableMap.copyOf(stats); - } - - @Override - public byte[][] getRegionGuidePosts(HRegionInfo region) { - return regionGuidePosts.get(region.getRegionNameAsString()); - } - - @Override - public void write(DataOutput output) throws IOException { - if (regionGuidePosts == null) { - WritableUtils.writeVInt(output, 0); - return; - } - WritableUtils.writeVInt(output, regionGuidePosts.size()); - for (Entry entry : regionGuidePosts.entrySet()) { - WritableUtils.writeString(output, entry.getKey()); - byte[][] value = entry.getValue(); - WritableUtils.writeVInt(output, value.length); - for (int i=0; i values; - - public MultiKeyValueTuple(List values) { - setKeyValues(values); - } - - public MultiKeyValueTuple() { - } - - public void setKeyValues(List values) { - this.values = ImmutableList.copyOf(values); - } - - @Override - public void getKey(ImmutableBytesWritable ptr) { - KeyValue value = values.get(0); - ptr.set(value.getBuffer(), value.getRowOffset(), value.getRowLength()); - } - - @Override - public boolean isImmutable() { - return true; - } - - @Override - public KeyValue getValue(byte[] family, byte[] qualifier) { - return KeyValueUtil.getColumnLatest(values, family, qualifier); - } - - @Override - public String toString() { - return values.toString(); - } - - @Override - public int size() { - return values.size(); - } - - @Override - public KeyValue getValue(int index) { - return values.get(index); - } - - @Override - public boolean getValue(byte[] family, byte[] qualifier, - ImmutableBytesWritable ptr) { - KeyValue kv = getValue(family, qualifier); - if (kv == null) - return false; - ptr.set(kv.getBuffer(), kv.getValueOffset(), kv.getValueLength()); - return true; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/BigDecimalUtil.java b/phoenix-core/src/main/java/com/salesforce/phoenix/util/BigDecimalUtil.java deleted file mode 100644 index 80e09409..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/BigDecimalUtil.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; - -import org.apache.hadoop.hbase.util.Pair; - -/** - * - * @author anoopsjohn - * @since 1.2.1 - */ -public class BigDecimalUtil { - - /** - * Calculates the precision and scale for BigDecimal arithmetic operation results. It uses the algorithm mentioned - * here - * @param lp precision of the left operand - * @param ls scale of the left operand - * @param rp precision of the right operand - * @param rs scale of the right operand - * @param op The operation type - * @return {@link Pair} comprising of the precision and scale. - */ - public static Pair getResultPrecisionScale(int lp, int ls, int rp, int rs, Operation op) { - int resultPrec = 0, resultScale = 0; - switch (op) { - case MULTIPLY: - resultPrec = lp + rp; - resultScale = ls + rs; - break; - case DIVIDE: - resultPrec = lp - ls + rp + Math.max(ls + rp - rs + 1, 4); - resultScale = 31 - lp + ls - rs; - break; - case ADD: - resultPrec = 2 * (lp - ls) + ls; // Is this correct? The page says addition -> 2 * (p - s) + s. - resultScale = Math.max(ls, rs); - break; - case AVG: - resultPrec = Math.max(lp - ls, rp - rs) + 1 + Math.max(ls, rs); - resultScale = Math.max(Math.max(ls, rs), 4); - break; - case OTHERS: - resultPrec = Math.max(lp - ls, rp - rs) + 1 + Math.max(ls, rs); - resultScale = Math.max(ls, rs); - } - return new Pair(resultPrec, resultScale); - } - - public static enum Operation { - MULTIPLY, DIVIDE, ADD, AVG, OTHERS; - } -} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/NumberUtil.java b/phoenix-core/src/main/java/com/salesforce/phoenix/util/NumberUtil.java deleted file mode 100644 index 25823a33..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/NumberUtil.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; - -import java.math.BigDecimal; - -import com.salesforce.phoenix.schema.PDataType; - -/** - * Utility methods for numbers like decimal, long, etc. - * - * @author elevine - * @since 0.1 - */ -public class NumberUtil { - - public static final String DEFAULT_NUMBER_FORMAT = "#,##0.###"; - - /** - * Strip all trailing zeros to ensure that no digit will be zero and - * round using our default context to ensure precision doesn't exceed max allowed. - * @return new {@link BigDecimal} instance - */ - public static BigDecimal normalize(BigDecimal bigDecimal) { - return bigDecimal.stripTrailingZeros().round(PDataType.DEFAULT_MATH_CONTEXT); - } - - public static BigDecimal setDecimalWidthAndScale(BigDecimal decimal, int precision, int scale) { - // If we could not fit all the digits before decimal point into the new desired precision and - // scale, return null and the caller method should handle the error. - if (((precision - scale) < (decimal.precision() - decimal.scale()))){ - return null; - } - decimal = decimal.setScale(scale, BigDecimal.ROUND_DOWN); - return decimal; - } -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/SQLCloseable.java b/phoenix-core/src/main/java/com/salesforce/phoenix/util/SQLCloseable.java deleted file mode 100644 index e2350119..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/SQLCloseable.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; - -import java.sql.SQLException; - -/** - * - * Interface for a SQL resource that should be closed - * after it is no longer in use. - * - * @author jtaylor - * @since 0.1 - */ -public interface SQLCloseable { - void close() throws SQLException; -} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/TrustedByteArrayOutputStream.java b/phoenix-core/src/main/java/com/salesforce/phoenix/util/TrustedByteArrayOutputStream.java deleted file mode 100644 index 94ff0228..00000000 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/TrustedByteArrayOutputStream.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -/** - * - * Derived version of {@link java.io.ByteArrayOutputStream} that provides access - * to underlying byte array buffer so that it doesn't have to be copied - * - * @author jtaylor - * @since 0.1 - */ -public class TrustedByteArrayOutputStream extends ByteArrayOutputStream { - public TrustedByteArrayOutputStream(int initialSize) { - super(initialSize); - } - public byte[] getBuffer() { - return buf; - } - @Override - public byte[] toByteArray() { - if (buf.length == size()) { - return buf; - } - return super.toByteArray(); - } - @Override - public void write(byte[] b) { - try { - super.write(b); - } catch (IOException e) { - throw new RuntimeException(e); // Impossible - } - } -} - diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/CapturingAbortable.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/CapturingAbortable.java new file mode 100644 index 00000000..5de5428d --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/CapturingAbortable.java @@ -0,0 +1,68 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index; + +import org.apache.hadoop.hbase.Abortable; + +/** + * {@link Abortable} that can rethrow the cause of the abort. + */ +public class CapturingAbortable implements Abortable { + + private Abortable delegate; + private Throwable cause; + private String why; + + public CapturingAbortable(Abortable delegate) { + this.delegate = delegate; + } + + @Override + public void abort(String why, Throwable e) { + if (delegate.isAborted()) { + return; + } + this.why = why; + this.cause = e; + delegate.abort(why, e); + + } + + @Override + public boolean isAborted() { + return delegate.isAborted(); + } + + /** + * Throw the cause of the abort, if this was aborted. If there was an exception causing + * the abort, re-throws that. Otherwise, just throws a generic {@link Exception} with the reason + * why the abort was caused. + * @throws Throwable the cause of the abort. + */ + public void throwCauseIfAborted() throws Throwable { + if (!this.isAborted()) { + return; + } + if (cause == null) { + throw new Exception(why); + } + throw cause; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/IndexLogRollSynchronizer.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/IndexLogRollSynchronizer.java similarity index 65% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/IndexLogRollSynchronizer.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/IndexLogRollSynchronizer.java index ae27cfa6..96e94cae 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/IndexLogRollSynchronizer.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/IndexLogRollSynchronizer.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index; import java.io.IOException; import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock; diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/Indexer.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/Indexer.java similarity index 90% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/Indexer.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/Indexer.java index f68d9ed9..ce7ef87e 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/Indexer.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/Indexer.java @@ -1,33 +1,25 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index; - -import static com.salesforce.hbase.index.util.IndexManagementUtil.rethrowIndexingException; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index; + +import static org.apache.hadoop.hbase.index.util.IndexManagementUtil.rethrowIndexingException; import java.io.DataInput; import java.io.DataOutput; @@ -68,19 +60,19 @@ import org.apache.hadoop.hbase.util.Pair; import com.google.common.collect.Multimap; -import com.salesforce.hbase.index.builder.IndexBuildManager; -import com.salesforce.hbase.index.builder.IndexBuilder; -import com.salesforce.hbase.index.builder.IndexBuildingFailureException; -import com.salesforce.hbase.index.table.HTableInterfaceReference; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.hbase.index.util.IndexManagementUtil; -import com.salesforce.hbase.index.wal.IndexedKeyValue; -import com.salesforce.hbase.index.write.IndexFailurePolicy; -import com.salesforce.hbase.index.write.IndexWriter; -import com.salesforce.hbase.index.write.recovery.PerRegionIndexWriteCache; -import com.salesforce.hbase.index.write.recovery.StoreFailuresInCachePolicy; -import com.salesforce.hbase.index.write.recovery.TrackingParallelWriterIndexCommitter; -import com.salesforce.phoenix.util.MetaDataUtil; +import org.apache.hadoop.hbase.index.builder.IndexBuildManager; +import org.apache.hadoop.hbase.index.builder.IndexBuilder; +import org.apache.hadoop.hbase.index.builder.IndexBuildingFailureException; +import org.apache.hadoop.hbase.index.table.HTableInterfaceReference; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.util.IndexManagementUtil; +import org.apache.hadoop.hbase.index.wal.IndexedKeyValue; +import org.apache.hadoop.hbase.index.write.IndexFailurePolicy; +import org.apache.hadoop.hbase.index.write.IndexWriter; +import org.apache.hadoop.hbase.index.write.recovery.PerRegionIndexWriteCache; +import org.apache.hadoop.hbase.index.write.recovery.StoreFailuresInCachePolicy; +import org.apache.hadoop.hbase.index.write.recovery.TrackingParallelWriterIndexCommitter; +import org.apache.phoenix.util.MetaDataUtil; /** * Do all the work of managing index updates from a single coprocessor. All Puts/Delets are passed @@ -122,7 +114,7 @@ public class Indexer extends BaseRegionObserver { */ public static final String CHECK_VERSION_CONF_KEY = "com.saleforce.hbase.index.checkversion"; - private static final String INDEX_RECOVERY_FAILURE_POLICY_KEY = "com.salesforce.hbase.index.recovery.failurepolicy"; + private static final String INDEX_RECOVERY_FAILURE_POLICY_KEY = "org.apache.hadoop.hbase.index.recovery.failurepolicy"; /** * Marker {@link KeyValue} to indicate that we are doing a batch operation. Needed because the diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/ValueGetter.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/ValueGetter.java new file mode 100644 index 00000000..54c4fbcd --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/ValueGetter.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index; + +import java.io.IOException; + +import org.apache.hadoop.hbase.index.covered.update.ColumnReference; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; + +public interface ValueGetter { + + /** + * Get the most recent (largest timestamp) for the given column reference + * @param ref to match against an underlying key value. Uses the passed object to match the + * keyValue via {@link ColumnReference#matches} + * @return the stored value for the given {@link ColumnReference}, or null if no value is + * present. + * @throws IOException if there is an error accessing the underlying data storage + */ + public ImmutableBytesPtr getLatestValue(ColumnReference ref) throws IOException; +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/builder/BaseIndexBuilder.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/builder/BaseIndexBuilder.java similarity index 55% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/builder/BaseIndexBuilder.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/builder/BaseIndexBuilder.java index 968ae780..73b74216 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/builder/BaseIndexBuilder.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/builder/BaseIndexBuilder.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.builder; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.builder; import java.io.IOException; @@ -36,7 +28,7 @@ import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress; import org.apache.hadoop.hbase.util.Pair; -import com.salesforce.hbase.index.covered.CoveredColumnsIndexBuilder; +import org.apache.hadoop.hbase.index.covered.CoveredColumnsIndexBuilder; /** * Basic implementation of the {@link IndexBuilder} that doesn't do any actual work of indexing. diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/builder/IndexBuildManager.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/builder/IndexBuildManager.java similarity index 77% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/builder/IndexBuildManager.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/builder/IndexBuildManager.java index 62f12e45..0752446d 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/builder/IndexBuildManager.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/builder/IndexBuildManager.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.builder; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.builder; import java.io.IOException; import java.util.ArrayList; @@ -45,12 +37,12 @@ import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress; import org.apache.hadoop.hbase.util.Pair; -import com.salesforce.hbase.index.Indexer; -import com.salesforce.hbase.index.parallel.QuickFailingTaskRunner; -import com.salesforce.hbase.index.parallel.Task; -import com.salesforce.hbase.index.parallel.TaskBatch; -import com.salesforce.hbase.index.parallel.ThreadPoolBuilder; -import com.salesforce.hbase.index.parallel.ThreadPoolManager; +import org.apache.hadoop.hbase.index.Indexer; +import org.apache.hadoop.hbase.index.parallel.QuickFailingTaskRunner; +import org.apache.hadoop.hbase.index.parallel.Task; +import org.apache.hadoop.hbase.index.parallel.TaskBatch; +import org.apache.hadoop.hbase.index.parallel.ThreadPoolBuilder; +import org.apache.hadoop.hbase.index.parallel.ThreadPoolManager; /** * Manage the building of index updates from primary table updates. diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/builder/IndexBuilder.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/builder/IndexBuilder.java similarity index 76% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/builder/IndexBuilder.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/builder/IndexBuilder.java index d19d0158..8e49d6d8 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/builder/IndexBuilder.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/builder/IndexBuilder.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.builder; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.builder; import java.io.IOException; import java.util.Collection; @@ -41,7 +33,7 @@ import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress; import org.apache.hadoop.hbase.util.Pair; -import com.salesforce.hbase.index.Indexer; +import org.apache.hadoop.hbase.index.Indexer; /** * Interface to build updates ({@link Mutation}s) to the index tables, based on the primary table diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/builder/IndexBuildingFailureException.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/builder/IndexBuildingFailureException.java new file mode 100644 index 00000000..1c89b7f9 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/builder/IndexBuildingFailureException.java @@ -0,0 +1,50 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.builder; + +import java.io.IOException; + +import org.apache.hadoop.hbase.DoNotRetryIOException; + +/** + * Unexpected failure while building index updates that wasn't caused by an {@link IOException}. + * This should be used if there is some basic issue with indexing - and no matter of retries will + * fix it. + */ +@SuppressWarnings("serial") +public class IndexBuildingFailureException extends DoNotRetryIOException { + + /** + * Constructor for over the wire propagation. Generally, shouldn't be used since index failure + * should have an underlying cause to propagate. + * @param msg reason for the failure + */ + public IndexBuildingFailureException(String msg) { + super(msg); + } + + /** + * @param msg reason + * @param cause underlying cause for the failure + */ + public IndexBuildingFailureException(String msg, Throwable cause) { + super(msg, cause); + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/Batch.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/Batch.java new file mode 100644 index 00000000..8b7815c8 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/Batch.java @@ -0,0 +1,62 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.hadoop.hbase.KeyValue; + +/** + * A collection of {@link KeyValue KeyValues} to the primary table + */ +public class Batch { + + private static final long pointDeleteCode = KeyValue.Type.Delete.getCode(); + private final long timestamp; + private List batch = new ArrayList(); + private boolean allPointDeletes = true; + + /** + * @param ts + */ + public Batch(long ts) { + this.timestamp = ts; + } + + public void add(KeyValue kv){ + if (pointDeleteCode != kv.getType()) { + allPointDeletes = false; + } + batch.add(kv); + } + + public boolean isAllPointDeletes() { + return allPointDeletes; + } + + public long getTimestamp() { + return this.timestamp; + } + + public List getKvs() { + return this.batch; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/CoveredColumns.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/CoveredColumns.java new file mode 100644 index 00000000..4846dc86 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/CoveredColumns.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.hadoop.hbase.index.covered.update.ColumnReference; + +/** + * Manage a set of {@link ColumnReference}s for the {@link LocalTableState}. + */ +public class CoveredColumns { + + Set columns = new HashSet(); + + public Collection findNonCoveredColumns( + Collection columns2) { + List uncovered = new ArrayList(); + for (ColumnReference column : columns2) { + if (!columns.contains(column)) { + uncovered.add(column); + } + } + return uncovered; + } + + public void addColumn(ColumnReference column) { + this.columns.add(column); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/CoveredColumnsIndexBuilder.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/CoveredColumnsIndexBuilder.java similarity index 90% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/CoveredColumnsIndexBuilder.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/CoveredColumnsIndexBuilder.java index 6a0dbe02..1e48d5c4 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/CoveredColumnsIndexBuilder.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/CoveredColumnsIndexBuilder.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered; import java.io.IOException; import java.lang.reflect.Constructor; @@ -52,12 +44,12 @@ import com.google.common.collect.Lists; import com.google.common.primitives.Longs; -import com.salesforce.hbase.index.builder.BaseIndexBuilder; -import com.salesforce.hbase.index.covered.data.LocalHBaseState; -import com.salesforce.hbase.index.covered.data.LocalTable; -import com.salesforce.hbase.index.covered.update.ColumnTracker; -import com.salesforce.hbase.index.covered.update.IndexUpdateManager; -import com.salesforce.hbase.index.covered.update.IndexedColumnGroup; +import org.apache.hadoop.hbase.index.builder.BaseIndexBuilder; +import org.apache.hadoop.hbase.index.covered.data.LocalHBaseState; +import org.apache.hadoop.hbase.index.covered.data.LocalTable; +import org.apache.hadoop.hbase.index.covered.update.ColumnTracker; +import org.apache.hadoop.hbase.index.covered.update.IndexUpdateManager; +import org.apache.hadoop.hbase.index.covered.update.IndexedColumnGroup; /** * Build covered indexes for phoenix updates. @@ -71,7 +63,7 @@ public class CoveredColumnsIndexBuilder extends BaseIndexBuilder { private static final Log LOG = LogFactory.getLog(CoveredColumnsIndexBuilder.class); - public static final String CODEC_CLASS_NAME_KEY = "com.salesforce.hbase.index.codec.class"; + public static final String CODEC_CLASS_NAME_KEY = "org.apache.hadoop.hbase.index.codec.class"; protected RegionCoprocessorEnvironment env; protected IndexCodec codec; diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/IndexCodec.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/IndexCodec.java similarity index 69% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/IndexCodec.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/IndexCodec.java index 5de43e4d..ba053074 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/IndexCodec.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/IndexCodec.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered; import java.io.IOException; @@ -33,7 +25,7 @@ import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; -import com.salesforce.phoenix.index.BaseIndexCodec; +import org.apache.phoenix.index.BaseIndexCodec; /** diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/IndexUpdate.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/IndexUpdate.java new file mode 100644 index 00000000..3a1866ed --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/IndexUpdate.java @@ -0,0 +1,79 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered; + +import org.apache.hadoop.hbase.client.Mutation; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.util.Bytes; + +import org.apache.hadoop.hbase.index.covered.update.ColumnTracker; + +/** + * Update to make to the index table. + */ +public class IndexUpdate { + Mutation update; + byte[] tableName; + ColumnTracker columns; + + IndexUpdate(ColumnTracker tracker) { + this.columns = tracker; + } + + public void setUpdate(Mutation p) { + this.update = p; + } + + public void setTable(byte[] tableName) { + this.tableName = tableName; + } + + public Mutation getUpdate() { + return update; + } + + public byte[] getTableName() { + return tableName; + } + + public ColumnTracker getIndexedColumns() { + return columns; + } + + @Override + public String toString() { + return "IndexUpdate: \n\ttable - " + Bytes.toString(tableName) + "\n\tupdate: " + update + + "\n\tcolumns: " + columns; + } + + public static IndexUpdate createIndexUpdateForTesting(ColumnTracker tracker, byte[] table, Put p) { + IndexUpdate update = new IndexUpdate(tracker); + update.setTable(table); + update.setUpdate(p); + return update; + } + + /** + * @return true if the necessary state for a valid index update has been set. + */ + public boolean isValid() { + return this.tableName != null && this.update != null; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/KeyValueStore.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/KeyValueStore.java new file mode 100644 index 00000000..1048831b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/KeyValueStore.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered; + +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.regionserver.KeyValueScanner; + +/** + * Store a collection of KeyValues in memory. + */ +public interface KeyValueStore { + + public void add(KeyValue kv, boolean overwrite); + + public KeyValueScanner getScanner(); + + public void rollback(KeyValue kv); +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/LocalTableState.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/LocalTableState.java similarity index 74% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/LocalTableState.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/LocalTableState.java index 9c32ed47..1950864f 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/LocalTableState.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/LocalTableState.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered; import java.io.IOException; import java.util.ArrayList; @@ -43,13 +35,13 @@ import org.apache.hadoop.hbase.regionserver.KeyValueScanner; import org.apache.hadoop.hbase.util.Pair; -import com.salesforce.hbase.index.covered.data.IndexMemStore; -import com.salesforce.hbase.index.covered.data.LocalHBaseState; -import com.salesforce.hbase.index.covered.update.ColumnReference; -import com.salesforce.hbase.index.covered.update.ColumnTracker; -import com.salesforce.hbase.index.covered.update.IndexedColumnGroup; -import com.salesforce.hbase.index.scanner.Scanner; -import com.salesforce.hbase.index.scanner.ScannerBuilder; +import org.apache.hadoop.hbase.index.covered.data.IndexMemStore; +import org.apache.hadoop.hbase.index.covered.data.LocalHBaseState; +import org.apache.hadoop.hbase.index.covered.update.ColumnReference; +import org.apache.hadoop.hbase.index.covered.update.ColumnTracker; +import org.apache.hadoop.hbase.index.covered.update.IndexedColumnGroup; +import org.apache.hadoop.hbase.index.scanner.Scanner; +import org.apache.hadoop.hbase.index.scanner.ScannerBuilder; /** * Manage the state of the HRegion's view of the table, for the single row. diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/TableState.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/TableState.java similarity index 94% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/TableState.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/TableState.java index a93639c3..52d4e851 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/TableState.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/TableState.java @@ -1,4 +1,4 @@ -package com.salesforce.hbase.index.covered; +package org.apache.hadoop.hbase.index.covered; import java.io.IOException; import java.util.Collection; @@ -10,9 +10,9 @@ import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; import org.apache.hadoop.hbase.util.Pair; -import com.salesforce.hbase.index.covered.update.ColumnReference; -import com.salesforce.hbase.index.covered.update.IndexedColumnGroup; -import com.salesforce.hbase.index.scanner.Scanner; +import org.apache.hadoop.hbase.index.covered.update.ColumnReference; +import org.apache.hadoop.hbase.index.covered.update.IndexedColumnGroup; +import org.apache.hadoop.hbase.index.scanner.Scanner; /** * Interface for the current state of the table. This is generally going to be as of a timestamp - a diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/IndexMemStore.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/IndexMemStore.java similarity index 84% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/IndexMemStore.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/IndexMemStore.java index f6637846..ac29dd1c 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/IndexMemStore.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/IndexMemStore.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered.data; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered.data; import java.util.Comparator; import java.util.Iterator; @@ -42,8 +34,8 @@ import org.apache.hadoop.hbase.regionserver.NonLazyKeyValueScanner; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.hbase.index.covered.KeyValueStore; -import com.salesforce.hbase.index.covered.LocalTableState; +import org.apache.hadoop.hbase.index.covered.KeyValueStore; +import org.apache.hadoop.hbase.index.covered.LocalTableState; /** * Like the HBase {@link MemStore}, but without all that extra work around maintaining snapshots and @@ -320,5 +312,22 @@ public boolean shouldUseScanner(Scan scan, SortedSet columns, long oldes throw new UnsupportedOperationException(this.getClass().getName() + " doesn't support checking to see if it should use a scanner!"); } + + /* + @Override + public boolean backwardSeek(KeyValue arg0) throws IOException { + throw new UnsupportedOperationException(); + } + + @Override + public boolean seekToLastRow() throws IOException { + throw new UnsupportedOperationException(); + } + + @Override + public boolean seekToPreviousRow(KeyValue arg0) throws IOException { + throw new UnsupportedOperationException(); + } + */ } } \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/LazyValueGetter.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/LazyValueGetter.java new file mode 100644 index 00000000..619a4cfb --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/LazyValueGetter.java @@ -0,0 +1,89 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered.data; + +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.apache.hadoop.hbase.KeyValue; + +import org.apache.hadoop.hbase.index.ValueGetter; +import org.apache.hadoop.hbase.index.covered.update.ColumnReference; +import org.apache.hadoop.hbase.index.scanner.Scanner; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; + +/** + * {@link ValueGetter} that uses lazy initialization to get the value for the given + * {@link ColumnReference}. Once stored, the mapping for that reference is retained. + */ +public class LazyValueGetter implements ValueGetter { + + private Scanner scan; + private volatile Map values; + private byte[] row; + + /** + * Back the getter with a {@link Scanner} to actually access the local data. + * @param scan backing scanner + * @param currentRow row key for the row to seek in the scanner + */ + public LazyValueGetter(Scanner scan, byte[] currentRow) { + this.scan = scan; + this.row = currentRow; + } + + @Override + public ImmutableBytesPtr getLatestValue(ColumnReference ref) throws IOException { + // ensure we have a backing map + if (values == null) { + synchronized (this) { + values = Collections.synchronizedMap(new HashMap()); + } + } + + // check the value in the map + ImmutableBytesPtr value = values.get(ref); + if (value == null) { + value = get(ref); + values.put(ref, value); + } + + return value; + } + + /** + * @param ref + * @return the first value on the scanner for the given column + */ + private ImmutableBytesPtr get(ColumnReference ref) throws IOException { + KeyValue first = ref.getFirstKeyValueForRow(row); + if (!scan.seek(first)) { + return null; + } + // there is a next value - we only care about the current value, so we can just snag that + KeyValue next = scan.next(); + if (ref.matches(next)) { + return new ImmutableBytesPtr(next.getBuffer(), next.getValueOffset(), next.getValueLength()); + } + return null; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/LocalHBaseState.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/LocalHBaseState.java new file mode 100644 index 00000000..0058efaf --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/LocalHBaseState.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered.data; + +import java.io.IOException; +import java.util.Collection; + +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.client.Mutation; +import org.apache.hadoop.hbase.client.Result; + +import org.apache.hadoop.hbase.index.covered.update.ColumnReference; + +/** + * Access the current state of the row in the local HBase table, given a mutation + */ +public interface LocalHBaseState { + + /** + * @param m mutation for which we should get the current table state + * @param toCover all the columns the current row state needs to cover; hint the underlying lookup + * to save getting all the columns for the row + * @return the full state of the given row. Includes all current versions (even if they are not + * usually visible to the client (unless they are also doing a raw scan)). Never returns a + * null {@link Result} - instead, when there is not data for the row, returns a + * {@link Result} with no stored {@link KeyValue}s. + * @throws IOException if there is an issue reading the row + */ + public Result getCurrentRowState(Mutation m, Collection toCover) + throws IOException; + +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/LocalTable.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/LocalTable.java similarity index 50% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/LocalTable.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/LocalTable.java index 26048b88..27905238 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/data/LocalTable.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/data/LocalTable.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered.data; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered.data; import java.io.IOException; import java.util.ArrayList; @@ -41,8 +33,8 @@ import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.regionserver.RegionScanner; -import com.salesforce.hbase.index.covered.update.ColumnReference; -import com.salesforce.hbase.index.util.IndexManagementUtil; +import org.apache.hadoop.hbase.index.covered.update.ColumnReference; +import org.apache.hadoop.hbase.index.util.IndexManagementUtil; /** * Wrapper around a lazily instantiated, local HTable. diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/ColumnGroup.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/ColumnGroup.java similarity index 97% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/ColumnGroup.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/ColumnGroup.java index 001a809c..9f923b10 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/ColumnGroup.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/ColumnGroup.java @@ -1,5 +1,5 @@ -package com.salesforce.hbase.index.covered.example; +package org.apache.hadoop.hbase.index.covered.example; import java.util.ArrayList; import java.util.Iterator; diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/CoveredColumn.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/CoveredColumn.java similarity index 95% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/CoveredColumn.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/CoveredColumn.java index 8c674dbb..ef4b2bac 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/CoveredColumn.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/CoveredColumn.java @@ -1,8 +1,8 @@ -package com.salesforce.hbase.index.covered.example; +package org.apache.hadoop.hbase.index.covered.example; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.hbase.index.covered.update.ColumnReference; +import org.apache.hadoop.hbase.index.covered.update.ColumnReference; /** * A single Column (either a Column Family or a full Family:Qualifier pair) in a {@link ColumnGroup} diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/CoveredColumnIndexCodec.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/CoveredColumnIndexCodec.java similarity index 98% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/CoveredColumnIndexCodec.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/CoveredColumnIndexCodec.java index 0567b3ab..8f0ee994 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/CoveredColumnIndexCodec.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/CoveredColumnIndexCodec.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.salesforce.hbase.index.covered.example; +package org.apache.hadoop.hbase.index.covered.example; import java.io.IOException; import java.util.ArrayList; @@ -33,10 +33,10 @@ import org.apache.hadoop.hbase.util.Pair; import com.google.common.collect.Lists; -import com.salesforce.hbase.index.covered.IndexUpdate; -import com.salesforce.hbase.index.covered.TableState; -import com.salesforce.hbase.index.scanner.Scanner; -import com.salesforce.phoenix.index.BaseIndexCodec; +import org.apache.hadoop.hbase.index.covered.IndexUpdate; +import org.apache.hadoop.hbase.index.covered.TableState; +import org.apache.hadoop.hbase.index.scanner.Scanner; +import org.apache.phoenix.index.BaseIndexCodec; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/CoveredColumnIndexSpecifierBuilder.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/CoveredColumnIndexSpecifierBuilder.java similarity index 95% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/CoveredColumnIndexSpecifierBuilder.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/CoveredColumnIndexSpecifierBuilder.java index abed62e6..0c9f1559 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/CoveredColumnIndexSpecifierBuilder.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/CoveredColumnIndexSpecifierBuilder.java @@ -1,4 +1,4 @@ -package com.salesforce.hbase.index.covered.example; +package org.apache.hadoop.hbase.index.covered.example; import java.io.IOException; import java.util.ArrayList; @@ -10,9 +10,9 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HTableDescriptor; -import com.salesforce.hbase.index.Indexer; -import com.salesforce.hbase.index.covered.CoveredColumnsIndexBuilder; -import com.salesforce.hbase.index.covered.IndexCodec; +import org.apache.hadoop.hbase.index.Indexer; +import org.apache.hadoop.hbase.index.covered.CoveredColumnsIndexBuilder; +import org.apache.hadoop.hbase.index.covered.IndexCodec; /** * Helper to build the configuration for the {@link CoveredColumnIndexer}. diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/CoveredColumnIndexer.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/CoveredColumnIndexer.java similarity index 95% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/CoveredColumnIndexer.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/CoveredColumnIndexer.java index 107bc9bf..c7019c4e 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/example/CoveredColumnIndexer.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/example/CoveredColumnIndexer.java @@ -1,4 +1,4 @@ -package com.salesforce.hbase.index.covered.example; +package org.apache.hadoop.hbase.index.covered.example; import java.io.IOException; import java.util.Collection; @@ -17,10 +17,10 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Pair; -import com.salesforce.hbase.index.covered.Batch; -import com.salesforce.hbase.index.covered.CoveredColumnsIndexBuilder; -import com.salesforce.hbase.index.covered.LocalTableState; -import com.salesforce.hbase.index.covered.update.IndexUpdateManager; +import org.apache.hadoop.hbase.index.covered.Batch; +import org.apache.hadoop.hbase.index.covered.CoveredColumnsIndexBuilder; +import org.apache.hadoop.hbase.index.covered.LocalTableState; +import org.apache.hadoop.hbase.index.covered.update.IndexUpdateManager; /** * Index maintainer that maintains multiple indexes based on '{@link ColumnGroup}s'. Each group is a diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java similarity index 84% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java index bb91bf99..ebec75a9 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered.filter; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered.filter; import java.io.DataInput; import java.io.DataOutput; @@ -41,7 +33,7 @@ import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.filter.FilterBase; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; /** * Only allow the 'latest' timestamp of each family:qualifier pair, ensuring that they aren't diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/ColumnTrackingNextLargestTimestampFilter.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/ColumnTrackingNextLargestTimestampFilter.java new file mode 100644 index 00000000..b23368d4 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/ColumnTrackingNextLargestTimestampFilter.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered.filter; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.filter.FilterBase; + +import org.apache.hadoop.hbase.index.covered.update.ColumnTracker; + +/** + * Similar to the {@link MaxTimestampFilter}, but also updates the 'next largest' timestamp seen + * that is not skipped by the below criteria. Note that it isn't as quick as the + * {@link MaxTimestampFilter} as we can't just seek ahead to a key with the matching timestamp, but + * have to iterate each kv until we find the right one with an allowed timestamp. + *

+ * Inclusively filter on the maximum timestamp allowed. Excludes all elements greater than (but not + * equal to) the given timestamp, so given ts = 5, a {@link KeyValue} with ts 6 is excluded, but not + * one with ts = 5. + *

+ * This filter generally doesn't make sense on its own - it should follow a per-column filter and + * possible a per-delete filter to only track the most recent (but not exposed to the user) + * timestamp. + */ +public class ColumnTrackingNextLargestTimestampFilter extends FilterBase { + + private long ts; + private ColumnTracker column; + + public ColumnTrackingNextLargestTimestampFilter(long maxTime, ColumnTracker toTrack) { + this.ts = maxTime; + this.column = toTrack; + } + + @Override + public ReturnCode filterKeyValue(KeyValue v) { + long timestamp = v.getTimestamp(); + if (timestamp > ts) { + this.column.setTs(timestamp); + return ReturnCode.SKIP; + } + return ReturnCode.INCLUDE; + } + + @Override + public void write(DataOutput out) throws IOException { + throw new UnsupportedOperationException("Server-side only filter, cannot be serialized!"); + } + + @Override + public void readFields(DataInput in) throws IOException { + throw new UnsupportedOperationException("Server-side only filter, cannot be deserialized!"); + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/FamilyOnlyFilter.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/FamilyOnlyFilter.java similarity index 97% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/FamilyOnlyFilter.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/FamilyOnlyFilter.java index 0f4c5342..8591f88d 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/FamilyOnlyFilter.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/FamilyOnlyFilter.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.salesforce.hbase.index.covered.filter; +package org.apache.hadoop.hbase.index.covered.filter; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.filter.BinaryComparator; diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/MaxTimestampFilter.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/MaxTimestampFilter.java new file mode 100644 index 00000000..5b765791 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/MaxTimestampFilter.java @@ -0,0 +1,76 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered.filter; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.filter.FilterBase; +import org.apache.hadoop.hbase.util.Bytes; + +/** + * Inclusive filter on the maximum timestamp allowed. Excludes all elements greater than (but not + * equal to) the given timestamp, so given ts = 5, a {@link KeyValue} with ts 6 is excluded, but not + * one with ts = 5. + */ +public class MaxTimestampFilter extends FilterBase { + + private long ts; + + public MaxTimestampFilter(long maxTime) { + this.ts = maxTime; + } + + @Override + public KeyValue getNextKeyHint(KeyValue currentKV) { + // this might be a little excessive right now - better safe than sorry though, so we don't mess + // with other filters too much. + KeyValue kv = currentKV.deepCopy(); + int offset =kv.getTimestampOffset(); + //set the timestamp in the buffer + byte[] buffer = kv.getBuffer(); + byte[] ts = Bytes.toBytes(this.ts); + System.arraycopy(ts, 0, buffer, offset, ts.length); + + return kv; + } + + @Override + public ReturnCode filterKeyValue(KeyValue v) { + long timestamp = v.getTimestamp(); + if (timestamp > ts) { + return ReturnCode.SEEK_NEXT_USING_HINT; + } + return ReturnCode.INCLUDE; + } + + @Override + public void write(DataOutput out) throws IOException { + throw new UnsupportedOperationException("Server-side only filter, cannot be serialized!"); + + } + + @Override + public void readFields(DataInput in) throws IOException { + throw new UnsupportedOperationException("Server-side only filter, cannot be deserialized!"); + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/NewerTimestampFilter.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/NewerTimestampFilter.java similarity index 95% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/NewerTimestampFilter.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/NewerTimestampFilter.java index 5140a9b1..560cdd83 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/filter/NewerTimestampFilter.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/filter/NewerTimestampFilter.java @@ -1,4 +1,4 @@ -package com.salesforce.hbase.index.covered.filter; +package org.apache.hadoop.hbase.index.covered.filter; import java.io.DataInput; import java.io.DataOutput; diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/ColumnReference.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/ColumnReference.java similarity index 69% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/ColumnReference.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/ColumnReference.java index 3e609961..0525028a 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/ColumnReference.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/ColumnReference.java @@ -1,37 +1,29 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered.update; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered.update; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/ColumnTracker.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/ColumnTracker.java similarity index 59% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/ColumnTracker.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/ColumnTracker.java index 6c2bf4ce..e41c3149 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/ColumnTracker.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/ColumnTracker.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered.update; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered.update; import java.util.ArrayList; import java.util.Collection; diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/IndexUpdateManager.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/IndexUpdateManager.java similarity index 79% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/IndexUpdateManager.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/IndexUpdateManager.java index 1a9d8c6f..52eb5dd1 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/IndexUpdateManager.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/IndexUpdateManager.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered.update; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered.update; import java.util.Collection; import java.util.Comparator; @@ -43,7 +35,7 @@ import com.google.common.collect.Lists; import com.google.common.primitives.Longs; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; /** * Keeps track of the index updates diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/IndexedColumnGroup.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/IndexedColumnGroup.java new file mode 100644 index 00000000..535742bb --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/IndexedColumnGroup.java @@ -0,0 +1,30 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered.update; + +import java.util.List; + +/** + * Group of columns that were requested to build an index + */ +public interface IndexedColumnGroup { + + public List getColumns(); +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/SortedCollection.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/SortedCollection.java similarity index 56% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/SortedCollection.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/SortedCollection.java index f25f73c8..b228e63b 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/covered/update/SortedCollection.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/covered/update/SortedCollection.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.covered.update; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.covered.update; import java.util.Arrays; import java.util.Collection; diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/exception/IndexWriteException.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/exception/IndexWriteException.java new file mode 100644 index 00000000..16fa1bca --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/exception/IndexWriteException.java @@ -0,0 +1,45 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.exception; + +import org.apache.hadoop.hbase.HBaseIOException; + +/** + * Generic {@link Exception} that an index write has failed + */ +@SuppressWarnings("serial") +public class IndexWriteException extends HBaseIOException { + + public IndexWriteException() { + super(); + } + + public IndexWriteException(String message, Throwable cause) { + super(message, cause); + } + + public IndexWriteException(String message) { + super(message); + } + + public IndexWriteException(Throwable cause) { + super(cause); + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/exception/MultiIndexWriteFailureException.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/exception/MultiIndexWriteFailureException.java new file mode 100644 index 00000000..6af43bc7 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/exception/MultiIndexWriteFailureException.java @@ -0,0 +1,46 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.exception; + +import java.util.List; + +import org.apache.hadoop.hbase.index.table.HTableInterfaceReference; + +/** + * Indicate a failure to write to multiple index tables. + */ +@SuppressWarnings("serial") +public class MultiIndexWriteFailureException extends IndexWriteException { + + private List failures; + + /** + * @param failures the tables to which the index write did not succeed + */ + public MultiIndexWriteFailureException(List failures) { + super("Failed to write to multiple index tables"); + this.failures = failures; + + } + + public List getFailedTables() { + return this.failures; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/exception/SingleIndexWriteFailureException.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/exception/SingleIndexWriteFailureException.java new file mode 100644 index 00000000..f0fcb4ba --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/exception/SingleIndexWriteFailureException.java @@ -0,0 +1,63 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.exception; + +import java.util.List; + +import org.apache.hadoop.hbase.client.Mutation; + +/** + * Exception thrown if we cannot successfully write to an index table. + */ +@SuppressWarnings("serial") +public class SingleIndexWriteFailureException extends IndexWriteException { + + private String table; + + /** + * Cannot reach the index, but not sure of the table or the mutations that caused the failure + * @param msg more description of what happened + * @param cause original cause + */ + public SingleIndexWriteFailureException(String msg, Throwable cause) { + super(msg, cause); + } + + /** + * Failed to write the passed mutations to an index table for some reason. + * @param targetTableName index table to which we attempted to write + * @param mutations mutations that were attempted + * @param cause underlying reason for the failure + */ + public SingleIndexWriteFailureException(String targetTableName, List mutations, + Exception cause) { + super("Failed to make index update:\n\t table: " + targetTableName + "\n\t edits: " + mutations + + "\n\tcause: " + cause == null ? "UNKNOWN" : cause.getMessage(), cause); + this.table = targetTableName; + } + + /** + * @return The table to which we failed to write the index updates. If unknown, returns + * null + */ + public String getTableName() { + return this.table; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/BaseTaskRunner.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/BaseTaskRunner.java similarity index 69% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/BaseTaskRunner.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/BaseTaskRunner.java index f95d5bbd..da6f7950 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/BaseTaskRunner.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/BaseTaskRunner.java @@ -1,22 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source - * and binary forms, with or without modification, are permitted provided that the following - * conditions are met: Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. Redistributions in binary form must reproduce - * the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of - * Salesforce.com nor the names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED - * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.parallel; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.parallel; import java.util.ArrayList; import java.util.List; diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/EarlyExitFailure.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/EarlyExitFailure.java new file mode 100644 index 00000000..ab2ffd5f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/EarlyExitFailure.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.parallel; + +import java.io.IOException; + +/** + * Exception denoting a need to early-exit a task (or group of tasks) due to external notification + */ +@SuppressWarnings("serial") +public class EarlyExitFailure extends IOException { + + /** + * @param msg reason for the early exit + */ + public EarlyExitFailure(String msg) { + super(msg); + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/QuickFailingTaskRunner.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/QuickFailingTaskRunner.java new file mode 100644 index 00000000..6a194a6e --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/QuickFailingTaskRunner.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.parallel; + +import java.util.List; +import java.util.concurrent.ExecutorService; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; + +/** + * {@link TaskRunner} that attempts to run all tasks passed, but quits early if any {@link Task} + * fails, not waiting for the remaining {@link Task}s to complete. + */ +public class QuickFailingTaskRunner extends BaseTaskRunner { + + static final Log LOG = LogFactory.getLog(QuickFailingTaskRunner.class); + + /** + * @param service thread pool to which {@link Task}s are submitted. This service is then 'owned' + * by this and will be shutdown on calls to {@link #stop(String)}. + */ + public QuickFailingTaskRunner(ExecutorService service) { + super(service); + } + + @Override + protected ListenableFuture> submitTasks(List> futures) { + return Futures.allAsList(futures); + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/Task.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/Task.java new file mode 100644 index 00000000..a052759e --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/Task.java @@ -0,0 +1,42 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.parallel; + +import java.util.concurrent.Callable; + +import org.apache.hadoop.hbase.Abortable; + +/** + * Like a {@link Callable}, but supports an internal {@link Abortable} that can be checked + * periodically to determine if the batch should abort + * @param expected result of the task + */ +public abstract class Task implements Callable { + + private Abortable batch; + + void setBatchMonitor(Abortable abort) { + this.batch = abort; + } + + protected boolean isBatchFailed() { + return this.batch.isAborted(); + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/TaskBatch.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/TaskBatch.java new file mode 100644 index 00000000..49d96bf9 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/TaskBatch.java @@ -0,0 +1,76 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.parallel; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hbase.Abortable; + +/** + * A group of {@link Task}s. The tasks are all bound together using the same {@link Abortable} ( + * this) to ensure that all tasks are aware when any of the other tasks fails. + * @param expected result type from all the tasks + */ +public class TaskBatch implements Abortable { + private static final Log LOG = LogFactory.getLog(TaskBatch.class); + private AtomicBoolean aborted = new AtomicBoolean(); + private List> tasks; + + /** + * @param size expected number of tasks + */ + public TaskBatch(int size) { + this.tasks = new ArrayList>(size); + } + + public void add(Task task) { + this.tasks.add(task); + task.setBatchMonitor(this); + } + + public Collection> getTasks() { + return this.tasks; + } + + @Override + public void abort(String why, Throwable e) { + if (this.aborted.getAndSet(true)) { + return; + } + LOG.info("Aborting batch of tasks because " + why); + } + + @Override + public boolean isAborted() { + return this.aborted.get(); + } + + /** + * @return the number of tasks assigned to this batch + */ + public int size() { + return this.tasks.size(); + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/TaskRunner.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/TaskRunner.java similarity index 51% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/TaskRunner.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/TaskRunner.java index 4ad8f905..bc8749c5 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/TaskRunner.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/TaskRunner.java @@ -1,22 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source - * and binary forms, with or without modification, are permitted provided that the following - * conditions are met: Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. Redistributions in binary form must reproduce - * the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of - * Salesforce.com nor the names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED - * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.parallel; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.parallel; import java.util.List; import java.util.concurrent.ExecutionException; diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/ThreadPoolBuilder.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/ThreadPoolBuilder.java similarity index 55% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/ThreadPoolBuilder.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/ThreadPoolBuilder.java index fd160a4a..869ccb8a 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/ThreadPoolBuilder.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/ThreadPoolBuilder.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.parallel; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.parallel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/ThreadPoolManager.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/ThreadPoolManager.java similarity index 74% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/ThreadPoolManager.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/ThreadPoolManager.java index 5d56f8ea..7a081055 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/parallel/ThreadPoolManager.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/ThreadPoolManager.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.parallel; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.parallel; import java.util.Collections; import java.util.List; diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/WaitForCompletionTaskRunner.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/WaitForCompletionTaskRunner.java new file mode 100644 index 00000000..fe9f3ac9 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/parallel/WaitForCompletionTaskRunner.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.parallel; + +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; + +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; + +/** + * A {@link TaskRunner} that ensures that all the tasks have been attempted before we return, even + * if some of the tasks cause failures. + *

+ * Because we wait until the entire batch is complete to see the failure, checking for failure of + * the {@link TaskBatch} on the submitted tasks will not help - they will never see the failure of + * the other tasks. You will need to provide an external mechanism to propagate the error. + *

+ * Does not throw an {@link ExecutionException} if any of the tasks fail. + */ +public class WaitForCompletionTaskRunner extends BaseTaskRunner { + + /** + * @param service thread pool to which {@link Task}s are submitted. This service is then 'owned' + * by this and will be shutdown on calls to {@link #stop(String)}. + */ + public WaitForCompletionTaskRunner(ExecutorService service) { + super(service); + } + + @Override + public ListenableFuture> submitTasks(List> futures) { + return Futures.successfulAsList(futures); + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/scanner/EmptyScanner.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/scanner/EmptyScanner.java similarity index 91% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/scanner/EmptyScanner.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/scanner/EmptyScanner.java index 51cb8a36..491a8950 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/scanner/EmptyScanner.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/scanner/EmptyScanner.java @@ -1,4 +1,4 @@ -package com.salesforce.hbase.index.scanner; +package org.apache.hadoop.hbase.index.scanner; import java.io.IOException; diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/scanner/FilteredKeyValueScanner.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/scanner/FilteredKeyValueScanner.java new file mode 100644 index 00000000..0f7fed3e --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/scanner/FilteredKeyValueScanner.java @@ -0,0 +1,144 @@ +package org.apache.hadoop.hbase.index.scanner; + +import java.io.IOException; +import java.util.SortedSet; + +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.filter.Filter; +import org.apache.hadoop.hbase.filter.Filter.ReturnCode; +import org.apache.hadoop.hbase.regionserver.KeyValueScanner; + +import org.apache.hadoop.hbase.index.covered.KeyValueStore; + +/** + * Combine a simplified version of the logic in the ScanQueryMatcher and the KeyValueScanner. We can get away with this + * here because we are only concerned with a single MemStore for the index; we don't need to worry about multiple column + * families or minimizing seeking through file - we just want to iterate the kvs quickly, in-memory. + */ +public class FilteredKeyValueScanner implements KeyValueScanner { + + private KeyValueScanner delegate; + private Filter filter; + + public FilteredKeyValueScanner(Filter filter, KeyValueStore store) { + this(filter, store.getScanner()); + } + + private FilteredKeyValueScanner(Filter filter, KeyValueScanner delegate) { + this.delegate = delegate; + this.filter = filter; + } + + @Override + public KeyValue peek() { + return delegate.peek(); + } + + /** + * Same a {@link KeyValueScanner#next()} except that we filter out the next {@link KeyValue} until we find one that + * passes the filter. + * + * @return the next {@link KeyValue} or null if no next {@link KeyValue} is present and passes all the + * filters. + */ + @Override + public KeyValue next() throws IOException { + seekToNextUnfilteredKeyValue(); + return delegate.next(); + } + + @Override + public boolean seek(KeyValue key) throws IOException { + if (filter.filterAllRemaining()) { return false; } + // see if we can seek to the next key + if (!delegate.seek(key)) { return false; } + + return seekToNextUnfilteredKeyValue(); + } + + private boolean seekToNextUnfilteredKeyValue() throws IOException { + while (true) { + KeyValue peeked = delegate.peek(); + // no more key values, so we are done + if (peeked == null) { return false; } + + // filter the peeked value to see if it should be served + ReturnCode code = filter.filterKeyValue(peeked); + switch (code) { + // included, so we are done + case INCLUDE: + case INCLUDE_AND_NEXT_COL: + return true; + // not included, so we need to go to the next row + case SKIP: + case NEXT_COL: + case NEXT_ROW: + delegate.next(); + break; + // use a seek hint to find out where we should go + case SEEK_NEXT_USING_HINT: + delegate.seek(filter.getNextKeyHint(peeked)); + } + } + } + + @Override + public boolean reseek(KeyValue key) throws IOException { + this.delegate.reseek(key); + return this.seekToNextUnfilteredKeyValue(); + } + + @Override + public boolean requestSeek(KeyValue kv, boolean forward, boolean useBloom) throws IOException { + return this.reseek(kv); + } + + @Override + public boolean isFileScanner() { + return false; + } + + @Override + public long getSequenceID() { + return this.delegate.getSequenceID(); + } + + @Override + public boolean shouldUseScanner(Scan scan, SortedSet columns, long oldestUnexpiredTS) { + throw new UnsupportedOperationException(this.getClass().getName() + + " doesn't support checking to see if it should use a scanner!"); + } + + @Override + public boolean realSeekDone() { + return this.delegate.realSeekDone(); + } + + @Override + public void enforceSeek() throws IOException { + this.delegate.enforceSeek(); + } + + @Override + public void close() { + this.delegate.close(); + } + + /* + @Override + public boolean backwardSeek(KeyValue arg0) throws IOException { + return this.delegate.backwardSeek(arg0); + } + + @Override + public boolean seekToLastRow() throws IOException { + return this.delegate.seekToLastRow(); + } + + @Override + public boolean seekToPreviousRow(KeyValue arg0) throws IOException { + return this.delegate.seekToPreviousRow(arg0); + } + */ +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/scanner/Scanner.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/scanner/Scanner.java similarity index 96% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/scanner/Scanner.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/scanner/Scanner.java index b412b995..9df96cd0 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/scanner/Scanner.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/scanner/Scanner.java @@ -1,4 +1,4 @@ -package com.salesforce.hbase.index.scanner; +package org.apache.hadoop.hbase.index.scanner; import java.io.Closeable; import java.io.IOException; diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/scanner/ScannerBuilder.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/scanner/ScannerBuilder.java similarity index 91% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/scanner/ScannerBuilder.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/scanner/ScannerBuilder.java index 8d681dc3..bbecb9a3 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/scanner/ScannerBuilder.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/scanner/ScannerBuilder.java @@ -1,4 +1,4 @@ -package com.salesforce.hbase.index.scanner; +package org.apache.hadoop.hbase.index.scanner; import java.io.IOException; import java.util.Collection; @@ -16,12 +16,12 @@ import org.apache.hadoop.hbase.util.Bytes; import com.google.common.collect.Lists; -import com.salesforce.hbase.index.covered.KeyValueStore; -import com.salesforce.hbase.index.covered.filter.ApplyAndFilterDeletesFilter; -import com.salesforce.hbase.index.covered.filter.ColumnTrackingNextLargestTimestampFilter; -import com.salesforce.hbase.index.covered.update.ColumnReference; -import com.salesforce.hbase.index.covered.update.ColumnTracker; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.covered.KeyValueStore; +import org.apache.hadoop.hbase.index.covered.filter.ApplyAndFilterDeletesFilter; +import org.apache.hadoop.hbase.index.covered.filter.ColumnTrackingNextLargestTimestampFilter; +import org.apache.hadoop.hbase.index.covered.update.ColumnReference; +import org.apache.hadoop.hbase.index.covered.update.ColumnTracker; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/table/CachingHTableFactory.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/table/CachingHTableFactory.java similarity index 61% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/table/CachingHTableFactory.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/table/CachingHTableFactory.java index 8d7eb730..d95e67a9 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/table/CachingHTableFactory.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/table/CachingHTableFactory.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.table; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.table; import java.io.IOException; import java.util.Map; @@ -37,7 +29,7 @@ import org.apache.hadoop.hbase.client.HTableInterface; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; /** * A simple cache that just uses usual GC mechanisms to cleanup unused {@link HTableInterface}s. diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/table/CoprocessorHTableFactory.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/table/CoprocessorHTableFactory.java similarity index 91% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/table/CoprocessorHTableFactory.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/table/CoprocessorHTableFactory.java index 757b1335..5ded8793 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/table/CoprocessorHTableFactory.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/table/CoprocessorHTableFactory.java @@ -1,4 +1,4 @@ -package com.salesforce.hbase.index.table; +package org.apache.hadoop.hbase.index.table; import java.io.IOException; @@ -10,8 +10,8 @@ import org.apache.hadoop.hbase.client.HTableInterface; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.hbase.index.util.IndexManagementUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.util.IndexManagementUtil; public class CoprocessorHTableFactory implements HTableFactory { diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/table/HTableFactory.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/table/HTableFactory.java similarity index 68% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/table/HTableFactory.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/table/HTableFactory.java index 6dca1da0..a27a2380 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/table/HTableFactory.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/table/HTableFactory.java @@ -1,10 +1,10 @@ -package com.salesforce.hbase.index.table; +package org.apache.hadoop.hbase.index.table; import java.io.IOException; import org.apache.hadoop.hbase.client.HTableInterface; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; public interface HTableFactory { diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/table/HTableInterfaceReference.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/table/HTableInterfaceReference.java similarity index 90% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/table/HTableInterfaceReference.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/table/HTableInterfaceReference.java index b3a5f7be..134006f0 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/table/HTableInterfaceReference.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/table/HTableInterfaceReference.java @@ -1,8 +1,8 @@ -package com.salesforce.hbase.index.table; +package org.apache.hadoop.hbase.index.table; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; /** * Reference to an HTableInterface. Currently, its pretty simple in that it is just a wrapper around diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/util/ImmutableBytesPtr.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/util/ImmutableBytesPtr.java similarity index 58% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/util/ImmutableBytesPtr.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/util/ImmutableBytesPtr.java index b053767c..4ae6afbd 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/util/ImmutableBytesPtr.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/util/ImmutableBytesPtr.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.util; import java.io.DataInput; import java.io.IOException; diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/util/IndexManagementUtil.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/util/IndexManagementUtil.java similarity index 82% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/util/IndexManagementUtil.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/util/IndexManagementUtil.java index f472741e..59e07cc7 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/util/IndexManagementUtil.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/util/IndexManagementUtil.java @@ -1,19 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the following conditions are met: Redistributions of source code - * must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in - * binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of Salesforce.com nor the names - * of its contributors may be used to endorse or promote products derived from this software without specific prior - * written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.util; import java.io.IOException; import java.util.Collection; @@ -28,11 +32,11 @@ import org.apache.hadoop.hbase.client.Scan; import com.google.common.collect.Maps; -import com.salesforce.hbase.index.ValueGetter; -import com.salesforce.hbase.index.builder.IndexBuildingFailureException; -import com.salesforce.hbase.index.covered.data.LazyValueGetter; -import com.salesforce.hbase.index.covered.update.ColumnReference; -import com.salesforce.hbase.index.scanner.Scanner; +import org.apache.hadoop.hbase.index.ValueGetter; +import org.apache.hadoop.hbase.index.builder.IndexBuildingFailureException; +import org.apache.hadoop.hbase.index.covered.data.LazyValueGetter; +import org.apache.hadoop.hbase.index.covered.update.ColumnReference; +import org.apache.hadoop.hbase.index.scanner.Scanner; /** * Utility class to help manage indexes diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/wal/IndexedKeyValue.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/wal/IndexedKeyValue.java similarity index 98% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/wal/IndexedKeyValue.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/wal/IndexedKeyValue.java index 09babf67..a7f4e825 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/wal/IndexedKeyValue.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/wal/IndexedKeyValue.java @@ -1,4 +1,4 @@ -package com.salesforce.hbase.index.wal; +package org.apache.hadoop.hbase.index.wal; import java.io.ByteArrayOutputStream; import java.io.DataInput; @@ -12,7 +12,7 @@ import org.apache.hadoop.hbase.regionserver.wal.HLog; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; public class IndexedKeyValue extends KeyValue { private static int calcHashCode(ImmutableBytesPtr indexTableName, Mutation mutation) { diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/wal/KeyValueCodec.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/wal/KeyValueCodec.java similarity index 98% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/wal/KeyValueCodec.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/wal/KeyValueCodec.java index d6d75bf4..0abdf8de 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/wal/KeyValueCodec.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/wal/KeyValueCodec.java @@ -1,4 +1,4 @@ -package com.salesforce.hbase.index.wal; +package org.apache.hadoop.hbase.index.wal; import java.io.DataInput; import java.io.DataOutput; diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexCommitter.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexCommitter.java new file mode 100644 index 00000000..aed4b896 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexCommitter.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.write; + +import org.apache.hadoop.hbase.Stoppable; +import org.apache.hadoop.hbase.client.Mutation; +import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; + +import com.google.common.collect.Multimap; +import org.apache.hadoop.hbase.index.exception.IndexWriteException; +import org.apache.hadoop.hbase.index.table.HTableInterfaceReference; + +/** + * Write the index updates to the index tables + */ +public interface IndexCommitter extends Stoppable { + + void setup(IndexWriter parent, RegionCoprocessorEnvironment env, String name); + + public void write(Multimap toWrite) + throws IndexWriteException; +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexFailurePolicy.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexFailurePolicy.java new file mode 100644 index 00000000..683efd5f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexFailurePolicy.java @@ -0,0 +1,46 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.write; + +import java.io.IOException; + +import org.apache.hadoop.hbase.Stoppable; +import org.apache.hadoop.hbase.client.Mutation; +import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; + +import com.google.common.collect.Multimap; +import org.apache.hadoop.hbase.index.table.HTableInterfaceReference; + +/** + * Handle failures to write to the index tables. + */ +public interface IndexFailurePolicy extends Stoppable { + + public void setup(Stoppable parent, RegionCoprocessorEnvironment env); + + /** + * Handle the failure of the attempted index updates + * @param attempted map of index table -> mutations to apply + * @param cause reason why there was a failure + * @throws IOException + */ + public void + handleFailure(Multimap attempted, Exception cause) throws IOException; +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexWriter.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexWriter.java similarity index 79% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexWriter.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexWriter.java index f3403937..8c30642e 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexWriter.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexWriter.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.write; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.write; import java.io.IOException; import java.util.Collection; @@ -43,9 +35,9 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; -import com.salesforce.hbase.index.exception.IndexWriteException; -import com.salesforce.hbase.index.table.HTableInterfaceReference; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.exception.IndexWriteException; +import org.apache.hadoop.hbase.index.table.HTableInterfaceReference; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; /** * Do the actual work of writing to the index tables. Ensures that if we do fail to write to the diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexWriterUtils.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexWriterUtils.java similarity index 58% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexWriterUtils.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexWriterUtils.java index 177d1c2f..bee89539 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/IndexWriterUtils.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/IndexWriterUtils.java @@ -1,40 +1,32 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.write; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.write; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.CoprocessorEnvironment; -import com.salesforce.hbase.index.table.CoprocessorHTableFactory; -import com.salesforce.hbase.index.table.HTableFactory; -import com.salesforce.hbase.index.util.IndexManagementUtil; +import org.apache.hadoop.hbase.index.table.CoprocessorHTableFactory; +import org.apache.hadoop.hbase.index.table.HTableFactory; +import org.apache.hadoop.hbase.index.util.IndexManagementUtil; public class IndexWriterUtils { diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/KillServerOnFailurePolicy.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/KillServerOnFailurePolicy.java new file mode 100644 index 00000000..76bde1ab --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/KillServerOnFailurePolicy.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.write; + +import java.io.IOException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hbase.Abortable; +import org.apache.hadoop.hbase.Stoppable; +import org.apache.hadoop.hbase.client.Mutation; +import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; + +import com.google.common.collect.Multimap; +import org.apache.hadoop.hbase.index.table.HTableInterfaceReference; + +/** + * Naive failure policy - kills the server on which it resides + */ +public class KillServerOnFailurePolicy implements IndexFailurePolicy { + + private static final Log LOG = LogFactory.getLog(KillServerOnFailurePolicy.class); + private Abortable abortable; + private Stoppable stoppable; + + @Override + public void setup(Stoppable parent, RegionCoprocessorEnvironment env) { + setup(parent, env.getRegionServerServices()); + } + + public void setup(Stoppable parent, Abortable abort) { + this.stoppable = parent; + this.abortable = abort; + } + + @Override + public void stop(String why) { + // noop + } + + @Override + public boolean isStopped() { + return this.stoppable.isStopped(); + } + + @Override + public void + handleFailure(Multimap attempted, Exception cause) throws IOException { + // cleanup resources + this.stop("Killing ourselves because of an error:" + cause); + // notify the regionserver of the failure + String msg = + "Could not update the index table, killing server region because couldn't write to an index table"; + LOG.error(msg, cause); + try { + this.abortable.abort(msg, cause); + } catch (Exception e) { + LOG.fatal("Couldn't abort this server to preserve index writes, " + + "attempting to hard kill the server"); + System.exit(1); + } + + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/ParallelWriterIndexCommitter.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/ParallelWriterIndexCommitter.java similarity index 76% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/write/ParallelWriterIndexCommitter.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/ParallelWriterIndexCommitter.java index 4adbcb12..86abde48 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/ParallelWriterIndexCommitter.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/ParallelWriterIndexCommitter.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.write; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.write; import java.io.IOException; import java.util.Collection; @@ -45,16 +37,16 @@ import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; import com.google.common.collect.Multimap; -import com.salesforce.hbase.index.exception.SingleIndexWriteFailureException; -import com.salesforce.hbase.index.parallel.EarlyExitFailure; -import com.salesforce.hbase.index.parallel.QuickFailingTaskRunner; -import com.salesforce.hbase.index.parallel.Task; -import com.salesforce.hbase.index.parallel.TaskBatch; -import com.salesforce.hbase.index.parallel.ThreadPoolBuilder; -import com.salesforce.hbase.index.parallel.ThreadPoolManager; -import com.salesforce.hbase.index.table.CachingHTableFactory; -import com.salesforce.hbase.index.table.HTableFactory; -import com.salesforce.hbase.index.table.HTableInterfaceReference; +import org.apache.hadoop.hbase.index.exception.SingleIndexWriteFailureException; +import org.apache.hadoop.hbase.index.parallel.EarlyExitFailure; +import org.apache.hadoop.hbase.index.parallel.QuickFailingTaskRunner; +import org.apache.hadoop.hbase.index.parallel.Task; +import org.apache.hadoop.hbase.index.parallel.TaskBatch; +import org.apache.hadoop.hbase.index.parallel.ThreadPoolBuilder; +import org.apache.hadoop.hbase.index.parallel.ThreadPoolManager; +import org.apache.hadoop.hbase.index.table.CachingHTableFactory; +import org.apache.hadoop.hbase.index.table.HTableFactory; +import org.apache.hadoop.hbase.index.table.HTableInterfaceReference; /** * Write index updates to the index tables in parallel. We attempt to early exit from the writes if diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/recovery/PerRegionIndexWriteCache.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/recovery/PerRegionIndexWriteCache.java new file mode 100644 index 00000000..3d77a837 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/recovery/PerRegionIndexWriteCache.java @@ -0,0 +1,65 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.write.recovery; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.apache.hadoop.hbase.client.Mutation; +import org.apache.hadoop.hbase.regionserver.HRegion; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import org.apache.hadoop.hbase.index.table.HTableInterfaceReference; + + +public class PerRegionIndexWriteCache { + + private Map> cache = + new HashMap>(); + + + /** + * Get the edits for the current region. Removes the edits from the cache. To add them back, call + * {@link #addEdits(HRegion, HTableInterfaceReference, Collection)}. + * @param region + * @return Get the edits for the given region. Returns null if there are no pending edits + * for the region + */ + public Multimap getEdits(HRegion region) { + return cache.remove(region); + } + + /** + * @param region + * @param table + * @param collection + */ + public void addEdits(HRegion region, HTableInterfaceReference table, + Collection collection) { + Multimap edits = cache.get(region); + if (edits == null) { + edits = ArrayListMultimap. create(); + cache.put(region, edits); + } + edits.putAll(table, collection); + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/recovery/StoreFailuresInCachePolicy.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/recovery/StoreFailuresInCachePolicy.java similarity index 89% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/write/recovery/StoreFailuresInCachePolicy.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/recovery/StoreFailuresInCachePolicy.java index a792c10f..a17395e0 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/recovery/StoreFailuresInCachePolicy.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/recovery/StoreFailuresInCachePolicy.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.salesforce.hbase.index.write.recovery; +package org.apache.hadoop.hbase.index.write.recovery; import java.io.IOException; import java.util.List; @@ -26,10 +26,10 @@ import org.apache.hadoop.hbase.regionserver.HRegion; import com.google.common.collect.Multimap; -import com.salesforce.hbase.index.exception.MultiIndexWriteFailureException; -import com.salesforce.hbase.index.table.HTableInterfaceReference; -import com.salesforce.hbase.index.write.IndexFailurePolicy; -import com.salesforce.hbase.index.write.KillServerOnFailurePolicy; +import org.apache.hadoop.hbase.index.exception.MultiIndexWriteFailureException; +import org.apache.hadoop.hbase.index.table.HTableInterfaceReference; +import org.apache.hadoop.hbase.index.write.IndexFailurePolicy; +import org.apache.hadoop.hbase.index.write.KillServerOnFailurePolicy; /** * Tracks any failed writes in The {@link PerRegionIndexWriteCache}, given a diff --git a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/recovery/TrackingParallelWriterIndexCommitter.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/recovery/TrackingParallelWriterIndexCommitter.java similarity index 74% rename from phoenix-core/src/main/java/com/salesforce/hbase/index/write/recovery/TrackingParallelWriterIndexCommitter.java rename to phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/recovery/TrackingParallelWriterIndexCommitter.java index 25f302b7..46a771b5 100644 --- a/phoenix-core/src/main/java/com/salesforce/hbase/index/write/recovery/TrackingParallelWriterIndexCommitter.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/index/write/recovery/TrackingParallelWriterIndexCommitter.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.hbase.index.write.recovery; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.index.write.recovery; import java.util.ArrayList; import java.util.Collection; @@ -46,23 +38,23 @@ import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; import com.google.common.collect.Multimap; -import com.salesforce.hbase.index.CapturingAbortable; -import com.salesforce.hbase.index.exception.MultiIndexWriteFailureException; -import com.salesforce.hbase.index.exception.SingleIndexWriteFailureException; -import com.salesforce.hbase.index.parallel.EarlyExitFailure; -import com.salesforce.hbase.index.parallel.Task; -import com.salesforce.hbase.index.parallel.TaskBatch; -import com.salesforce.hbase.index.parallel.TaskRunner; -import com.salesforce.hbase.index.parallel.ThreadPoolBuilder; -import com.salesforce.hbase.index.parallel.ThreadPoolManager; -import com.salesforce.hbase.index.parallel.WaitForCompletionTaskRunner; -import com.salesforce.hbase.index.table.CachingHTableFactory; -import com.salesforce.hbase.index.table.HTableFactory; -import com.salesforce.hbase.index.table.HTableInterfaceReference; -import com.salesforce.hbase.index.write.IndexCommitter; -import com.salesforce.hbase.index.write.IndexWriter; -import com.salesforce.hbase.index.write.IndexWriterUtils; -import com.salesforce.hbase.index.write.ParallelWriterIndexCommitter; +import org.apache.hadoop.hbase.index.CapturingAbortable; +import org.apache.hadoop.hbase.index.exception.MultiIndexWriteFailureException; +import org.apache.hadoop.hbase.index.exception.SingleIndexWriteFailureException; +import org.apache.hadoop.hbase.index.parallel.EarlyExitFailure; +import org.apache.hadoop.hbase.index.parallel.Task; +import org.apache.hadoop.hbase.index.parallel.TaskBatch; +import org.apache.hadoop.hbase.index.parallel.TaskRunner; +import org.apache.hadoop.hbase.index.parallel.ThreadPoolBuilder; +import org.apache.hadoop.hbase.index.parallel.ThreadPoolManager; +import org.apache.hadoop.hbase.index.parallel.WaitForCompletionTaskRunner; +import org.apache.hadoop.hbase.index.table.CachingHTableFactory; +import org.apache.hadoop.hbase.index.table.HTableFactory; +import org.apache.hadoop.hbase.index.table.HTableInterfaceReference; +import org.apache.hadoop.hbase.index.write.IndexCommitter; +import org.apache.hadoop.hbase.index.write.IndexWriter; +import org.apache.hadoop.hbase.index.write.IndexWriterUtils; +import org.apache.hadoop.hbase.index.write.ParallelWriterIndexCommitter; /** * Like the {@link ParallelWriterIndexCommitter}, but blocks until all writes have attempted to diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexKeyValueSkipListSet.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexKeyValueSkipListSet.java index 6ad31043..8314fef6 100644 --- a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexKeyValueSkipListSet.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexKeyValueSkipListSet.java @@ -1,30 +1,22 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.hadoop.hbase.regionserver; import java.util.Comparator; diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEdit.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEdit.java index e7e2cb53..6749cc93 100644 --- a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEdit.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEdit.java @@ -10,7 +10,7 @@ import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.hbase.index.wal.KeyValueCodec; +import org.apache.hadoop.hbase.index.wal.KeyValueCodec; /** * Read in data for a delegate {@link WALEdit}. This should only be used in concert with an IndexedHLogReader diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEditCodec.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEditCodec.java index cba13724..01d73904 100644 --- a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEditCodec.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEditCodec.java @@ -13,8 +13,8 @@ import org.apache.hadoop.hbase.codec.Decoder; import org.apache.hadoop.hbase.codec.Encoder; -import com.salesforce.hbase.index.wal.IndexedKeyValue; -import com.salesforce.hbase.index.wal.KeyValueCodec; +import org.apache.hadoop.hbase.index.wal.IndexedKeyValue; +import org.apache.hadoop.hbase.index.wal.KeyValueCodec; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/GlobalCache.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/GlobalCache.java similarity index 62% rename from phoenix-core/src/main/java/com/salesforce/phoenix/cache/GlobalCache.java rename to phoenix-core/src/main/java/org/apache/phoenix/cache/GlobalCache.java index 9b2b035e..77684c5c 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/GlobalCache.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/GlobalCache.java @@ -1,35 +1,27 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.cache; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.cache; -import static com.salesforce.phoenix.query.QueryServices.MAX_MEMORY_PERC_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.MAX_MEMORY_WAIT_MS_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.MAX_TENANT_MEMORY_PERC_ATTRIB; +import static org.apache.phoenix.query.QueryServices.MAX_MEMORY_PERC_ATTRIB; +import static org.apache.phoenix.query.QueryServices.MAX_MEMORY_WAIT_MS_ATTRIB; +import static org.apache.phoenix.query.QueryServices.MAX_TENANT_MEMORY_PERC_ATTRIB; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -38,12 +30,12 @@ import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.memory.ChildMemoryManager; -import com.salesforce.phoenix.memory.GlobalMemoryManager; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.PTable; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.memory.ChildMemoryManager; +import org.apache.phoenix.memory.GlobalMemoryManager; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.PTable; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/cache/HashCache.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/HashCache.java new file mode 100644 index 00000000..4260a50b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/HashCache.java @@ -0,0 +1,40 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.cache; + +import java.io.Closeable; +import java.util.List; + +import org.apache.http.annotation.Immutable; + +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * Encapsulate deserialized hash cache from bytes into Map. + * The Map uses the row key as the key and the row as the value. + * @author jtaylor + * @since 0.1 + */ +@Immutable +public interface HashCache extends Closeable { + public List get(ImmutableBytesPtr hashKey); +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/IndexMetaDataCache.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/IndexMetaDataCache.java similarity index 64% rename from phoenix-core/src/main/java/com/salesforce/phoenix/cache/IndexMetaDataCache.java rename to phoenix-core/src/main/java/org/apache/phoenix/cache/IndexMetaDataCache.java index b3eb8b1d..fac78de9 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/IndexMetaDataCache.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/IndexMetaDataCache.java @@ -1,9 +1,9 @@ -package com.salesforce.phoenix.cache; +package org.apache.phoenix.cache; import java.io.Closeable; import java.util.List; -import com.salesforce.phoenix.index.IndexMaintainer; +import org.apache.phoenix.index.IndexMaintainer; public interface IndexMetaDataCache extends Closeable { public List getIndexMaintainers(); diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/ServerCacheClient.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java similarity index 81% rename from phoenix-core/src/main/java/com/salesforce/phoenix/cache/ServerCacheClient.java rename to phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java index 2d9210f9..8703c7c5 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/ServerCacheClient.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.cache; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.cache; import java.io.Closeable; import java.io.IOException; @@ -52,19 +44,19 @@ import org.apache.hadoop.hbase.util.Bytes; import com.google.common.collect.ImmutableSet; -import com.salesforce.phoenix.compile.ScanRanges; -import com.salesforce.phoenix.coprocessor.ServerCachingProtocol; -import com.salesforce.phoenix.coprocessor.ServerCachingProtocol.ServerCacheFactory; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.job.JobManager.JobCallable; -import com.salesforce.phoenix.memory.MemoryManager.MemoryChunk; -import com.salesforce.phoenix.query.ConnectionQueryServices; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.Closeables; -import com.salesforce.phoenix.util.SQLCloseable; -import com.salesforce.phoenix.util.SQLCloseables; +import org.apache.phoenix.compile.ScanRanges; +import org.apache.phoenix.coprocessor.ServerCachingProtocol; +import org.apache.phoenix.coprocessor.ServerCachingProtocol.ServerCacheFactory; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.job.JobManager.JobCallable; +import org.apache.phoenix.memory.MemoryManager.MemoryChunk; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.Closeables; +import org.apache.phoenix.util.SQLCloseable; +import org.apache.phoenix.util.SQLCloseables; /** * diff --git a/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCache.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCache.java new file mode 100644 index 00000000..ad40d8c7 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCache.java @@ -0,0 +1,44 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.cache; + +import java.io.Closeable; +import java.sql.SQLException; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.coprocessor.ServerCachingProtocol.ServerCacheFactory; +import org.apache.phoenix.memory.MemoryManager; + + +/** + * + * Inteface to set and set cached values for a tenant + * + * @author jtaylor + * @since 0.1 + */ +public interface TenantCache { + MemoryManager getMemoryManager(); + Closeable getServerCache(ImmutableBytesPtr cacheId); + Closeable addServerCache(ImmutableBytesPtr cacheId, ImmutableBytesWritable cachePtr, ServerCacheFactory cacheFactory) throws SQLException; + void removeServerCache(ImmutableBytesPtr cacheId) throws SQLException; +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/TenantCacheImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java similarity index 54% rename from phoenix-core/src/main/java/com/salesforce/phoenix/cache/TenantCacheImpl.java rename to phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java index 39f7f5c4..eabeb111 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/TenantCacheImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.cache; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.cache; import java.io.Closeable; import java.sql.SQLException; @@ -35,11 +27,11 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import com.google.common.cache.*; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.coprocessor.ServerCachingProtocol.ServerCacheFactory; -import com.salesforce.phoenix.memory.MemoryManager; -import com.salesforce.phoenix.memory.MemoryManager.MemoryChunk; -import com.salesforce.phoenix.util.Closeables; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.coprocessor.ServerCachingProtocol.ServerCacheFactory; +import org.apache.phoenix.memory.MemoryManager; +import org.apache.phoenix.memory.MemoryManager.MemoryChunk; +import org.apache.phoenix.util.Closeables; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/aggcache/SpillFile.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillFile.java similarity index 99% rename from phoenix-core/src/main/java/com/salesforce/phoenix/cache/aggcache/SpillFile.java rename to phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillFile.java index fa3815bb..f2ad9084 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/aggcache/SpillFile.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillFile.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.cache.aggcache; +package org.apache.phoenix.cache.aggcache; import java.io.Closeable; import java.io.File; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/aggcache/SpillManager.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java similarity index 80% rename from phoenix-core/src/main/java/com/salesforce/phoenix/cache/aggcache/SpillManager.java rename to phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java index b2cc17ae..448ffa57 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/aggcache/SpillManager.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java @@ -1,22 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source - * and binary forms, with or without modification, are permitted provided that the following - * conditions are met: Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. Redistributions in binary form must reproduce - * the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of - * Salesforce.com nor the names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED - * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.cache.aggcache; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.cache.aggcache; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -36,17 +37,17 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.common.io.Closeables; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.ServerAggregators; -import com.salesforce.phoenix.expression.function.SingleAggregateFunction; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.KeyValueSchema; -import com.salesforce.phoenix.schema.ValueBitSet; -import com.salesforce.phoenix.schema.tuple.SingleKeyValueTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.KeyValueUtil; -import com.salesforce.phoenix.util.TupleUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.ServerAggregators; +import org.apache.phoenix.expression.function.SingleAggregateFunction; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.KeyValueSchema; +import org.apache.phoenix.schema.ValueBitSet; +import org.apache.phoenix.schema.tuple.SingleKeyValueTuple; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.KeyValueUtil; +import org.apache.phoenix.util.TupleUtil; /** * Class servers as an adapter between the in-memory LRU cache and the Spill data structures. It diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/aggcache/SpillMap.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillMap.java similarity index 99% rename from phoenix-core/src/main/java/com/salesforce/phoenix/cache/aggcache/SpillMap.java rename to phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillMap.java index 5a8237b9..d93d08c6 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/aggcache/SpillMap.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillMap.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.cache.aggcache; +package org.apache.phoenix.cache.aggcache; import java.io.IOException; import java.nio.BufferOverflowException; @@ -18,7 +18,7 @@ import com.google.common.collect.Maps; import com.google.common.hash.BloomFilter; import com.google.common.hash.Funnels; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; /** * Class implements an active spilled partition serialized tuples are first written into an in-memory data structure diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/aggcache/SpillableGroupByCache.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillableGroupByCache.java similarity index 92% rename from phoenix-core/src/main/java/com/salesforce/phoenix/cache/aggcache/SpillableGroupByCache.java rename to phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillableGroupByCache.java index a2f63aef..41a4e659 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/cache/aggcache/SpillableGroupByCache.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillableGroupByCache.java @@ -1,12 +1,12 @@ -package com.salesforce.phoenix.cache.aggcache; +package org.apache.phoenix.cache.aggcache; -import static com.salesforce.phoenix.query.QueryConstants.AGG_TIMESTAMP; -import static com.salesforce.phoenix.query.QueryConstants.SINGLE_COLUMN; -import static com.salesforce.phoenix.query.QueryConstants.SINGLE_COLUMN_FAMILY; -import static com.salesforce.phoenix.query.QueryServices.GROUPBY_MAX_CACHE_SIZE_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.GROUPBY_SPILL_FILES_ATTRIB; -import static com.salesforce.phoenix.query.QueryServicesOptions.DEFAULT_GROUPBY_MAX_CACHE_MAX; -import static com.salesforce.phoenix.query.QueryServicesOptions.DEFAULT_GROUPBY_SPILL_FILES; +import static org.apache.phoenix.query.QueryConstants.AGG_TIMESTAMP; +import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN; +import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN_FAMILY; +import static org.apache.phoenix.query.QueryServices.GROUPBY_MAX_CACHE_SIZE_ATTRIB; +import static org.apache.phoenix.query.QueryServices.GROUPBY_SPILL_FILES_ATTRIB; +import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_GROUPBY_MAX_CACHE_MAX; +import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_GROUPBY_SPILL_FILES; import java.io.IOException; import java.util.Iterator; @@ -26,18 +26,18 @@ import org.slf4j.LoggerFactory; import com.google.common.io.Closeables; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.cache.GlobalCache; -import com.salesforce.phoenix.cache.TenantCache; -import com.salesforce.phoenix.cache.aggcache.SpillManager.CacheEntry; -import com.salesforce.phoenix.coprocessor.BaseRegionScanner; -import com.salesforce.phoenix.coprocessor.GroupByCache; -import com.salesforce.phoenix.coprocessor.GroupedAggregateRegionObserver; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.ServerAggregators; -import com.salesforce.phoenix.memory.InsufficientMemoryException; -import com.salesforce.phoenix.memory.MemoryManager.MemoryChunk; -import com.salesforce.phoenix.util.KeyValueUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.cache.GlobalCache; +import org.apache.phoenix.cache.TenantCache; +import org.apache.phoenix.cache.aggcache.SpillManager.CacheEntry; +import org.apache.phoenix.coprocessor.BaseRegionScanner; +import org.apache.phoenix.coprocessor.GroupByCache; +import org.apache.phoenix.coprocessor.GroupedAggregateRegionObserver; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.ServerAggregators; +import org.apache.phoenix.memory.InsufficientMemoryException; +import org.apache.phoenix.memory.MemoryManager.MemoryChunk; +import org.apache.phoenix.util.KeyValueUtil; /** * The main entry point is in GroupedAggregateRegionObserver. It instantiates a SpillableGroupByCache and invokes a diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/client/ClientKeyValue.java b/phoenix-core/src/main/java/org/apache/phoenix/client/ClientKeyValue.java similarity index 99% rename from phoenix-core/src/main/java/com/salesforce/phoenix/client/ClientKeyValue.java rename to phoenix-core/src/main/java/org/apache/phoenix/client/ClientKeyValue.java index 39f86e61..3288c4d6 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/client/ClientKeyValue.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/client/ClientKeyValue.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.salesforce.phoenix.client; +package org.apache.phoenix.client; import java.io.DataInput; import java.io.DataOutput; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/client/ClientKeyValueBuilder.java b/phoenix-core/src/main/java/org/apache/phoenix/client/ClientKeyValueBuilder.java new file mode 100644 index 00000000..09e295ad --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/client/ClientKeyValueBuilder.java @@ -0,0 +1,67 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.client; + +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.KeyValue.Type; +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; + +/** + * A {@link KeyValueBuilder} that builds {@link ClientKeyValue}, eliminating the extra byte copies + * inherent in the standard {@link KeyValue} implementation. + *

+ * This {@link KeyValueBuilder} is only supported in HBase 0.94.14+ ( + * {@link PhoenixDatabaseMetaData#CLIENT_KEY_VALUE_BUILDER_THRESHOLD}), with the addition of + * HBASE-9834. + */ +public class ClientKeyValueBuilder extends KeyValueBuilder { + + public static final KeyValueBuilder INSTANCE = new ClientKeyValueBuilder(); + + private ClientKeyValueBuilder() { + // private ctor for singleton + } + + @Override + public KeyValue buildPut(ImmutableBytesWritable row, ImmutableBytesWritable family, + ImmutableBytesWritable qualifier, long ts, ImmutableBytesWritable value) { + return new ClientKeyValue(row, family, qualifier, ts, Type.Put, value); + } + + @Override + public KeyValue buildDeleteFamily(ImmutableBytesWritable row, ImmutableBytesWritable family, + ImmutableBytesWritable qualifier, long ts) { + return new ClientKeyValue(row, family, qualifier, ts, Type.DeleteFamily, null); + } + + @Override + public KeyValue buildDeleteColumns(ImmutableBytesWritable row, ImmutableBytesWritable family, + ImmutableBytesWritable qualifier, long ts) { + return new ClientKeyValue(row, family, qualifier, ts, Type.DeleteColumn, null); + } + + @Override + public KeyValue buildDeleteColumn(ImmutableBytesWritable row, ImmutableBytesWritable family, + ImmutableBytesWritable qualifier, long ts) { + return new ClientKeyValue(row, family, qualifier, ts, Type.Delete, null); + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/client/GenericKeyValueBuilder.java b/phoenix-core/src/main/java/org/apache/phoenix/client/GenericKeyValueBuilder.java similarity index 51% rename from phoenix-core/src/main/java/com/salesforce/phoenix/client/GenericKeyValueBuilder.java rename to phoenix-core/src/main/java/org/apache/phoenix/client/GenericKeyValueBuilder.java index b5529759..b3771ca2 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/client/GenericKeyValueBuilder.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/client/GenericKeyValueBuilder.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.client; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.client; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue.Type; @@ -33,7 +25,7 @@ import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import static com.salesforce.hbase.index.util.ImmutableBytesPtr.copyBytesIfNecessary; +import static org.apache.hadoop.hbase.index.util.ImmutableBytesPtr.copyBytesIfNecessary; /** * {@link KeyValueBuilder} that does simple byte[] copies to build the underlying key-value. This is diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/client/KeyValueBuilder.java b/phoenix-core/src/main/java/org/apache/phoenix/client/KeyValueBuilder.java similarity index 66% rename from phoenix-core/src/main/java/com/salesforce/phoenix/client/KeyValueBuilder.java rename to phoenix-core/src/main/java/org/apache/phoenix/client/KeyValueBuilder.java index 6a57b295..48608ff3 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/client/KeyValueBuilder.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/client/KeyValueBuilder.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.client; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.client; import java.io.IOException; @@ -35,7 +27,7 @@ import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.util.MetaDataUtil; +import org.apache.phoenix.util.MetaDataUtil; /** * Build {@link KeyValue} in an efficient way diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/AggregationManager.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/AggregationManager.java new file mode 100644 index 00000000..70ea3a2b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/AggregationManager.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; + +import org.apache.phoenix.expression.aggregator.ClientAggregators; + +/** + * + * Class that manages aggregations during query compilation + * + * @author jtaylor + * @since 0.1 + */ +public class AggregationManager { + private ClientAggregators aggregators; + private int position = 0; + + public AggregationManager() { + } + + public ClientAggregators getAggregators() { + return aggregators; + } + + /** + * @return allocate the next available zero-based positional index + * for the client-side aggregate function. + */ + protected int nextPosition() { + return position++; + } + + public void setAggregators(ClientAggregators clientAggregator) { + this.aggregators = clientAggregator; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/BindManager.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/BindManager.java new file mode 100644 index 00000000..859d233d --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/BindManager.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; + +import java.sql.ParameterMetaData; +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.jdbc.PhoenixParameterMetaData; +import org.apache.phoenix.parse.BindParseNode; +import org.apache.phoenix.schema.PDatum; + + +/** + * + * Class that manages binding parameters and checking type matching. There are + * two main usages: + * + * 1) the standard query case where we have the values for the binds. + * 2) the retrieve param metadata case where we don't have the bind values. + * + * In both cases, during query compilation we figure out what type the bind variable + * "should" be, based on how it's used in the query. For example foo < ? would expect + * that the bind variable type matches or can be coerced to the type of foo. For (1), + * we check that the bind value has the correct type and for (2) we set the param + * metadata type. + * + * @author jtaylor + * @since 0.1 + */ +public class BindManager { + public static final Object UNBOUND_PARAMETER = new Object(); + + private final List binds; + private final PhoenixParameterMetaData bindMetaData; + + public BindManager(List binds) { + this.binds = binds; + this.bindMetaData = new PhoenixParameterMetaData(binds.size()); + } + + public ParameterMetaData getParameterMetaData() { + return bindMetaData; + } + + public Object getBindValue(BindParseNode node) throws SQLException { + int index = node.getIndex(); + if (index < 0 || index >= binds.size()) { + throw new SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_INDEX_OUT_OF_BOUND) + .setMessage("binds size: " + binds.size() + "; index: " + index).build().buildException(); + } + Object value = binds.get(index); + if (value == UNBOUND_PARAMETER) { + throw new SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_VALUE_UNBOUND) + .setMessage(node.toString()).build().buildException(); + } + return value; + } + + public void addParamMetaData(BindParseNode bind, PDatum column) throws SQLException { + bindMetaData.addParam(bind,column); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ColumnProjector.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ColumnProjector.java new file mode 100644 index 00000000..8c1697b7 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ColumnProjector.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; + +import java.sql.SQLException; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + + + +/** + * + * Interface used to access the value of a projected column. + * + * @author jtaylor + * @since 0.1 + */ +public interface ColumnProjector { + /** + * Get the column name as it was referenced in the query + * @return the database column name + */ + String getName(); + + /** + * Get the expression + * @return the expression for the column projector + */ + public Expression getExpression(); + + // TODO: An expression may contain references to multiple tables. + /** + * Get the name of the hbase table containing the column + * @return the hbase table name + */ + String getTableName(); + + /** + * Get the value of the column, coercing it if necessary to the specified type + * @param tuple the row containing the column + * @param type the type to which to coerce the binary value + * @param ptr used to retrieve the value + * @return the object representation of the column value. + * @throws SQLException + */ + Object getValue(Tuple tuple, PDataType type, ImmutableBytesWritable ptr) throws SQLException; + + boolean isCaseSensitive(); +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ColumnResolver.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ColumnResolver.java new file mode 100644 index 00000000..49a19477 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ColumnResolver.java @@ -0,0 +1,55 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.schema.ColumnRef; +import org.apache.phoenix.schema.TableRef; + + + +/** + * + * Interface used to resolve column references occurring + * in the select statement. + * + * @author jtaylor + * @since 0.1 + */ +public interface ColumnResolver { + + /** + * Returns the collection of resolved tables in the FROM clause. + */ + public List getTables(); + + /** + * Resolves column using name and alias. + * @param schemaName TODO + * @param tableName TODO + * @param colName TODO + * @return the resolved ColumnRef + * @throws ColumnNotFoundException if the column could not be resolved + * @throws AmbiguousColumnException if the column name is ambiguous + */ + public ColumnRef resolveColumn(String schemaName, String tableName, String colName) throws SQLException; +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateIndexCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateIndexCompiler.java new file mode 100644 index 00000000..718d09a3 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateIndexCompiler.java @@ -0,0 +1,88 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; + +import java.sql.ParameterMetaData; +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + +import org.apache.hadoop.hbase.client.Scan; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixStatement; +import org.apache.phoenix.parse.CreateIndexStatement; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.schema.MetaDataClient; + +public class CreateIndexCompiler { + private final PhoenixStatement statement; + + public CreateIndexCompiler(PhoenixStatement statement) { + this.statement = statement; + } + + public MutationPlan compile(final CreateIndexStatement create) throws SQLException { + final PhoenixConnection connection = statement.getConnection(); + final ColumnResolver resolver = FromCompiler.getResolver(create, connection); + Scan scan = new Scan(); + final StatementContext context = new StatementContext(statement, resolver, statement.getParameters(), scan); + ExpressionCompiler expressionCompiler = new ExpressionCompiler(context); + List splitNodes = create.getSplitNodes(); + final byte[][] splits = new byte[splitNodes.size()][]; + for (int i = 0; i < splits.length; i++) { + ParseNode node = splitNodes.get(i); + if (!node.isStateless()) { + throw new SQLExceptionInfo.Builder(SQLExceptionCode.SPLIT_POINT_NOT_CONSTANT) + .setMessage("Node: " + node).build().buildException(); + } + LiteralExpression expression = (LiteralExpression)node.accept(expressionCompiler); + splits[i] = expression.getBytes(); + } + final MetaDataClient client = new MetaDataClient(connection); + + return new MutationPlan() { + + @Override + public ParameterMetaData getParameterMetaData() { + return context.getBindManager().getParameterMetaData(); + } + + @Override + public PhoenixConnection getConnection() { + return connection; + } + + @Override + public MutationState execute() throws SQLException { + return client.createIndex(create, splits); + } + + @Override + public ExplainPlan getExplainPlan() throws SQLException { + return new ExplainPlan(Collections.singletonList("CREATE INDEX")); + } + }; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/CreateSequenceCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateSequenceCompiler.java similarity index 72% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/CreateSequenceCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/CreateSequenceCompiler.java index 0b5899d3..1a22f110 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/CreateSequenceCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateSequenceCompiler.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.ParameterMetaData; import java.sql.SQLException; @@ -34,21 +26,21 @@ import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixStatement; -import com.salesforce.phoenix.parse.BindParseNode; -import com.salesforce.phoenix.parse.CreateSequenceStatement; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.MetaDataClient; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PDatum; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixStatement; +import org.apache.phoenix.parse.BindParseNode; +import org.apache.phoenix.parse.CreateSequenceStatement; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.MetaDataClient; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PDatum; public class CreateSequenceCompiler { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/CreateTableCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateTableCompiler.java similarity index 71% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/CreateTableCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/CreateTableCompiler.java index 39e1b7db..5e224f0a 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/CreateTableCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateTableCompiler.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.ParameterMetaData; import java.sql.SQLException; @@ -38,28 +30,28 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import com.google.common.collect.Iterators; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.expression.AndExpression; -import com.salesforce.phoenix.expression.ComparisonExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.IsNullExpression; -import com.salesforce.phoenix.expression.KeyValueColumnExpression; -import com.salesforce.phoenix.expression.RowKeyColumnExpression; -import com.salesforce.phoenix.expression.visitor.TraverseNoExpressionVisitor; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixStatement; -import com.salesforce.phoenix.parse.CreateTableStatement; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.query.DelegateConnectionQueryServices; -import com.salesforce.phoenix.schema.MetaDataClient; -import com.salesforce.phoenix.schema.PMetaData; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTable.ViewType; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.ByteUtil; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.expression.AndExpression; +import org.apache.phoenix.expression.ComparisonExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.IsNullExpression; +import org.apache.phoenix.expression.KeyValueColumnExpression; +import org.apache.phoenix.expression.RowKeyColumnExpression; +import org.apache.phoenix.expression.visitor.TraverseNoExpressionVisitor; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixStatement; +import org.apache.phoenix.parse.CreateTableStatement; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.query.DelegateConnectionQueryServices; +import org.apache.phoenix.schema.MetaDataClient; +import org.apache.phoenix.schema.PMetaData; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTable.ViewType; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.ByteUtil; public class CreateTableCompiler { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/DeleteCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java similarity index 79% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/DeleteCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java index 8e94b1f1..02dd4bb2 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/DeleteCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.ParameterMetaData; import java.sql.ResultSet; @@ -41,43 +33,43 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.cache.ServerCacheClient.ServerCache; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.compile.OrderByCompiler.OrderBy; -import com.salesforce.phoenix.coprocessor.UngroupedAggregateRegionObserver; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.execute.AggregatePlan; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.index.IndexMetaDataCacheClient; -import com.salesforce.phoenix.index.PhoenixIndexCodec; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixResultSet; -import com.salesforce.phoenix.jdbc.PhoenixStatement; -import com.salesforce.phoenix.optimize.QueryOptimizer; -import com.salesforce.phoenix.parse.AliasedNode; -import com.salesforce.phoenix.parse.DeleteStatement; -import com.salesforce.phoenix.parse.HintNode; -import com.salesforce.phoenix.parse.HintNode.Hint; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.parse.ParseNodeFactory; -import com.salesforce.phoenix.parse.SelectStatement; -import com.salesforce.phoenix.query.ConnectionQueryServices; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PRow; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.ReadOnlyTableException; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.IndexUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.cache.ServerCacheClient.ServerCache; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.compile.OrderByCompiler.OrderBy; +import org.apache.phoenix.coprocessor.UngroupedAggregateRegionObserver; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.execute.AggregatePlan; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.index.IndexMetaDataCacheClient; +import org.apache.phoenix.index.PhoenixIndexCodec; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixResultSet; +import org.apache.phoenix.jdbc.PhoenixStatement; +import org.apache.phoenix.optimize.QueryOptimizer; +import org.apache.phoenix.parse.AliasedNode; +import org.apache.phoenix.parse.DeleteStatement; +import org.apache.phoenix.parse.HintNode; +import org.apache.phoenix.parse.HintNode.Hint; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.parse.ParseNodeFactory; +import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PRow; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.ReadOnlyTableException; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.IndexUtil; public class DeleteCompiler { private static ParseNodeFactory FACTORY = new ParseNodeFactory(); diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/DropSequenceCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/DropSequenceCompiler.java new file mode 100644 index 00000000..be53f6b2 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/DropSequenceCompiler.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; + +import java.sql.ParameterMetaData; +import java.sql.SQLException; +import java.util.Collections; + +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixParameterMetaData; +import org.apache.phoenix.jdbc.PhoenixStatement; +import org.apache.phoenix.parse.DropSequenceStatement; +import org.apache.phoenix.schema.MetaDataClient; + + +public class DropSequenceCompiler { + private final PhoenixStatement statement; + + public DropSequenceCompiler(PhoenixStatement statement) { + this.statement = statement; + } + + + public MutationPlan compile(final DropSequenceStatement sequence) throws SQLException { + final PhoenixConnection connection = statement.getConnection(); + final MetaDataClient client = new MetaDataClient(connection); + return new MutationPlan() { + + @Override + public MutationState execute() throws SQLException { + return client.dropSequence(sequence); + } + + @Override + public ExplainPlan getExplainPlan() throws SQLException { + return new ExplainPlan(Collections.singletonList("DROP SEQUENCE")); + } + + @Override + public PhoenixConnection getConnection() { + return connection; + } + + @Override + public ParameterMetaData getParameterMetaData() { + return PhoenixParameterMetaData.EMPTY_PARAMETER_META_DATA; + } + + }; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExplainPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExplainPlan.java new file mode 100644 index 00000000..e1049a04 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExplainPlan.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; + +import java.util.Collections; +import java.util.List; + +import com.google.common.collect.ImmutableList; + +public class ExplainPlan { + public static final ExplainPlan EMPTY_PLAN = new ExplainPlan(Collections.emptyList()); + + private final List planSteps; + + public ExplainPlan(List planSteps) { + this.planSteps = ImmutableList.copyOf(planSteps); + } + + public List getPlanSteps() { + return planSteps; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExpressionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java similarity index 91% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExpressionCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java index 5b729eae..cd2b0e27 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExpressionCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.math.BigDecimal; import java.sql.SQLException; @@ -40,79 +32,79 @@ import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.expression.AndExpression; -import com.salesforce.phoenix.expression.ArrayConstructorExpression; -import com.salesforce.phoenix.expression.CaseExpression; -import com.salesforce.phoenix.expression.CoerceExpression; -import com.salesforce.phoenix.expression.ComparisonExpression; -import com.salesforce.phoenix.expression.DateAddExpression; -import com.salesforce.phoenix.expression.DateSubtractExpression; -import com.salesforce.phoenix.expression.DecimalAddExpression; -import com.salesforce.phoenix.expression.DecimalDivideExpression; -import com.salesforce.phoenix.expression.DecimalMultiplyExpression; -import com.salesforce.phoenix.expression.DecimalSubtractExpression; -import com.salesforce.phoenix.expression.DoubleAddExpression; -import com.salesforce.phoenix.expression.DoubleDivideExpression; -import com.salesforce.phoenix.expression.DoubleMultiplyExpression; -import com.salesforce.phoenix.expression.DoubleSubtractExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.InListExpression; -import com.salesforce.phoenix.expression.IsNullExpression; -import com.salesforce.phoenix.expression.LikeExpression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.expression.LongAddExpression; -import com.salesforce.phoenix.expression.LongDivideExpression; -import com.salesforce.phoenix.expression.LongMultiplyExpression; -import com.salesforce.phoenix.expression.LongSubtractExpression; -import com.salesforce.phoenix.expression.NotExpression; -import com.salesforce.phoenix.expression.OrExpression; -import com.salesforce.phoenix.expression.RowKeyColumnExpression; -import com.salesforce.phoenix.expression.RowValueConstructorExpression; -import com.salesforce.phoenix.expression.StringConcatExpression; -import com.salesforce.phoenix.expression.TimestampAddExpression; -import com.salesforce.phoenix.expression.TimestampSubtractExpression; -import com.salesforce.phoenix.parse.AddParseNode; -import com.salesforce.phoenix.parse.AndParseNode; -import com.salesforce.phoenix.parse.ArithmeticParseNode; -import com.salesforce.phoenix.parse.ArrayConstructorNode; -import com.salesforce.phoenix.parse.BindParseNode; -import com.salesforce.phoenix.parse.CaseParseNode; -import com.salesforce.phoenix.parse.CastParseNode; -import com.salesforce.phoenix.parse.ColumnParseNode; -import com.salesforce.phoenix.parse.ComparisonParseNode; -import com.salesforce.phoenix.parse.DivideParseNode; -import com.salesforce.phoenix.parse.FunctionParseNode; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo; -import com.salesforce.phoenix.parse.InListParseNode; -import com.salesforce.phoenix.parse.IsNullParseNode; -import com.salesforce.phoenix.parse.LikeParseNode; -import com.salesforce.phoenix.parse.LiteralParseNode; -import com.salesforce.phoenix.parse.MultiplyParseNode; -import com.salesforce.phoenix.parse.NotParseNode; -import com.salesforce.phoenix.parse.OrParseNode; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.parse.RowValueConstructorParseNode; -import com.salesforce.phoenix.parse.SequenceValueParseNode; -import com.salesforce.phoenix.parse.StringConcatParseNode; -import com.salesforce.phoenix.parse.SubtractParseNode; -import com.salesforce.phoenix.parse.UnsupportedAllParseNodeVisitor; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.ColumnRef; -import com.salesforce.phoenix.schema.DelegateDatum; -import com.salesforce.phoenix.schema.PArrayDataType; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PDatum; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.RowKeyValueAccessor; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.schema.TypeMismatchException; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.expression.AndExpression; +import org.apache.phoenix.expression.ArrayConstructorExpression; +import org.apache.phoenix.expression.CaseExpression; +import org.apache.phoenix.expression.CoerceExpression; +import org.apache.phoenix.expression.ComparisonExpression; +import org.apache.phoenix.expression.DateAddExpression; +import org.apache.phoenix.expression.DateSubtractExpression; +import org.apache.phoenix.expression.DecimalAddExpression; +import org.apache.phoenix.expression.DecimalDivideExpression; +import org.apache.phoenix.expression.DecimalMultiplyExpression; +import org.apache.phoenix.expression.DecimalSubtractExpression; +import org.apache.phoenix.expression.DoubleAddExpression; +import org.apache.phoenix.expression.DoubleDivideExpression; +import org.apache.phoenix.expression.DoubleMultiplyExpression; +import org.apache.phoenix.expression.DoubleSubtractExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.InListExpression; +import org.apache.phoenix.expression.IsNullExpression; +import org.apache.phoenix.expression.LikeExpression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.LongAddExpression; +import org.apache.phoenix.expression.LongDivideExpression; +import org.apache.phoenix.expression.LongMultiplyExpression; +import org.apache.phoenix.expression.LongSubtractExpression; +import org.apache.phoenix.expression.NotExpression; +import org.apache.phoenix.expression.OrExpression; +import org.apache.phoenix.expression.RowKeyColumnExpression; +import org.apache.phoenix.expression.RowValueConstructorExpression; +import org.apache.phoenix.expression.StringConcatExpression; +import org.apache.phoenix.expression.TimestampAddExpression; +import org.apache.phoenix.expression.TimestampSubtractExpression; +import org.apache.phoenix.parse.AddParseNode; +import org.apache.phoenix.parse.AndParseNode; +import org.apache.phoenix.parse.ArithmeticParseNode; +import org.apache.phoenix.parse.ArrayConstructorNode; +import org.apache.phoenix.parse.BindParseNode; +import org.apache.phoenix.parse.CaseParseNode; +import org.apache.phoenix.parse.CastParseNode; +import org.apache.phoenix.parse.ColumnParseNode; +import org.apache.phoenix.parse.ComparisonParseNode; +import org.apache.phoenix.parse.DivideParseNode; +import org.apache.phoenix.parse.FunctionParseNode; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo; +import org.apache.phoenix.parse.InListParseNode; +import org.apache.phoenix.parse.IsNullParseNode; +import org.apache.phoenix.parse.LikeParseNode; +import org.apache.phoenix.parse.LiteralParseNode; +import org.apache.phoenix.parse.MultiplyParseNode; +import org.apache.phoenix.parse.NotParseNode; +import org.apache.phoenix.parse.OrParseNode; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.parse.RowValueConstructorParseNode; +import org.apache.phoenix.parse.SequenceValueParseNode; +import org.apache.phoenix.parse.StringConcatParseNode; +import org.apache.phoenix.parse.SubtractParseNode; +import org.apache.phoenix.parse.UnsupportedAllParseNodeVisitor; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.ColumnRef; +import org.apache.phoenix.schema.DelegateDatum; +import org.apache.phoenix.schema.PArrayDataType; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PDatum; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.RowKeyValueAccessor; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.schema.TypeMismatchException; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.SchemaUtil; public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor { diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionManager.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionManager.java new file mode 100644 index 00000000..f66e61f8 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionManager.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; + +import java.util.Iterator; +import java.util.Map; + + +import com.google.common.collect.Maps; +import org.apache.phoenix.expression.Expression; + +/** + * + * Class to manage list of expressions inside of a select statement by + * deduping them. + * + * @author jtaylor + * @since 0.1 + */ +public class ExpressionManager { + // Use a Map instead of a Set because we need to get and return + // the existing Expression + private final Map expressionMap; + + public ExpressionManager() { + expressionMap = Maps.newHashMap(); + } + + /** + * Add the expression to the set of known expressions for the select + * clause. If the expression is already in the set, then the new one + * passed in is ignored. + * @param expression the new expression to add + * @return the new expression if not already present in the set and + * the existing one otherwise. + */ + public Expression addIfAbsent(Expression expression) { + Expression existingExpression = expressionMap.get(expression); + if (existingExpression == null) { + expressionMap.put(expression, expression); + return expression; + } + return existingExpression; + } + + public int getExpressionCount() { + return expressionMap.size(); + } + + public Iterator getExpressions() { + return expressionMap.keySet().iterator(); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionProjector.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionProjector.java new file mode 100644 index 00000000..8b30f0fd --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionProjector.java @@ -0,0 +1,93 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; + + +import java.sql.SQLException; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + + + +/** + * + * Projector for getting value from a select statement for an expression + * + * @author jtaylor + * @since 0.1 + */ +public class ExpressionProjector implements ColumnProjector { + private final String name; + private final Expression expression; + private final String tableName; + private final boolean isCaseSensitive; + + public ExpressionProjector(String name, String tableName, Expression expression, boolean isCaseSensitive) { + this.name = name; + this.expression = expression; + this.tableName = tableName; + this.isCaseSensitive = isCaseSensitive; + } + + @Override + public String getTableName() { + return tableName; + } + + @Override + public Expression getExpression() { + return expression; + } + + @Override + public String getName() { + return name; + } + + @Override + public final Object getValue(Tuple tuple, PDataType type, ImmutableBytesWritable ptr) throws SQLException { + try { + Expression expression = getExpression(); + if (!expression.evaluate(tuple, ptr)) { + return null; + } + if (ptr.getLength() == 0) { + return null; + } + return type.toObject(ptr, expression.getDataType(), expression.getColumnModifier()); + } catch (RuntimeException e) { + // FIXME: Expression.evaluate does not throw SQLException + // so this will unwrap throws from that. + if (e.getCause() instanceof SQLException) { + throw (SQLException) e.getCause(); + } + throw e; + } + } + + @Override + public boolean isCaseSensitive() { + return isCaseSensitive; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/FromCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java similarity index 84% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/FromCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java index 288a091d..2e20f015 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/FromCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java @@ -1,19 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the following conditions are met: Redistributions of source code - * must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in - * binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of Salesforce.com nor the names - * of its contributors may be used to endorse or promote products derived from this software without specific prior - * written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; @@ -32,39 +36,39 @@ import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.common.io.Closeables; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.parse.BindTableNode; -import com.salesforce.phoenix.parse.ColumnDef; -import com.salesforce.phoenix.parse.CreateTableStatement; -import com.salesforce.phoenix.parse.DerivedTableNode; -import com.salesforce.phoenix.parse.JoinTableNode; -import com.salesforce.phoenix.parse.NamedTableNode; -import com.salesforce.phoenix.parse.SelectStatement; -import com.salesforce.phoenix.parse.SingleTableSQLStatement; -import com.salesforce.phoenix.parse.TableName; -import com.salesforce.phoenix.parse.TableNode; -import com.salesforce.phoenix.parse.TableNodeVisitor; -import com.salesforce.phoenix.query.ConnectionQueryServices; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.AmbiguousColumnException; -import com.salesforce.phoenix.schema.AmbiguousTableException; -import com.salesforce.phoenix.schema.ColumnFamilyNotFoundException; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.ColumnRef; -import com.salesforce.phoenix.schema.MetaDataClient; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PColumnFamily; -import com.salesforce.phoenix.schema.PColumnFamilyImpl; -import com.salesforce.phoenix.schema.PColumnImpl; -import com.salesforce.phoenix.schema.PName; -import com.salesforce.phoenix.schema.PNameFactory; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTableImpl; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.TableNotFoundException; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.parse.BindTableNode; +import org.apache.phoenix.parse.ColumnDef; +import org.apache.phoenix.parse.CreateTableStatement; +import org.apache.phoenix.parse.DerivedTableNode; +import org.apache.phoenix.parse.JoinTableNode; +import org.apache.phoenix.parse.NamedTableNode; +import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.parse.SingleTableSQLStatement; +import org.apache.phoenix.parse.TableName; +import org.apache.phoenix.parse.TableNode; +import org.apache.phoenix.parse.TableNodeVisitor; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.AmbiguousColumnException; +import org.apache.phoenix.schema.AmbiguousTableException; +import org.apache.phoenix.schema.ColumnFamilyNotFoundException; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.ColumnRef; +import org.apache.phoenix.schema.MetaDataClient; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PColumnFamily; +import org.apache.phoenix.schema.PColumnFamilyImpl; +import org.apache.phoenix.schema.PColumnImpl; +import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.PNameFactory; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableImpl; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.TableNotFoundException; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.SchemaUtil; /** * Validates FROM clause and builds a ColumnResolver for resolving column references diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/GroupByCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/GroupByCompiler.java similarity index 80% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/GroupByCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/GroupByCompiler.java index bebb759d..e9b08f85 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/GroupByCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/GroupByCompiler.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.SQLException; import java.util.ArrayList; @@ -37,20 +29,20 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import com.salesforce.phoenix.compile.TrackOrderPreservingExpressionCompiler.Entry; -import com.salesforce.phoenix.compile.TrackOrderPreservingExpressionCompiler.Ordering; -import com.salesforce.phoenix.coprocessor.GroupedAggregateRegionObserver; -import com.salesforce.phoenix.coprocessor.UngroupedAggregateRegionObserver; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.expression.CoerceExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.AliasedNode; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.parse.SelectStatement; -import com.salesforce.phoenix.schema.AmbiguousColumnException; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.PDataType; +import org.apache.phoenix.compile.TrackOrderPreservingExpressionCompiler.Entry; +import org.apache.phoenix.compile.TrackOrderPreservingExpressionCompiler.Ordering; +import org.apache.phoenix.coprocessor.GroupedAggregateRegionObserver; +import org.apache.phoenix.coprocessor.UngroupedAggregateRegionObserver; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.expression.CoerceExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.AliasedNode; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.schema.AmbiguousColumnException; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.PDataType; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/HavingCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/HavingCompiler.java similarity index 69% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/HavingCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/HavingCompiler.java index 0d8a0003..857d48ab 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/HavingCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/HavingCompiler.java @@ -1,61 +1,53 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.SQLException; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.parse.AddParseNode; -import com.salesforce.phoenix.parse.AndParseNode; -import com.salesforce.phoenix.parse.BetweenParseNode; -import com.salesforce.phoenix.parse.CaseParseNode; -import com.salesforce.phoenix.parse.ColumnParseNode; -import com.salesforce.phoenix.parse.ComparisonParseNode; -import com.salesforce.phoenix.parse.DivideParseNode; -import com.salesforce.phoenix.parse.FunctionParseNode; -import com.salesforce.phoenix.parse.IsNullParseNode; -import com.salesforce.phoenix.parse.MultiplyParseNode; -import com.salesforce.phoenix.parse.OrParseNode; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.parse.SelectStatement; -import com.salesforce.phoenix.parse.SelectStatementRewriter; -import com.salesforce.phoenix.parse.SubtractParseNode; -import com.salesforce.phoenix.parse.TraverseNoParseNodeVisitor; -import com.salesforce.phoenix.schema.ColumnRef; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.TypeMismatchException; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.parse.AddParseNode; +import org.apache.phoenix.parse.AndParseNode; +import org.apache.phoenix.parse.BetweenParseNode; +import org.apache.phoenix.parse.CaseParseNode; +import org.apache.phoenix.parse.ColumnParseNode; +import org.apache.phoenix.parse.ComparisonParseNode; +import org.apache.phoenix.parse.DivideParseNode; +import org.apache.phoenix.parse.FunctionParseNode; +import org.apache.phoenix.parse.IsNullParseNode; +import org.apache.phoenix.parse.MultiplyParseNode; +import org.apache.phoenix.parse.OrParseNode; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.parse.SelectStatementRewriter; +import org.apache.phoenix.parse.SubtractParseNode; +import org.apache.phoenix.parse.TraverseNoParseNodeVisitor; +import org.apache.phoenix.schema.ColumnRef; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.TypeMismatchException; public class HavingCompiler { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/IndexStatementRewriter.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/IndexStatementRewriter.java similarity index 86% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/IndexStatementRewriter.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/IndexStatementRewriter.java index b4383c21..84ac0a11 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/IndexStatementRewriter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/IndexStatementRewriter.java @@ -1,20 +1,20 @@ -package com.salesforce.phoenix.compile; +package org.apache.phoenix.compile; import java.sql.SQLException; import java.util.Map; -import com.salesforce.phoenix.parse.ColumnParseNode; -import com.salesforce.phoenix.parse.FamilyWildcardParseNode; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.parse.ParseNodeFactory; -import com.salesforce.phoenix.parse.ParseNodeRewriter; -import com.salesforce.phoenix.parse.SelectStatement; -import com.salesforce.phoenix.parse.TableName; -import com.salesforce.phoenix.parse.WildcardParseNode; -import com.salesforce.phoenix.schema.ColumnRef; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.IndexUtil; +import org.apache.phoenix.parse.ColumnParseNode; +import org.apache.phoenix.parse.FamilyWildcardParseNode; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.parse.ParseNodeFactory; +import org.apache.phoenix.parse.ParseNodeRewriter; +import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.parse.TableName; +import org.apache.phoenix.parse.WildcardParseNode; +import org.apache.phoenix.schema.ColumnRef; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.IndexUtil; public class IndexStatementRewriter extends ParseNodeRewriter { private static final ParseNodeFactory FACTORY = new ParseNodeFactory(); diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/JoinCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java similarity index 91% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/JoinCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java index 807509f1..38c31b8c 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/JoinCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java @@ -1,33 +1,25 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; -import static com.salesforce.phoenix.schema.SaltingUtil.SALTING_COLUMN; +import static org.apache.phoenix.schema.SaltingUtil.SALTING_COLUMN; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; @@ -48,56 +40,56 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.expression.AndExpression; -import com.salesforce.phoenix.expression.CoerceExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.jdbc.PhoenixStatement; -import com.salesforce.phoenix.join.ScanProjector; -import com.salesforce.phoenix.parse.AliasedNode; -import com.salesforce.phoenix.parse.AndParseNode; -import com.salesforce.phoenix.parse.BetweenParseNode; -import com.salesforce.phoenix.parse.BindTableNode; -import com.salesforce.phoenix.parse.CaseParseNode; -import com.salesforce.phoenix.parse.CastParseNode; -import com.salesforce.phoenix.parse.ColumnParseNode; -import com.salesforce.phoenix.parse.ComparisonParseNode; -import com.salesforce.phoenix.parse.ConcreteTableNode; -import com.salesforce.phoenix.parse.DerivedTableNode; -import com.salesforce.phoenix.parse.EqualParseNode; -import com.salesforce.phoenix.parse.FunctionParseNode; -import com.salesforce.phoenix.parse.InListParseNode; -import com.salesforce.phoenix.parse.IsNullParseNode; -import com.salesforce.phoenix.parse.JoinTableNode; -import com.salesforce.phoenix.parse.JoinTableNode.JoinType; -import com.salesforce.phoenix.parse.LikeParseNode; -import com.salesforce.phoenix.parse.NamedTableNode; -import com.salesforce.phoenix.parse.NotParseNode; -import com.salesforce.phoenix.parse.OrParseNode; -import com.salesforce.phoenix.parse.OrderByNode; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.parse.ParseNodeFactory; -import com.salesforce.phoenix.parse.SelectStatement; -import com.salesforce.phoenix.parse.StatelessTraverseAllParseNodeVisitor; -import com.salesforce.phoenix.parse.TableName; -import com.salesforce.phoenix.parse.TableNode; -import com.salesforce.phoenix.parse.TableNodeVisitor; -import com.salesforce.phoenix.parse.TraverseNoParseNodeVisitor; -import com.salesforce.phoenix.parse.WildcardParseNode; -import com.salesforce.phoenix.schema.AmbiguousColumnException; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.ColumnRef; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PColumnImpl; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PName; -import com.salesforce.phoenix.schema.PNameFactory; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTableImpl; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.expression.AndExpression; +import org.apache.phoenix.expression.CoerceExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.jdbc.PhoenixStatement; +import org.apache.phoenix.join.ScanProjector; +import org.apache.phoenix.parse.AliasedNode; +import org.apache.phoenix.parse.AndParseNode; +import org.apache.phoenix.parse.BetweenParseNode; +import org.apache.phoenix.parse.BindTableNode; +import org.apache.phoenix.parse.CaseParseNode; +import org.apache.phoenix.parse.CastParseNode; +import org.apache.phoenix.parse.ColumnParseNode; +import org.apache.phoenix.parse.ComparisonParseNode; +import org.apache.phoenix.parse.ConcreteTableNode; +import org.apache.phoenix.parse.DerivedTableNode; +import org.apache.phoenix.parse.EqualParseNode; +import org.apache.phoenix.parse.FunctionParseNode; +import org.apache.phoenix.parse.InListParseNode; +import org.apache.phoenix.parse.IsNullParseNode; +import org.apache.phoenix.parse.JoinTableNode; +import org.apache.phoenix.parse.JoinTableNode.JoinType; +import org.apache.phoenix.parse.LikeParseNode; +import org.apache.phoenix.parse.NamedTableNode; +import org.apache.phoenix.parse.NotParseNode; +import org.apache.phoenix.parse.OrParseNode; +import org.apache.phoenix.parse.OrderByNode; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.parse.ParseNodeFactory; +import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.parse.StatelessTraverseAllParseNodeVisitor; +import org.apache.phoenix.parse.TableName; +import org.apache.phoenix.parse.TableNode; +import org.apache.phoenix.parse.TableNodeVisitor; +import org.apache.phoenix.parse.TraverseNoParseNodeVisitor; +import org.apache.phoenix.parse.WildcardParseNode; +import org.apache.phoenix.schema.AmbiguousColumnException; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.ColumnRef; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PColumnImpl; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.PNameFactory; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableImpl; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.SchemaUtil; public class JoinCompiler { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/KeyPart.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/KeyPart.java similarity index 50% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/KeyPart.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/KeyPart.java index d4622dc2..1c8b0eb8 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/KeyPart.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/KeyPart.java @@ -1,39 +1,31 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.util.List; import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.schema.PColumn; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.schema.PColumn; /** * @@ -58,7 +50,7 @@ public interface KeyPart { * @return the key range that encompasses the range for the * expression for which this keyPart is associated * - * @see com.salesforce.phoenix.expression.function.ScalarFunction#newKeyPart(KeyPart) + * @see org.apache.phoenix.expression.function.ScalarFunction#newKeyPart(KeyPart) */ public KeyRange getKeyRange(CompareOp op, Expression rhs); diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/LimitCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/LimitCompiler.java similarity index 60% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/LimitCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/LimitCompiler.java index 538183c1..5c4cbb21 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/LimitCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/LimitCompiler.java @@ -1,36 +1,28 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.SQLException; -import com.salesforce.phoenix.parse.*; -import com.salesforce.phoenix.schema.*; +import org.apache.phoenix.parse.*; +import org.apache.phoenix.schema.*; public class LimitCompiler { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/MutatingParallelIteratorFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/MutatingParallelIteratorFactory.java similarity index 51% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/MutatingParallelIteratorFactory.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/MutatingParallelIteratorFactory.java index a78aa525..b19af439 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/MutatingParallelIteratorFactory.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/MutatingParallelIteratorFactory.java @@ -1,55 +1,47 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; -import static com.salesforce.phoenix.query.QueryConstants.AGG_TIMESTAMP; -import static com.salesforce.phoenix.query.QueryConstants.SINGLE_COLUMN; -import static com.salesforce.phoenix.query.QueryConstants.SINGLE_COLUMN_FAMILY; -import static com.salesforce.phoenix.query.QueryConstants.UNGROUPED_AGG_ROW_KEY; +import static org.apache.phoenix.query.QueryConstants.AGG_TIMESTAMP; +import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN; +import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN_FAMILY; +import static org.apache.phoenix.query.QueryConstants.UNGROUPED_AGG_ROW_KEY; import java.sql.SQLException; import java.util.List; import org.apache.hadoop.hbase.KeyValue; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; -import com.salesforce.phoenix.iterate.PeekingResultIterator; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.query.ConnectionQueryServices; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.schema.tuple.SingleKeyValueTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.KeyValueUtil; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; +import org.apache.phoenix.iterate.PeekingResultIterator; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.schema.tuple.SingleKeyValueTuple; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.KeyValueUtil; /** * Factory class used to instantiate an iterator to handle mutations made during a parallel scan. diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java new file mode 100644 index 00000000..11fd2cd6 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java @@ -0,0 +1,31 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; + +import java.sql.SQLException; + +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.jdbc.PhoenixConnection; + + +public interface MutationPlan extends StatementPlan { + public PhoenixConnection getConnection(); + public MutationState execute() throws SQLException; +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/OrderByCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/OrderByCompiler.java similarity index 63% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/OrderByCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/OrderByCompiler.java index f7c85351..61c0fcc5 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/OrderByCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/OrderByCompiler.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.SQLException; @@ -36,15 +28,16 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.compile.TrackOrderPreservingExpressionCompiler.Ordering; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.OrderByExpression; -import com.salesforce.phoenix.parse.FilterableStatement; -import com.salesforce.phoenix.parse.OrderByNode; -import com.salesforce.phoenix.schema.ColumnModifier; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.compile.TrackOrderPreservingExpressionCompiler.Ordering; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.OrderByExpression; +import org.apache.phoenix.parse.FilterableStatement; +import org.apache.phoenix.parse.OrderByNode; +import org.apache.phoenix.query.ConnectionQueryServices.Feature; +import org.apache.phoenix.schema.ColumnModifier; /** * Validates ORDER BY clause and builds up a list of referenced columns. @@ -59,7 +52,8 @@ public static class OrderBy { * Used to indicate that there was an ORDER BY, but it was optimized out because * rows are already returned in this order. */ - public static final OrderBy ROW_KEY_ORDER_BY = new OrderBy(Collections.emptyList()); + public static final OrderBy FWD_ROW_KEY_ORDER_BY = new OrderBy(Collections.emptyList()); + public static final OrderBy REV_ROW_KEY_ORDER_BY = new OrderBy(Collections.emptyList()); private final List orderByExpressions; @@ -126,7 +120,13 @@ public static OrderBy compile(StatementContext context, } // If we're ordering by the order returned by the scan, we don't need an order by if (visitor.isOrderPreserving()) { - return OrderBy.ROW_KEY_ORDER_BY; + if (visitor.isReverse()) { + if (context.getConnection().getQueryServices().supportsFeature(Feature.REVERSE_SCAN)) { + return OrderBy.REV_ROW_KEY_ORDER_BY; + } + } else { + return OrderBy.FWD_ROW_KEY_ORDER_BY; + } } return new OrderBy(Lists.newArrayList(orderByExpressions.iterator())); @@ -135,4 +135,4 @@ public static OrderBy compile(StatementContext context, private OrderByCompiler() { } -} +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/PostDDLCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/PostDDLCompiler.java similarity index 77% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/PostDDLCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/PostDDLCompiler.java index 9ac09855..d971ba61 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/PostDDLCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/PostDDLCompiler.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.ParameterMetaData; import java.sql.SQLException; @@ -36,31 +28,31 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import com.google.common.collect.Lists; -import com.salesforce.phoenix.cache.ServerCacheClient.ServerCache; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.compile.OrderByCompiler.OrderBy; -import com.salesforce.phoenix.coprocessor.UngroupedAggregateRegionObserver; -import com.salesforce.phoenix.execute.AggregatePlan; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixParameterMetaData; -import com.salesforce.phoenix.jdbc.PhoenixStatement; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.parse.SQLParser; -import com.salesforce.phoenix.parse.SelectStatement; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.AmbiguousColumnException; -import com.salesforce.phoenix.schema.ColumnFamilyNotFoundException; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.ColumnRef; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PColumnFamily; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ScanUtil; +import org.apache.phoenix.cache.ServerCacheClient.ServerCache; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.compile.OrderByCompiler.OrderBy; +import org.apache.phoenix.coprocessor.UngroupedAggregateRegionObserver; +import org.apache.phoenix.execute.AggregatePlan; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixParameterMetaData; +import org.apache.phoenix.jdbc.PhoenixStatement; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.parse.SQLParser; +import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.AmbiguousColumnException; +import org.apache.phoenix.schema.ColumnFamilyNotFoundException; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.ColumnRef; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PColumnFamily; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ScanUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/PostIndexDDLCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/PostIndexDDLCompiler.java similarity index 66% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/PostIndexDDLCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/PostIndexDDLCompiler.java index fe15d076..69108d32 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/PostIndexDDLCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/PostIndexDDLCompiler.java @@ -1,44 +1,36 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.ParameterMetaData; import java.sql.PreparedStatement; import java.sql.SQLException; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixParameterMetaData; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.IndexUtil; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixParameterMetaData; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.IndexUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ProjectionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java similarity index 82% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/ProjectionCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java index 624a71b7..13a70a94 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ProjectionCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.SQLException; import java.util.ArrayList; @@ -42,39 +34,39 @@ import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.coprocessor.GroupedAggregateRegionObserver; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.expression.CoerceExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.aggregator.ClientAggregators; -import com.salesforce.phoenix.expression.aggregator.ServerAggregators; -import com.salesforce.phoenix.expression.function.SingleAggregateFunction; -import com.salesforce.phoenix.expression.visitor.SingleAggregateFunctionVisitor; -import com.salesforce.phoenix.parse.AliasedNode; -import com.salesforce.phoenix.parse.BindParseNode; -import com.salesforce.phoenix.parse.ColumnParseNode; -import com.salesforce.phoenix.parse.FamilyWildcardParseNode; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.parse.SelectStatement; -import com.salesforce.phoenix.parse.SequenceValueParseNode; -import com.salesforce.phoenix.parse.WildcardParseNode; -import com.salesforce.phoenix.schema.ArgumentTypeMismatchException; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.ColumnRef; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PColumnFamily; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PDatum; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTable.ViewType; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.RowKeySchema; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.IndexUtil; -import com.salesforce.phoenix.util.SchemaUtil; -import com.salesforce.phoenix.util.SizedUtil; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.coprocessor.GroupedAggregateRegionObserver; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.expression.CoerceExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.aggregator.ClientAggregators; +import org.apache.phoenix.expression.aggregator.ServerAggregators; +import org.apache.phoenix.expression.function.SingleAggregateFunction; +import org.apache.phoenix.expression.visitor.SingleAggregateFunctionVisitor; +import org.apache.phoenix.parse.AliasedNode; +import org.apache.phoenix.parse.BindParseNode; +import org.apache.phoenix.parse.ColumnParseNode; +import org.apache.phoenix.parse.FamilyWildcardParseNode; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.parse.SequenceValueParseNode; +import org.apache.phoenix.parse.WildcardParseNode; +import org.apache.phoenix.schema.ArgumentTypeMismatchException; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.ColumnRef; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PColumnFamily; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PDatum; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTable.ViewType; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.RowKeySchema; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.IndexUtil; +import org.apache.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.SizedUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/QueryCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java similarity index 79% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/QueryCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java index 7784abb0..e8ea6a23 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/QueryCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; @@ -35,39 +27,39 @@ import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.util.Pair; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.compile.JoinCompiler.JoinSpec; -import com.salesforce.phoenix.compile.JoinCompiler.JoinTable; -import com.salesforce.phoenix.compile.JoinCompiler.JoinedTableColumnResolver; -import com.salesforce.phoenix.compile.JoinCompiler.PTableWrapper; -import com.salesforce.phoenix.compile.JoinCompiler.ProjectedPTableWrapper; -import com.salesforce.phoenix.compile.OrderByCompiler.OrderBy; -import com.salesforce.phoenix.execute.AggregatePlan; -import com.salesforce.phoenix.execute.BasicQueryPlan; -import com.salesforce.phoenix.execute.DegenerateQueryPlan; -import com.salesforce.phoenix.execute.HashJoinPlan; -import com.salesforce.phoenix.execute.ScanPlan; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData; -import com.salesforce.phoenix.jdbc.PhoenixStatement; -import com.salesforce.phoenix.join.HashJoinInfo; -import com.salesforce.phoenix.join.ScanProjector; -import com.salesforce.phoenix.parse.JoinTableNode.JoinType; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.parse.SQLParser; -import com.salesforce.phoenix.parse.SelectStatement; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.AmbiguousColumnException; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.PDatum; -import com.salesforce.phoenix.schema.PIndexState; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.ScanUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.compile.JoinCompiler.JoinSpec; +import org.apache.phoenix.compile.JoinCompiler.JoinTable; +import org.apache.phoenix.compile.JoinCompiler.JoinedTableColumnResolver; +import org.apache.phoenix.compile.JoinCompiler.PTableWrapper; +import org.apache.phoenix.compile.JoinCompiler.ProjectedPTableWrapper; +import org.apache.phoenix.compile.OrderByCompiler.OrderBy; +import org.apache.phoenix.execute.AggregatePlan; +import org.apache.phoenix.execute.BasicQueryPlan; +import org.apache.phoenix.execute.DegenerateQueryPlan; +import org.apache.phoenix.execute.HashJoinPlan; +import org.apache.phoenix.execute.ScanPlan; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixStatement; +import org.apache.phoenix.join.HashJoinInfo; +import org.apache.phoenix.join.ScanProjector; +import org.apache.phoenix.parse.JoinTableNode.JoinType; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.parse.SQLParser; +import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.AmbiguousColumnException; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.PDatum; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.ScanUtil; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java new file mode 100644 index 00000000..d41fb7f8 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.compile.OrderByCompiler.OrderBy; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.parse.FilterableStatement; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.schema.TableRef; + + + +/** + * + * Interface for an executable query plan + * + * @author jtaylor + * @since 0.1 + */ +public interface QueryPlan extends StatementPlan { + /** + * Get a result iterator to iterate over the results + * @return result iterator for iterating over the results + * @throws SQLException + */ + public ResultIterator iterator() throws SQLException; + + public long getEstimatedSize(); + + // TODO: change once joins are supported + TableRef getTableRef(); + /** + * Returns projector used to formulate resultSet row + */ + RowProjector getProjector(); + + Integer getLimit(); + + OrderBy getOrderBy(); + + GroupBy getGroupBy(); + + List getSplits(); + + StatementContext getContext(); + + FilterableStatement getStatement(); +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/RowProjector.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java similarity index 66% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/RowProjector.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java index 6113c37a..6b6344c7 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/RowProjector.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java @@ -1,38 +1,30 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.SQLException; import java.util.*; import com.google.common.collect.Maps; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.util.SchemaUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ScanRanges.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ScanRanges.java similarity index 73% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/ScanRanges.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/ScanRanges.java index f58beb77..44f4473e 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/ScanRanges.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ScanRanges.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.util.Collections; import java.util.List; @@ -35,10 +27,10 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import com.salesforce.phoenix.filter.SkipScanFilter; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.schema.RowKeySchema; -import com.salesforce.phoenix.util.ScanUtil; +import org.apache.phoenix.filter.SkipScanFilter; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.schema.RowKeySchema; +import org.apache.phoenix.util.ScanUtil; public class ScanRanges { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/SequenceManager.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/SequenceManager.java similarity index 72% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/SequenceManager.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/SequenceManager.java index 0fa4c180..665c33b3 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/SequenceManager.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/SequenceManager.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.SQLException; import java.util.BitSet; @@ -38,15 +30,15 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.salesforce.phoenix.expression.BaseTerminalExpression; -import com.salesforce.phoenix.jdbc.PhoenixStatement; -import com.salesforce.phoenix.parse.SequenceValueParseNode; -import com.salesforce.phoenix.parse.TableName; -import com.salesforce.phoenix.query.ConnectionQueryServices; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PName; -import com.salesforce.phoenix.schema.SequenceKey; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.BaseTerminalExpression; +import org.apache.phoenix.jdbc.PhoenixStatement; +import org.apache.phoenix.parse.SequenceValueParseNode; +import org.apache.phoenix.parse.TableName; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.SequenceKey; +import org.apache.phoenix.schema.tuple.Tuple; public class SequenceManager { private final PhoenixStatement statement; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/StatementContext.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java similarity index 74% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/StatementContext.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java index 0ae42e23..57365363 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/StatementContext.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.SQLException; import java.text.Format; @@ -35,17 +27,17 @@ import org.apache.hadoop.hbase.filter.FilterList; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixStatement; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.schema.MetaDataClient; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.DateUtil; -import com.salesforce.phoenix.util.NumberUtil; -import com.salesforce.phoenix.util.ScanUtil; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixStatement; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.schema.MetaDataClient; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.DateUtil; +import org.apache.phoenix.util.NumberUtil; +import org.apache.phoenix.util.ScanUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/StatementNormalizer.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementNormalizer.java similarity index 58% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/StatementNormalizer.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/StatementNormalizer.java index a8e7af36..8eb769e9 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/StatementNormalizer.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementNormalizer.java @@ -1,44 +1,36 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.SQLException; import java.util.List; import com.google.common.collect.Lists; -import com.salesforce.phoenix.parse.BetweenParseNode; -import com.salesforce.phoenix.parse.ColumnParseNode; -import com.salesforce.phoenix.parse.ComparisonParseNode; -import com.salesforce.phoenix.parse.LessThanOrEqualParseNode; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.parse.ParseNodeRewriter; -import com.salesforce.phoenix.parse.SelectStatement; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.parse.BetweenParseNode; +import org.apache.phoenix.parse.ColumnParseNode; +import org.apache.phoenix.parse.ComparisonParseNode; +import org.apache.phoenix.parse.LessThanOrEqualParseNode; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.parse.ParseNodeRewriter; +import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.util.SchemaUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementPlan.java new file mode 100644 index 00000000..e41e86a9 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementPlan.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; + +import java.sql.ParameterMetaData; +import java.sql.SQLException; + +import org.apache.phoenix.jdbc.PhoenixParameterMetaData; + + +public interface StatementPlan { + public final StatementPlan EMPTY_PLAN = new StatementPlan() { + @Override + public ParameterMetaData getParameterMetaData() { + return new PhoenixParameterMetaData(0); + } + + @Override + public ExplainPlan getExplainPlan() throws SQLException { + return ExplainPlan.EMPTY_PLAN; + } + }; + + /** + * Returns the ParameterMetaData for the statement + */ + ParameterMetaData getParameterMetaData(); + + ExplainPlan getExplainPlan() throws SQLException; +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/TrackOrderPreservingExpressionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/TrackOrderPreservingExpressionCompiler.java similarity index 85% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/TrackOrderPreservingExpressionCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/TrackOrderPreservingExpressionCompiler.java index b119031b..a0c4674f 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/TrackOrderPreservingExpressionCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/TrackOrderPreservingExpressionCompiler.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.compile; +package org.apache.phoenix.compile; import java.sql.SQLException; import java.util.Collections; @@ -7,19 +7,19 @@ import com.google.common.base.Objects; import com.google.common.collect.Lists; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.expression.function.FunctionExpression; -import com.salesforce.phoenix.expression.function.FunctionExpression.OrderPreserving; -import com.salesforce.phoenix.parse.CaseParseNode; -import com.salesforce.phoenix.parse.ColumnParseNode; -import com.salesforce.phoenix.parse.DivideParseNode; -import com.salesforce.phoenix.parse.MultiplyParseNode; -import com.salesforce.phoenix.parse.SubtractParseNode; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.ColumnRef; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.function.FunctionExpression; +import org.apache.phoenix.expression.function.FunctionExpression.OrderPreserving; +import org.apache.phoenix.parse.CaseParseNode; +import org.apache.phoenix.parse.ColumnParseNode; +import org.apache.phoenix.parse.DivideParseNode; +import org.apache.phoenix.parse.MultiplyParseNode; +import org.apache.phoenix.parse.SubtractParseNode; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.ColumnRef; +import org.apache.phoenix.util.SchemaUtil; /** * Visitor that builds the expressions of a GROUP BY and ORDER BY clause. While traversing @@ -40,6 +40,7 @@ public enum Ordering {ORDERED, UNORDERED}; private OrderPreserving orderPreserving = OrderPreserving.YES; private ColumnRef columnRef; private boolean isOrderPreserving = true; + private Boolean isReverse; TrackOrderPreservingExpressionCompiler(StatementContext context, GroupBy groupBy, int expectedEntrySize, Ordering ordering) { super(context, groupBy); @@ -48,6 +49,9 @@ public enum Ordering {ORDERED, UNORDERED}; this.ordering = ordering; } + public Boolean isReverse() { + return isReverse; + } public boolean isOrderPreserving() { if (!isOrderPreserving) { @@ -158,7 +162,17 @@ public boolean addEntry(Expression expression, ColumnModifier modifier) { // If the expression is sorted in a different order than the specified sort order // then the expressions are not order preserving. if (!Objects.equal(expression.getColumnModifier(), modifier)) { - orderPreserving = OrderPreserving.NO; + if (isReverse == null) { + isReverse = true; + } else if (!isReverse){ + orderPreserving = OrderPreserving.NO; + } + } else { + if (isReverse == null) { + isReverse = false; + } else if (isReverse){ + orderPreserving = OrderPreserving.NO; + } } return addEntry(expression); } diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/UpsertCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java similarity index 90% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/UpsertCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java index e187bdd7..03b61363 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/UpsertCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import static com.google.common.collect.Lists.newArrayListWithCapacity; @@ -45,58 +37,58 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.cache.ServerCacheClient.ServerCache; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.compile.OrderByCompiler.OrderBy; -import com.salesforce.phoenix.coprocessor.UngroupedAggregateRegionObserver; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.execute.AggregatePlan; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.index.IndexMetaDataCacheClient; -import com.salesforce.phoenix.index.PhoenixIndexCodec; -import com.salesforce.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixResultSet; -import com.salesforce.phoenix.jdbc.PhoenixStatement; -import com.salesforce.phoenix.optimize.QueryOptimizer; -import com.salesforce.phoenix.parse.AliasedNode; -import com.salesforce.phoenix.parse.BindParseNode; -import com.salesforce.phoenix.parse.ColumnName; -import com.salesforce.phoenix.parse.ColumnParseNode; -import com.salesforce.phoenix.parse.ComparisonParseNode; -import com.salesforce.phoenix.parse.HintNode; -import com.salesforce.phoenix.parse.HintNode.Hint; -import com.salesforce.phoenix.parse.IsNullParseNode; -import com.salesforce.phoenix.parse.LiteralParseNode; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.parse.SQLParser; -import com.salesforce.phoenix.parse.SelectStatement; -import com.salesforce.phoenix.parse.SequenceValueParseNode; -import com.salesforce.phoenix.parse.UpsertStatement; -import com.salesforce.phoenix.query.ConnectionQueryServices; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.ColumnRef; -import com.salesforce.phoenix.schema.ConstraintViolationException; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PColumnImpl; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTable.ViewType; -import com.salesforce.phoenix.schema.PTableImpl; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.ReadOnlyTableException; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.schema.TypeMismatchException; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.cache.ServerCacheClient.ServerCache; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.compile.OrderByCompiler.OrderBy; +import org.apache.phoenix.coprocessor.UngroupedAggregateRegionObserver; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.execute.AggregatePlan; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.index.IndexMetaDataCacheClient; +import org.apache.phoenix.index.PhoenixIndexCodec; +import org.apache.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixResultSet; +import org.apache.phoenix.jdbc.PhoenixStatement; +import org.apache.phoenix.optimize.QueryOptimizer; +import org.apache.phoenix.parse.AliasedNode; +import org.apache.phoenix.parse.BindParseNode; +import org.apache.phoenix.parse.ColumnName; +import org.apache.phoenix.parse.ColumnParseNode; +import org.apache.phoenix.parse.ComparisonParseNode; +import org.apache.phoenix.parse.HintNode; +import org.apache.phoenix.parse.HintNode.Hint; +import org.apache.phoenix.parse.IsNullParseNode; +import org.apache.phoenix.parse.LiteralParseNode; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.parse.SQLParser; +import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.parse.SequenceValueParseNode; +import org.apache.phoenix.parse.UpsertStatement; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.ColumnRef; +import org.apache.phoenix.schema.ConstraintViolationException; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PColumnImpl; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTable.ViewType; +import org.apache.phoenix.schema.PTableImpl; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.ReadOnlyTableException; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.schema.TypeMismatchException; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.SchemaUtil; public class UpsertCompiler { private static void setValues(byte[][] values, int[] pkSlotIndex, int[] columnIndexes, PTable table, Map> mutation) { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/WhereCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java similarity index 68% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/WhereCompiler.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java index 7a407077..6f76f0a5 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/WhereCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; @@ -37,32 +29,32 @@ import com.google.common.collect.Iterators; import com.google.common.collect.Sets; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.KeyValueColumnExpression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.expression.visitor.KeyValueExpressionVisitor; -import com.salesforce.phoenix.filter.MultiCFCQKeyValueComparisonFilter; -import com.salesforce.phoenix.filter.MultiCQKeyValueComparisonFilter; -import com.salesforce.phoenix.filter.RowKeyComparisonFilter; -import com.salesforce.phoenix.filter.SingleCFCQKeyValueComparisonFilter; -import com.salesforce.phoenix.filter.SingleCQKeyValueComparisonFilter; -import com.salesforce.phoenix.parse.ColumnParseNode; -import com.salesforce.phoenix.parse.FilterableStatement; -import com.salesforce.phoenix.parse.HintNode.Hint; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.parse.ParseNodeFactory; -import com.salesforce.phoenix.schema.AmbiguousColumnException; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.ColumnRef; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.TypeMismatchException; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.ScanUtil; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.KeyValueColumnExpression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.visitor.KeyValueExpressionVisitor; +import org.apache.phoenix.filter.MultiCFCQKeyValueComparisonFilter; +import org.apache.phoenix.filter.MultiCQKeyValueComparisonFilter; +import org.apache.phoenix.filter.RowKeyComparisonFilter; +import org.apache.phoenix.filter.SingleCFCQKeyValueComparisonFilter; +import org.apache.phoenix.filter.SingleCQKeyValueComparisonFilter; +import org.apache.phoenix.parse.ColumnParseNode; +import org.apache.phoenix.parse.FilterableStatement; +import org.apache.phoenix.parse.HintNode.Hint; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.parse.ParseNodeFactory; +import org.apache.phoenix.schema.AmbiguousColumnException; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.ColumnRef; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.TypeMismatchException; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.ScanUtil; +import org.apache.phoenix.util.SchemaUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/WhereOptimizer.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java similarity index 93% rename from phoenix-core/src/main/java/com/salesforce/phoenix/compile/WhereOptimizer.java rename to phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java index 9406a198..552ff95c 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/compile/WhereOptimizer.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.compile; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.compile; import static java.util.Collections.singletonList; @@ -44,37 +36,37 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; -import com.salesforce.phoenix.expression.AndExpression; -import com.salesforce.phoenix.expression.BaseTerminalExpression; -import com.salesforce.phoenix.expression.CoerceExpression; -import com.salesforce.phoenix.expression.ComparisonExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.InListExpression; -import com.salesforce.phoenix.expression.IsNullExpression; -import com.salesforce.phoenix.expression.LikeExpression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.expression.OrExpression; -import com.salesforce.phoenix.expression.RowKeyColumnExpression; -import com.salesforce.phoenix.expression.RowValueConstructorExpression; -import com.salesforce.phoenix.expression.RowValueConstructorExpression.ExpressionComparabilityWrapper; -import com.salesforce.phoenix.expression.function.FunctionExpression.OrderPreserving; -import com.salesforce.phoenix.expression.function.ScalarFunction; -import com.salesforce.phoenix.expression.visitor.TraverseNoExpressionVisitor; -import com.salesforce.phoenix.parse.FilterableStatement; -import com.salesforce.phoenix.parse.HintNode.Hint; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PName; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.RowKeySchema; -import com.salesforce.phoenix.schema.SaltingUtil; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.ScanUtil; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.expression.AndExpression; +import org.apache.phoenix.expression.BaseTerminalExpression; +import org.apache.phoenix.expression.CoerceExpression; +import org.apache.phoenix.expression.ComparisonExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.InListExpression; +import org.apache.phoenix.expression.IsNullExpression; +import org.apache.phoenix.expression.LikeExpression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.OrExpression; +import org.apache.phoenix.expression.RowKeyColumnExpression; +import org.apache.phoenix.expression.RowValueConstructorExpression; +import org.apache.phoenix.expression.RowValueConstructorExpression.ExpressionComparabilityWrapper; +import org.apache.phoenix.expression.function.FunctionExpression.OrderPreserving; +import org.apache.phoenix.expression.function.ScalarFunction; +import org.apache.phoenix.expression.visitor.TraverseNoExpressionVisitor; +import org.apache.phoenix.parse.FilterableStatement; +import org.apache.phoenix.parse.HintNode.Hint; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.RowKeySchema; +import org.apache.phoenix.schema.SaltingUtil; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.ScanUtil; +import org.apache.phoenix.util.SchemaUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseRegionScanner.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseRegionScanner.java new file mode 100644 index 00000000..44f4303e --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseRegionScanner.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.coprocessor; + +import java.io.IOException; +import java.util.List; + +import org.apache.hadoop.hbase.DoNotRetryIOException; +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.regionserver.RegionScanner; + +public abstract class BaseRegionScanner implements RegionScanner { + + @Override + public boolean isFilterDone() { + return false; + } + + @Override + public boolean next(List results, String metric) throws IOException { + return next(results); + } + + @Override + public boolean next(List result, int limit, String metric) throws IOException { + return next(result); + } + @Override + public boolean next(List result, int limit) throws IOException { + return next(result); + } + + @Override + public boolean reseek(byte[] row) throws IOException { + throw new DoNotRetryIOException("Unsupported"); + } + + @Override + public long getMvccReadPoint() { + return Long.MAX_VALUE; + } + + @Override + public boolean nextRaw(List result, String metric) throws IOException { + return next(result, metric); + } + + @Override + public boolean nextRaw(List result, int limit, String metric) throws IOException { + return next(result, limit, metric); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java new file mode 100644 index 00000000..6c8306e6 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java @@ -0,0 +1,57 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.coprocessor; + +import java.io.IOException; + +import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.coprocessor.*; +import org.apache.hadoop.hbase.regionserver.RegionScanner; + +import org.apache.phoenix.util.ServerUtil; + + +abstract public class BaseScannerRegionObserver extends BaseRegionObserver { + + /** + * Used by logger to identify coprocessor + */ + @Override + public String toString() { + return this.getClass().getName(); + } + + abstract protected RegionScanner doPostScannerOpen(final ObserverContext c, final Scan scan, final RegionScanner s) throws Throwable; + + /** + * Wrapper for {@link #postScannerOpen(ObserverContext, Scan, RegionScanner)} that ensures no non IOException is thrown, + * to prevent the coprocessor from becoming blacklisted. + * + */ + @Override + public final RegionScanner postScannerOpen(final ObserverContext c, final Scan scan, final RegionScanner s) throws IOException { + try { + return doPostScannerOpen(c, scan, s); + } catch (Throwable t) { + ServerUtil.throwIOException(c.getEnvironment().getRegion().getRegionNameAsString(), t); + return null; // impossible + } + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupByCache.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupByCache.java new file mode 100644 index 00000000..1fdf272f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupByCache.java @@ -0,0 +1,41 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.coprocessor; + +import java.io.Closeable; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; +import org.apache.hadoop.hbase.regionserver.RegionScanner; + +import org.apache.phoenix.expression.aggregator.Aggregator; + +/** + * + * Interface to abstract the way in which distinct group by + * elements are cached + * + * @author jtaylor + * @since 3.0.0 + */ +public interface GroupByCache extends Closeable { + int size(); + Aggregator[] cache(ImmutableBytesWritable key); + RegionScanner getScanner(RegionScanner s); +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/GroupedAggregateRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java similarity index 87% rename from phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/GroupedAggregateRegionObserver.java rename to phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java index 593ecc35..abdd7bba 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/GroupedAggregateRegionObserver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java @@ -1,28 +1,29 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source - * and binary forms, with or without modification, are permitted provided that the following - * conditions are met: Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. Redistributions in binary form must reproduce - * the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of - * Salesforce.com nor the names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED - * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.coprocessor; - -import static com.salesforce.phoenix.query.QueryConstants.AGG_TIMESTAMP; -import static com.salesforce.phoenix.query.QueryConstants.SINGLE_COLUMN; -import static com.salesforce.phoenix.query.QueryConstants.SINGLE_COLUMN_FAMILY; -import static com.salesforce.phoenix.query.QueryServices.GROUPBY_SPILLABLE_ATTRIB; -import static com.salesforce.phoenix.query.QueryServicesOptions.DEFAULT_GROUPBY_SPILLABLE; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.coprocessor; + +import static org.apache.phoenix.query.QueryConstants.AGG_TIMESTAMP; +import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN; +import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN_FAMILY; +import static org.apache.phoenix.query.QueryServices.GROUPBY_SPILLABLE_ATTRIB; +import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_GROUPBY_SPILLABLE; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -53,23 +54,23 @@ import com.google.common.collect.Maps; import com.google.common.io.Closeables; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.cache.GlobalCache; -import com.salesforce.phoenix.cache.TenantCache; -import com.salesforce.phoenix.cache.aggcache.SpillableGroupByCache; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.ExpressionType; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.ServerAggregators; -import com.salesforce.phoenix.join.HashJoinInfo; -import com.salesforce.phoenix.join.ScanProjector; -import com.salesforce.phoenix.memory.MemoryManager.MemoryChunk; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.tuple.MultiKeyValueTuple; -import com.salesforce.phoenix.util.KeyValueUtil; -import com.salesforce.phoenix.util.ScanUtil; -import com.salesforce.phoenix.util.SizedUtil; -import com.salesforce.phoenix.util.TupleUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.cache.GlobalCache; +import org.apache.phoenix.cache.TenantCache; +import org.apache.phoenix.cache.aggcache.SpillableGroupByCache; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.ExpressionType; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.ServerAggregators; +import org.apache.phoenix.join.HashJoinInfo; +import org.apache.phoenix.join.ScanProjector; +import org.apache.phoenix.memory.MemoryManager.MemoryChunk; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.tuple.MultiKeyValueTuple; +import org.apache.phoenix.util.KeyValueUtil; +import org.apache.phoenix.util.ScanUtil; +import org.apache.phoenix.util.SizedUtil; +import org.apache.phoenix.util.TupleUtil; /** * Region observer that aggregates grouped rows (i.e. SQL query with GROUP BY clause) diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/HashJoinRegionScanner.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java similarity index 78% rename from phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/HashJoinRegionScanner.java rename to phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java index 22e08f3f..32185395 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/HashJoinRegionScanner.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.coprocessor; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.coprocessor; import java.io.IOException; import java.util.Iterator; @@ -41,21 +33,21 @@ import org.apache.hadoop.hbase.regionserver.RegionScanner; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.cache.GlobalCache; -import com.salesforce.phoenix.cache.HashCache; -import com.salesforce.phoenix.cache.TenantCache; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.join.HashJoinInfo; -import com.salesforce.phoenix.join.ScanProjector; -import com.salesforce.phoenix.join.ScanProjector.ProjectedValueTuple; -import com.salesforce.phoenix.parse.JoinTableNode.JoinType; -import com.salesforce.phoenix.schema.IllegalDataException; -import com.salesforce.phoenix.schema.KeyValueSchema; -import com.salesforce.phoenix.schema.ValueBitSet; -import com.salesforce.phoenix.schema.tuple.ResultTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.TupleUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.cache.GlobalCache; +import org.apache.phoenix.cache.HashCache; +import org.apache.phoenix.cache.TenantCache; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.join.HashJoinInfo; +import org.apache.phoenix.join.ScanProjector; +import org.apache.phoenix.join.ScanProjector.ProjectedValueTuple; +import org.apache.phoenix.parse.JoinTableNode.JoinType; +import org.apache.phoenix.schema.IllegalDataException; +import org.apache.phoenix.schema.KeyValueSchema; +import org.apache.phoenix.schema.ValueBitSet; +import org.apache.phoenix.schema.tuple.ResultTuple; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.TupleUtil; public class HashJoinRegionScanner implements RegionScanner { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/MetaDataEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java similarity index 92% rename from phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/MetaDataEndpointImpl.java rename to phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java index 79021a5e..bf760833 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/MetaDataEndpointImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java @@ -1,63 +1,55 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.coprocessor; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.coprocessor; import static com.google.common.collect.Lists.newArrayList; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.BASE_SCHEMA_NAME_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.BASE_TABLE_NAME_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_COUNT_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_MODIFIER; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_NAME_INDEX; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_SIZE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TABLE_NAME_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TYPE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DECIMAL_DIGITS; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DISABLE_WAL_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.FAMILY_NAME_INDEX; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.IMMUTABLE_ROWS_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_STATE_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.MULTI_TENANT_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.NULLABLE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.ORDINAL_POSITION; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.PK_NAME_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SALT_BUCKETS_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SCHEMA_NAME_INDEX; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_NAME_INDEX; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SEQ_NUM_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_TYPE_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TENANT_ID_INDEX; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_EXPRESSION_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_TYPE_BYTES; -import static com.salesforce.phoenix.schema.PTableType.INDEX; -import static com.salesforce.phoenix.util.SchemaUtil.getVarCharLength; -import static com.salesforce.phoenix.util.SchemaUtil.getVarChars; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.BASE_SCHEMA_NAME_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.BASE_TABLE_NAME_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_COUNT_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_MODIFIER; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_NAME_INDEX; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_SIZE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TABLE_NAME_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TYPE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DECIMAL_DIGITS; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DISABLE_WAL_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.FAMILY_NAME_INDEX; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IMMUTABLE_ROWS_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_STATE_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MULTI_TENANT_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.NULLABLE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ORDINAL_POSITION; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.PK_NAME_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SALT_BUCKETS_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SCHEMA_NAME_INDEX; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_NAME_INDEX; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SEQ_NUM_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_TYPE_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TENANT_ID_INDEX; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_EXPRESSION_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_TYPE_BYTES; +import static org.apache.phoenix.schema.PTableType.INDEX; +import static org.apache.phoenix.util.SchemaUtil.getVarCharLength; +import static org.apache.phoenix.util.SchemaUtil.getVarChars; import static org.apache.hadoop.hbase.filter.CompareFilter.CompareOp.EQUAL; import java.io.IOException; @@ -93,33 +85,33 @@ import org.slf4j.LoggerFactory; import com.google.common.collect.Lists; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.hbase.index.util.IndexManagementUtil; -import com.salesforce.phoenix.cache.GlobalCache; -import com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.AmbiguousColumnException; -import com.salesforce.phoenix.schema.ColumnFamilyNotFoundException; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PColumnFamily; -import com.salesforce.phoenix.schema.PColumnImpl; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PIndexState; -import com.salesforce.phoenix.schema.PName; -import com.salesforce.phoenix.schema.PNameFactory; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTable.ViewType; -import com.salesforce.phoenix.schema.PTableImpl; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.TableNotFoundException; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.IndexUtil; -import com.salesforce.phoenix.util.KeyValueUtil; -import com.salesforce.phoenix.util.MetaDataUtil; -import com.salesforce.phoenix.util.SchemaUtil; -import com.salesforce.phoenix.util.ServerUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.util.IndexManagementUtil; +import org.apache.phoenix.cache.GlobalCache; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.AmbiguousColumnException; +import org.apache.phoenix.schema.ColumnFamilyNotFoundException; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PColumnFamily; +import org.apache.phoenix.schema.PColumnImpl; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.PNameFactory; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTable.ViewType; +import org.apache.phoenix.schema.PTableImpl; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.TableNotFoundException; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.IndexUtil; +import org.apache.phoenix.util.KeyValueUtil; +import org.apache.phoenix.util.MetaDataUtil; +import org.apache.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.ServerUtil; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/MetaDataProtocol.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java similarity index 81% rename from phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/MetaDataProtocol.java rename to phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java index 8b55139f..9f01fff1 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/MetaDataProtocol.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.coprocessor; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.coprocessor; import java.io.DataInput; import java.io.DataOutput; @@ -40,11 +32,11 @@ import org.apache.hadoop.io.WritableUtils; import com.google.common.collect.Lists; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTableImpl; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.MetaDataUtil; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableImpl; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.MetaDataUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java new file mode 100644 index 00000000..d0bd7c54 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java @@ -0,0 +1,40 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.coprocessor; + +import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver; +import org.apache.hadoop.hbase.coprocessor.ObserverContext; +import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; + +import org.apache.phoenix.cache.GlobalCache; + + +/** + * Coprocessor for metadata related operations. This coprocessor would only be registered + * to SYSTEM.TABLE. + */ +public class MetaDataRegionObserver extends BaseRegionObserver { + + @Override + public void preClose(final ObserverContext c, + boolean abortRequested) { + GlobalCache.getInstance(c.getEnvironment()).getMetaDataCache().clear(); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ScanProjector.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ScanProjector.java similarity index 80% rename from phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ScanProjector.java rename to phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ScanProjector.java index 062b7cc1..ee9e6e29 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ScanProjector.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ScanProjector.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.coprocessor; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.coprocessor; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -41,9 +33,9 @@ import org.apache.hadoop.hbase.util.Pair; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.KeyValueUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.KeyValueUtil; public class ScanProjector { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ScanRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ScanRegionObserver.java similarity index 81% rename from phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ScanRegionObserver.java rename to phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ScanRegionObserver.java index ad7964ca..cb76b700 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/ScanRegionObserver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ScanRegionObserver.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.coprocessor; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.coprocessor; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -46,19 +38,19 @@ import org.apache.hadoop.io.WritableUtils; import com.google.common.collect.Lists; -import com.salesforce.phoenix.cache.GlobalCache; -import com.salesforce.phoenix.cache.TenantCache; -import com.salesforce.phoenix.expression.OrderByExpression; -import com.salesforce.phoenix.iterate.OrderedResultIterator; -import com.salesforce.phoenix.iterate.RegionScannerResultIterator; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.join.HashJoinInfo; -import com.salesforce.phoenix.join.ScanProjector; -import com.salesforce.phoenix.memory.MemoryManager.MemoryChunk; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ScanUtil; -import com.salesforce.phoenix.util.ServerUtil; +import org.apache.phoenix.cache.GlobalCache; +import org.apache.phoenix.cache.TenantCache; +import org.apache.phoenix.expression.OrderByExpression; +import org.apache.phoenix.iterate.OrderedResultIterator; +import org.apache.phoenix.iterate.RegionScannerResultIterator; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.join.HashJoinInfo; +import org.apache.phoenix.join.ScanProjector; +import org.apache.phoenix.memory.MemoryManager.MemoryChunk; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ScanUtil; +import org.apache.phoenix.util.ServerUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/SequenceRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java similarity index 96% rename from phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/SequenceRegionObserver.java rename to phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java index 6f43ba5e..ed04cc34 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/SequenceRegionObserver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.coprocessor; +package org.apache.phoenix.coprocessor; import java.io.IOException; import java.util.Collections; @@ -24,15 +24,15 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.Pair; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.Sequence; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.KeyValueUtil; -import com.salesforce.phoenix.util.MetaDataUtil; -import com.salesforce.phoenix.util.ServerUtil; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.Sequence; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.KeyValueUtil; +import org.apache.phoenix.util.MetaDataUtil; +import org.apache.phoenix.util.ServerUtil; /** * diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ServerCachingEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ServerCachingEndpointImpl.java new file mode 100644 index 00000000..b27c14ce --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ServerCachingEndpointImpl.java @@ -0,0 +1,57 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.coprocessor; + +import java.sql.SQLException; + +import org.apache.hadoop.hbase.coprocessor.BaseEndpointCoprocessor; +import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.cache.GlobalCache; +import org.apache.phoenix.cache.TenantCache; + + + + +/** + * + * Server-side implementation of {@link ServerCachingProtocol} + * + * @author jtaylor + * @since 0.1 + */ +public class ServerCachingEndpointImpl extends BaseEndpointCoprocessor implements ServerCachingProtocol { + + @Override + public boolean addServerCache(byte[] tenantId, byte[] cacheId, ImmutableBytesWritable cachePtr, ServerCacheFactory cacheFactory) throws SQLException { + TenantCache tenantCache = GlobalCache.getTenantCache((RegionCoprocessorEnvironment)this.getEnvironment(), tenantId == null ? null : new ImmutableBytesPtr(tenantId)); + tenantCache.addServerCache(new ImmutableBytesPtr(cacheId), cachePtr, cacheFactory); + return true; + } + + @Override + public boolean removeServerCache(byte[] tenantId, byte[] cacheId) throws SQLException { + TenantCache tenantCache = GlobalCache.getTenantCache((RegionCoprocessorEnvironment)this.getEnvironment(), tenantId == null ? null : new ImmutableBytesPtr(tenantId)); + tenantCache.removeServerCache(new ImmutableBytesPtr(cacheId)); + return true; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ServerCachingProtocol.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ServerCachingProtocol.java new file mode 100644 index 00000000..abda834c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ServerCachingProtocol.java @@ -0,0 +1,63 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.coprocessor; + +import java.io.Closeable; +import java.sql.SQLException; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; +import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; +import org.apache.hadoop.io.Writable; + +import org.apache.phoenix.memory.MemoryManager.MemoryChunk; + +/** + * + * EndPoint coprocessor to send a cache to a region server. + * Used for: + * a) hash joins, to send the smaller side of the join to each region server + * b) secondary indexes, to send the necessary meta data to each region server + * @author jtaylor + * @since 0.1 + */ +public interface ServerCachingProtocol extends CoprocessorProtocol { + public static interface ServerCacheFactory extends Writable { + public Closeable newCache(ImmutableBytesWritable cachePtr, MemoryChunk chunk) throws SQLException; + } + /** + * Add the cache to the region server cache. + * @param tenantId the tenantId or null if not applicable + * @param cacheId unique identifier of the cache + * @param cachePtr pointer to the byte array of the cache + * @param cacheFactory factory that converts from byte array to object representation on the server side + * @return true on success and otherwise throws + * @throws SQLException + */ + public boolean addServerCache(byte[] tenantId, byte[] cacheId, ImmutableBytesWritable cachePtr, ServerCacheFactory cacheFactory) throws SQLException; + /** + * Remove the cache from the region server cache. Called upon completion of + * the operation when cache is no longer needed. + * @param tenantId the tenantId or null if not applicable + * @param cacheId unique identifier of the cache + * @return true on success and otherwise throws + * @throws SQLException + */ + public boolean removeServerCache(byte[] tenantId, byte[] cacheId) throws SQLException; +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/UngroupedAggregateRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java similarity index 83% rename from phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/UngroupedAggregateRegionObserver.java rename to phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java index 0040400b..c7c4575b 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/coprocessor/UngroupedAggregateRegionObserver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java @@ -1,37 +1,29 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.coprocessor; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.coprocessor; -import static com.salesforce.phoenix.query.QueryConstants.AGG_TIMESTAMP; -import static com.salesforce.phoenix.query.QueryConstants.SINGLE_COLUMN; -import static com.salesforce.phoenix.query.QueryConstants.SINGLE_COLUMN_FAMILY; -import static com.salesforce.phoenix.query.QueryConstants.UNGROUPED_AGG_ROW_KEY; -import static com.salesforce.phoenix.query.QueryServices.MUTATE_BATCH_SIZE_ATTRIB; +import static org.apache.phoenix.query.QueryConstants.AGG_TIMESTAMP; +import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN; +import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN_FAMILY; +import static org.apache.phoenix.query.QueryConstants.UNGROUPED_AGG_ROW_KEY; +import static org.apache.phoenix.query.QueryServices.MUTATE_BATCH_SIZE_ATTRIB; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -65,30 +57,30 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import com.salesforce.phoenix.client.KeyValueBuilder; -import com.salesforce.phoenix.exception.ValueTypeIncompatibleException; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.ExpressionType; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.Aggregators; -import com.salesforce.phoenix.expression.aggregator.ServerAggregators; -import com.salesforce.phoenix.index.PhoenixIndexCodec; -import com.salesforce.phoenix.join.HashJoinInfo; -import com.salesforce.phoenix.join.ScanProjector; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.ConstraintViolationException; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PRow; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTableImpl; -import com.salesforce.phoenix.schema.tuple.MultiKeyValueTuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.KeyValueUtil; -import com.salesforce.phoenix.util.ScanUtil; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.client.KeyValueBuilder; +import org.apache.phoenix.exception.ValueTypeIncompatibleException; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.ExpressionType; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.Aggregators; +import org.apache.phoenix.expression.aggregator.ServerAggregators; +import org.apache.phoenix.index.PhoenixIndexCodec; +import org.apache.phoenix.join.HashJoinInfo; +import org.apache.phoenix.join.ScanProjector; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.ConstraintViolationException; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PRow; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableImpl; +import org.apache.phoenix.schema.tuple.MultiKeyValueTuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.KeyValueUtil; +import org.apache.phoenix.util.ScanUtil; +import org.apache.phoenix.util.SchemaUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/PhoenixIOException.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/PhoenixIOException.java new file mode 100644 index 00000000..d1b0b180 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/PhoenixIOException.java @@ -0,0 +1,33 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.exception; + +import java.sql.SQLException; + + +public class PhoenixIOException extends SQLException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.IO_EXCEPTION; + + public PhoenixIOException(Throwable e) { + super(e.getMessage(), code.getSQLState(), code.getErrorCode(), e); + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/exception/PhoenixParserException.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/PhoenixParserException.java similarity index 68% rename from phoenix-core/src/main/java/com/salesforce/phoenix/exception/PhoenixParserException.java rename to phoenix-core/src/main/java/org/apache/phoenix/exception/PhoenixParserException.java index ada58587..fc969235 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/exception/PhoenixParserException.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/PhoenixParserException.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.exception; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.exception; import java.sql.SQLSyntaxErrorException; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/exception/SQLExceptionCode.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java similarity index 85% rename from phoenix-core/src/main/java/com/salesforce/phoenix/exception/SQLExceptionCode.java rename to phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java index 58862d31..322257c6 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/exception/SQLExceptionCode.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java @@ -1,52 +1,44 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.exception; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.exception; import java.sql.SQLException; import java.util.Map; import com.google.common.collect.Maps; -import com.salesforce.hbase.index.util.IndexManagementUtil; -import com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData; -import com.salesforce.phoenix.schema.AmbiguousColumnException; -import com.salesforce.phoenix.schema.AmbiguousTableException; -import com.salesforce.phoenix.schema.ColumnAlreadyExistsException; -import com.salesforce.phoenix.schema.ColumnFamilyNotFoundException; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.ConcurrentTableMutationException; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.ReadOnlyTableException; -import com.salesforce.phoenix.schema.SequenceAlreadyExistsException; -import com.salesforce.phoenix.schema.SequenceNotFoundException; -import com.salesforce.phoenix.schema.TableAlreadyExistsException; -import com.salesforce.phoenix.schema.TableNotFoundException; -import com.salesforce.phoenix.schema.TypeMismatchException; -import com.salesforce.phoenix.util.MetaDataUtil; +import org.apache.hadoop.hbase.index.util.IndexManagementUtil; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.schema.AmbiguousColumnException; +import org.apache.phoenix.schema.AmbiguousTableException; +import org.apache.phoenix.schema.ColumnAlreadyExistsException; +import org.apache.phoenix.schema.ColumnFamilyNotFoundException; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.ConcurrentTableMutationException; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.ReadOnlyTableException; +import org.apache.phoenix.schema.SequenceAlreadyExistsException; +import org.apache.phoenix.schema.SequenceNotFoundException; +import org.apache.phoenix.schema.TableAlreadyExistsException; +import org.apache.phoenix.schema.TableNotFoundException; +import org.apache.phoenix.schema.TypeMismatchException; +import org.apache.phoenix.util.MetaDataUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/exception/SQLExceptionInfo.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionInfo.java similarity index 68% rename from phoenix-core/src/main/java/com/salesforce/phoenix/exception/SQLExceptionInfo.java rename to phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionInfo.java index 289a185c..e0250547 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/exception/SQLExceptionInfo.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionInfo.java @@ -1,35 +1,27 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.exception; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.exception; import java.sql.SQLException; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.SchemaUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/UnknownFunctionException.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/UnknownFunctionException.java new file mode 100644 index 00000000..1f669927 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/UnknownFunctionException.java @@ -0,0 +1,37 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.exception; + +/** + * Thrown by ParseNodeFactory when it could not identify a node as a valid function. + */ +public class UnknownFunctionException extends RuntimeException { + private static final long serialVersionUID = 1L; + private final String funcName; + + public UnknownFunctionException(String funcName) { + super(); + this.funcName = funcName; + } + + public String getFuncName() { + return funcName; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/ValueTypeIncompatibleException.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/ValueTypeIncompatibleException.java new file mode 100644 index 00000000..403c0093 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/ValueTypeIncompatibleException.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.exception; + +import org.apache.phoenix.schema.IllegalDataException; +import org.apache.phoenix.schema.PDataType; + + +public class ValueTypeIncompatibleException extends IllegalDataException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.DATA_INCOMPATIBLE_WITH_TYPE; + + public ValueTypeIncompatibleException(PDataType type, Integer precision, Integer scale) { + super(new SQLExceptionInfo.Builder(code).setMessage(getTypeDisplayString(type, precision, scale)) + .build().toString()); + } + + private static String getTypeDisplayString(PDataType type, Integer precision, Integer scale) { + return type.toString() + "(" + precision + "," + scale + ")"; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/AggregatePlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java similarity index 59% rename from phoenix-core/src/main/java/com/salesforce/phoenix/execute/AggregatePlan.java rename to phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java index 4232c2fe..b16a4e1d 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/AggregatePlan.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java @@ -1,67 +1,59 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.execute; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.execute; import java.sql.SQLException; import java.util.Collections; import java.util.List; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.compile.OrderByCompiler.OrderBy; -import com.salesforce.phoenix.compile.RowProjector; -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.coprocessor.UngroupedAggregateRegionObserver; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.OrderByExpression; -import com.salesforce.phoenix.expression.RowKeyExpression; -import com.salesforce.phoenix.expression.aggregator.Aggregators; -import com.salesforce.phoenix.iterate.AggregatingResultIterator; -import com.salesforce.phoenix.iterate.ConcatResultIterator; -import com.salesforce.phoenix.iterate.DistinctAggregatingResultIterator; -import com.salesforce.phoenix.iterate.FilterAggregatingResultIterator; -import com.salesforce.phoenix.iterate.GroupedAggregatingResultIterator; -import com.salesforce.phoenix.iterate.LimitingResultIterator; -import com.salesforce.phoenix.iterate.MergeSortRowKeyResultIterator; -import com.salesforce.phoenix.iterate.OrderedAggregatingResultIterator; -import com.salesforce.phoenix.iterate.OrderedResultIterator; -import com.salesforce.phoenix.iterate.ParallelIterators; -import com.salesforce.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; -import com.salesforce.phoenix.iterate.PeekingResultIterator; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.iterate.SequenceResultIterator; -import com.salesforce.phoenix.iterate.SpoolingResultIterator; -import com.salesforce.phoenix.iterate.UngroupedAggregatingResultIterator; -import com.salesforce.phoenix.parse.FilterableStatement; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.TableRef; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.compile.OrderByCompiler.OrderBy; +import org.apache.phoenix.compile.RowProjector; +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.coprocessor.UngroupedAggregateRegionObserver; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.OrderByExpression; +import org.apache.phoenix.expression.RowKeyExpression; +import org.apache.phoenix.expression.aggregator.Aggregators; +import org.apache.phoenix.iterate.AggregatingResultIterator; +import org.apache.phoenix.iterate.ConcatResultIterator; +import org.apache.phoenix.iterate.DistinctAggregatingResultIterator; +import org.apache.phoenix.iterate.FilterAggregatingResultIterator; +import org.apache.phoenix.iterate.GroupedAggregatingResultIterator; +import org.apache.phoenix.iterate.LimitingResultIterator; +import org.apache.phoenix.iterate.MergeSortRowKeyResultIterator; +import org.apache.phoenix.iterate.OrderedAggregatingResultIterator; +import org.apache.phoenix.iterate.OrderedResultIterator; +import org.apache.phoenix.iterate.ParallelIterators; +import org.apache.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; +import org.apache.phoenix.iterate.PeekingResultIterator; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.iterate.SequenceResultIterator; +import org.apache.phoenix.iterate.SpoolingResultIterator; +import org.apache.phoenix.iterate.UngroupedAggregatingResultIterator; +import org.apache.phoenix.parse.FilterableStatement; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.TableRef; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/BasicQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/BasicQueryPlan.java similarity index 65% rename from phoenix-core/src/main/java/com/salesforce/phoenix/execute/BasicQueryPlan.java rename to phoenix-core/src/main/java/org/apache/phoenix/execute/BasicQueryPlan.java index ee64192c..2656aaf3 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/BasicQueryPlan.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/BasicQueryPlan.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.execute; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.execute; import java.sql.ParameterMetaData; import java.sql.SQLException; @@ -36,23 +28,23 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import com.google.common.collect.Lists; -import com.salesforce.phoenix.compile.ExplainPlan; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.compile.OrderByCompiler.OrderBy; -import com.salesforce.phoenix.compile.QueryPlan; -import com.salesforce.phoenix.compile.RowProjector; -import com.salesforce.phoenix.compile.ScanRanges; -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.iterate.DelegateResultIterator; -import com.salesforce.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.parse.FilterableStatement; -import com.salesforce.phoenix.query.ConnectionQueryServices; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.SQLCloseable; -import com.salesforce.phoenix.util.SQLCloseables; -import com.salesforce.phoenix.util.ScanUtil; +import org.apache.phoenix.compile.ExplainPlan; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.compile.OrderByCompiler.OrderBy; +import org.apache.phoenix.compile.QueryPlan; +import org.apache.phoenix.compile.RowProjector; +import org.apache.phoenix.compile.ScanRanges; +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.iterate.DelegateResultIterator; +import org.apache.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.parse.FilterableStatement; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.SQLCloseable; +import org.apache.phoenix.util.SQLCloseables; +import org.apache.phoenix.util.ScanUtil; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/CommitException.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/CommitException.java new file mode 100644 index 00000000..4ca47ec8 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/CommitException.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.execute; + +import java.sql.SQLException; + +public class CommitException extends SQLException { + private static final long serialVersionUID = 1L; + private final MutationState uncommittedState; + private final MutationState committedState; + + public CommitException(Exception e, MutationState uncommittedState, MutationState committedState) { + super(e); + this.uncommittedState = uncommittedState; + this.committedState = committedState; + } + + public MutationState getUncommittedState() { + return uncommittedState; + } + + public MutationState getCommittedState() { + return committedState; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/DegenerateQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/DegenerateQueryPlan.java new file mode 100644 index 00000000..ba38faee --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/DegenerateQueryPlan.java @@ -0,0 +1,52 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.execute; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.compile.OrderByCompiler.OrderBy; +import org.apache.phoenix.compile.*; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.jdbc.PhoenixParameterMetaData; +import org.apache.phoenix.parse.FilterableStatement; +import org.apache.phoenix.query.*; +import org.apache.phoenix.schema.TableRef; + +public class DegenerateQueryPlan extends BasicQueryPlan { + + public DegenerateQueryPlan(StatementContext context, FilterableStatement statement, TableRef table) { + super(context, statement, table, RowProjector.EMPTY_PROJECTOR, PhoenixParameterMetaData.EMPTY_PARAMETER_META_DATA, null, OrderBy.EMPTY_ORDER_BY, GroupBy.EMPTY_GROUP_BY, null); + context.setScanRanges(ScanRanges.NOTHING); + } + + @Override + public List getSplits() { + return Collections.emptyList(); + } + + @Override + protected ResultIterator newIterator() throws SQLException { + return null; + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/HashJoinPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java similarity index 63% rename from phoenix-core/src/main/java/com/salesforce/phoenix/execute/HashJoinPlan.java rename to phoenix-core/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java index 884ecf90..73b456a5 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/HashJoinPlan.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.execute; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.execute; import java.sql.ParameterMetaData; import java.sql.SQLException; @@ -37,25 +29,25 @@ import org.apache.hadoop.hbase.client.Scan; import com.google.common.collect.Lists; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.cache.ServerCacheClient.ServerCache; -import com.salesforce.phoenix.compile.ExplainPlan; -import com.salesforce.phoenix.compile.QueryPlan; -import com.salesforce.phoenix.compile.RowProjector; -import com.salesforce.phoenix.compile.ScanRanges; -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.compile.OrderByCompiler.OrderBy; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.job.JobManager.JobCallable; -import com.salesforce.phoenix.join.HashCacheClient; -import com.salesforce.phoenix.join.HashJoinInfo; -import com.salesforce.phoenix.parse.FilterableStatement; -import com.salesforce.phoenix.query.ConnectionQueryServices; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.SQLCloseable; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.cache.ServerCacheClient.ServerCache; +import org.apache.phoenix.compile.ExplainPlan; +import org.apache.phoenix.compile.QueryPlan; +import org.apache.phoenix.compile.RowProjector; +import org.apache.phoenix.compile.ScanRanges; +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.compile.OrderByCompiler.OrderBy; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.job.JobManager.JobCallable; +import org.apache.phoenix.join.HashCacheClient; +import org.apache.phoenix.join.HashJoinInfo; +import org.apache.phoenix.parse.FilterableStatement; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.SQLCloseable; public class HashJoinPlan implements QueryPlan { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/MutationState.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java similarity index 87% rename from phoenix-core/src/main/java/com/salesforce/phoenix/execute/MutationState.java rename to phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java index c883295f..298c7c10 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/execute/MutationState.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.execute; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.execute; import java.io.IOException; import java.sql.SQLException; @@ -46,27 +38,27 @@ import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.cache.ServerCacheClient; -import com.salesforce.phoenix.cache.ServerCacheClient.ServerCache; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.index.IndexMaintainer; -import com.salesforce.phoenix.index.IndexMetaDataCacheClient; -import com.salesforce.phoenix.index.PhoenixIndexCodec; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.IllegalDataException; -import com.salesforce.phoenix.schema.MetaDataClient; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PRow; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.IndexUtil; -import com.salesforce.phoenix.util.PhoenixRuntime; -import com.salesforce.phoenix.util.SQLCloseable; -import com.salesforce.phoenix.util.ServerUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.cache.ServerCacheClient; +import org.apache.phoenix.cache.ServerCacheClient.ServerCache; +import org.apache.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.index.IndexMaintainer; +import org.apache.phoenix.index.IndexMetaDataCacheClient; +import org.apache.phoenix.index.PhoenixIndexCodec; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.IllegalDataException; +import org.apache.phoenix.schema.MetaDataClient; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PRow; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.IndexUtil; +import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.SQLCloseable; +import org.apache.phoenix.util.ServerUtil; /** * diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java new file mode 100644 index 00000000..01199c98 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java @@ -0,0 +1,116 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.execute; + + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.compile.OrderByCompiler.OrderBy; +import org.apache.phoenix.compile.RowProjector; +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.coprocessor.ScanRegionObserver; +import org.apache.phoenix.iterate.ConcatResultIterator; +import org.apache.phoenix.iterate.LimitingResultIterator; +import org.apache.phoenix.iterate.MergeSortRowKeyResultIterator; +import org.apache.phoenix.iterate.MergeSortTopNResultIterator; +import org.apache.phoenix.iterate.ParallelIterators; +import org.apache.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.iterate.SequenceResultIterator; +import org.apache.phoenix.iterate.SpoolingResultIterator; +import org.apache.phoenix.parse.FilterableStatement; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.SaltingUtil; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.ScanUtil; + + + +/** + * + * Query plan for a basic table scan + * + * @author jtaylor + * @since 0.1 + */ +public class ScanPlan extends BasicQueryPlan { + private List splits; + + public ScanPlan(StatementContext context, FilterableStatement statement, TableRef table, RowProjector projector, Integer limit, OrderBy orderBy, ParallelIteratorFactory parallelIteratorFactory) { + super(context, statement, table, projector, context.getBindManager().getParameterMetaData(), limit, orderBy, null, parallelIteratorFactory == null ? new SpoolingResultIterator.SpoolingResultIteratorFactory(context.getConnection().getQueryServices()) : parallelIteratorFactory); + if (!orderBy.getOrderByExpressions().isEmpty()) { // TopN + int thresholdBytes = context.getConnection().getQueryServices().getProps().getInt( + QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB, QueryServicesOptions.DEFAULT_SPOOL_THRESHOLD_BYTES); + ScanRegionObserver.serializeIntoScan(context.getScan(), thresholdBytes, limit == null ? -1 : limit, orderBy.getOrderByExpressions(), projector.getEstimatedRowByteSize()); + } + } + + @Override + public List getSplits() { + return splits; + } + + @Override + protected ResultIterator newIterator() throws SQLException { + // Set any scan attributes before creating the scanner, as it will be too late afterwards + context.getScan().setAttribute(ScanRegionObserver.NON_AGGREGATE_QUERY, QueryConstants.TRUE); + if (OrderBy.REV_ROW_KEY_ORDER_BY.equals(orderBy)) { + ScanUtil.setReversed(context.getScan()); + } + ResultIterator scanner; + TableRef tableRef = this.getTableRef(); + PTable table = tableRef.getTable(); + boolean isSalted = table.getBucketNum() != null; + /* If no limit or topN, use parallel iterator so that we get results faster. Otherwise, if + * limit is provided, run query serially. + */ + boolean isOrdered = !orderBy.getOrderByExpressions().isEmpty(); + ParallelIterators iterators = new ParallelIterators(context, tableRef, statement, projection, GroupBy.EMPTY_GROUP_BY, isOrdered ? null : limit, parallelIteratorFactory); + splits = iterators.getSplits(); + if (isOrdered) { + scanner = new MergeSortTopNResultIterator(iterators, limit, orderBy.getOrderByExpressions()); + } else { + if (isSalted && + (getConnectionQueryServices(context.getConnection().getQueryServices()).getProps().getBoolean( + QueryServices.ROW_KEY_ORDER_SALTED_TABLE_ATTRIB, + QueryServicesOptions.DEFAULT_ROW_KEY_ORDER_SALTED_TABLE) || + orderBy == OrderBy.FWD_ROW_KEY_ORDER_BY || + orderBy == OrderBy.REV_ROW_KEY_ORDER_BY)) { // ORDER BY was optimized out b/c query is in row key order + scanner = new MergeSortRowKeyResultIterator(iterators, SaltingUtil.NUM_SALTING_BYTES, orderBy == OrderBy.REV_ROW_KEY_ORDER_BY); + } else { + scanner = new ConcatResultIterator(iterators); + } + if (limit != null) { + scanner = new LimitingResultIterator(scanner, limit); + } + } + + if (context.getSequenceManager().getSequenceCount() > 0) { + scanner = new SequenceResultIterator(scanner, context.getSequenceManager()); + } + return scanner; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/AddExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/AddExpression.java new file mode 100644 index 00000000..fd906c5f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/AddExpression.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.util.List; + +import org.apache.phoenix.expression.visitor.ExpressionVisitor; + + +/** + * + * Subtract expression implementation + * + * @author jtaylor + * @since 0.1 + */ +public abstract class AddExpression extends BaseAddSubtractExpression { + public AddExpression() { + } + + public AddExpression(List children) { + super(children); + } + + @Override + public final T accept(ExpressionVisitor visitor) { + List l = acceptChildren(visitor, visitor.visitEnter(this)); + T t = visitor.visitLeave(this, l); + if (t == null) { + t = visitor.defaultReturn(this, l); + } + return t; + } + + @Override + public String getOperatorString() { + return " + "; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/AndExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/AndExpression.java new file mode 100644 index 00000000..c35eca51 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/AndExpression.java @@ -0,0 +1,79 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.util.List; + +import org.apache.phoenix.expression.visitor.ExpressionVisitor; + + +/** + * + * AND expression implementation + * + * @author jtaylor + * @since 0.1 + */ +public class AndExpression extends AndOrExpression { + private static final String AND = "AND"; + + public static String combine(String expression1, String expression2) { + if (expression1 == null) { + return expression2; + } + if (expression2 == null) { + return expression1; + } + return "(" + expression1 + ") " + AND + " (" + expression2 + ")"; + } + + public AndExpression() { + } + + public AndExpression(List children) { + super(children); + } + + @Override + protected boolean getStopValue() { + return Boolean.FALSE; + } + + @Override + public String toString() { + StringBuilder buf = new StringBuilder("("); + for (int i = 0; i < children.size() - 1; i++) { + buf.append(children.get(i) + " " + AND + " "); + } + buf.append(children.get(children.size()-1)); + buf.append(')'); + return buf.toString(); + } + + @Override + public final T accept(ExpressionVisitor visitor) { + List l = acceptChildren(visitor, visitor.visitEnter(this)); + T t = visitor.visitLeave(this, l); + if (t == null) { + t = visitor.defaultReturn(this, l); + } + return t; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/AndOrExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/AndOrExpression.java similarity index 54% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/AndOrExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/AndOrExpression.java index c45dd843..aebd63ae 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/AndOrExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/AndOrExpression.java @@ -1,39 +1,31 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.util.BitSet; import java.util.List; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/ArithmeticExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/ArithmeticExpression.java new file mode 100644 index 00000000..622d709c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/ArithmeticExpression.java @@ -0,0 +1,45 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.util.List; + +public abstract class ArithmeticExpression extends BaseCompoundExpression { + + public ArithmeticExpression() { + } + + public ArithmeticExpression(List children) { + super(children); + } + + @Override + public String toString() { + StringBuilder buf = new StringBuilder("("); + for (int i = 0; i < children.size() - 1; i++) { + buf.append(children.get(i) + getOperatorString()); + } + buf.append(children.get(children.size()-1)); + buf.append(')'); + return buf.toString(); + } + + abstract protected String getOperatorString(); +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/ArrayConstructorExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/ArrayConstructorExpression.java similarity index 55% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/ArrayConstructorExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/ArrayConstructorExpression.java index 63dc5a49..6dbf8650 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/ArrayConstructorExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/ArrayConstructorExpression.java @@ -1,19 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2014, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the following conditions are met: Redistributions of source code - * must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in - * binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of Salesforce.com nor the names - * of its contributors may be used to endorse or promote products derived from this software without specific prior - * written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.io.DataInput; import java.io.DataOutput; @@ -25,10 +29,10 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.phoenix.schema.PArrayDataType; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PhoenixArray; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.schema.PArrayDataType; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PhoenixArray; +import org.apache.phoenix.schema.tuple.Tuple; /** * Creates an expression for Upsert with Values/Select using ARRAY @@ -94,4 +98,4 @@ public void write(DataOutput output) throws IOException { WritableUtils.writeVInt(output, baseType.ordinal()); } -} +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseAddSubtractExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseAddSubtractExpression.java new file mode 100644 index 00000000..1b9e4e54 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseAddSubtractExpression.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.util.List; + +import org.apache.phoenix.schema.PDataType; + + +abstract public class BaseAddSubtractExpression extends ArithmeticExpression { + public BaseAddSubtractExpression() { + } + + public BaseAddSubtractExpression(List children) { + super(children); + } + + protected static Integer getPrecision(Integer lp, Integer rp, Integer ls, Integer rs) { + if (ls == null || rs == null) { + return PDataType.MAX_PRECISION; + } + int val = getScale(lp, rp, ls, rs) + Math.max(lp - ls, rp - rs) + 1; + return Math.min(PDataType.MAX_PRECISION, val); + } + + protected static Integer getScale(Integer lp, Integer rp, Integer ls, Integer rs) { + // If we are adding a decimal with scale and precision to a decimal + // with no precision nor scale, the scale system does not apply. + if (ls == null || rs == null) { + return null; + } + int val = Math.max(ls, rs); + return Math.min(PDataType.MAX_PRECISION, val); + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseCompoundExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseCompoundExpression.java similarity index 65% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseCompoundExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/BaseCompoundExpression.java index 22bee05f..82a130d3 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseCompoundExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseCompoundExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.io.DataInput; import java.io.DataOutput; @@ -36,7 +28,7 @@ import org.apache.hadoop.io.WritableUtils; import com.google.common.collect.ImmutableList; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; public abstract class BaseCompoundExpression extends BaseExpression { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseDecimalAddSubtractExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseDecimalAddSubtractExpression.java similarity index 54% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseDecimalAddSubtractExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/BaseDecimalAddSubtractExpression.java index 9f88e4d1..4f641fe5 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/BaseDecimalAddSubtractExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseDecimalAddSubtractExpression.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.expression; +package org.apache.phoenix.expression; public class BaseDecimalAddSubtractExpression { diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseExpression.java new file mode 100644 index 00000000..9bd55813 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseExpression.java @@ -0,0 +1,108 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.schema.ColumnModifier; + + + +/** + * + * Base class for Expression hierarchy that provides common + * default implementations for most methods + * + * @author jtaylor + * @since 0.1 + */ +public abstract class BaseExpression implements Expression { + @Override + public boolean isNullable() { + return false; + } + + @Override + public Integer getByteSize() { + return getDataType().isFixedWidth() ? getDataType().getByteSize() : null; + } + + @Override + public Integer getMaxLength() { + return null; + } + + @Override + public Integer getScale() { + return null; + } + + @Override + public ColumnModifier getColumnModifier() { + return null; + } + + @Override + public void readFields(DataInput input) throws IOException { + } + + @Override + public void write(DataOutput output) throws IOException { + } + + @Override + public void reset() { + } + + protected final List acceptChildren(ExpressionVisitor visitor, Iterator iterator) { + if (iterator == null) { + iterator = visitor.defaultIterator(this); + } + List l = Collections.emptyList(); + while (iterator.hasNext()) { + Expression child = iterator.next(); + T t = child.accept(visitor); + if (t != null) { + if (l.isEmpty()) { + l = new ArrayList(getChildren().size()); + } + l.add(t); + } + } + return l; + } + + @Override + public boolean isDeterministic() { + return true; + } + + @Override + public boolean isStateless() { + return false; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseSingleExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseSingleExpression.java new file mode 100644 index 00000000..17584387 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseSingleExpression.java @@ -0,0 +1,91 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.util.List; + +import org.apache.hadoop.io.WritableUtils; + +import com.google.common.collect.ImmutableList; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; + + +/** + * + * Base class for expressions which have a single child expression + * + * @author jtaylor + * @since 0.1 + */ +public abstract class BaseSingleExpression extends BaseExpression { + + protected List children; + + public BaseSingleExpression() { + } + + public BaseSingleExpression(Expression expression) { + this.children = ImmutableList.of(expression); + } + + @Override + public List getChildren() { + return children; + } + + @Override + public void readFields(DataInput input) throws IOException { + Expression expression = ExpressionType.values()[WritableUtils.readVInt(input)].newInstance(); + expression.readFields(input); + children = ImmutableList.of(expression); + } + + @Override + public void write(DataOutput output) throws IOException { + WritableUtils.writeVInt(output, ExpressionType.valueOf(children.get(0)).ordinal()); + children.get(0).write(output); + } + + @Override + public boolean isNullable() { + return children.get(0).isNullable(); + } + + @Override + public void reset() { + children.get(0).reset(); + } + + @Override + public T accept(ExpressionVisitor visitor) { + List l = acceptChildren(visitor, null); + if (l.isEmpty()) { + return visitor.defaultReturn(this, l); + } + return l.get(0); + } + + public Expression getChild() { + return children.get(0); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseTerminalExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseTerminalExpression.java new file mode 100644 index 00000000..aaa43718 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/BaseTerminalExpression.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.util.Collections; +import java.util.List; + +import org.apache.phoenix.expression.visitor.ExpressionVisitor; + + + +/** + * + * Grouping class for expression that have no expression children + * + * @author jtaylor + * @since 0.1 + */ +public abstract class BaseTerminalExpression extends BaseExpression { + @Override + public List getChildren() { + return Collections.emptyList(); + } + + @Override + public T accept(ExpressionVisitor visitor) { + return null; + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/CaseExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/CaseExpression.java similarity index 77% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/CaseExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/CaseExpression.java index c10ffe65..f9a524a5 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/CaseExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/CaseExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.io.DataInput; import java.io.DataOutput; @@ -37,11 +29,11 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/CoerceExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/CoerceExpression.java similarity index 66% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/CoerceExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/CoerceExpression.java index 1e35fce8..827d70e8 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/CoerceExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/CoerceExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.io.DataInput; import java.io.DataOutput; @@ -36,10 +28,10 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; public class CoerceExpression extends BaseSingleExpression { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/ColumnExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/ColumnExpression.java similarity index 67% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/ColumnExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/ColumnExpression.java index ba78d086..bfb0d70a 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/ColumnExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/ColumnExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.io.DataInput; import java.io.DataOutput; @@ -34,9 +26,9 @@ import org.apache.hadoop.io.WritableUtils; import com.google.common.base.Objects; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PDatum; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PDatum; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/ComparisonExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/ComparisonExpression.java similarity index 67% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/ComparisonExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/ComparisonExpression.java index 9a74539d..5d3af1b0 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/ComparisonExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/ComparisonExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.io.DataInput; import java.io.DataOutput; @@ -36,12 +28,12 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.StringUtil; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.StringUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/CurrentDateTimeFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/CurrentDateTimeFunction.java new file mode 100644 index 00000000..b221c1ca --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/CurrentDateTimeFunction.java @@ -0,0 +1,44 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.util.List; + +import org.apache.phoenix.expression.function.ScalarFunction; + +public abstract class CurrentDateTimeFunction extends ScalarFunction { + + public CurrentDateTimeFunction() { + } + + public CurrentDateTimeFunction(List children) { + super(children); + } + + @Override + public boolean isStateless() { + return true; + } + + @Override + public boolean isDeterministic() { + return false; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/DateAddExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/DateAddExpression.java new file mode 100644 index 00000000..a36bb48f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/DateAddExpression.java @@ -0,0 +1,80 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.math.BigDecimal; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + + +public class DateAddExpression extends AddExpression { + static private final BigDecimal BD_MILLIS_IN_DAY = BigDecimal.valueOf(QueryConstants.MILLIS_IN_DAY); + + public DateAddExpression() { + } + + public DateAddExpression(List children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + long finalResult=0; + + for(int i=0;i children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + long finalResult=0; + + for(int i=0;i children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + BigDecimal result = null; + for (int i=0; i children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + BigDecimal result = null; + for (int i=0; i children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + double result = 0.0; + for (int i = 0; i < children.size(); i++) { + Expression child = children.get(i); + if (!child.evaluate(tuple, ptr)) { + return false; + } + if (ptr.getLength() == 0) { + return true; + } + double childvalue = child.getDataType().getCodec() + .decodeDouble(ptr, child.getColumnModifier()); + if (!Double.isNaN(childvalue) + && childvalue != Double.NEGATIVE_INFINITY + && childvalue != Double.POSITIVE_INFINITY) { + result += childvalue; + } else { + return false; + } + } + byte[] resultPtr = new byte[getDataType().getByteSize()]; + ptr.set(resultPtr); + getDataType().getCodec().encodeDouble(result, ptr); + return true; + } + + @Override + public PDataType getDataType() { + return PDataType.DOUBLE; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/DoubleDivideExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/DoubleDivideExpression.java new file mode 100644 index 00000000..561cf90f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/DoubleDivideExpression.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + +public class DoubleDivideExpression extends DivideExpression { + + public DoubleDivideExpression() { + } + + public DoubleDivideExpression(List children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + double result = 0.0; + for (int i = 0; i < children.size(); i++) { + Expression child = children.get(i); + if (!child.evaluate(tuple, ptr)) { + return false; + } + if (ptr.getLength() == 0) { + return true; + } + double childvalue = child.getDataType().getCodec() + .decodeDouble(ptr, child.getColumnModifier()); + if (!Double.isNaN(childvalue) + && childvalue != Double.NEGATIVE_INFINITY + && childvalue != Double.POSITIVE_INFINITY) { + if (i == 0) { + result = childvalue; + } else { + result /= childvalue; + } + } else { + return false; + } + } + byte[] resultPtr = new byte[getDataType().getByteSize()]; + ptr.set(resultPtr); + getDataType().getCodec().encodeDouble(result, ptr); + return true; + } + + @Override + public PDataType getDataType() { + return PDataType.DOUBLE; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/DoubleMultiplyExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/DoubleMultiplyExpression.java new file mode 100644 index 00000000..b9e81657 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/DoubleMultiplyExpression.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + +public class DoubleMultiplyExpression extends MultiplyExpression { + + public DoubleMultiplyExpression() { + } + + public DoubleMultiplyExpression(List children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + double result = 1.0; + for (int i = 0; i < children.size(); i++) { + Expression child = children.get(i); + if (!child.evaluate(tuple, ptr)) { + return false; + } + if (ptr.getLength() == 0) { + return true; + } + double childvalue = child.getDataType().getCodec() + .decodeDouble(ptr, child.getColumnModifier()); + if (!Double.isNaN(childvalue) + && childvalue != Double.NEGATIVE_INFINITY + && childvalue != Double.POSITIVE_INFINITY) { + result *= childvalue; + } else { + return false; + } + } + byte[] resultPtr = new byte[getDataType().getByteSize()]; + ptr.set(resultPtr); + getDataType().getCodec().encodeDouble(result, ptr); + return true; + } + + @Override + public PDataType getDataType() { + return PDataType.DOUBLE; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/DoubleSubtractExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/DoubleSubtractExpression.java new file mode 100644 index 00000000..8752c154 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/DoubleSubtractExpression.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + +public class DoubleSubtractExpression extends SubtractExpression { + + public DoubleSubtractExpression() { + } + + public DoubleSubtractExpression(List children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + double result = 0.0; + for (int i = 0; i < children.size(); i++) { + Expression child = children.get(i); + if (!child.evaluate(tuple, ptr)) { + return false; + } + if (ptr.getLength() == 0) { + return true; + } + double childvalue = child.getDataType().getCodec() + .decodeDouble(ptr, child.getColumnModifier()); + if (!Double.isNaN(childvalue) + && childvalue != Double.NEGATIVE_INFINITY + && childvalue != Double.POSITIVE_INFINITY) { + if (i == 0) { + result = childvalue; + } else { + result -= childvalue; + } + } else { + return false; + } + } + byte[] resultPtr = new byte[getDataType().getByteSize()]; + ptr.set(resultPtr); + getDataType().getCodec().encodeDouble(result, ptr); + return true; + } + + @Override + public PDataType getDataType() { + return PDataType.DOUBLE; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/Expression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/Expression.java new file mode 100644 index 00000000..ddced6a9 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/Expression.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; +import org.apache.hadoop.io.Writable; + +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.schema.PDatum; +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Interface for general expression evaluation + * + * @author jtaylor + * @since 0.1 + */ +public interface Expression extends PDatum, Writable { + /** + * Access the value by setting a pointer to it (as opposed to making + * a copy of it which can be expensive) + * @param tuple Single row result during scan iteration + * @param ptr Pointer to byte value being accessed + * @return true if the expression could be evaluated (i.e. ptr was set) + * and false otherwise + */ + boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr); + + /** + * Means of traversing expression tree through visitor. + * @param visitor + */ + T accept(ExpressionVisitor visitor); + + /** + * @return the child expressions + */ + List getChildren(); + + /** + * Resets the state of a expression back to its initial state and + * enables the expession to be evaluated incrementally (which + * occurs during filter evaluation where we see one key value at + * a time; it's possible to evaluate immediately rather than + * wait until all key values have been seen). Note that when + * evaluating incrementally, you must call this method before + * processing a new row. + */ + void reset(); + + /** + * @return true if the expression can be evaluated without + * requiring a row Tuple and false otherwise. + */ + boolean isStateless(); + /** + * @return true if the expression returns the same output every + * time given the same input. + */ + boolean isDeterministic(); +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/ExpressionType.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/ExpressionType.java similarity index 53% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/ExpressionType.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/ExpressionType.java index 5fb3dbd3..24bcf21f 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/ExpressionType.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/ExpressionType.java @@ -1,79 +1,71 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.util.Map; import com.google.common.collect.Maps; -import com.salesforce.phoenix.expression.function.ArrayIndexFunction; -import com.salesforce.phoenix.expression.function.ArrayLengthFunction; -import com.salesforce.phoenix.expression.function.CeilDateExpression; -import com.salesforce.phoenix.expression.function.CeilDecimalExpression; -import com.salesforce.phoenix.expression.function.CeilFunction; -import com.salesforce.phoenix.expression.function.CeilTimestampExpression; -import com.salesforce.phoenix.expression.function.CoalesceFunction; -import com.salesforce.phoenix.expression.function.CountAggregateFunction; -import com.salesforce.phoenix.expression.function.DistinctCountAggregateFunction; -import com.salesforce.phoenix.expression.function.FloorDateExpression; -import com.salesforce.phoenix.expression.function.FloorDecimalExpression; -import com.salesforce.phoenix.expression.function.FloorFunction; -import com.salesforce.phoenix.expression.function.IndexStateNameFunction; -import com.salesforce.phoenix.expression.function.InvertFunction; -import com.salesforce.phoenix.expression.function.LTrimFunction; -import com.salesforce.phoenix.expression.function.LengthFunction; -import com.salesforce.phoenix.expression.function.LowerFunction; -import com.salesforce.phoenix.expression.function.MD5Function; -import com.salesforce.phoenix.expression.function.MaxAggregateFunction; -import com.salesforce.phoenix.expression.function.MinAggregateFunction; -import com.salesforce.phoenix.expression.function.PercentRankAggregateFunction; -import com.salesforce.phoenix.expression.function.PercentileContAggregateFunction; -import com.salesforce.phoenix.expression.function.PercentileDiscAggregateFunction; -import com.salesforce.phoenix.expression.function.RTrimFunction; -import com.salesforce.phoenix.expression.function.RegexpReplaceFunction; -import com.salesforce.phoenix.expression.function.RegexpSubstrFunction; -import com.salesforce.phoenix.expression.function.ReverseFunction; -import com.salesforce.phoenix.expression.function.RoundDateExpression; -import com.salesforce.phoenix.expression.function.RoundDecimalExpression; -import com.salesforce.phoenix.expression.function.RoundFunction; -import com.salesforce.phoenix.expression.function.RoundTimestampExpression; -import com.salesforce.phoenix.expression.function.SQLTableTypeFunction; -import com.salesforce.phoenix.expression.function.SQLViewTypeFunction; -import com.salesforce.phoenix.expression.function.SqlTypeNameFunction; -import com.salesforce.phoenix.expression.function.StddevPopFunction; -import com.salesforce.phoenix.expression.function.StddevSampFunction; -import com.salesforce.phoenix.expression.function.SubstrFunction; -import com.salesforce.phoenix.expression.function.SumAggregateFunction; -import com.salesforce.phoenix.expression.function.ToCharFunction; -import com.salesforce.phoenix.expression.function.ToDateFunction; -import com.salesforce.phoenix.expression.function.ToNumberFunction; -import com.salesforce.phoenix.expression.function.TrimFunction; -import com.salesforce.phoenix.expression.function.TruncFunction; -import com.salesforce.phoenix.expression.function.UpperFunction; +import org.apache.phoenix.expression.function.ArrayIndexFunction; +import org.apache.phoenix.expression.function.ArrayLengthFunction; +import org.apache.phoenix.expression.function.CeilDateExpression; +import org.apache.phoenix.expression.function.CeilDecimalExpression; +import org.apache.phoenix.expression.function.CeilFunction; +import org.apache.phoenix.expression.function.CeilTimestampExpression; +import org.apache.phoenix.expression.function.CoalesceFunction; +import org.apache.phoenix.expression.function.CountAggregateFunction; +import org.apache.phoenix.expression.function.DistinctCountAggregateFunction; +import org.apache.phoenix.expression.function.FloorDateExpression; +import org.apache.phoenix.expression.function.FloorDecimalExpression; +import org.apache.phoenix.expression.function.FloorFunction; +import org.apache.phoenix.expression.function.IndexStateNameFunction; +import org.apache.phoenix.expression.function.InvertFunction; +import org.apache.phoenix.expression.function.LTrimFunction; +import org.apache.phoenix.expression.function.LengthFunction; +import org.apache.phoenix.expression.function.LowerFunction; +import org.apache.phoenix.expression.function.MD5Function; +import org.apache.phoenix.expression.function.MaxAggregateFunction; +import org.apache.phoenix.expression.function.MinAggregateFunction; +import org.apache.phoenix.expression.function.PercentRankAggregateFunction; +import org.apache.phoenix.expression.function.PercentileContAggregateFunction; +import org.apache.phoenix.expression.function.PercentileDiscAggregateFunction; +import org.apache.phoenix.expression.function.RTrimFunction; +import org.apache.phoenix.expression.function.RegexpReplaceFunction; +import org.apache.phoenix.expression.function.RegexpSubstrFunction; +import org.apache.phoenix.expression.function.ReverseFunction; +import org.apache.phoenix.expression.function.RoundDateExpression; +import org.apache.phoenix.expression.function.RoundDecimalExpression; +import org.apache.phoenix.expression.function.RoundFunction; +import org.apache.phoenix.expression.function.RoundTimestampExpression; +import org.apache.phoenix.expression.function.SQLTableTypeFunction; +import org.apache.phoenix.expression.function.SQLViewTypeFunction; +import org.apache.phoenix.expression.function.SqlTypeNameFunction; +import org.apache.phoenix.expression.function.StddevPopFunction; +import org.apache.phoenix.expression.function.StddevSampFunction; +import org.apache.phoenix.expression.function.SubstrFunction; +import org.apache.phoenix.expression.function.SumAggregateFunction; +import org.apache.phoenix.expression.function.ToCharFunction; +import org.apache.phoenix.expression.function.ToDateFunction; +import org.apache.phoenix.expression.function.ToNumberFunction; +import org.apache.phoenix.expression.function.TrimFunction; +import org.apache.phoenix.expression.function.TruncFunction; +import org.apache.phoenix.expression.function.UpperFunction; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/InListExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/InListExpression.java similarity index 82% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/InListExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/InListExpression.java index 5dc621c7..f6a397d4 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/InListExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/InListExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.io.DataInput; import java.io.DataOutput; @@ -43,12 +35,12 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.schema.ConstraintViolationException; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.schema.ConstraintViolationException; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; /* * Implementation of a SQL foo IN (a,b,c) expression. Other than the first diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/IndexKeyValueColumnExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/IndexKeyValueColumnExpression.java similarity index 79% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/IndexKeyValueColumnExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/IndexKeyValueColumnExpression.java index 65a08039..fb066c17 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/IndexKeyValueColumnExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/IndexKeyValueColumnExpression.java @@ -1,10 +1,10 @@ -package com.salesforce.phoenix.expression; +package org.apache.phoenix.expression; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.util.IndexUtil; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.util.IndexUtil; +import org.apache.phoenix.util.SchemaUtil; public class IndexKeyValueColumnExpression extends KeyValueColumnExpression { public IndexKeyValueColumnExpression() { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/IsNullExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/IsNullExpression.java similarity index 50% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/IsNullExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/IsNullExpression.java index 0e26781b..e6ef6218 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/IsNullExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/IsNullExpression.java @@ -1,40 +1,32 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.io.*; import java.util.List; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/KeyValueColumnExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/KeyValueColumnExpression.java similarity index 52% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/KeyValueColumnExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/KeyValueColumnExpression.java index 8a155389..b082abaf 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/KeyValueColumnExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/KeyValueColumnExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.io.DataInput; import java.io.DataOutput; @@ -35,10 +27,10 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.SchemaUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/LikeExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/LikeExpression.java similarity index 82% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/LikeExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/LikeExpression.java index fbf0d8b5..038f7050 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/LikeExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/LikeExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.io.DataInput; import java.io.IOException; @@ -36,10 +28,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.StringUtil; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.StringUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/LiteralExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/LiteralExpression.java similarity index 82% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/LiteralExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/LiteralExpression.java index a42ce4a4..202bcb05 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/LiteralExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/LiteralExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.io.DataInput; import java.io.DataOutput; @@ -35,16 +27,16 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.IllegalDataException; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.TypeMismatchException; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.StringUtil; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.IllegalDataException; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.TypeMismatchException; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.StringUtil; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/LongAddExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/LongAddExpression.java new file mode 100644 index 00000000..a14286d6 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/LongAddExpression.java @@ -0,0 +1,62 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + + +public class LongAddExpression extends AddExpression { + + public LongAddExpression() { + } + + public LongAddExpression(List children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + long finalResult=0; + + for(int i=0;i children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + long finalResult=0; + + for(int i=0;i children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + long finalResult=1; + + for(int i=0;i children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + long finalResult=0; + + for(int i=0;i T accept(ExpressionVisitor visitor) { + List l = acceptChildren(visitor, visitor.visitEnter(this)); + T t = visitor.visitLeave(this, l); + if (t == null) { + t = visitor.defaultReturn(this, l); + } + return t; + } + + @Override + public String toString() { + StringBuilder buf = new StringBuilder("NOT ("); + buf.append(children.get(0).toString()); + buf.append(")"); + return buf.toString(); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/OrExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/OrExpression.java new file mode 100644 index 00000000..7339852c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/OrExpression.java @@ -0,0 +1,67 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.util.List; + +import org.apache.phoenix.expression.visitor.ExpressionVisitor; + + +/** + * + * OR expression implementation + * + * @author jtaylor + * @since 0.1 + */ +public class OrExpression extends AndOrExpression { + public OrExpression() { + } + + public OrExpression(List children) { + super(children); + } + + @Override + protected boolean getStopValue() { + return Boolean.TRUE; + } + + @Override + public String toString() { + StringBuilder buf = new StringBuilder("("); + for (int i = 0; i < children.size() - 1; i++) { + buf.append(children.get(i) + " OR "); + } + buf.append(children.get(children.size()-1)); + buf.append(')'); + return buf.toString(); + } + + @Override + public final T accept(ExpressionVisitor visitor) { + List l = acceptChildren(visitor, visitor.visitEnter(this)); + T t = visitor.visitLeave(this, l); + if (t == null) { + t = visitor.defaultReturn(this, l); + } + return t; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/OrderByExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/OrderByExpression.java similarity index 98% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/OrderByExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/OrderByExpression.java index fe9d42dd..67d7e994 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/OrderByExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/OrderByExpression.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.expression; +package org.apache.phoenix.expression; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/ProjectedColumnExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java similarity index 58% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/ProjectedColumnExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java index f0a95292..22628821 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/ProjectedColumnExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.io.DataInput; import java.io.DataOutput; @@ -34,15 +26,15 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.join.ScanProjector; -import com.salesforce.phoenix.schema.KeyValueSchema; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.ValueBitSet; -import com.salesforce.phoenix.schema.KeyValueSchema.KeyValueSchemaBuilder; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.join.ScanProjector; +import org.apache.phoenix.schema.KeyValueSchema; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.ValueBitSet; +import org.apache.phoenix.schema.KeyValueSchema.KeyValueSchemaBuilder; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.SchemaUtil; public class ProjectedColumnExpression extends ColumnExpression { private KeyValueSchema schema; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/RowKeyColumnExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/RowKeyColumnExpression.java similarity index 66% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/RowKeyColumnExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/RowKeyColumnExpression.java index 31107020..383ef2e9 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/RowKeyColumnExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/RowKeyColumnExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.io.DataInput; import java.io.DataOutput; @@ -33,12 +25,12 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PDatum; -import com.salesforce.phoenix.schema.RowKeyValueAccessor; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PDatum; +import org.apache.phoenix.schema.RowKeyValueAccessor; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/RowKeyExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/RowKeyExpression.java similarity index 77% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/RowKeyExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/RowKeyExpression.java index 518bb48a..c3119329 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/RowKeyExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/RowKeyExpression.java @@ -1,9 +1,9 @@ -package com.salesforce.phoenix.expression; +package org.apache.phoenix.expression; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; public class RowKeyExpression extends BaseTerminalExpression { public static final RowKeyExpression INSTANCE = new RowKeyExpression(); diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/RowValueConstructorExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java similarity index 85% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/RowValueConstructorExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java index c5ed69b3..3e410cbf 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/RowValueConstructorExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java @@ -1,30 +1,22 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /** * Implementation for row value constructor (a,b,c) expression. @@ -32,7 +24,7 @@ * @author samarth.jain * @since 0.1 */ -package com.salesforce.phoenix.expression; +package org.apache.phoenix.expression; import java.io.DataInput; import java.io.DataOutput; @@ -45,18 +37,18 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import com.google.common.collect.Lists; -import com.salesforce.phoenix.expression.function.CeilDecimalExpression; -import com.salesforce.phoenix.expression.function.CeilTimestampExpression; -import com.salesforce.phoenix.expression.function.FloorDateExpression; -import com.salesforce.phoenix.expression.function.FloorDecimalExpression; -import com.salesforce.phoenix.expression.function.TimeUnit; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.TypeMismatchException; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.TrustedByteArrayOutputStream; +import org.apache.phoenix.expression.function.CeilDecimalExpression; +import org.apache.phoenix.expression.function.CeilTimestampExpression; +import org.apache.phoenix.expression.function.FloorDateExpression; +import org.apache.phoenix.expression.function.FloorDecimalExpression; +import org.apache.phoenix.expression.function.TimeUnit; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.TypeMismatchException; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.TrustedByteArrayOutputStream; public class RowValueConstructorExpression extends BaseCompoundExpression { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/StringConcatExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/StringConcatExpression.java similarity index 50% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/StringConcatExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/StringConcatExpression.java index c5a86927..24e96f7c 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/StringConcatExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/StringConcatExpression.java @@ -1,42 +1,34 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.util.List; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/SubtractExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/SubtractExpression.java new file mode 100644 index 00000000..a9c9c932 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/SubtractExpression.java @@ -0,0 +1,60 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; + +import java.math.BigDecimal; +import java.util.List; + +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.query.QueryConstants; + + +/** + * + * Subtract expression implementation + * + * @author kmahadik + * @since 0.1 + */ +public abstract class SubtractExpression extends BaseAddSubtractExpression { + protected static final BigDecimal BD_MILLIS_IN_DAY = BigDecimal.valueOf(QueryConstants.MILLIS_IN_DAY); + + public SubtractExpression() { + } + + public SubtractExpression(List children) { + super(children); + } + + @Override + public final T accept(ExpressionVisitor visitor) { + List l = acceptChildren(visitor, visitor.visitEnter(this)); + T t = visitor.visitLeave(this, l); + if (t == null) { + t = visitor.defaultReturn(this, l); + } + return t; + } + + @Override + public String getOperatorString() { + return " - "; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/TimestampAddExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/TimestampAddExpression.java similarity index 52% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/TimestampAddExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/TimestampAddExpression.java index 6ff37b48..12067042 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/TimestampAddExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/TimestampAddExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.math.BigDecimal; import java.math.RoundingMode; @@ -34,11 +26,11 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.DateUtil; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.DateUtil; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/TimestampSubtractExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/TimestampSubtractExpression.java similarity index 53% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/TimestampSubtractExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/TimestampSubtractExpression.java index 80e7d59b..57450c03 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/TimestampSubtractExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/TimestampSubtractExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression; import java.math.BigDecimal; import java.math.RoundingMode; @@ -34,10 +26,10 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.DateUtil; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.DateUtil; /** * * Class to encapsulate subtraction arithmetic for {@link PDataType#TIMESTAMP}. diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/Aggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/Aggregator.java new file mode 100644 index 00000000..4067eb45 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/Aggregator.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Interface to abstract the incremental calculation of an aggregated value. + * + * @author jtaylor + * @since 0.1 + */ +public interface Aggregator extends Expression { + + /** + * Incrementally aggregate the value with the current row + * @param tuple the result containing all the key values of the row + * @param ptr the bytes pointer to the underlying result + */ + public void aggregate(Tuple tuple, ImmutableBytesWritable ptr); + + /** + * Get the size in bytes + */ + public int getSize(); +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/Aggregators.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/Aggregators.java similarity index 59% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/Aggregators.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/Aggregators.java index efd66744..18dfc4a1 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/Aggregators.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/Aggregators.java @@ -1,40 +1,32 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.function.SingleAggregateFunction; -import com.salesforce.phoenix.schema.KeyValueSchema; -import com.salesforce.phoenix.schema.KeyValueSchema.KeyValueSchemaBuilder; -import com.salesforce.phoenix.schema.ValueBitSet; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.SizedUtil; +import org.apache.phoenix.expression.function.SingleAggregateFunction; +import org.apache.phoenix.schema.KeyValueSchema; +import org.apache.phoenix.schema.KeyValueSchema.KeyValueSchemaBuilder; +import org.apache.phoenix.schema.ValueBitSet; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.SizedUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseAggregator.java new file mode 100644 index 00000000..8dd66687 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseAggregator.java @@ -0,0 +1,59 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.BaseTerminalExpression; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.util.SizedUtil; + +/** + * Base class for Aggregator implementations + * + * @author jtaylor + * @since 0.1 + */ +public abstract class BaseAggregator extends BaseTerminalExpression implements Aggregator { + + protected final ColumnModifier columnModifier; + + public BaseAggregator(ColumnModifier columnModifier) { + this.columnModifier = columnModifier; + } + + @Override + public boolean isNullable() { + return true; + } + + @Override + public int getSize() { + return SizedUtil.OBJECT_SIZE; + } + + ImmutableBytesWritable evalClientAggs(Aggregator clientAgg) { + CountAggregator ca = (CountAggregator)clientAgg; + ImmutableBytesWritable ptr = new ImmutableBytesWritable(); + ca.evaluate(null, ptr); + return ptr; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/BaseDecimalStddevAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseDecimalStddevAggregator.java similarity index 62% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/BaseDecimalStddevAggregator.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseDecimalStddevAggregator.java index 198d5a25..b28cb924 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/BaseDecimalStddevAggregator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseDecimalStddevAggregator.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; import java.math.*; import java.util.List; @@ -34,14 +26,14 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Pair; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.expression.ColumnExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.*; -import com.salesforce.phoenix.util.BigDecimalUtil.Operation; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.expression.ColumnExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.*; +import org.apache.phoenix.util.BigDecimalUtil.Operation; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/BaseStddevAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseStddevAggregator.java similarity index 50% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/BaseStddevAggregator.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseStddevAggregator.java index 52e6840a..eaafc793 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/BaseStddevAggregator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseStddevAggregator.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; import java.math.BigDecimal; import java.util.List; @@ -33,11 +25,11 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** * diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/ClientAggregators.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/ClientAggregators.java new file mode 100644 index 00000000..0ac5baf7 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/ClientAggregators.java @@ -0,0 +1,80 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import java.util.List; + +import org.apache.phoenix.expression.function.SingleAggregateFunction; +import org.apache.phoenix.schema.ValueBitSet; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.TupleUtil; + + + +/** + * + * Aggregators that execute on the client-side + * + * @author jtaylor + * @since 0.1 + */ +public class ClientAggregators extends Aggregators { + private final ValueBitSet tempValueSet; + + private static Aggregator[] getAggregators(List aggFuncs) { + Aggregator[] aggregators = new Aggregator[aggFuncs.size()]; + for (int i = 0; i < aggregators.length; i++) { + aggregators[i] = aggFuncs.get(i).getAggregator(); + } + return aggregators; + } + + public ClientAggregators(List functions, int minNullableIndex) { + super(functions.toArray(new SingleAggregateFunction[functions.size()]), getAggregators(functions), minNullableIndex); + this.tempValueSet = ValueBitSet.newInstance(schema); + } + + @Override + public void aggregate(Aggregator[] aggregators, Tuple result) { + TupleUtil.getAggregateValue(result, ptr); + tempValueSet.clear(); + tempValueSet.or(ptr); + + int i = 0, maxOffset = ptr.getOffset() + ptr.getLength(); + Boolean hasValue; + schema.iterator(ptr); + while ((hasValue=schema.next(ptr, i, maxOffset, tempValueSet)) != null) { + if (hasValue) { + aggregators[i].aggregate(result, ptr); + } + i++; + } + } + + @Override + public Aggregator[] newAggregators() { + Aggregator[] aggregators = new Aggregator[functions.length]; + for (int i = 0; i < functions.length; i++) { + aggregators[i] = functions[i].newClientAggregator(); + } + return aggregators; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/CountAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/CountAggregator.java new file mode 100644 index 00000000..33740c2e --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/CountAggregator.java @@ -0,0 +1,92 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.SizedUtil; + +/** + * + * Aggregator for COUNT aggregations + * + * @author jtaylor + * @since 0.1 + */ +public class CountAggregator extends BaseAggregator { + + private long count = 0; + private byte[] buffer = null; + + public CountAggregator() { + super(null); + } + + public CountAggregator(LongSumAggregator clientAgg) { + this(); + count = clientAgg.getSum(); + } + + @Override + public void aggregate(Tuple tuple, ImmutableBytesWritable ptr) { + count++; + } + + @Override + public boolean isNullable() { + return false; + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + if (buffer == null) { + buffer = new byte[getDataType().getByteSize()]; + } + getDataType().getCodec().encodeLong(count, buffer, 0); + ptr.set(buffer); + return true; + } + + @Override + public final PDataType getDataType() { + return PDataType.LONG; + } + + @Override + public void reset() { + count = 0; + buffer = null; + super.reset(); + } + + @Override + public String toString() { + return "COUNT [count=" + count + "]"; + } + + @Override + public int getSize() { + return super.getSize() + SizedUtil.LONG_SIZE + SizedUtil.ARRAY_SIZE + + getDataType().getByteSize(); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DecimalStddevPopAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DecimalStddevPopAggregator.java new file mode 100644 index 00000000..c707057e --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DecimalStddevPopAggregator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import java.util.List; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.ColumnModifier; + +/** + * Client side Aggregator for STDDEV_POP aggregations for DECIMAL data type. + * + * @author anoopsjohn + * @since 1.2.1 + */ +public class DecimalStddevPopAggregator extends BaseDecimalStddevAggregator { + + public DecimalStddevPopAggregator(List exps, ColumnModifier columnModifier) { + super(exps, columnModifier); + } + + @Override + protected long getDataPointsCount() { + return totalCount; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DecimalStddevSampAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DecimalStddevSampAggregator.java new file mode 100644 index 00000000..0aa19280 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DecimalStddevSampAggregator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import java.util.List; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.ColumnModifier; + +/** + * Client side Aggregator for STDDEV_SAMP aggregations for DECIMAL data type. + * + * @author anoopsjohn + * @since 1.2.1 + */ +public class DecimalStddevSampAggregator extends BaseDecimalStddevAggregator { + + public DecimalStddevSampAggregator(List exps, ColumnModifier columnModifier) { + super(exps, columnModifier); + } + + @Override + protected long getDataPointsCount() { + return totalCount - 1; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DecimalSumAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DecimalSumAggregator.java new file mode 100644 index 00000000..5b91ef3b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DecimalSumAggregator.java @@ -0,0 +1,103 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import java.math.BigDecimal; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.SizedUtil; + + +/** + * + * Aggregator that sums BigDecimal values + * + * @author jtaylor + * @since 0.1 + */ +public class DecimalSumAggregator extends BaseAggregator { + private BigDecimal sum = BigDecimal.ZERO; + private byte[] sumBuffer; + + public DecimalSumAggregator(ColumnModifier columnModifier, ImmutableBytesWritable ptr) { + super(columnModifier); + if (ptr != null) { + initBuffer(); + sum = (BigDecimal)PDataType.DECIMAL.toObject(ptr); + } + } + + private PDataType getInputDataType() { + return PDataType.DECIMAL; + } + + private int getBufferLength() { + return getDataType().getByteSize(); + } + + private void initBuffer() { + sumBuffer = new byte[getBufferLength()]; + } + + @Override + public void aggregate(Tuple tuple, ImmutableBytesWritable ptr) { + BigDecimal value = (BigDecimal)getDataType().toObject(ptr, getInputDataType(), columnModifier); + sum = sum.add(value); + if (sumBuffer == null) { + sumBuffer = new byte[getDataType().getByteSize()]; + } + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + if (sumBuffer == null) { + return false; + } + int len = getDataType().toBytes(sum, sumBuffer, 0); + ptr.set(sumBuffer, 0, len); + return true; + } + + @Override + public final PDataType getDataType() { + return PDataType.DECIMAL; + } + + @Override + public void reset() { + sum = BigDecimal.ZERO; + sumBuffer = null; + super.reset(); + } + + @Override + public String toString() { + return "DECIMAL SUM [sum=" + sum + "]"; + } + + @Override + public int getSize() { + return super.getSize() + SizedUtil.BIG_DECIMAL_SIZE + SizedUtil.ARRAY_SIZE + getDataType().getByteSize(); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DistinctCountClientAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DistinctCountClientAggregator.java new file mode 100644 index 00000000..d221e910 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DistinctCountClientAggregator.java @@ -0,0 +1,55 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + +/** + * Client side Aggregator for DISTINCT COUNT aggregations + * + * @author anoopsjohn + * @since 1.2.1 + */ +public class DistinctCountClientAggregator extends DistinctValueWithCountClientAggregator { + + public DistinctCountClientAggregator(ColumnModifier columnModifier) { + super(columnModifier); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + if (buffer == null) { + initBuffer(); + } + long value = this.valueVsCount.size(); + buffer = PDataType.LONG.toBytes(value); + ptr.set(buffer); + return true; + } + + @Override + protected int getBufferLength() { + return PDataType.LONG.getByteSize(); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DistinctValueWithCountClientAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DistinctValueWithCountClientAggregator.java similarity index 65% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DistinctValueWithCountClientAggregator.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DistinctValueWithCountClientAggregator.java index 59e063af..c009a28b 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DistinctValueWithCountClientAggregator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DistinctValueWithCountClientAggregator.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; import java.io.ByteArrayInputStream; import java.io.DataInputStream; @@ -41,10 +33,10 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** * Client side Aggregator which will aggregate data and find distinct values with number of occurrences for each. diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DistinctValueWithCountServerAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DistinctValueWithCountServerAggregator.java similarity index 75% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DistinctValueWithCountServerAggregator.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DistinctValueWithCountServerAggregator.java index 3110f29e..ef0a9c22 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/DistinctValueWithCountServerAggregator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DistinctValueWithCountServerAggregator.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; import java.io.ByteArrayOutputStream; import java.io.OutputStream; @@ -41,13 +33,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.SizedUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.SizedUtil; /** * Server side Aggregator which will aggregate data and find distinct values with number of occurrences for each. diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DoubleSumAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DoubleSumAggregator.java new file mode 100644 index 00000000..fa1dda7b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/DoubleSumAggregator.java @@ -0,0 +1,94 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.SizedUtil; + +public class DoubleSumAggregator extends BaseAggregator { + + private double sum = 0; + private byte[] buffer; + + public DoubleSumAggregator(ColumnModifier columnModifier, ImmutableBytesWritable ptr) { + super(columnModifier); + if (ptr != null) { + initBuffer(); + sum = PDataType.DOUBLE.getCodec().decodeDouble(ptr, columnModifier); + } + } + + protected PDataType getInputDataType() { + return PDataType.DOUBLE; + } + + private void initBuffer() { + buffer = new byte[getDataType().getByteSize()]; + } + + @Override + public void aggregate(Tuple tuple, ImmutableBytesWritable ptr) { + double value = getInputDataType().getCodec().decodeDouble(ptr, columnModifier); + sum += value; + if (buffer == null) { + initBuffer(); + } + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + if (buffer == null) { + if (isNullable()) { + return false; + } + initBuffer(); + } + ptr.set(buffer); + getDataType().getCodec().encodeDouble(sum, ptr); + return true; + } + + @Override + public PDataType getDataType() { + return PDataType.DOUBLE; + } + + @Override + public String toString() { + return "SUM [sum=" + sum + "]"; + } + + @Override + public void reset() { + sum = 0; + buffer = null; + super.reset(); + } + + @Override + public int getSize() { + return super.getSize() + SizedUtil.LONG_SIZE + SizedUtil.ARRAY_SIZE + getDataType().getByteSize(); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/IntSumAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/IntSumAggregator.java new file mode 100644 index 00000000..e96a993b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/IntSumAggregator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; + +/** + * + * Aggregator that sums integer values + * + * @author jtaylor + * @since 0.1 + */ +public class IntSumAggregator extends NumberSumAggregator { + + public IntSumAggregator(ColumnModifier columnModifier) { + super(columnModifier); + } + + @Override + protected PDataType getInputDataType() { + return PDataType.INTEGER; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/LongSumAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/LongSumAggregator.java new file mode 100644 index 00000000..bfdadc90 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/LongSumAggregator.java @@ -0,0 +1,42 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; + +/** + * + * Aggregator that sums long values + * + * @author jtaylor + * @since 0.1 + */ +public class LongSumAggregator extends NumberSumAggregator { + + public LongSumAggregator(ColumnModifier columnModifier) { + super(columnModifier); + } + + @Override + protected PDataType getInputDataType() { + return PDataType.LONG; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/MaxAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/MaxAggregator.java new file mode 100644 index 00000000..890e14aa --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/MaxAggregator.java @@ -0,0 +1,50 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; +import org.apache.hadoop.hbase.util.Bytes; + +import org.apache.phoenix.schema.ColumnModifier; + + +/** + * Aggregator that finds the max of values. Inverse of {@link MinAggregator}. + * + * @author syyang + * @since 0.1 + */ +abstract public class MaxAggregator extends MinAggregator { + + public MaxAggregator(ColumnModifier columnModifier) { + super(columnModifier); + } + + @Override + protected boolean keepFirst(ImmutableBytesWritable ibw1, ImmutableBytesWritable ibw2) { + return !super.keepFirst(ibw1, ibw2); + } + + @Override + public String toString() { + return "MAX [value=" + Bytes.toStringBinary(value.get(),value.getOffset(),value.getLength()) + "]"; + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/MinAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/MinAggregator.java similarity index 53% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/MinAggregator.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/MinAggregator.java index d1b636d3..8954de28 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/MinAggregator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/MinAggregator.java @@ -1,39 +1,31 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.SizedUtil; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.SizedUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/NumberSumAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/NumberSumAggregator.java similarity index 51% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/NumberSumAggregator.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/NumberSumAggregator.java index 0ad4ae23..a7cfcd19 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/NumberSumAggregator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/NumberSumAggregator.java @@ -1,38 +1,30 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.SizedUtil; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.SizedUtil; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/PercentRankClientAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/PercentRankClientAggregator.java similarity index 53% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/PercentRankClientAggregator.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/PercentRankClientAggregator.java index 333431df..42ca2676 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/PercentRankClientAggregator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/PercentRankClientAggregator.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; import java.math.BigDecimal; import java.util.*; @@ -33,10 +25,10 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.*; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.*; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** * Client side Aggregator for PERCENT_RANK aggregations diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/PercentileClientAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/PercentileClientAggregator.java similarity index 58% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/PercentileClientAggregator.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/PercentileClientAggregator.java index cbfb5bb6..095842ab 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/PercentileClientAggregator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/PercentileClientAggregator.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; import java.math.BigDecimal; import java.util.*; @@ -33,10 +25,10 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.*; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.*; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** * Client side Aggregator for PERCENTILE_CONT aggregations diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/PercentileDiscClientAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/PercentileDiscClientAggregator.java similarity index 56% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/PercentileDiscClientAggregator.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/PercentileDiscClientAggregator.java index 98efb0d3..206ed1d8 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/PercentileDiscClientAggregator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/PercentileDiscClientAggregator.java @@ -1,41 +1,33 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; import java.util.*; import java.util.Map.Entry; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.*; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.*; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/ServerAggregators.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/ServerAggregators.java similarity index 69% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/ServerAggregators.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/ServerAggregators.java index de6ad316..64577933 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/aggregator/ServerAggregators.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/ServerAggregators.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.aggregator; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -38,10 +30,10 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.ExpressionType; -import com.salesforce.phoenix.expression.function.SingleAggregateFunction; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.ExpressionType; +import org.apache.phoenix.expression.function.SingleAggregateFunction; +import org.apache.phoenix.schema.tuple.Tuple; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/StddevPopAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/StddevPopAggregator.java new file mode 100644 index 00000000..30276e11 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/StddevPopAggregator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import java.util.List; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.ColumnModifier; + +/** + * Client side Aggregator for STDDEV_POP aggregations + * + * @author anoopsjohn + * @since 1.2.1 + */ +public class StddevPopAggregator extends BaseStddevAggregator { + + public StddevPopAggregator(List exps, ColumnModifier columnModifier) { + super(exps, columnModifier); + } + + @Override + protected long getDataPointsCount() { + return totalCount; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/StddevSampAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/StddevSampAggregator.java new file mode 100644 index 00000000..49f52d22 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/StddevSampAggregator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import java.util.List; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.ColumnModifier; + +/** + * Client side Aggregator for STDDEV_SAMP aggregations + * + * @author anoopsjohn + * @since 1.2.1 + */ +public class StddevSampAggregator extends BaseStddevAggregator { + + public StddevSampAggregator(List exps, ColumnModifier columnModifier) { + super(exps, columnModifier); + } + + @Override + protected long getDataPointsCount() { + return totalCount - 1; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/UnsignedIntSumAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/UnsignedIntSumAggregator.java new file mode 100644 index 00000000..c8befcab --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/UnsignedIntSumAggregator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; + +/** + * + * Aggregator that sums unsigned integer values + * + * @author jtaylor + * @since 0.12 + */ +public class UnsignedIntSumAggregator extends NumberSumAggregator { + + public UnsignedIntSumAggregator(ColumnModifier columnModifier) { + super(columnModifier); + } + + @Override + protected PDataType getInputDataType() { + return PDataType.UNSIGNED_INT; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/UnsignedLongSumAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/UnsignedLongSumAggregator.java new file mode 100644 index 00000000..b91a9346 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/UnsignedLongSumAggregator.java @@ -0,0 +1,44 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.aggregator; + +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; + +/** + * + * Aggregator that sums unsigned long values + * TODO: create these classes dynamically based on the type passed through + * + * @author jtaylor + * @since 0.12 + */ +public class UnsignedLongSumAggregator extends NumberSumAggregator { + + public UnsignedLongSumAggregator(ColumnModifier columnModifier) { + super(columnModifier); + } + + @Override + protected PDataType getInputDataType() { + return PDataType.UNSIGNED_LONG; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/AggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/AggregateFunction.java new file mode 100644 index 00000000..72809f51 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/AggregateFunction.java @@ -0,0 +1,54 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.phoenix.expression.Expression; + + + + +/** + * + * Compiled representation of a built-in aggregate function + * + * @author jtaylor + * @since 0.1 + */ +abstract public class AggregateFunction extends FunctionExpression { + + public AggregateFunction() { + } + + public AggregateFunction(List children) { + super(children); + } + + @Override + public boolean isStateless() { + return false; + } + + @Override + public boolean isDeterministic() { + return false; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ArrayIndexFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ArrayIndexFunction.java new file mode 100644 index 00000000..a4185e6a --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ArrayIndexFunction.java @@ -0,0 +1,88 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.sql.Types; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.parse.ParseException; +import org.apache.phoenix.schema.PArrayDataType; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + +@BuiltInFunction(name = ArrayIndexFunction.NAME, args = { + @Argument(allowedTypes = { PDataType.BINARY_ARRAY, + PDataType.VARBINARY_ARRAY }), + @Argument(allowedTypes = { PDataType.INTEGER }) }) +public class ArrayIndexFunction extends ScalarFunction { + + public static final String NAME = "ARRAY_ELEM"; + + public ArrayIndexFunction() { + } + + public ArrayIndexFunction(List children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + Expression indexExpr = children.get(1); + if (!indexExpr.evaluate(tuple, ptr)) { + return false; + } else if (ptr.getLength() == 0) { + return true; + } + // Use Codec to prevent Integer object allocation + int index = PDataType.INTEGER.getCodec().decodeInt(ptr, indexExpr.getColumnModifier()); + if(index < 0) { + throw new ParseException("Index cannot be negative :" + index); + } + Expression arrayExpr = children.get(0); + if (!arrayExpr.evaluate(tuple, ptr)) { + return false; + } else if (ptr.getLength() == 0) { + return true; + } + + // Given a ptr to the entire array, set ptr to point to a particular element within that array + // given the type of an array element (see comments in PDataTypeForArray) + PArrayDataType.positionAtArrayElement(ptr, index, getDataType()); + return true; + + } + + @Override + public PDataType getDataType() { + return PDataType.fromTypeId(children.get(0).getDataType().getSqlType() + - Types.ARRAY); + } + + @Override + public String getName() { + return NAME; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ArrayLengthFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ArrayLengthFunction.java new file mode 100644 index 00000000..9a94129b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ArrayLengthFunction.java @@ -0,0 +1,75 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.sql.Types; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PArrayDataType; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + +@BuiltInFunction(name = ArrayLengthFunction.NAME, args = { @Argument(allowedTypes = { + PDataType.BINARY_ARRAY, PDataType.VARBINARY_ARRAY }) }) +public class ArrayLengthFunction extends ScalarFunction { + public static final String NAME = "ARRAY_LENGTH"; + + public ArrayLengthFunction() { + } + + public ArrayLengthFunction(List children) { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + Expression arrayExpr = children.get(0); + if (!arrayExpr.evaluate(tuple, ptr)) { + return false; + } else if (ptr.getLength() == 0) { + return true; + } + PDataType baseType = PDataType.fromTypeId(children.get(0).getDataType() + .getSqlType() + - Types.ARRAY); + int length = PArrayDataType.getArrayLength(ptr, baseType); + byte[] lengthBuf = new byte[PDataType.INTEGER.getByteSize()]; + PDataType.INTEGER.getCodec().encodeInt(length, lengthBuf, 0); + ptr.set(lengthBuf); + return true; + } + + @Override + public PDataType getDataType() { + // Array length will return an Integer + return PDataType.INTEGER; + } + + @Override + public String getName() { + return NAME; + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/AvgAggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/AvgAggregateFunction.java similarity index 57% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/AvgAggregateFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/AvgAggregateFunction.java index 15c2e7ae..62bb565e 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/AvgAggregateFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/AvgAggregateFunction.java @@ -1,44 +1,36 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.math.BigDecimal; import java.util.List; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.parse.*; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.parse.*; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; @BuiltInFunction(name=AvgAggregateFunction.NAME, nodeClass=AvgAggregateParseNode.class, args= {@Argument(allowedTypes={PDataType.DECIMAL})} ) diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilDateExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilDateExpression.java new file mode 100644 index 00000000..d0951cf8 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilDateExpression.java @@ -0,0 +1,77 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.sql.SQLException; +import java.util.List; + +import com.google.common.collect.Lists; +import org.apache.phoenix.expression.Expression; + +/** + * + * Class encapsulating ceil operation on {@link org.apache.phoenix.schema.PDataType#DATE}. + * + * @author samarth.jain + * @since 3.0.0 + */ +public class CeilDateExpression extends RoundDateExpression { + + public CeilDateExpression() {} + + /** + * @param timeUnit - unit of time to round up to. + * Creates a {@link CeilDateExpression} with default multiplier of 1. + */ + public static Expression create(Expression expr, TimeUnit timeUnit) throws SQLException { + return create(expr, timeUnit, 1); + } + + /** + * @param timeUnit - unit of time to round up to + * @param multiplier - determines the roll up window size. + * Create a {@link CeilDateExpression}. + */ + public static Expression create(Expression expr, TimeUnit timeUnit, int multiplier) throws SQLException { + Expression timeUnitExpr = getTimeUnitExpr(timeUnit); + Expression defaultMultiplierExpr = getMultiplierExpr(multiplier); + List expressions = Lists.newArrayList(expr, timeUnitExpr, defaultMultiplierExpr); + return CeilDateExpression.create(expressions); + } + + public static Expression create(List children) throws SQLException { + return new CeilDateExpression(children); + } + + CeilDateExpression(List children) { + super(children); + } + + @Override + protected long getRoundUpAmount() { + return divBy - 1; + } + + @Override + public String getName() { + return CeilFunction.NAME; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilDecimalExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilDecimalExpression.java new file mode 100644 index 00000000..dd2c22a9 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilDecimalExpression.java @@ -0,0 +1,77 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.math.RoundingMode; +import java.sql.SQLException; +import java.util.List; + +import com.google.common.collect.Lists; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.schema.PDataType; + +/** + * + * Class encapsulating the CEIL operation on a {@link org.apache.phoenix.schema.PDataType#DECIMAL} + * + * @author samarth.jain + * @since 3.0.0 + */ +public class CeilDecimalExpression extends RoundDecimalExpression { + + public CeilDecimalExpression() {} + + public CeilDecimalExpression(List children) { + super(children); + } + + /** + * Creates a {@link CeilDecimalExpression} with rounding scale given by @param scale. + * + */ + public static Expression create(Expression expr, int scale) throws SQLException { + if (expr.getDataType().isCoercibleTo(PDataType.LONG)) { + return expr; + } + Expression scaleExpr = LiteralExpression.newConstant(scale, PDataType.INTEGER, true); + List expressions = Lists.newArrayList(expr, scaleExpr); + return new CeilDecimalExpression(expressions); + } + + /** + * Creates a {@link CeilDecimalExpression} with a default scale of 0 used for rounding. + * + */ + public static Expression create(Expression expr) throws SQLException { + return create(expr, 0); + } + + @Override + protected RoundingMode getRoundingMode() { + return RoundingMode.CEILING; + } + + @Override + public String getName() { + return CeilFunction.NAME; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilFunction.java new file mode 100644 index 00000000..60ad329b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilFunction.java @@ -0,0 +1,57 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.CeilParseNode; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +/** + * + * Base class for built-in CEIL function. + * + * @author samarth.jain + * @since 3.0.0 + */ +@BuiltInFunction(name = CeilFunction.NAME, + nodeClass = CeilParseNode.class, + args = { + @Argument(allowedTypes={PDataType.TIMESTAMP, PDataType.DECIMAL}), + @Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValue = "null", isConstant=true), + @Argument(allowedTypes={PDataType.INTEGER}, defaultValue="1", isConstant=true) + } + ) +public abstract class CeilFunction extends ScalarFunction { + + public static final String NAME = "CEIL"; + + public CeilFunction(List children) { + super(children); + } + + @Override + public String getName() { + return NAME; + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilTimestampExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilTimestampExpression.java similarity index 59% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilTimestampExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilTimestampExpression.java index bd387eae..7f54cbc0 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CeilTimestampExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CeilTimestampExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.sql.SQLException; import java.sql.Timestamp; @@ -34,17 +26,17 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import com.google.common.collect.Lists; -import com.salesforce.phoenix.expression.CoerceExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PDataType.PDataCodec; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.CoerceExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PDataType.PDataCodec; +import org.apache.phoenix.schema.tuple.Tuple; /** * - * Class encapsulating the CEIL operation on {@link com.salesforce.phoenix.schema.PDataType#TIMESTAMP} + * Class encapsulating the CEIL operation on {@link org.apache.phoenix.schema.PDataType#TIMESTAMP} * This class only supports CEIL {@link TimeUnit#MILLISECOND}. If you want more options of CEIL like * using {@link TimeUnit#HOUR} use {@link CeilDateExpression} * diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CoalesceFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CoalesceFunction.java new file mode 100644 index 00000000..05f6bd8d --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CoalesceFunction.java @@ -0,0 +1,100 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Function used to provide an alternative value when the first argument is null. + * Usage: + * COALESCE(expr1,expr2) + * If expr1 is not null, then it is returned, otherwise expr2 is returned. + * + * TODO: better bind parameter type matching, since arg2 must be coercible + * to arg1. consider allowing a common base type? + * @author jtaylor + * @since 0.1 + */ +@BuiltInFunction(name=CoalesceFunction.NAME, args= { + @Argument(), + @Argument()} ) +public class CoalesceFunction extends ScalarFunction { + public static final String NAME = "COALESCE"; + + public CoalesceFunction() { + } + + public CoalesceFunction(List children) throws SQLException { + super(children); + if (!children.get(1).getDataType().isCoercibleTo(children.get(0).getDataType())) { + throw new SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_CONVERT_TYPE) + .setMessage(getName() + " expected " + children.get(0).getDataType() + ", but got " + children.get(1).getDataType()) + .build().buildException(); + } + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + if (children.get(0).evaluate(tuple, ptr)) { + return true; + } + return children.get(1).evaluate(tuple, ptr); + } + + @Override + public PDataType getDataType() { + return children.get(0).getDataType(); + } + + @Override + public Integer getByteSize() { + Integer maxByteSize1 = children.get(0).getByteSize(); + if (maxByteSize1 != null) { + Integer maxByteSize2 = children.get(1).getByteSize(); + if (maxByteSize2 != null) { + return maxByteSize1 > maxByteSize2 ? maxByteSize1 : maxByteSize2; + } + } + return null; + } + + @Override + public boolean isNullable() { + return children.get(0).isNullable() && children.get(1).isNullable(); + } + + @Override + public String getName() { + return NAME; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CompositeAggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CompositeAggregateFunction.java new file mode 100644 index 00000000..2c8da08c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CompositeAggregateFunction.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; + + +/** + * + * Base class for aggregation functions which are composed of other + * aggregation functions (for example, AVG is modeled as a SUM aggregate + * function and a COUNT aggregate function). + * + * @author jtaylor + * @since 0.1 + */ +abstract public class CompositeAggregateFunction extends AggregateFunction { + + public CompositeAggregateFunction(List children) { + super(children); + } + + @Override + public final T accept(ExpressionVisitor visitor) { + return null; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CountAggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CountAggregateFunction.java similarity index 51% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CountAggregateFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/CountAggregateFunction.java index 0ed9b05d..5e7dceb4 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/CountAggregateFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CountAggregateFunction.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.util.Arrays; import java.util.List; @@ -33,15 +25,15 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.CountAggregator; -import com.salesforce.phoenix.expression.aggregator.LongSumAggregator; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.CountAggregator; +import org.apache.phoenix.expression.aggregator.LongSumAggregator; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.util.SchemaUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CurrentDateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CurrentDateFunction.java new file mode 100644 index 00000000..ad9e989a --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CurrentDateFunction.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.CurrentDateTimeFunction; +import org.apache.phoenix.parse.CurrentDateParseNode; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Function that returns the current date accurate to the millisecond. Note that this + * function is never evaluated on the server-side, instead the server side date is + * retrieved (piggy-backed on the call to check that the metadata is up-to-date) and + * passed into this function at create time. + * + * @author jtaylor + * @since 0.1 + */ +@BuiltInFunction(name=CurrentDateFunction.NAME, nodeClass=CurrentDateParseNode.class, args= {} ) +public class CurrentDateFunction extends CurrentDateTimeFunction { + public static final String NAME = "CURRENT_DATE"; + private final ImmutableBytesWritable currentDate = new ImmutableBytesWritable(new byte[PDataType.DATE.getByteSize()]); + + public CurrentDateFunction() { + this(System.currentTimeMillis()); + } + + public CurrentDateFunction(long timeStamp) { + getDataType().getCodec().encodeLong(timeStamp, currentDate); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + ptr.set(currentDate.get(), 0, PDataType.DATE.getByteSize()); + return true; + } + + @Override + public final PDataType getDataType() { + return PDataType.DATE; + } + + @Override + public String getName() { + return NAME; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CurrentTimeFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CurrentTimeFunction.java new file mode 100644 index 00000000..71a16024 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/CurrentTimeFunction.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.CurrentDateTimeFunction; +import org.apache.phoenix.parse.CurrentTimeParseNode; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Function that returns the current date accurate to the millisecond. Note that this + * function is never evaluated on the server-side, instead the server side date is + * retrieved (piggy-backed on the call to check that the metadata is up-to-date) and + * passed into this function at create time. + * + * @author jtaylor + * @since 0.1 + */ +@BuiltInFunction(name=CurrentTimeFunction.NAME, nodeClass=CurrentTimeParseNode.class, args={} ) +public class CurrentTimeFunction extends CurrentDateTimeFunction { + public static final String NAME = "CURRENT_TIME"; + private final ImmutableBytesWritable currentDate = new ImmutableBytesWritable(new byte[PDataType.TIME.getByteSize()]); + + public CurrentTimeFunction() { + this(System.currentTimeMillis()); + } + + public CurrentTimeFunction(long timeStamp) { + getDataType().getCodec().encodeLong(timeStamp, currentDate); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + ptr.set(currentDate.get(), 0, PDataType.TIME.getByteSize()); + return true; + } + + @Override + public final PDataType getDataType() { + return PDataType.TIME; + } + + @Override + public String getName() { + return NAME; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/DelegateConstantToCountAggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/DelegateConstantToCountAggregateFunction.java new file mode 100644 index 00000000..744e5bbb --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/DelegateConstantToCountAggregateFunction.java @@ -0,0 +1,75 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Base class for non composite aggregation functions that optimize aggregation by + * delegating to {@link CountAggregateFunction} when the child expression is a + * constant. + * + * @author jtaylor + * @since 0.1 + */ +abstract public class DelegateConstantToCountAggregateFunction extends SingleAggregateFunction { + private static final ImmutableBytesWritable ZERO = new ImmutableBytesWritable(PDataType.LONG.toBytes(0L)); + private CountAggregateFunction delegate; + + public DelegateConstantToCountAggregateFunction() { + } + + public DelegateConstantToCountAggregateFunction(List childExpressions, CountAggregateFunction delegate) { + super(childExpressions); + // Using a delegate here causes us to optimize the number of aggregators + // by sharing the CountAggregator across functions. On the server side, + // this will always be null, since if it had not been null on the client, + // the function would not have been transfered over (the delegate would + // have instead). + this.delegate = delegate; + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + if (delegate == null) { + return super.evaluate(tuple, ptr); + } + delegate.evaluate(tuple, ptr); + if (PDataType.LONG.compareTo(ptr,ZERO) == 0) { + return false; + } + return true; + } + + + @Override + protected SingleAggregateFunction getDelegate() { + return delegate != null ? delegate : super.getDelegate(); + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/DistinctCountAggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/DistinctCountAggregateFunction.java similarity index 56% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/DistinctCountAggregateFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/DistinctCountAggregateFunction.java index 0f74d5a6..b6ea58e0 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/DistinctCountAggregateFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/DistinctCountAggregateFunction.java @@ -1,46 +1,38 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.util.List; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctCountClientAggregator; -import com.salesforce.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.DistinctCountClientAggregator; +import org.apache.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.SchemaUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/DistinctValueWithCountAggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/DistinctValueWithCountAggregateFunction.java new file mode 100644 index 00000000..b12c96af --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/DistinctValueWithCountAggregateFunction.java @@ -0,0 +1,50 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.DistinctValueWithCountClientAggregator; +import org.apache.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; + +public abstract class DistinctValueWithCountAggregateFunction extends SingleAggregateFunction { + + public DistinctValueWithCountAggregateFunction() { + } + + public DistinctValueWithCountAggregateFunction(List children) { + super(children); + } + + @Override + abstract public DistinctValueWithCountClientAggregator newClientAggregator(); + + @Override + public Aggregator newServerAggregator(Configuration config, ImmutableBytesWritable ptr) { + DistinctValueWithCountClientAggregator clientAgg = newClientAggregator(); + clientAgg.aggregate(null, ptr); + return new DistinctValueWithCountServerAggregator(config, clientAgg); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FloorDateExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/FloorDateExpression.java similarity index 52% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FloorDateExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/FloorDateExpression.java index 7adb4bd5..bfc39693 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FloorDateExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/FloorDateExpression.java @@ -1,44 +1,36 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.sql.SQLException; import java.util.List; import com.google.common.collect.Lists; -import com.salesforce.phoenix.expression.CoerceExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.PDataType; +import org.apache.phoenix.expression.CoerceExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.PDataType; /** * * Class encapsulating the FLOOR operation on - * a column/literal of type {@link com.salesforce.phoenix.schema.PDataType#DATE}. + * a column/literal of type {@link org.apache.phoenix.schema.PDataType#DATE}. * * @author samarth.jain * @since 3.0.0 diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/FloorDecimalExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/FloorDecimalExpression.java new file mode 100644 index 00000000..e8353f21 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/FloorDecimalExpression.java @@ -0,0 +1,77 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.math.RoundingMode; +import java.sql.SQLException; +import java.util.List; + +import com.google.common.collect.Lists; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.schema.PDataType; + +/** + * + * Class encapsulating the FLOOR operation on + * a column/literal of type {@link org.apache.phoenix.schema.PDataType#DECIMAL}. + * + * @author samarth.jain + * @since 3.0.0 + */ +public class FloorDecimalExpression extends RoundDecimalExpression { + + public FloorDecimalExpression() {} + + public FloorDecimalExpression(List children) { + super(children); + } + + /** + * Creates a {@link FloorDecimalExpression} with rounding scale given by @param scale. + * + */ + public static Expression create(Expression expr, int scale) throws SQLException { + if (expr.getDataType().isCoercibleTo(PDataType.LONG)) { + return expr; + } + Expression scaleExpr = LiteralExpression.newConstant(scale, PDataType.INTEGER, true); + List expressions = Lists.newArrayList(expr, scaleExpr); + return new FloorDecimalExpression(expressions); + } + + /** + * Creates a {@link FloorDecimalExpression} with a default scale of 0 used for rounding. + * + */ + public static Expression create(Expression expr) throws SQLException { + return create(expr, 0); + } + + @Override + protected RoundingMode getRoundingMode() { + return RoundingMode.FLOOR; + } + + @Override + public String getName() { + return FloorFunction.NAME; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/FloorFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/FloorFunction.java new file mode 100644 index 00000000..cceb9660 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/FloorFunction.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FloorParseNode; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +/** + * + * Base class for built-in FLOOR function. + * + * @author samarth.jain + * @since 3.0.0 + */ +@BuiltInFunction(name = FloorFunction.NAME, + nodeClass = FloorParseNode.class, + args = { + @Argument(allowedTypes={PDataType.TIMESTAMP, PDataType.DECIMAL}), + @Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValue = "null", isConstant=true), + @Argument(allowedTypes={PDataType.INTEGER}, defaultValue="1", isConstant=true) + } + ) +public abstract class FloorFunction extends ScalarFunction { + + public static final String NAME = "FLOOR"; + + public FloorFunction(List children) { + super(children); + } + + @Override + public String getName() { + return NAME; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FunctionArgumentType.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/FunctionArgumentType.java similarity index 89% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FunctionArgumentType.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/FunctionArgumentType.java index 160facc8..0284caf9 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/FunctionArgumentType.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/FunctionArgumentType.java @@ -1,9 +1,9 @@ -package com.salesforce.phoenix.expression.function; +package org.apache.phoenix.expression.function; import java.text.DecimalFormat; import java.text.Format; -import com.salesforce.phoenix.util.DateUtil; +import org.apache.phoenix.util.DateUtil; public enum FunctionArgumentType { TEMPORAL { diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/FunctionExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/FunctionExpression.java new file mode 100644 index 00000000..db305d3c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/FunctionExpression.java @@ -0,0 +1,71 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.phoenix.expression.BaseCompoundExpression; +import org.apache.phoenix.expression.Expression; + +/** + * + * Compiled representation of a built-in function + * + * @author jtaylor + * @since 0.1 + */ +public abstract class FunctionExpression extends BaseCompoundExpression { + public enum OrderPreserving {NO, YES_IF_LAST, YES}; + public FunctionExpression() { + } + + public FunctionExpression(List children) { + super(children); + } + + /** + * Determines whether or not the result of the function invocation + * will be ordered in the same way as the input to the function. + * Returning YES enables an optimization to occur when a + * GROUP BY contains function invocations using the leading PK + * column(s). + * @return YES if the function invocation will always preserve order for + * the inputs versus the outputs and false otherwise, YES_IF_LAST if the + * function preserves order, but any further column reference would not + * continue to preserve order, and NO if the function does not preserve + * order. + */ + public OrderPreserving preservesOrder() { + return OrderPreserving.NO; + } + + abstract public String getName(); + + @Override + public final String toString() { + StringBuilder buf = new StringBuilder(getName() + "("); + for (int i = 0; i < children.size() - 1; i++) { + buf.append(children.get(i) + ", "); + } + buf.append(children.get(children.size()-1) + ")"); + return buf.toString(); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/IndexStateNameFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/IndexStateNameFunction.java new file mode 100644 index 00000000..41890bc7 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/IndexStateNameFunction.java @@ -0,0 +1,81 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Function used to get the index state name from the serialized byte value + * Usage: + * IndexStateName('a') + * will return 'ACTIVE' + * + * @author jtaylor + * @since 2.1 + */ +@BuiltInFunction(name=IndexStateNameFunction.NAME, args= { + @Argument(allowedTypes=PDataType.CHAR)} ) +public class IndexStateNameFunction extends ScalarFunction { + public static final String NAME = "IndexStateName"; + + public IndexStateNameFunction() { + } + + public IndexStateNameFunction(List children) throws SQLException { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + Expression child = children.get(0); + if (!child.evaluate(tuple, ptr)) { + return false; + } + if (ptr.getLength() == 0) { + return true; + } + byte serializedByte = ptr.get()[ptr.getOffset()]; + PIndexState indexState = PIndexState.fromSerializedValue(serializedByte); + ptr.set(indexState.toBytes()); + return true; + } + + @Override + public PDataType getDataType() { + return PDataType.VARCHAR; + } + + @Override + public String getName() { + return NAME; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/InvertFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/InvertFunction.java similarity index 53% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/InvertFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/InvertFunction.java index a4d70c22..72ac31aa 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/InvertFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/InvertFunction.java @@ -1,19 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the following conditions are met: Redistributions of source code - * must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in - * binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of Salesforce.com nor the names - * of its contributors may be used to endorse or promote products derived from this software without specific prior - * written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.sql.SQLException; import java.util.List; @@ -21,15 +25,15 @@ import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.compile.KeyPart; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.compile.KeyPart; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; @BuiltInFunction(name = InvertFunction.NAME, args = { @Argument() }) public class InvertFunction extends ScalarFunction { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/LTrimFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/LTrimFunction.java similarity index 53% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/LTrimFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/LTrimFunction.java index 42216e18..1622f55d 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/LTrimFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/LTrimFunction.java @@ -1,45 +1,37 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.sql.SQLException; import java.util.List; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.StringUtil; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.StringUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/LengthFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/LengthFunction.java new file mode 100644 index 00000000..770f77a6 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/LengthFunction.java @@ -0,0 +1,96 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.io.UnsupportedEncodingException; +import java.sql.SQLException; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.StringUtil; + + +/** + * + * Implementation of the LENGTH() build-in function. is the string + * of characters we want to find the length of. If is NULL or empty, null + * is returned. + * + * @author zhuang + * @since 0.1 + */ +@BuiltInFunction(name=LengthFunction.NAME, args={ + @Argument(allowedTypes={PDataType.VARCHAR})} ) +public class LengthFunction extends ScalarFunction { + public static final String NAME = "LENGTH"; + + public LengthFunction() { } + + public LengthFunction(List children) throws SQLException { + super(children); + } + + private Expression getStringExpression() { + return children.get(0); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + Expression child = getStringExpression(); + if (!child.evaluate(tuple, ptr)) { + return false; + } + if (ptr.getLength() == 0) { + ptr.set(ByteUtil.EMPTY_BYTE_ARRAY); + return true; + } + int len; + if (child.getDataType() == PDataType.CHAR) { + // Only single-byte characters allowed in CHAR + len = ptr.getLength(); + } else { + try { + len = StringUtil.calculateUTF8Length(ptr.get(), ptr.getOffset(), ptr.getLength(), child.getColumnModifier()); + } catch (UnsupportedEncodingException e) { + return false; + } + } + ptr.set(PDataType.INTEGER.toBytes(len)); + return true; + } + + @Override + public PDataType getDataType() { + return PDataType.INTEGER; + } + + @Override + public String getName() { + return NAME; + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/LowerFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/LowerFunction.java similarity index 83% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/LowerFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/LowerFunction.java index 73fd8737..b8e731f1 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/LowerFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/LowerFunction.java @@ -1,14 +1,14 @@ -package com.salesforce.phoenix.expression.function; +package org.apache.phoenix.expression.function; import java.sql.SQLException; import java.util.List; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; @FunctionParseNode.BuiltInFunction(name=LowerFunction.NAME, args={ @FunctionParseNode.Argument(allowedTypes={PDataType.VARCHAR})} ) diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/MD5Function.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/MD5Function.java new file mode 100644 index 00000000..32ef6427 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/MD5Function.java @@ -0,0 +1,100 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.sql.SQLException; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + +@BuiltInFunction(name = MD5Function.NAME, args={@Argument()}) +public class MD5Function extends ScalarFunction { + public static final String NAME = "MD5"; + public static final Integer LENGTH = 16; + + private final MessageDigest messageDigest; + + public MD5Function() throws SQLException { + try { + messageDigest = MessageDigest.getInstance("MD5"); + } catch (NoSuchAlgorithmException e) { + throw new SQLException(e); + } + } + + public MD5Function(List children) throws SQLException { + super(children); + try { + messageDigest = MessageDigest.getInstance("MD5"); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException(e); + } + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + if (!getChildExpression().evaluate(tuple, ptr)) { + return false; + } + + // Update the digest value + messageDigest.update(ptr.get(), ptr.getOffset(), ptr.getLength()); + // Get the digest bytes (note this resets the messageDigest as well) + ptr.set(messageDigest.digest()); + return true; + } + + @Override + public PDataType getDataType() { + return PDataType.BINARY; + } + + @Override + public Integer getMaxLength() { + return LENGTH; + } + + @Override + public Integer getByteSize() { + return LENGTH; + } + + @Override + public boolean isNullable() { + return getChildExpression().isNullable(); + } + + @Override + public String getName() { + return NAME; + } + + private Expression getChildExpression() { + return children.get(0); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/MaxAggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/MaxAggregateFunction.java new file mode 100644 index 00000000..72e59841 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/MaxAggregateFunction.java @@ -0,0 +1,75 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.hadoop.conf.Configuration; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.MaxAggregator; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.parse.MaxAggregateParseNode; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; + + + +/** + * Built-in function for finding MAX. + * + * @author syyang + * @since 0.1 + */ +@BuiltInFunction(name=MaxAggregateFunction.NAME, nodeClass=MaxAggregateParseNode.class, args= {@Argument()} ) +public class MaxAggregateFunction extends MinAggregateFunction { + public static final String NAME = "MAX"; + + public MaxAggregateFunction() { + } + + public MaxAggregateFunction(List childExpressions, CountAggregateFunction delegate) { + super(childExpressions, delegate); + } + + @Override + public Aggregator newServerAggregator(Configuration conf) { + final PDataType type = getAggregatorExpression().getDataType(); + ColumnModifier columnModifier = getAggregatorExpression().getColumnModifier(); + return new MaxAggregator(columnModifier) { + @Override + public PDataType getDataType() { + return type; + } + }; + } + + @Override + public String getName() { + return NAME; + } + + @Override + public ColumnModifier getColumnModifier() { + return getAggregatorExpression().getColumnModifier(); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/MinAggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/MinAggregateFunction.java new file mode 100644 index 00000000..26e8fd9f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/MinAggregateFunction.java @@ -0,0 +1,89 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.MinAggregator; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.parse.MinAggregateParseNode; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + + + +/** + * Built-in function for finding MIN. + * + * @author syyang + * @since 0.1 + */ +@BuiltInFunction(name=MinAggregateFunction.NAME, nodeClass=MinAggregateParseNode.class, args= {@Argument()} ) +public class MinAggregateFunction extends DelegateConstantToCountAggregateFunction { + public static final String NAME = "MIN"; + + public MinAggregateFunction() { + } + + public MinAggregateFunction(List childExpressions, CountAggregateFunction delegate) { + super(childExpressions, delegate); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + boolean wasEvaluated = super.evaluate(tuple, ptr); + if (!wasEvaluated) { + return false; + } + if (isConstantExpression()) { + getAggregatorExpression().evaluate(tuple, ptr); + } + return true; + } + + @Override + public Aggregator newServerAggregator(Configuration conf) { + final PDataType type = getAggregatorExpression().getDataType(); + ColumnModifier columnModifier = getAggregatorExpression().getColumnModifier(); + return new MinAggregator(columnModifier) { + @Override + public PDataType getDataType() { + return type; + } + }; + } + + @Override + public ColumnModifier getColumnModifier() { + return getAggregatorExpression().getColumnModifier(); + } + + @Override + public String getName() { + return NAME; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/PercentRankAggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/PercentRankAggregateFunction.java new file mode 100644 index 00000000..bf6c9753 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/PercentRankAggregateFunction.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.hadoop.conf.Configuration; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.DistinctValueWithCountClientAggregator; +import org.apache.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; +import org.apache.phoenix.expression.aggregator.PercentRankClientAggregator; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; + +/** + * + * PERCENT_RANK([,]) WITHIN GROUP (ORDER BY [,] ASC/DESC) aggregate function + * + * @author anoopsjohn + * @since 1.2.1 + */ +@BuiltInFunction(name = PercentRankAggregateFunction.NAME, args = { @Argument(), + @Argument(allowedTypes = { PDataType.BOOLEAN }, isConstant = true), @Argument(isConstant = true) }) +public class PercentRankAggregateFunction extends DistinctValueWithCountAggregateFunction { + public static final String NAME = "PERCENT_RANK"; + + public PercentRankAggregateFunction() { + + } + + public PercentRankAggregateFunction(List childern) { + super(childern); + } + + @Override + public Aggregator newServerAggregator(Configuration conf) { + return new DistinctValueWithCountServerAggregator(conf); + } + + @Override + public DistinctValueWithCountClientAggregator newClientAggregator() { + return new PercentRankClientAggregator(children, getAggregatorExpression().getColumnModifier()); + } + + @Override + public String getName() { + return NAME; + } + + @Override + public PDataType getDataType() { + return PDataType.DECIMAL; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/PercentileContAggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/PercentileContAggregateFunction.java new file mode 100644 index 00000000..703d619c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/PercentileContAggregateFunction.java @@ -0,0 +1,75 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.hadoop.conf.Configuration; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.DistinctValueWithCountClientAggregator; +import org.apache.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; +import org.apache.phoenix.expression.aggregator.PercentileClientAggregator; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; + +/** + * + * Built-in function for PERCENTILE_CONT() WITHIN GROUP (ORDER BY ASC/DESC) aggregate function + * + * @author anoopsjohn + * @since 1.2.1 + */ +@BuiltInFunction(name = PercentileContAggregateFunction.NAME, args = { @Argument(allowedTypes = { PDataType.DECIMAL }), + @Argument(allowedTypes = { PDataType.BOOLEAN }, isConstant = true), + @Argument(allowedTypes = { PDataType.DECIMAL }, isConstant = true, minValue = "0", maxValue = "1") }) +public class PercentileContAggregateFunction extends DistinctValueWithCountAggregateFunction { + public static final String NAME = "PERCENTILE_CONT"; + + public PercentileContAggregateFunction() { + + } + + public PercentileContAggregateFunction(List childern) { + super(childern); + } + + @Override + public Aggregator newServerAggregator(Configuration conf) { + return new DistinctValueWithCountServerAggregator(conf); + } + + @Override + public DistinctValueWithCountClientAggregator newClientAggregator() { + return new PercentileClientAggregator(children, getAggregatorExpression().getColumnModifier()); + } + + @Override + public String getName() { + return NAME; + } + + @Override + public PDataType getDataType() { + return PDataType.DECIMAL; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/PercentileDiscAggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/PercentileDiscAggregateFunction.java new file mode 100644 index 00000000..7909c41e --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/PercentileDiscAggregateFunction.java @@ -0,0 +1,72 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.hadoop.conf.Configuration; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.DistinctValueWithCountClientAggregator; +import org.apache.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; +import org.apache.phoenix.expression.aggregator.PercentileDiscClientAggregator; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; + + +/** + * + * Built-in function for PERCENTILE_DISC() WITHIN GROUP (ORDER BY ASC/DESC) aggregate function + * + * @author ramkrishna + * @since 1.2.1 + */ +@BuiltInFunction(name = PercentileDiscAggregateFunction.NAME, args = { @Argument(allowedTypes = { PDataType.DECIMAL }), + @Argument(allowedTypes = { PDataType.BOOLEAN }, isConstant = true), + @Argument(allowedTypes = { PDataType.DECIMAL }, isConstant = true, minValue = "0", maxValue = "1") }) +public class PercentileDiscAggregateFunction extends DistinctValueWithCountAggregateFunction { + + public static final String NAME = "PERCENTILE_DISC"; + + public PercentileDiscAggregateFunction() { + } + + public PercentileDiscAggregateFunction(List childern) { + super(childern); + } + + @Override + public Aggregator newServerAggregator(Configuration conf) { + return new DistinctValueWithCountServerAggregator(conf); + } + + @Override + public DistinctValueWithCountClientAggregator newClientAggregator() { + return new PercentileDiscClientAggregator(children, getAggregatorExpression().getColumnModifier()); + } + + @Override + public String getName() { + return NAME; + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PrefixFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/PrefixFunction.java similarity index 88% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PrefixFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/PrefixFunction.java index b3ef87a5..2612d741 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/PrefixFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/PrefixFunction.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.expression.function; +package org.apache.phoenix.expression.function; import java.util.Collections; import java.util.List; @@ -6,12 +6,12 @@ import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.compile.KeyPart; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.util.ByteUtil; +import org.apache.phoenix.compile.KeyPart; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.util.ByteUtil; abstract public class PrefixFunction extends ScalarFunction { public PrefixFunction() { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RTrimFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RTrimFunction.java similarity index 63% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RTrimFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/RTrimFunction.java index 841bc50a..d7702a57 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RTrimFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RTrimFunction.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.sql.SQLException; import java.util.Collections; @@ -34,17 +26,17 @@ import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.compile.KeyPart; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.StringUtil; +import org.apache.phoenix.compile.KeyPart; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.StringUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RegexpReplaceFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RegexpReplaceFunction.java similarity index 58% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RegexpReplaceFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/RegexpReplaceFunction.java index 0c551806..1f0e28ef 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RegexpReplaceFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RegexpReplaceFunction.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.io.DataInput; import java.io.IOException; @@ -34,12 +26,12 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** @@ -49,10 +41,10 @@ * REGEXP_REPLACE(,,) * source_char is the string in which we want to perform string replacement. pattern is a * Java compatible regular expression string, and we replace all the matching part with - * replace_string. The first 2 arguments are required and are {@link com.salesforce.phoenix.schema.PDataType#VARCHAR}, + * replace_string. The first 2 arguments are required and are {@link org.apache.phoenix.schema.PDataType#VARCHAR}, * the replace_string is default to empty string. * - * The function returns a {@link com.salesforce.phoenix.schema.PDataType#VARCHAR} + * The function returns a {@link org.apache.phoenix.schema.PDataType#VARCHAR} * * @author zhuang * @since 0.1 diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RegexpSubstrFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RegexpSubstrFunction.java similarity index 69% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RegexpSubstrFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/RegexpSubstrFunction.java index 2948591d..2308581f 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RegexpSubstrFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RegexpSubstrFunction.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.util.List; import java.util.regex.Matcher; @@ -33,13 +25,13 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ReverseFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ReverseFunction.java similarity index 79% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ReverseFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/ReverseFunction.java index 29a4e434..b90fd7c5 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ReverseFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ReverseFunction.java @@ -1,17 +1,17 @@ -package com.salesforce.phoenix.expression.function; +package org.apache.phoenix.expression.function; import java.sql.SQLException; import java.util.List; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.StringUtil; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.StringUtil; @BuiltInFunction(name=ReverseFunction.NAME, args={ @Argument(allowedTypes={PDataType.VARCHAR})} ) diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RoundDateExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RoundDateExpression.java similarity index 78% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RoundDateExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/RoundDateExpression.java index 51cb5a3f..eab4b281 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RoundDateExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RoundDateExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.io.DataInput; import java.io.DataOutput; @@ -40,22 +32,22 @@ import org.apache.hadoop.io.WritableUtils; import com.google.common.collect.Lists; -import com.salesforce.phoenix.compile.KeyPart; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PDataType.PDataCodec; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; +import org.apache.phoenix.compile.KeyPart; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PDataType.PDataCodec; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; /** * Function used to bucketize date/time values by rounding them to * an even increment. Usage: * ROUND(,<'day'|'hour'|'minute'|'second'|'millisecond'>,) * The integer multiplier is optional and is used to do rollups to a partial time unit (i.e. 10 minute rollup) - * The function returns a {@link com.salesforce.phoenix.schema.PDataType#DATE} + * The function returns a {@link org.apache.phoenix.schema.PDataType#DATE} * @author jtaylor, samarth.jain * @since 0.1 diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RoundDecimalExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RoundDecimalExpression.java similarity index 61% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RoundDecimalExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/RoundDecimalExpression.java index 4da2badb..85e7b754 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RoundDecimalExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RoundDecimalExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.io.DataInput; import java.io.DataOutput; @@ -39,16 +31,16 @@ import org.apache.hadoop.io.WritableUtils; import com.google.common.collect.Lists; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.schema.IllegalDataException; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.schema.IllegalDataException; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** * * Class encapsulating the process for rounding off a column/literal of - * type {@link com.salesforce.phoenix.schema.PDataType#DECIMAL} + * type {@link org.apache.phoenix.schema.PDataType#DECIMAL} * * @author samarth.jain * @since 3.0.0 diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RoundFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RoundFunction.java new file mode 100644 index 00000000..1b0782b0 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RoundFunction.java @@ -0,0 +1,57 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.parse.RoundParseNode; +import org.apache.phoenix.schema.PDataType; + + +/** + * Base class for RoundFunction. + * + * @author jtaylor, samarth.jain + * @since 0.1 + */ +@BuiltInFunction(name = RoundFunction.NAME, + nodeClass = RoundParseNode.class, + args = { + @Argument(allowedTypes={PDataType.TIMESTAMP, PDataType.DECIMAL}), + @Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValue = "null", isConstant=true), + @Argument(allowedTypes={PDataType.INTEGER}, defaultValue="1", isConstant=true) + } + ) +public abstract class RoundFunction extends ScalarFunction { + + public static final String NAME = "ROUND"; + + public RoundFunction(List children) { + super(children); + } + + @Override + public String getName() { + return NAME; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RoundTimestampExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RoundTimestampExpression.java similarity index 59% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RoundTimestampExpression.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/RoundTimestampExpression.java index 6cf31b1d..0146b19d 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/RoundTimestampExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/RoundTimestampExpression.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.sql.SQLException; import java.sql.Timestamp; @@ -34,18 +26,18 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import com.google.common.collect.Lists; -import com.salesforce.phoenix.expression.CoerceExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PDataType.PDataCodec; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.CoerceExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PDataType.PDataCodec; +import org.apache.phoenix.schema.tuple.Tuple; /** * * Class encapsulating the process for rounding off a column/literal of - * type {@link com.salesforce.phoenix.schema.PDataType#TIMESTAMP} + * type {@link org.apache.phoenix.schema.PDataType#TIMESTAMP} * This class only supports rounding off the milliseconds that is for * {@link TimeUnit#MILLISECOND}. If you want more options of rounding like * using {@link TimeUnit#HOUR} use {@link RoundDateExpression} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SQLTableTypeFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SQLTableTypeFunction.java new file mode 100644 index 00000000..04465eae --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SQLTableTypeFunction.java @@ -0,0 +1,80 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Function used to get the SQL table type name from the serialized table type. + * Usage: + * SqlTableType('v') will return 'VIEW' based on + * {@link java.sql.DatabaseMetaData#getTableTypes()} + * + * @author jtaylor + * @since 2.2 + */ +@BuiltInFunction(name=SQLTableTypeFunction.NAME, args= { + @Argument(allowedTypes=PDataType.CHAR)} ) +public class SQLTableTypeFunction extends ScalarFunction { + public static final String NAME = "SQLTableType"; + + public SQLTableTypeFunction() { + } + + public SQLTableTypeFunction(List children) throws SQLException { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + Expression child = children.get(0); + if (!child.evaluate(tuple, ptr)) { + return false; + } + if (ptr.getLength() == 0) { + return true; + } + PTableType tableType = PTableType.fromSerializedValue(ptr.get()[ptr.getOffset()]); + ptr.set(tableType.getValue().getBytes()); + return true; + } + + @Override + public PDataType getDataType() { + return PDataType.VARCHAR; + } + + @Override + public String getName() { + return NAME; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SQLViewTypeFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SQLViewTypeFunction.java new file mode 100644 index 00000000..e70ec8e0 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SQLViewTypeFunction.java @@ -0,0 +1,80 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PTable.ViewType; +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Function used to get the SQL view type name from the serialized view type. + * Usage: + * SQLViewType('v') will return 'VIEW' based on + * {@link java.sql.DatabaseMetaData#getTableTypes()} + * + * @author jtaylor + * @since 2.2 + */ +@BuiltInFunction(name=SQLViewTypeFunction.NAME, args= { + @Argument(allowedTypes=PDataType.UNSIGNED_TINYINT)} ) +public class SQLViewTypeFunction extends ScalarFunction { + public static final String NAME = "SQLViewType"; + + public SQLViewTypeFunction() { + } + + public SQLViewTypeFunction(List children) throws SQLException { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + Expression child = children.get(0); + if (!child.evaluate(tuple, ptr)) { + return false; + } + if (ptr.getLength() == 0) { + return true; + } + ViewType viewType = ViewType.fromSerializedValue(ptr.get()[ptr.getOffset()]); + ptr.set(viewType.getBytes()); + return true; + } + + @Override + public PDataType getDataType() { + return PDataType.VARCHAR; + } + + @Override + public String getName() { + return NAME; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ScalarFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ScalarFunction.java new file mode 100644 index 00000000..1d1059bf --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ScalarFunction.java @@ -0,0 +1,72 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.phoenix.compile.KeyPart; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; + + +public abstract class ScalarFunction extends FunctionExpression { + public static final int NO_TRAVERSAL = -1; + + public ScalarFunction() { + } + + public ScalarFunction(List children) { + super(children); + } + + @Override + public final T accept(ExpressionVisitor visitor) { + List l = acceptChildren(visitor, visitor.visitEnter(this)); + T t = visitor.visitLeave(this, l); + if (t == null) { + t = visitor.defaultReturn(this, l); + } + return t; + } + + /** + * Determines whether or not a function may be used to form + * the start/stop key of a scan + * @return the zero-based position of the argument to traverse + * into to look for a primary key column reference, or + * {@value #NO_TRAVERSAL} if the function cannot be used to + * form the scan key. + */ + public int getKeyFormationTraversalIndex() { + return NO_TRAVERSAL; + } + + /** + * Manufactures a KeyPart used to construct the KeyRange given + * a constant and a comparison operator. + * @param childPart the KeyPart formulated for the child expression + * at the {@link #getKeyFormationTraversalIndex()} position. + * @return the KeyPart for constructing the KeyRange for this + * function. + */ + public KeyPart newKeyPart(KeyPart childPart) { + return null; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SingleAggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SingleAggregateFunction.java similarity index 70% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SingleAggregateFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/SingleAggregateFunction.java index 99455a60..f02c4e7d 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SingleAggregateFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SingleAggregateFunction.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.io.DataInput; import java.io.IOException; @@ -36,12 +28,12 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.visitor.ExpressionVisitor; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.visitor.ExpressionVisitor; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SqlTypeNameFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SqlTypeNameFunction.java new file mode 100644 index 00000000..5d391234 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SqlTypeNameFunction.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.IllegalDataException; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; + + +/** + * + * Function used to get the SQL type name from the SQL type integer. + * Usage: + * SqlTypeName(12) + * will return 'VARCHAR' based on {@link java.sql.Types#VARCHAR} being 12 + * + * @author jtaylor + * @since 0.1 + */ +@BuiltInFunction(name=SqlTypeNameFunction.NAME, args= { + @Argument(allowedTypes=PDataType.INTEGER)} ) +public class SqlTypeNameFunction extends ScalarFunction { + public static final String NAME = "SqlTypeName"; + + public SqlTypeNameFunction() { + } + + public SqlTypeNameFunction(List children) throws SQLException { + super(children); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + Expression child = children.get(0); + if (!child.evaluate(tuple, ptr)) { + return false; + } + if (ptr.getLength() == 0) { + return true; + } + int sqlType = child.getDataType().getCodec().decodeInt(ptr, child.getColumnModifier()); + try { + byte[] sqlTypeNameBytes = PDataType.fromTypeId(sqlType).getSqlTypeNameBytes(); + ptr.set(sqlTypeNameBytes); + } catch (IllegalDataException e) { + ptr.set(ByteUtil.EMPTY_BYTE_ARRAY); + } + return true; + } + + @Override + public PDataType getDataType() { + return PDataType.VARCHAR; + } + + @Override + public String getName() { + return NAME; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StddevPopFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StddevPopFunction.java new file mode 100644 index 00000000..4a4e7b82 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StddevPopFunction.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.hadoop.conf.Configuration; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.DecimalStddevPopAggregator; +import org.apache.phoenix.expression.aggregator.DistinctValueWithCountClientAggregator; +import org.apache.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; +import org.apache.phoenix.expression.aggregator.StddevPopAggregator; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; + +/** + * + * Built-in function for STDDEV_POP() aggregate function + * + * @author anoopsjohn + * @since 1.2.1 + */ +@BuiltInFunction(name = StddevPopFunction.NAME, args = { @Argument(allowedTypes={PDataType.DECIMAL})}) +public class StddevPopFunction extends DistinctValueWithCountAggregateFunction { + public static final String NAME = "STDDEV_POP"; + + public StddevPopFunction() { + + } + + public StddevPopFunction(List childern) { + super(childern); + } + + @Override + public Aggregator newServerAggregator(Configuration conf) { + return new DistinctValueWithCountServerAggregator(conf); + } + + @Override + public DistinctValueWithCountClientAggregator newClientAggregator() { + if (children.get(0).getDataType() == PDataType.DECIMAL) { + // Special Aggregators for DECIMAL datatype for more precision than double + return new DecimalStddevPopAggregator(children, getAggregatorExpression().getColumnModifier()); + } + return new StddevPopAggregator(children, getAggregatorExpression().getColumnModifier()); + } + + @Override + public String getName() { + return NAME; + } + + @Override + public PDataType getDataType() { + return PDataType.DECIMAL; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StddevSampFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StddevSampFunction.java new file mode 100644 index 00000000..0e931c60 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StddevSampFunction.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.util.List; + +import org.apache.hadoop.conf.Configuration; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.DecimalStddevSampAggregator; +import org.apache.phoenix.expression.aggregator.DistinctValueWithCountClientAggregator; +import org.apache.phoenix.expression.aggregator.DistinctValueWithCountServerAggregator; +import org.apache.phoenix.expression.aggregator.StddevSampAggregator; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; + +/** + * + * Built-in function for STDDEV_SAMP() aggregate function + * + * @author anoopsjohn + * @since 1.2.1 + */ +@BuiltInFunction(name = StddevSampFunction.NAME, args = { @Argument(allowedTypes={PDataType.DECIMAL})}) +public class StddevSampFunction extends DistinctValueWithCountAggregateFunction { + public static final String NAME = "STDDEV_SAMP"; + + public StddevSampFunction() { + + } + + public StddevSampFunction(List childern) { + super(childern); + } + + @Override + public Aggregator newServerAggregator(Configuration conf) { + return new DistinctValueWithCountServerAggregator(conf); + } + + @Override + public DistinctValueWithCountClientAggregator newClientAggregator() { + if (children.get(0).getDataType() == PDataType.DECIMAL) { + // Special Aggregators for DECIMAL datatype for more precision than double + return new DecimalStddevSampAggregator(children, getAggregatorExpression().getColumnModifier()); + } + return new StddevSampAggregator(children, getAggregatorExpression().getColumnModifier()); + } + + @Override + public String getName() { + return NAME; + } + + @Override + public PDataType getDataType() { + return PDataType.DECIMAL; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SubstrFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SubstrFunction.java similarity index 75% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SubstrFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/SubstrFunction.java index d52b561b..90aa3c8e 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SubstrFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SubstrFunction.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.io.DataInput; import java.io.IOException; @@ -34,14 +26,14 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.StringUtil; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.StringUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SumAggregateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SumAggregateFunction.java similarity index 59% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SumAggregateFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/SumAggregateFunction.java index 04f8520d..ab64ce83 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/SumAggregateFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SumAggregateFunction.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.math.BigDecimal; import java.util.List; @@ -33,18 +25,18 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.DecimalSumAggregator; -import com.salesforce.phoenix.expression.aggregator.DoubleSumAggregator; -import com.salesforce.phoenix.expression.aggregator.NumberSumAggregator; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.parse.SumAggregateParseNode; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.DecimalSumAggregator; +import org.apache.phoenix.expression.aggregator.DoubleSumAggregator; +import org.apache.phoenix.expression.aggregator.NumberSumAggregator; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.parse.SumAggregateParseNode; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/TimeUnit.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/TimeUnit.java new file mode 100644 index 00000000..7ea51612 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/TimeUnit.java @@ -0,0 +1,50 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import com.google.common.base.Joiner; + +public enum TimeUnit { + DAY("day"), + HOUR("hour"), + MINUTE("minute"), + SECOND("second"), + MILLISECOND("millisecond"); + + private String value; + + private TimeUnit(String value) { + this.value = value; + } + + public static final String VALID_VALUES = Joiner.on(", ").join(TimeUnit.values()); + + public static TimeUnit getTimeUnit(String timeUnit) { + if(timeUnit == null) { + throw new IllegalArgumentException("No time unit value specified. Only a time unit value that belongs to one of these : " + VALID_VALUES + " is allowed."); + } + for(TimeUnit tu : values()) { + if(timeUnit.equalsIgnoreCase(tu.value)) { + return tu; + } + } + throw new IllegalArgumentException("Invalid value of time unit " + timeUnit + ". Only a time unit value that belongs to one of these : " + VALID_VALUES + " is allowed."); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ToCharFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ToCharFunction.java similarity index 61% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ToCharFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/ToCharFunction.java index 3dc631ea..d6cdc995 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ToCharFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ToCharFunction.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.io.*; import java.sql.SQLException; @@ -36,12 +28,12 @@ import org.apache.hadoop.io.WritableUtils; import com.google.common.base.Preconditions; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.parse.*; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.parse.*; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ToDateFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ToDateFunction.java similarity index 60% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ToDateFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/ToDateFunction.java index 390d509c..5ef0034d 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ToDateFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ToDateFunction.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; import java.io.*; import java.sql.SQLException; @@ -36,13 +28,13 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.*; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.DateUtil; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.*; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.DateUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ToNumberFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ToNumberFunction.java similarity index 69% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ToNumberFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/ToNumberFunction.java index f7f5b609..84cc2b4d 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/ToNumberFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ToNumberFunction.java @@ -1,33 +1,25 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.function; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; -import static com.salesforce.phoenix.util.ByteUtil.EMPTY_BYTE_ARRAY; +import static org.apache.phoenix.util.ByteUtil.EMPTY_BYTE_ARRAY; import java.io.*; import java.math.BigDecimal; @@ -40,12 +32,12 @@ import org.apache.hadoop.io.WritableUtils; import com.google.common.base.Preconditions; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode.Argument; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.parse.*; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.parse.*; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; /** * diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/TrimFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/TrimFunction.java new file mode 100644 index 00000000..b8c06cdb --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/TrimFunction.java @@ -0,0 +1,108 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.StringUtil; + + +/** + * Implementation of the Trim() build-in function. It removes from both end of + * space character and other function bytes in single byte utf8 characters set. + * + * @author zhuang + * @since 0.1 + */ +@BuiltInFunction(name=TrimFunction.NAME, args={ + @Argument(allowedTypes={PDataType.VARCHAR})} ) +public class TrimFunction extends ScalarFunction { + public static final String NAME = "TRIM"; + + private Integer byteSize; + + public TrimFunction() { } + + public TrimFunction(List children) throws SQLException { + super(children); + if (getStringExpression().getDataType().isFixedWidth()) { + byteSize = getStringExpression().getByteSize(); + } + } + + private Expression getStringExpression() { + return children.get(0); + } + + @Override + public ColumnModifier getColumnModifier() { + return children.get(0).getColumnModifier(); + } + + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + if (!getStringExpression().evaluate(tuple, ptr)) { + return false; + } + if (ptr.getLength() == 0) { + ptr.set(ByteUtil.EMPTY_BYTE_ARRAY); + return true; + } + byte[] string = ptr.get(); + int offset = ptr.getOffset(); + int length = ptr.getLength(); + + ColumnModifier columnModifier = getColumnModifier(); + int end = StringUtil.getFirstNonBlankCharIdxFromEnd(string, offset, length, columnModifier); + if (end == offset - 1) { + ptr.set(ByteUtil.EMPTY_BYTE_ARRAY); + return true; + } + int head = StringUtil.getFirstNonBlankCharIdxFromStart(string, offset, length, columnModifier); + ptr.set(string, head, end - head + 1); + return true; + } + + @Override + public Integer getByteSize() { + return byteSize; + } + + @Override + public PDataType getDataType() { + return PDataType.VARCHAR; + } + + @Override + public String getName() { + return NAME; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/TruncFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/TruncFunction.java new file mode 100644 index 00000000..26a75eec --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/TruncFunction.java @@ -0,0 +1,65 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.function; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FloorParseNode; +import org.apache.phoenix.parse.FunctionParseNode.Argument; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.schema.PDataType; + + +/** + * + * Function used to bucketize date/time values by truncating them to + * an even increment. Usage: + * TRUNC(,<'day'|'hour'|'minute'|'second'|'millisecond'>,[]) + * The integer multiplier is optional and is used to do rollups to a partial time unit (i.e. 10 minute rollup) + * The function returns a {@link org.apache.phoenix.schema.PDataType#DATE} + * + * @author jtaylor + * @since 0.1 + */ +@BuiltInFunction(name = TruncFunction.NAME, +nodeClass = FloorParseNode.class, +args = { + @Argument(allowedTypes={PDataType.TIMESTAMP, PDataType.DECIMAL}), + @Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValue = "null", isConstant=true), + @Argument(allowedTypes={PDataType.INTEGER}, defaultValue="1", isConstant=true) + } +) +public abstract class TruncFunction extends ScalarFunction { + + public static final String NAME = "TRUNC"; + + public TruncFunction(List children) throws SQLException { + super(children); + } + + @Override + public String getName() { + return NAME; + } + + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/UpperFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/UpperFunction.java similarity index 83% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/UpperFunction.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/function/UpperFunction.java index bfc88b50..af4c39c6 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/function/UpperFunction.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/UpperFunction.java @@ -1,14 +1,14 @@ -package com.salesforce.phoenix.expression.function; +package org.apache.phoenix.expression.function; import java.sql.SQLException; import java.util.List; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.parse.FunctionParseNode; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.parse.FunctionParseNode; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; @FunctionParseNode.BuiltInFunction(name=UpperFunction.NAME, args={ @FunctionParseNode.Argument(allowedTypes={PDataType.VARCHAR})} ) diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/BaseExpressionVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/BaseExpressionVisitor.java similarity index 59% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/BaseExpressionVisitor.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/BaseExpressionVisitor.java index 4417954a..a5246176 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/BaseExpressionVisitor.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/BaseExpressionVisitor.java @@ -1,58 +1,50 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.visitor; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.visitor; import java.util.Iterator; import java.util.List; -import com.salesforce.phoenix.expression.AddExpression; -import com.salesforce.phoenix.expression.AndExpression; -import com.salesforce.phoenix.expression.ArrayConstructorExpression; -import com.salesforce.phoenix.expression.CaseExpression; -import com.salesforce.phoenix.expression.CoerceExpression; -import com.salesforce.phoenix.expression.ComparisonExpression; -import com.salesforce.phoenix.expression.DivideExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.InListExpression; -import com.salesforce.phoenix.expression.IsNullExpression; -import com.salesforce.phoenix.expression.KeyValueColumnExpression; -import com.salesforce.phoenix.expression.LikeExpression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.expression.MultiplyExpression; -import com.salesforce.phoenix.expression.NotExpression; -import com.salesforce.phoenix.expression.OrExpression; -import com.salesforce.phoenix.expression.ProjectedColumnExpression; -import com.salesforce.phoenix.expression.RowKeyColumnExpression; -import com.salesforce.phoenix.expression.RowValueConstructorExpression; -import com.salesforce.phoenix.expression.StringConcatExpression; -import com.salesforce.phoenix.expression.SubtractExpression; -import com.salesforce.phoenix.expression.function.ScalarFunction; -import com.salesforce.phoenix.expression.function.SingleAggregateFunction; +import org.apache.phoenix.expression.AddExpression; +import org.apache.phoenix.expression.AndExpression; +import org.apache.phoenix.expression.ArrayConstructorExpression; +import org.apache.phoenix.expression.CaseExpression; +import org.apache.phoenix.expression.CoerceExpression; +import org.apache.phoenix.expression.ComparisonExpression; +import org.apache.phoenix.expression.DivideExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.InListExpression; +import org.apache.phoenix.expression.IsNullExpression; +import org.apache.phoenix.expression.KeyValueColumnExpression; +import org.apache.phoenix.expression.LikeExpression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.MultiplyExpression; +import org.apache.phoenix.expression.NotExpression; +import org.apache.phoenix.expression.OrExpression; +import org.apache.phoenix.expression.ProjectedColumnExpression; +import org.apache.phoenix.expression.RowKeyColumnExpression; +import org.apache.phoenix.expression.RowValueConstructorExpression; +import org.apache.phoenix.expression.StringConcatExpression; +import org.apache.phoenix.expression.SubtractExpression; +import org.apache.phoenix.expression.function.ScalarFunction; +import org.apache.phoenix.expression.function.SingleAggregateFunction; public abstract class BaseExpressionVisitor implements ExpressionVisitor { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/ExpressionVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/ExpressionVisitor.java similarity index 54% rename from phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/ExpressionVisitor.java rename to phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/ExpressionVisitor.java index 92aa7a69..efde2a4e 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/expression/visitor/ExpressionVisitor.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/ExpressionVisitor.java @@ -1,58 +1,50 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.expression.visitor; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.visitor; import java.util.Iterator; import java.util.List; -import com.salesforce.phoenix.expression.AddExpression; -import com.salesforce.phoenix.expression.AndExpression; -import com.salesforce.phoenix.expression.ArrayConstructorExpression; -import com.salesforce.phoenix.expression.CaseExpression; -import com.salesforce.phoenix.expression.CoerceExpression; -import com.salesforce.phoenix.expression.ComparisonExpression; -import com.salesforce.phoenix.expression.DivideExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.InListExpression; -import com.salesforce.phoenix.expression.IsNullExpression; -import com.salesforce.phoenix.expression.KeyValueColumnExpression; -import com.salesforce.phoenix.expression.LikeExpression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.expression.MultiplyExpression; -import com.salesforce.phoenix.expression.NotExpression; -import com.salesforce.phoenix.expression.OrExpression; -import com.salesforce.phoenix.expression.ProjectedColumnExpression; -import com.salesforce.phoenix.expression.RowKeyColumnExpression; -import com.salesforce.phoenix.expression.RowValueConstructorExpression; -import com.salesforce.phoenix.expression.StringConcatExpression; -import com.salesforce.phoenix.expression.SubtractExpression; -import com.salesforce.phoenix.expression.function.ScalarFunction; -import com.salesforce.phoenix.expression.function.SingleAggregateFunction; +import org.apache.phoenix.expression.AddExpression; +import org.apache.phoenix.expression.AndExpression; +import org.apache.phoenix.expression.ArrayConstructorExpression; +import org.apache.phoenix.expression.CaseExpression; +import org.apache.phoenix.expression.CoerceExpression; +import org.apache.phoenix.expression.ComparisonExpression; +import org.apache.phoenix.expression.DivideExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.InListExpression; +import org.apache.phoenix.expression.IsNullExpression; +import org.apache.phoenix.expression.KeyValueColumnExpression; +import org.apache.phoenix.expression.LikeExpression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.MultiplyExpression; +import org.apache.phoenix.expression.NotExpression; +import org.apache.phoenix.expression.OrExpression; +import org.apache.phoenix.expression.ProjectedColumnExpression; +import org.apache.phoenix.expression.RowKeyColumnExpression; +import org.apache.phoenix.expression.RowValueConstructorExpression; +import org.apache.phoenix.expression.StringConcatExpression; +import org.apache.phoenix.expression.SubtractExpression; +import org.apache.phoenix.expression.function.ScalarFunction; +import org.apache.phoenix.expression.function.SingleAggregateFunction; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/KeyValueExpressionVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/KeyValueExpressionVisitor.java new file mode 100644 index 00000000..838bb0b1 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/KeyValueExpressionVisitor.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.visitor; + +import org.apache.phoenix.expression.KeyValueColumnExpression; + + + + +/** + * + * Implementation of ExpressionVisitor where only KeyValueDataAccessor + * is being visited + * + * @author jtaylor + * @since 0.1 + */ +public abstract class KeyValueExpressionVisitor extends TraverseAllExpressionVisitor { + @Override + abstract public Void visit(KeyValueColumnExpression node); +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/SingleAggregateFunctionVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/SingleAggregateFunctionVisitor.java new file mode 100644 index 00000000..63313a7a --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/SingleAggregateFunctionVisitor.java @@ -0,0 +1,40 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.visitor; + +import java.util.Iterator; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.function.SingleAggregateFunction; + + + +/** + * + * Implementation of ExpressionVisitor where only SingleAggregateFunction + * instances are visited + * + * @author jtaylor + * @since 0.1 + */ +public abstract class SingleAggregateFunctionVisitor extends TraverseAllExpressionVisitor { + @Override + abstract public Iterator visitEnter(SingleAggregateFunction node); +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/TraverseAllExpressionVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/TraverseAllExpressionVisitor.java new file mode 100644 index 00000000..39e7a3db --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/TraverseAllExpressionVisitor.java @@ -0,0 +1,57 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.visitor; + +import java.util.*; + +import org.apache.phoenix.expression.Expression; + + + + +public class TraverseAllExpressionVisitor extends BaseExpressionVisitor { + + @Override + public Iterator defaultIterator(Expression node) { + final List children = node.getChildren(); + return new Iterator() { + private int position; + + @Override + public final boolean hasNext() { + return position < children.size(); + } + + @Override + public final Expression next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + return children.get(position++); + } + + @Override + public final void remove() { + throw new UnsupportedOperationException(); + } + }; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/TraverseNoExpressionVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/TraverseNoExpressionVisitor.java new file mode 100644 index 00000000..fe1d1f5e --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/TraverseNoExpressionVisitor.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.expression.visitor; + +import java.util.Iterator; + + +import com.google.common.collect.Iterators; +import org.apache.phoenix.expression.Expression; + +public class TraverseNoExpressionVisitor extends BaseExpressionVisitor { + + @Override + public Iterator defaultIterator(Expression node) { + return Iterators.emptyIterator(); + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/BooleanExpressionFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/BooleanExpressionFilter.java similarity index 56% rename from phoenix-core/src/main/java/com/salesforce/phoenix/filter/BooleanExpressionFilter.java rename to phoenix-core/src/main/java/org/apache/phoenix/filter/BooleanExpressionFilter.java index 75b72245..1f89a153 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/BooleanExpressionFilter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/BooleanExpressionFilter.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.filter; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.filter; import java.io.DataInput; import java.io.DataOutput; @@ -35,10 +27,10 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.ExpressionType; -import com.salesforce.phoenix.schema.IllegalDataException; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.ExpressionType; +import org.apache.phoenix.schema.IllegalDataException; +import org.apache.phoenix.schema.tuple.Tuple; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/filter/EvaluateOnCompletionVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/EvaluateOnCompletionVisitor.java new file mode 100644 index 00000000..7dcc9549 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/EvaluateOnCompletionVisitor.java @@ -0,0 +1,83 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.filter; + +import java.util.Iterator; + +import org.apache.phoenix.expression.ArrayConstructorExpression; +import org.apache.phoenix.expression.CaseExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.IsNullExpression; +import org.apache.phoenix.expression.RowKeyColumnExpression; +import org.apache.phoenix.expression.RowValueConstructorExpression; +import org.apache.phoenix.expression.visitor.TraverseAllExpressionVisitor; + + +/** + * + * Implementation of ExpressionVisitor for the expression used by the + * BooleanExpressionFilter that looks for expressions that need to be + * evaluated upon completion. Examples include: + * - CaseExpression with an else clause, since upon completion, the + * else clause would apply if the when clauses could not be evaluated + * due to the absense of a value. + * - IsNullExpression that's not negated, since upon completion, we + * know definitively that a column value was not found. + * - row key columns are used, since we may never have encountered a + * key value column of interest, but the expression may evaluate to true + * just based on the row key columns. + * @author jtaylor + * @since 0.1 + */ +public class EvaluateOnCompletionVisitor extends TraverseAllExpressionVisitor { + private boolean evaluateOnCompletion = false; + + public boolean evaluateOnCompletion() { + return evaluateOnCompletion; + } + + @Override + public Iterator visitEnter(IsNullExpression node) { + evaluateOnCompletion |= !node.isNegate(); + return null; + } + @Override + public Iterator visitEnter(CaseExpression node) { + evaluateOnCompletion |= node.hasElse(); + return null; + } + @Override + public Void visit(RowKeyColumnExpression node) { + evaluateOnCompletion = true; + return null; + } + @Override + public Iterator visitEnter(RowValueConstructorExpression node) { + evaluateOnCompletion = true; + return null; + } + + @Override + public Iterator visitEnter(ArrayConstructorExpression node) { + evaluateOnCompletion = true; + return null; + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/MultiCFCQKeyValueComparisonFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/MultiCFCQKeyValueComparisonFilter.java similarity index 68% rename from phoenix-core/src/main/java/com/salesforce/phoenix/filter/MultiCFCQKeyValueComparisonFilter.java rename to phoenix-core/src/main/java/org/apache/phoenix/filter/MultiCFCQKeyValueComparisonFilter.java index 4fcabbfc..27a356b4 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/MultiCFCQKeyValueComparisonFilter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/MultiCFCQKeyValueComparisonFilter.java @@ -1,37 +1,29 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.filter; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.filter; import java.util.TreeSet; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.phoenix.expression.Expression; +import org.apache.phoenix.expression.Expression; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/filter/MultiCQKeyValueComparisonFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/MultiCQKeyValueComparisonFilter.java new file mode 100644 index 00000000..c66b7889 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/MultiCQKeyValueComparisonFilter.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.filter; + +import org.apache.hadoop.hbase.util.Bytes; + +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.expression.Expression; + +/** + * + * Filter that evaluates WHERE clause expression, used in the case where there + * are references to multiple column qualifiers over a single column family. + * + * @author jtaylor + * @since 0.1 + */ +public class MultiCQKeyValueComparisonFilter extends MultiKeyValueComparisonFilter { + private ImmutableBytesPtr ptr = new ImmutableBytesPtr(); + private byte[] cf; + + public MultiCQKeyValueComparisonFilter() { + } + + public MultiCQKeyValueComparisonFilter(Expression expression) { + super(expression); + } + + @Override + protected Object setColumnKey(byte[] cf, int cfOffset, int cfLength, byte[] cq, int cqOffset, + int cqLength) { + ptr.set(cq, cqOffset, cqLength); + return ptr; + } + + @Override + protected Object newColumnKey(byte[] cf, int cfOffset, int cfLength, byte[] cq, int cqOffset, + int cqLength) { + if (cfOffset == 0 && cf.length == cfLength) { + this.cf = cf; + } else { + this.cf = new byte[cfLength]; + System.arraycopy(cf, cfOffset, this.cf, 0, cfLength); + } + return new ImmutableBytesPtr(cq, cqOffset, cqLength); + } + + + @SuppressWarnings("all") // suppressing missing @Override since this doesn't exist for HBase 0.94.4 + public boolean isFamilyEssential(byte[] name) { + return Bytes.compareTo(cf, name) == 0; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/MultiKeyValueComparisonFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/MultiKeyValueComparisonFilter.java similarity index 80% rename from phoenix-core/src/main/java/com/salesforce/phoenix/filter/MultiKeyValueComparisonFilter.java rename to phoenix-core/src/main/java/org/apache/phoenix/filter/MultiKeyValueComparisonFilter.java index d69110f8..ab8e1c0b 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/MultiKeyValueComparisonFilter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/MultiKeyValueComparisonFilter.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.filter; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.filter; import java.io.DataInput; import java.io.IOException; @@ -36,9 +28,9 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.KeyValueColumnExpression; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.KeyValueColumnExpression; +import org.apache.phoenix.schema.tuple.Tuple; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/RowKeyComparisonFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/RowKeyComparisonFilter.java similarity index 67% rename from phoenix-core/src/main/java/com/salesforce/phoenix/filter/RowKeyComparisonFilter.java rename to phoenix-core/src/main/java/org/apache/phoenix/filter/RowKeyComparisonFilter.java index 03cfd3cd..bd47a8c8 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/RowKeyComparisonFilter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/RowKeyComparisonFilter.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.filter; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.filter; import java.io.DataInput; import java.io.DataOutput; @@ -38,8 +30,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.tuple.Tuple; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/filter/SingleCFCQKeyValueComparisonFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/SingleCFCQKeyValueComparisonFilter.java new file mode 100644 index 00000000..5b8a5f06 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/SingleCFCQKeyValueComparisonFilter.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.filter; + +import org.apache.hadoop.hbase.util.Bytes; + +import org.apache.phoenix.expression.Expression; + + +/** + * + * SingleKeyValueComparisonFilter that needs to compare both the column family and + * column qualifier parts of the key value to disambiguate with another similarly + * named column qualifier in a different column family. + * + * @author jtaylor + * @since 0.1 + */ +public class SingleCFCQKeyValueComparisonFilter extends SingleKeyValueComparisonFilter { + public SingleCFCQKeyValueComparisonFilter() { + } + + public SingleCFCQKeyValueComparisonFilter(Expression expression) { + super(expression); + } + + @Override + protected final int compare(byte[] cfBuf, int cfOffset, int cfLength, byte[] cqBuf, int cqOffset, int cqLength) { + int c = Bytes.compareTo(cf, 0, cf.length, cfBuf, cfOffset, cfLength); + if (c != 0) return c; + return Bytes.compareTo(cq, 0, cq.length, cqBuf, cqOffset, cqLength); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/filter/SingleCQKeyValueComparisonFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/SingleCQKeyValueComparisonFilter.java new file mode 100644 index 00000000..425839ae --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/SingleCQKeyValueComparisonFilter.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.filter; + +import org.apache.hadoop.hbase.util.Bytes; + +import org.apache.phoenix.expression.Expression; + + +/** + * + * SingleKeyValueComparisonFilter that needs to only compare the column qualifier + * part of the key value since the column qualifier is unique across all column + * families. + * + * @author jtaylor + * @since 0.1 + */ +public class SingleCQKeyValueComparisonFilter extends SingleKeyValueComparisonFilter { + public SingleCQKeyValueComparisonFilter() { + } + + public SingleCQKeyValueComparisonFilter(Expression expression) { + super(expression); + } + + @Override + protected final int compare(byte[] cfBuf, int cfOffset, int cfLength, byte[] cqBuf, int cqOffset, int cqLength) { + return Bytes.compareTo(cq, 0, cq.length, cqBuf, cqOffset, cqLength); + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/SingleKeyValueComparisonFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/SingleKeyValueComparisonFilter.java similarity index 69% rename from phoenix-core/src/main/java/com/salesforce/phoenix/filter/SingleKeyValueComparisonFilter.java rename to phoenix-core/src/main/java/org/apache/phoenix/filter/SingleKeyValueComparisonFilter.java index 3c5613ee..1caa3325 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/SingleKeyValueComparisonFilter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/SingleKeyValueComparisonFilter.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.filter; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.filter; import java.io.DataInput; import java.io.IOException; @@ -33,9 +25,9 @@ import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.KeyValueColumnExpression; -import com.salesforce.phoenix.schema.tuple.SingleKeyValueTuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.KeyValueColumnExpression; +import org.apache.phoenix.schema.tuple.SingleKeyValueTuple; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/SkipScanFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java similarity index 90% rename from phoenix-core/src/main/java/com/salesforce/phoenix/filter/SkipScanFilter.java rename to phoenix-core/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java index 4ac68213..ac8f174d 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/filter/SkipScanFilter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.filter; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.filter; import java.io.DataInput; import java.io.DataOutput; @@ -45,13 +37,13 @@ import com.google.common.hash.HashFunction; import com.google.common.hash.Hasher; import com.google.common.hash.Hashing; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.query.KeyRange.Bound; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.RowKeySchema; -import com.salesforce.phoenix.schema.ValueSchema.Field; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.ScanUtil; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.query.KeyRange.Bound; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.RowKeySchema; +import org.apache.phoenix.schema.ValueSchema.Field; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.ScanUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/index/BaseIndexCodec.java b/phoenix-core/src/main/java/org/apache/phoenix/index/BaseIndexCodec.java new file mode 100644 index 00000000..c06beccb --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/index/BaseIndexCodec.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.index; + +import java.io.IOException; + +import org.apache.hadoop.hbase.client.Mutation; +import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; + +import org.apache.hadoop.hbase.index.covered.IndexCodec; + +/** + * + */ +public abstract class BaseIndexCodec implements IndexCodec { + + @Override + public void initialize(RegionCoprocessorEnvironment env) throws IOException { + // noop + } + + /** + * {@inheritDoc} + *

+ * By default, the codec is always enabled. Subclasses should override this method if they want do + * decide to index on a per-mutation basis. + * @throws IOException + */ + @Override + public boolean isEnabled(Mutation m) throws IOException { + return true; + } + + /** + * {@inheritDoc} + *

+ * Assumes each mutation is not in a batch. Subclasses that have different batching behavior + * should override this. + */ + @Override + public byte[] getBatchId(Mutation m) { + return null; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/index/IndexMaintainer.java b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java similarity index 92% rename from phoenix-core/src/main/java/com/salesforce/phoenix/index/IndexMaintainer.java rename to phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java index 89f8413d..99d0b207 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/index/IndexMaintainer.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java @@ -1,19 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the following conditions are met: Redistributions of source code - * must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in - * binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of Salesforce.com nor the names - * of its contributors may be used to endorse or promote products derived from this software without specific prior - * written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.index; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.index; import java.io.ByteArrayInputStream; import java.io.DataInput; @@ -43,27 +47,27 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import com.salesforce.hbase.index.ValueGetter; -import com.salesforce.hbase.index.covered.update.ColumnReference; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.client.KeyValueBuilder; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PColumnFamily; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PIndexState; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.RowKeySchema; -import com.salesforce.phoenix.schema.SaltingUtil; -import com.salesforce.phoenix.schema.ValueSchema; -import com.salesforce.phoenix.schema.ValueSchema.Field; -import com.salesforce.phoenix.util.BitSet; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.IndexUtil; -import com.salesforce.phoenix.util.SchemaUtil; -import com.salesforce.phoenix.util.TrustedByteArrayOutputStream; +import org.apache.hadoop.hbase.index.ValueGetter; +import org.apache.hadoop.hbase.index.covered.update.ColumnReference; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.client.KeyValueBuilder; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PColumnFamily; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.RowKeySchema; +import org.apache.phoenix.schema.SaltingUtil; +import org.apache.phoenix.schema.ValueSchema; +import org.apache.phoenix.schema.ValueSchema.Field; +import org.apache.phoenix.util.BitSet; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.IndexUtil; +import org.apache.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.TrustedByteArrayOutputStream; /** * @@ -71,9 +75,9 @@ * row and caches any covered columns. Client-side serializes into byte array using * @link #serialize(PTable, ImmutableBytesWritable)} * and transmits to server-side through either the - * {@link com.salesforce.phoenix.index.PhoenixIndexCodec#INDEX_MD} + * {@link org.apache.phoenix.index.PhoenixIndexCodec#INDEX_MD} * Mutation attribute or as a separate RPC call using - * {@link com.salesforce.phoenix.cache.ServerCacheClient}) + * {@link org.apache.phoenix.cache.ServerCacheClient}) * * @author jtaylor * @since 2.1.0 diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/index/IndexMetaDataCacheClient.java b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMetaDataCacheClient.java similarity index 56% rename from phoenix-core/src/main/java/com/salesforce/phoenix/index/IndexMetaDataCacheClient.java rename to phoenix-core/src/main/java/org/apache/phoenix/index/IndexMetaDataCacheClient.java index e5853077..97ba55b1 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/index/IndexMetaDataCacheClient.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMetaDataCacheClient.java @@ -1,21 +1,25 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the following conditions are met: Redistributions of source code - * must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in - * binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of Salesforce.com nor the names - * of its contributors may be used to endorse or promote products derived from this software without specific prior - * written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.index; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.index; -import static com.salesforce.phoenix.query.QueryServices.INDEX_MUTATE_BATCH_SIZE_THRESHOLD_ATTRIB; +import static org.apache.phoenix.query.QueryServices.INDEX_MUTATE_BATCH_SIZE_THRESHOLD_ATTRIB; import java.sql.SQLException; import java.util.List; @@ -23,15 +27,15 @@ import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.cache.ServerCacheClient; -import com.salesforce.phoenix.cache.ServerCacheClient.ServerCache; -import com.salesforce.phoenix.compile.ScanRanges; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.join.MaxServerCacheSizeExceededException; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.ReadOnlyProps; -import com.salesforce.phoenix.util.ScanUtil; +import org.apache.phoenix.cache.ServerCacheClient; +import org.apache.phoenix.cache.ServerCacheClient.ServerCache; +import org.apache.phoenix.compile.ScanRanges; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.join.MaxServerCacheSizeExceededException; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.ScanUtil; public class IndexMetaDataCacheClient { diff --git a/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMetaDataCacheFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMetaDataCacheFactory.java new file mode 100644 index 00000000..3be88332 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMetaDataCacheFactory.java @@ -0,0 +1,66 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.index; + +import java.io.Closeable; +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.sql.SQLException; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.cache.IndexMetaDataCache; +import org.apache.phoenix.client.GenericKeyValueBuilder; +import org.apache.phoenix.coprocessor.ServerCachingProtocol.ServerCacheFactory; +import org.apache.phoenix.memory.MemoryManager.MemoryChunk; + +public class IndexMetaDataCacheFactory implements ServerCacheFactory { + public IndexMetaDataCacheFactory() { + } + + @Override + public void readFields(DataInput arg0) throws IOException { + } + + @Override + public void write(DataOutput arg0) throws IOException { + } + + @Override + public Closeable newCache (ImmutableBytesWritable cachePtr, final MemoryChunk chunk) throws SQLException { + // just use the standard keyvalue builder - this doesn't really need to be fast + final List maintainers = + IndexMaintainer.deserialize(cachePtr, GenericKeyValueBuilder.INSTANCE); + return new IndexMetaDataCache() { + + @Override + public void close() throws IOException { + chunk.close(); + } + + @Override + public List getIndexMaintainers() { + return maintainers; + } + }; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/index/PhoenixIndexBuilder.java b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexBuilder.java similarity index 59% rename from phoenix-core/src/main/java/com/salesforce/phoenix/index/PhoenixIndexBuilder.java rename to phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexBuilder.java index be3267f7..e278b24e 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/index/PhoenixIndexBuilder.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexBuilder.java @@ -1,19 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the following conditions are met: Redistributions of source code - * must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in - * binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of Salesforce.com nor the names - * of its contributors may be used to endorse or promote products derived from this software without specific prior - * written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.index; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.index; import java.io.IOException; import java.util.ArrayList; @@ -30,12 +34,12 @@ import org.apache.hadoop.hbase.util.Pair; import com.google.common.collect.Lists; -import com.salesforce.hbase.index.covered.CoveredColumnsIndexBuilder; -import com.salesforce.hbase.index.util.IndexManagementUtil; -import com.salesforce.phoenix.compile.ScanRanges; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.hadoop.hbase.index.covered.CoveredColumnsIndexBuilder; +import org.apache.hadoop.hbase.index.util.IndexManagementUtil; +import org.apache.phoenix.compile.ScanRanges; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.util.SchemaUtil; /** * Index builder for covered-columns index that ties into phoenix for faster use. diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/index/PhoenixIndexCodec.java b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexCodec.java similarity index 71% rename from phoenix-core/src/main/java/com/salesforce/phoenix/index/PhoenixIndexCodec.java rename to phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexCodec.java index f59310bb..4f98a32b 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/index/PhoenixIndexCodec.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexCodec.java @@ -1,19 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the following conditions are met: Redistributions of source code - * must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in - * binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of Salesforce.com nor the names - * of its contributors may be used to endorse or promote products derived from this software without specific prior - * written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.index; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.index; import java.io.IOException; import java.sql.SQLException; @@ -30,23 +34,23 @@ import org.apache.hadoop.hbase.util.Pair; import com.google.common.collect.Lists; -import com.salesforce.hbase.index.ValueGetter; -import com.salesforce.hbase.index.covered.IndexCodec; -import com.salesforce.hbase.index.covered.IndexUpdate; -import com.salesforce.hbase.index.covered.TableState; -import com.salesforce.hbase.index.scanner.Scanner; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.hbase.index.util.IndexManagementUtil; -import com.salesforce.hbase.index.write.IndexWriter; -import com.salesforce.phoenix.cache.GlobalCache; -import com.salesforce.phoenix.cache.IndexMetaDataCache; -import com.salesforce.phoenix.cache.ServerCacheClient; -import com.salesforce.phoenix.cache.TenantCache; -import com.salesforce.phoenix.client.KeyValueBuilder; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.util.PhoenixRuntime; -import com.salesforce.phoenix.util.ServerUtil; +import org.apache.hadoop.hbase.index.ValueGetter; +import org.apache.hadoop.hbase.index.covered.IndexCodec; +import org.apache.hadoop.hbase.index.covered.IndexUpdate; +import org.apache.hadoop.hbase.index.covered.TableState; +import org.apache.hadoop.hbase.index.scanner.Scanner; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.util.IndexManagementUtil; +import org.apache.hadoop.hbase.index.write.IndexWriter; +import org.apache.phoenix.cache.GlobalCache; +import org.apache.phoenix.cache.IndexMetaDataCache; +import org.apache.phoenix.cache.ServerCacheClient; +import org.apache.phoenix.cache.TenantCache; +import org.apache.phoenix.client.KeyValueBuilder; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.ServerUtil; /** * Phoenix-based {@link IndexCodec}. Manages all the logic of how to cleanup an index ( diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/index/PhoenixIndexFailurePolicy.java b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java similarity index 60% rename from phoenix-core/src/main/java/com/salesforce/phoenix/index/PhoenixIndexFailurePolicy.java rename to phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java index e7cac372..3f56bb8b 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/index/PhoenixIndexFailurePolicy.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java @@ -1,19 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the following conditions are met: Redistributions of source code - * must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in - * binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of Salesforce.com nor the names - * of its contributors may be used to endorse or promote products derived from this software without specific prior - * written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.index; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.index; import java.io.IOException; import java.util.Collections; @@ -30,14 +34,14 @@ import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; import com.google.common.collect.Multimap; -import com.salesforce.hbase.index.table.HTableInterfaceReference; -import com.salesforce.hbase.index.write.KillServerOnFailurePolicy; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol.MutationCode; -import com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData; -import com.salesforce.phoenix.schema.PIndexState; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.hadoop.hbase.index.table.HTableInterfaceReference; +import org.apache.hadoop.hbase.index.write.KillServerOnFailurePolicy; +import org.apache.phoenix.coprocessor.MetaDataProtocol; +import org.apache.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; +import org.apache.phoenix.coprocessor.MetaDataProtocol.MutationCode; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.util.SchemaUtil; /** * diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/AggregatingResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/AggregatingResultIterator.java new file mode 100644 index 00000000..237a89ad --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/AggregatingResultIterator.java @@ -0,0 +1,40 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Interface for scanners that either do aggregation + * or delegate to scanners that do aggregation. + * + * @author jtaylor + * @since 0.1 + */ +public interface AggregatingResultIterator extends ResultIterator { + /** + * Provides a means of re-aggregating a result row. For + * scanners that need to look ahead (i.e. {@link org.apache.phoenix.iterate.OrderedAggregatingResultIterator} + * @param result the row to re-aggregate + */ + void aggregate(Tuple result); +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterator.java new file mode 100644 index 00000000..ed6c3600 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; +import java.util.List; + +/** + * + * Abstract base class for ResultIterator implementations that + * do nothing on close and have no explain plan steps + * + * @author jtaylor + * @since 1.2 + */ +public abstract class BaseResultIterator implements ResultIterator { + + @Override + public void close() throws SQLException { + } + + @Override + public void explain(List planSteps) { + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ConcatResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ConcatResultIterator.java new file mode 100644 index 00000000..08b4639a --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ConcatResultIterator.java @@ -0,0 +1,91 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Result iterator that concatenates a list of other iterators. + * + * @author jtaylor + * @since 0.1 + */ +public class ConcatResultIterator implements PeekingResultIterator { + private final ResultIterators resultIterators; + private List iterators; + private int index; + + public ConcatResultIterator(ResultIterators iterators) { + this.resultIterators = iterators; + } + + private List getIterators() throws SQLException { + if (iterators == null) { + iterators = resultIterators.getIterators(); + } + return iterators; + } + + @Override + public void close() throws SQLException { + if (iterators != null) { + for (;index < iterators.size(); index++) { + PeekingResultIterator iterator = iterators.get(index); + iterator.close(); + } + } + } + + + @Override + public void explain(List planSteps) { + resultIterators.explain(planSteps); + } + + private PeekingResultIterator currentIterator() throws SQLException { + List iterators = getIterators(); + while (index < iterators.size()) { + PeekingResultIterator iterator = iterators.get(index); + Tuple r = iterator.peek(); + if (r != null) { + return iterator; + } + iterator.close(); + index++; + } + return EMPTY_ITERATOR; + } + + @Override + public Tuple peek() throws SQLException { + return currentIterator().peek(); + } + + @Override + public Tuple next() throws SQLException { + return currentIterator().next(); + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/DefaultParallelIteratorRegionSplitter.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/DefaultParallelIteratorRegionSplitter.java similarity index 81% rename from phoenix-core/src/main/java/com/salesforce/phoenix/iterate/DefaultParallelIteratorRegionSplitter.java rename to phoenix-core/src/main/java/org/apache/phoenix/iterate/DefaultParallelIteratorRegionSplitter.java index 003bd74f..ab194f6d 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/DefaultParallelIteratorRegionSplitter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/DefaultParallelIteratorRegionSplitter.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; import java.sql.SQLException; import java.util.Collection; @@ -43,16 +35,16 @@ import com.google.common.collect.Iterables; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.parse.HintNode; -import com.salesforce.phoenix.parse.HintNode.Hint; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.query.StatsManager; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.parse.HintNode; +import org.apache.phoenix.parse.HintNode.Hint; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.query.StatsManager; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.ReadOnlyProps; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/DelegateResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/DelegateResultIterator.java new file mode 100644 index 00000000..25df5ada --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/DelegateResultIterator.java @@ -0,0 +1,50 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.schema.tuple.Tuple; + + +public class DelegateResultIterator implements ResultIterator { + private final ResultIterator delegate; + + public DelegateResultIterator(ResultIterator delegate) { + this.delegate = delegate; + } + + @Override + public void close() throws SQLException { + delegate.close(); + } + + @Override + public Tuple next() throws SQLException { + return delegate.next(); + } + + @Override + public void explain(List planSteps) { + delegate.explain(planSteps); + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/DistinctAggregatingResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/DistinctAggregatingResultIterator.java similarity index 67% rename from phoenix-core/src/main/java/com/salesforce/phoenix/iterate/DistinctAggregatingResultIterator.java rename to phoenix-core/src/main/java/org/apache/phoenix/iterate/DistinctAggregatingResultIterator.java index 01db41ea..f7af26cc 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/DistinctAggregatingResultIterator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/DistinctAggregatingResultIterator.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; import java.sql.SQLException; import java.util.*; @@ -34,10 +26,10 @@ import com.google.common.collect.Iterators; import com.google.common.collect.Sets; -import com.salesforce.phoenix.compile.ColumnProjector; -import com.salesforce.phoenix.compile.RowProjector; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.compile.ColumnProjector; +import org.apache.phoenix.compile.RowProjector; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.tuple.Tuple; /** * Result scanner that dedups the incoming tuples to make them distinct. diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ExplainTable.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ExplainTable.java similarity index 80% rename from phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ExplainTable.java rename to phoenix-core/src/main/java/org/apache/phoenix/iterate/ExplainTable.java index 7dfd1db7..f32b3776 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ExplainTable.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ExplainTable.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; import java.text.Format; import java.util.Collections; @@ -42,16 +34,16 @@ import org.apache.hadoop.hbase.util.Bytes; import com.google.common.collect.Iterators; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.compile.ScanRanges; -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.query.KeyRange.Bound; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.RowKeySchema; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.StringUtil; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.compile.ScanRanges; +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.query.KeyRange.Bound; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.RowKeySchema; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.StringUtil; public abstract class ExplainTable { diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/FilterAggregatingResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/FilterAggregatingResultIterator.java new file mode 100644 index 00000000..d6874804 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/FilterAggregatingResultIterator.java @@ -0,0 +1,80 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Post aggregation filter for HAVING clause. Due to the way we cache aggregation values + * we cannot have a look ahead for this Iterator, because the expressions in the SELECT + * clause would return values for the peeked row instead of the current row. If we only + * use the Result argument in {@link org.apache.phoenix.expression.Expression} + * instead of our cached value in Aggregators, we could have a look ahead. + * + * @author jtaylor + * @since 0.1 + */ +public class FilterAggregatingResultIterator implements AggregatingResultIterator { + private final AggregatingResultIterator delegate; + private final Expression expression; + private final ImmutableBytesWritable ptr = new ImmutableBytesWritable(); + + public FilterAggregatingResultIterator(AggregatingResultIterator delegate, Expression expression) { + this.delegate = delegate; + this.expression = expression; + if (expression.getDataType() != PDataType.BOOLEAN) { + throw new IllegalArgumentException("FilterResultIterator requires a boolean expression, but got " + expression); + } + } + + @Override + public Tuple next() throws SQLException { + Tuple next; + do { + next = delegate.next(); + } while (next != null && expression.evaluate(next, ptr) && Boolean.FALSE.equals(expression.getDataType().toObject(ptr))); + return next; + } + + @Override + public void close() throws SQLException { + delegate.close(); + } + + @Override + public void aggregate(Tuple result) { + delegate.aggregate(result); + } + + @Override + public void explain(List planSteps) { + delegate.explain(planSteps); + planSteps.add("CLIENT FILTER BY " + expression.toString()); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/FilterResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/FilterResultIterator.java new file mode 100644 index 00000000..5518643d --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/FilterResultIterator.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Result scanner that filters out rows based on the results of a boolean + * expression (i.e. filters out if {@link org.apache.phoenix.expression.Expression#evaluate(Tuple, ImmutableBytesWritable)} + * returns false or the ptr contains a FALSE value}). May not be used where + * the delegate provided is an {@link org.apache.phoenix.iterate.AggregatingResultIterator}. + * For these, the {@link org.apache.phoenix.iterate.FilterAggregatingResultIterator} should be used. + * + * @author jtaylor + * @since 0.1 + */ +public class FilterResultIterator extends LookAheadResultIterator { + private final ResultIterator delegate; + private final Expression expression; + private final ImmutableBytesWritable ptr = new ImmutableBytesWritable(); + + public FilterResultIterator(ResultIterator delegate, Expression expression) { + if (delegate instanceof AggregatingResultIterator) { + throw new IllegalArgumentException("FilterResultScanner may not be used with an aggregate delegate. Use phoenix.iterate.FilterAggregateResultScanner instead"); + } + this.delegate = delegate; + this.expression = expression; + if (expression.getDataType() != PDataType.BOOLEAN) { + throw new IllegalArgumentException("FilterResultIterator requires a boolean expression, but got " + expression); + } + } + + @Override + protected Tuple advance() throws SQLException { + Tuple next; + do { + next = delegate.next(); + } while (next != null && expression.evaluate(next, ptr) && Boolean.FALSE.equals(expression.getDataType().toObject(ptr))); + return next; + } + + @Override + public void close() throws SQLException { + delegate.close(); + } + + @Override + public void explain(List planSteps) { + delegate.explain(planSteps); + planSteps.add("CLIENT FILTER BY " + expression.toString()); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/GroupedAggregatingResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/GroupedAggregatingResultIterator.java similarity index 52% rename from phoenix-core/src/main/java/com/salesforce/phoenix/iterate/GroupedAggregatingResultIterator.java rename to phoenix-core/src/main/java/org/apache/phoenix/iterate/GroupedAggregatingResultIterator.java index a956cb09..79856998 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/GroupedAggregatingResultIterator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/GroupedAggregatingResultIterator.java @@ -1,45 +1,37 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; -import static com.salesforce.phoenix.query.QueryConstants.*; +import static org.apache.phoenix.query.QueryConstants.*; import java.sql.SQLException; import java.util.List; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.aggregator.Aggregator; -import com.salesforce.phoenix.expression.aggregator.Aggregators; -import com.salesforce.phoenix.schema.tuple.SingleKeyValueTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.KeyValueUtil; -import com.salesforce.phoenix.util.TupleUtil; +import org.apache.phoenix.expression.aggregator.Aggregator; +import org.apache.phoenix.expression.aggregator.Aggregators; +import org.apache.phoenix.schema.tuple.SingleKeyValueTuple; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.KeyValueUtil; +import org.apache.phoenix.util.TupleUtil; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/LimitingResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/LimitingResultIterator.java new file mode 100644 index 00000000..ecea92d0 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/LimitingResultIterator.java @@ -0,0 +1,57 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.schema.tuple.Tuple; + +/** + * + * Iterates through tuples up to a limit + * + * @author jtaylor + * @since 1.2 + */ +public class LimitingResultIterator extends DelegateResultIterator { + private int rowCount; + private final int limit; + + public LimitingResultIterator(ResultIterator delegate, int limit) { + super(delegate); + this.limit = limit; + } + + @Override + public Tuple next() throws SQLException { + if (rowCount++ >= limit) { + return null; + } + return super.next(); + } + + @Override + public void explain(List planSteps) { + super.explain(planSteps); + planSteps.add("CLIENT " + limit + " ROW LIMIT"); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/LookAheadResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/LookAheadResultIterator.java new file mode 100644 index 00000000..0e4b78b2 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/LookAheadResultIterator.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; + +import org.apache.phoenix.schema.tuple.ResultTuple; +import org.apache.phoenix.schema.tuple.Tuple; + + +abstract public class LookAheadResultIterator implements PeekingResultIterator { + private final static Tuple UNINITIALIZED = new ResultTuple(); + private Tuple next = UNINITIALIZED; + + abstract protected Tuple advance() throws SQLException; + + private void init() throws SQLException { + if (next == UNINITIALIZED) { + next = advance(); + } + } + + @Override + public Tuple next() throws SQLException { + init(); + Tuple next = this.next; + this.next = advance(); + return next; + } + + @Override + public Tuple peek() throws SQLException { + init(); + return next; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MappedByteBufferSortedQueue.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/MappedByteBufferSortedQueue.java similarity index 87% rename from phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MappedByteBufferSortedQueue.java rename to phoenix-core/src/main/java/org/apache/phoenix/iterate/MappedByteBufferSortedQueue.java index 8be164e2..1606ae6a 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MappedByteBufferSortedQueue.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/MappedByteBufferSortedQueue.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; import java.io.File; import java.io.IOException; @@ -46,9 +38,9 @@ import org.apache.hadoop.hbase.util.Bytes; import com.google.common.collect.MinMaxPriorityQueue; -import com.salesforce.phoenix.iterate.OrderedResultIterator.ResultEntry; -import com.salesforce.phoenix.schema.tuple.ResultTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.iterate.OrderedResultIterator.ResultEntry; +import org.apache.phoenix.schema.tuple.ResultTuple; +import org.apache.phoenix.schema.tuple.Tuple; public class MappedByteBufferSortedQueue extends AbstractQueue { private Comparator comparator; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MaterializedResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/MaterializedResultIterator.java similarity index 53% rename from phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MaterializedResultIterator.java rename to phoenix-core/src/main/java/org/apache/phoenix/iterate/MaterializedResultIterator.java index 7cd9438e..c509b2ca 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MaterializedResultIterator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/MaterializedResultIterator.java @@ -1,36 +1,28 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; import java.sql.SQLException; import java.util.*; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.schema.tuple.Tuple; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MergeSortResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortResultIterator.java similarity index 52% rename from phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MergeSortResultIterator.java rename to phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortResultIterator.java index 94014643..58b7e40f 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MergeSortResultIterator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortResultIterator.java @@ -1,39 +1,31 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; import java.sql.SQLException; import java.util.List; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.SQLCloseables; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.SQLCloseables; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortRowKeyResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortRowKeyResultIterator.java new file mode 100644 index 00000000..a411bab2 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortRowKeyResultIterator.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.util.List; + +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.TupleUtil; + + +/** + * + * ResultIterator that does a merge sort on the list of iterators provided, + * returning the rows in row key ascending order. The iterators provided + * must be in row key ascending order. + * + * @author jtaylor + * @since 0.1 + */ +public class MergeSortRowKeyResultIterator extends MergeSortResultIterator { + private final int keyOffset; + private final int factor; + + public MergeSortRowKeyResultIterator(ResultIterators iterators) { + this(iterators, 0, false); + } + + public MergeSortRowKeyResultIterator(ResultIterators iterators, int keyOffset, boolean isReverse) { + super(iterators); + this.keyOffset = keyOffset; + this.factor = isReverse ? -1 : 1; + } + + @Override + protected int compare(Tuple t1, Tuple t2) { + return factor * TupleUtil.compare(t1, t2, tempPtr, keyOffset); + } + + @Override + public void explain(List planSteps) { + resultIterators.explain(planSteps); + planSteps.add("CLIENT MERGE SORT"); + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MergeSortTopNResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortTopNResultIterator.java similarity index 55% rename from phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MergeSortTopNResultIterator.java rename to phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortTopNResultIterator.java index ffbe982b..77d1c62a 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/MergeSortTopNResultIterator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortTopNResultIterator.java @@ -1,40 +1,32 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; import java.sql.SQLException; import java.util.List; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.OrderByExpression; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.OrderByExpression; +import org.apache.phoenix.schema.tuple.Tuple; /** * diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/OrderedAggregatingResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/OrderedAggregatingResultIterator.java new file mode 100644 index 00000000..2b7011ad --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/OrderedAggregatingResultIterator.java @@ -0,0 +1,63 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.expression.OrderByExpression; +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * Result scanner that sorts aggregated rows by columns specified in the ORDER BY clause. + *

+ * Note that currently the sort is entirely done in memory. + * + * @author syyang + * @since 0.1 + */ +public class OrderedAggregatingResultIterator extends OrderedResultIterator implements AggregatingResultIterator { + + public OrderedAggregatingResultIterator(AggregatingResultIterator delegate, + List orderByExpressions, + int thresholdBytes, Integer limit) throws SQLException { + super (delegate, orderByExpressions, thresholdBytes, limit); + } + + @Override + protected AggregatingResultIterator getDelegate() { + return (AggregatingResultIterator)super.getDelegate(); + } + + @Override + public Tuple next() throws SQLException { + Tuple tuple = super.next(); + if (tuple != null) { + aggregate(tuple); + } + return tuple; + } + + @Override + public void aggregate(Tuple result) { + getDelegate().aggregate(result); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/OrderedResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/OrderedResultIterator.java similarity index 81% rename from phoenix-core/src/main/java/com/salesforce/phoenix/iterate/OrderedResultIterator.java rename to phoenix-core/src/main/java/org/apache/phoenix/iterate/OrderedResultIterator.java index 7aa56416..288c4659 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/OrderedResultIterator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/OrderedResultIterator.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkPositionIndex; @@ -42,10 +34,10 @@ import com.google.common.collect.Collections2; import com.google.common.collect.Lists; import com.google.common.collect.Ordering; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.OrderByExpression; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.SizedUtil; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.OrderByExpression; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.SizedUtil; /** * Result scanner that sorts aggregated rows by columns specified in the ORDER BY clause. diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIteratorRegionSplitter.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIteratorRegionSplitter.java new file mode 100644 index 00000000..a14b1e88 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIteratorRegionSplitter.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.query.KeyRange; + + +/** + * Interface for strategies determining how to split regions in ParallelIterators. + * + * @author zhuang + */ +public interface ParallelIteratorRegionSplitter { + + public List getSplits() throws SQLException; +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIteratorRegionSplitterFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIteratorRegionSplitterFactory.java new file mode 100644 index 00000000..88efc44f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIteratorRegionSplitterFactory.java @@ -0,0 +1,40 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.parse.HintNode; +import org.apache.phoenix.schema.TableRef; + + +/** + * Factory class for the Region Splitter used by the project. + */ +public class ParallelIteratorRegionSplitterFactory { + + public static ParallelIteratorRegionSplitter getSplitter(StatementContext context, TableRef table, HintNode hintNode) throws SQLException { + if (context.getScanRanges().useSkipScanFilter()) { + return SkipRangeParallelIteratorRegionSplitter.getInstance(context, table, hintNode); + } + return DefaultParallelIteratorRegionSplitter.getInstance(context, table, hintNode); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ParallelIterators.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIterators.java similarity index 76% rename from phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ParallelIterators.java rename to phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIterators.java index 2805fde0..8ea2d3df 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/ParallelIterators.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIterators.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; import java.sql.SQLException; import java.util.ArrayList; @@ -49,24 +41,24 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Function; -import com.salesforce.phoenix.compile.GroupByCompiler.GroupBy; -import com.salesforce.phoenix.compile.RowProjector; -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.job.JobManager.JobCallable; -import com.salesforce.phoenix.parse.FilterableStatement; -import com.salesforce.phoenix.parse.HintNode; -import com.salesforce.phoenix.query.ConnectionQueryServices; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.SaltingUtil; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.ReadOnlyProps; -import com.salesforce.phoenix.util.SQLCloseables; -import com.salesforce.phoenix.util.ScanUtil; -import com.salesforce.phoenix.util.SchemaUtil; -import com.salesforce.phoenix.util.ServerUtil; +import org.apache.phoenix.compile.GroupByCompiler.GroupBy; +import org.apache.phoenix.compile.RowProjector; +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.job.JobManager.JobCallable; +import org.apache.phoenix.parse.FilterableStatement; +import org.apache.phoenix.parse.HintNode; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.SaltingUtil; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.SQLCloseables; +import org.apache.phoenix.util.ScanUtil; +import org.apache.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.ServerUtil; /** @@ -170,6 +162,8 @@ public List getIterators() throws SQLException { } } if (ScanUtil.intersectScanRange(splitScan, split.getLowerRange(), split.getUpperRange(), this.context.getScanRanges().useSkipScanFilter())) { + // Delay the swapping of start/stop row until row so we don't muck with the intersect logic + ScanUtil.swapStartStopRowIfReversed(splitScan); Future future = executor.submit(new JobCallable() { @@ -199,12 +193,13 @@ public Object getJobId() { } int timeoutMs = props.getInt(QueryServices.THREAD_TIMEOUT_MS_ATTRIB, DEFAULT_THREAD_TIMEOUT_MS); + final int factor = ScanUtil.isReversed(this.context.getScan()) ? -1 : 1; // Sort futures by row key so that we have a predicatble order we're getting rows back for scans. // We're going to wait here until they're finished anyway and this makes testing much easier. Collections.sort(futures, new Comparator>>() { @Override public int compare(Pair> o1, Pair> o2) { - return Bytes.compareTo(o1.getFirst(), o2.getFirst()); + return factor * Bytes.compareTo(o1.getFirst(), o2.getFirst()); } }); for (Pair> future : futures) { @@ -237,4 +232,4 @@ public void explain(List planSteps) { buf.append("CLIENT PARALLEL " + size() + "-WAY "); explain(buf.toString(),planSteps); } -} +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/PeekingResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/PeekingResultIterator.java new file mode 100644 index 00000000..994f343f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/PeekingResultIterator.java @@ -0,0 +1,63 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.schema.tuple.Tuple; + + +/** + * + * Interface for iterating through results returned from a scan, adding the + * ability to peek at the next result. + * + * @author jtaylor + * @since 0.1 + */ +public interface PeekingResultIterator extends ResultIterator { + public static final PeekingResultIterator EMPTY_ITERATOR = new PeekingResultIterator() { + + @Override + public Tuple next() throws SQLException { + return null; + } + + @Override + public Tuple peek() { + return null; + } + + @Override + public void close() throws SQLException { + } + + @Override + public void explain(List planSteps) { + } + }; + + /** + * Returns the next result without advancing the iterator + * @throws SQLException + */ + public Tuple peek() throws SQLException; +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/RegionScannerResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/RegionScannerResultIterator.java new file mode 100644 index 00000000..41601742 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/RegionScannerResultIterator.java @@ -0,0 +1,65 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.io.IOException; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.regionserver.MultiVersionConsistencyControl; +import org.apache.hadoop.hbase.regionserver.RegionScanner; + +import org.apache.phoenix.schema.tuple.MultiKeyValueTuple; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ServerUtil; + + +public class RegionScannerResultIterator extends BaseResultIterator { + private final RegionScanner scanner; + + public RegionScannerResultIterator(RegionScanner scanner) { + this.scanner = scanner; + MultiVersionConsistencyControl.setThreadReadPoint(scanner.getMvccReadPoint()); + } + + @Override + public Tuple next() throws SQLException { + try { + // TODO: size + List results = new ArrayList(); + // Results are potentially returned even when the return value of s.next is false + // since this is an indication of whether or not there are more values after the + // ones returned + boolean hasMore = scanner.nextRaw(results, null); + if (!hasMore && results.isEmpty()) { + return null; + } + // We instantiate a new tuple because in all cases currently we hang on to it (i.e. + // to compute and hold onto the TopN). + MultiKeyValueTuple tuple = new MultiKeyValueTuple(); + tuple.setKeyValues(results); + return tuple; + } catch (IOException e) { + throw ServerUtil.parseServerException(e); + } + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ResultIterator.java new file mode 100644 index 00000000..43e4758f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ResultIterator.java @@ -0,0 +1,54 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.SQLCloseable; + + +public interface ResultIterator extends SQLCloseable { + public static final ResultIterator EMPTY_ITERATOR = new ResultIterator() { + @Override + public void close() throws SQLException { + } + + @Override + public Tuple next() throws SQLException { + return null; + } + + @Override + public void explain(List planSteps) { + } + }; + + /** + * Grab the next row's worth of values. The iterator will return a Tuple. + * @return Tuple object if there is another row, null if the scanner is + * exhausted. + * @throws SQLException e + */ + public Tuple next() throws SQLException; + + public void explain(List planSteps); +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ResultIterators.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ResultIterators.java new file mode 100644 index 00000000..0ee95628 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ResultIterators.java @@ -0,0 +1,29 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; +import java.util.List; + +public interface ResultIterators { + public List getIterators() throws SQLException; + public int size(); + public void explain(List planSteps); +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java new file mode 100644 index 00000000..0c981214 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.io.IOException; +import java.sql.SQLException; +import java.util.List; + +import org.apache.hadoop.hbase.client.Result; +import org.apache.hadoop.hbase.client.ResultScanner; + +import org.apache.phoenix.schema.tuple.ResultTuple; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ServerUtil; + + +public class ScanningResultIterator implements ResultIterator { + private final ResultScanner scanner; + + public ScanningResultIterator(ResultScanner scanner) { + this.scanner = scanner; + } + + @Override + public void close() throws SQLException { + scanner.close(); + } + + @Override + public Tuple next() throws SQLException { + try { + Result result = scanner.next(); + // TODO: use ResultTuple.setResult(result) + // Need to create a new one if holding on to it (i.e. OrderedResultIterator) + return result == null ? null : new ResultTuple(result); + } catch (IOException e) { + throw ServerUtil.parseServerException(e); + } + } + + @Override + public void explain(List planSteps) { + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/SequenceResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/SequenceResultIterator.java new file mode 100644 index 00000000..e3aeb7f8 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/SequenceResultIterator.java @@ -0,0 +1,59 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.SequenceManager; +import org.apache.phoenix.schema.tuple.Tuple; + +/** + * + * Iterates through tuples retrieving sequences from the server as needed + * + * @author jtaylor + * @since 3.0 + */ +public class SequenceResultIterator extends DelegateResultIterator { + private final SequenceManager sequenceManager; + + public SequenceResultIterator(ResultIterator delegate, SequenceManager sequenceManager) throws SQLException { + super(delegate); + sequenceManager.initSequences(); + this.sequenceManager = sequenceManager; + } + + @Override + public Tuple next() throws SQLException { + Tuple next = super.next(); + if (next == null) { + return null; + } + sequenceManager.incrementSequenceValues(); + return next; + } + + @Override + public void explain(List planSteps) { + super.explain(planSteps); + planSteps.add("CLIENT RESERVE " + sequenceManager.getSequenceCount() + " SEQUENCES"); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/SkipRangeParallelIteratorRegionSplitter.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/SkipRangeParallelIteratorRegionSplitter.java similarity index 56% rename from phoenix-core/src/main/java/com/salesforce/phoenix/iterate/SkipRangeParallelIteratorRegionSplitter.java rename to phoenix-core/src/main/java/org/apache/phoenix/iterate/SkipRangeParallelIteratorRegionSplitter.java index 439a49fe..2f6e0fae 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/SkipRangeParallelIteratorRegionSplitter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/SkipRangeParallelIteratorRegionSplitter.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; import java.sql.SQLException; import java.util.List; @@ -35,12 +27,12 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.salesforce.phoenix.compile.ScanRanges; -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.parse.HintNode; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.schema.SaltingUtil; -import com.salesforce.phoenix.schema.TableRef; +import org.apache.phoenix.compile.ScanRanges; +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.parse.HintNode; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.schema.SaltingUtil; +import org.apache.phoenix.schema.TableRef; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/SpoolTooBigToDiskException.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolTooBigToDiskException.java similarity index 70% rename from phoenix-core/src/main/java/com/salesforce/phoenix/iterate/SpoolTooBigToDiskException.java rename to phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolTooBigToDiskException.java index 74e35e6f..4dffee00 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/SpoolTooBigToDiskException.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolTooBigToDiskException.java @@ -1,7 +1,7 @@ -package com.salesforce.phoenix.iterate; +package org.apache.phoenix.iterate; /** - * Thrown by {@link com.salesforce.phoenix.iterate.SpoolingResultIterator } when + * Thrown by {@link org.apache.phoenix.iterate.SpoolingResultIterator } when * result is too big to fit into memory and too big to spool to disk. * * @author haitaoyao diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/SpoolingResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolingResultIterator.java similarity index 81% rename from phoenix-core/src/main/java/com/salesforce/phoenix/iterate/SpoolingResultIterator.java rename to phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolingResultIterator.java index 70f9112e..5acf71c5 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/iterate/SpoolingResultIterator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolingResultIterator.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.iterate; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; import java.io.*; import java.sql.SQLException; @@ -36,14 +28,14 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; -import com.salesforce.phoenix.memory.MemoryManager; -import com.salesforce.phoenix.memory.MemoryManager.MemoryChunk; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.tuple.ResultTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.*; +import org.apache.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; +import org.apache.phoenix.memory.MemoryManager; +import org.apache.phoenix.memory.MemoryManager.MemoryChunk; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.tuple.ResultTuple; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.*; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/TableResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/TableResultIterator.java new file mode 100644 index 00000000..c9354a86 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/TableResultIterator.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import java.io.IOException; +import java.sql.SQLException; +import java.util.List; + +import org.apache.hadoop.hbase.client.HTableInterface; +import org.apache.hadoop.hbase.client.Scan; + +import com.google.common.io.Closeables; +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ServerUtil; + + +/** + * + * Wrapper for ResultScanner creation that closes HTableInterface + * when ResultScanner is closed. + * + * @author jtaylor + * @since 0.1 + */ +public class TableResultIterator extends ExplainTable implements ResultIterator { + private final HTableInterface htable; + private final ResultIterator delegate; + + public TableResultIterator(StatementContext context, TableRef tableRef) throws SQLException { + this(context, tableRef, context.getScan()); + } + + public TableResultIterator(StatementContext context, TableRef tableRef, Scan scan) throws SQLException { + super(context, tableRef); + htable = context.getConnection().getQueryServices().getTable(tableRef.getTable().getPhysicalName().getBytes()); + try { + delegate = new ScanningResultIterator(htable.getScanner(scan)); + } catch (IOException e) { + Closeables.closeQuietly(htable); + throw ServerUtil.parseServerException(e); + } + } + + @Override + public void close() throws SQLException { + try { + delegate.close(); + } finally { + try { + htable.close(); + } catch (IOException e) { + throw ServerUtil.parseServerException(e); + } + } + } + + @Override + public Tuple next() throws SQLException { + return delegate.next(); + } + + @Override + public void explain(List planSteps) { + StringBuilder buf = new StringBuilder(); + explain(buf.toString(),planSteps); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/UngroupedAggregatingResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/UngroupedAggregatingResultIterator.java new file mode 100644 index 00000000..347e8eb0 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/UngroupedAggregatingResultIterator.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.iterate; + +import static org.apache.phoenix.query.QueryConstants.*; + +import java.sql.SQLException; + +import org.apache.phoenix.expression.aggregator.Aggregators; +import org.apache.phoenix.schema.tuple.SingleKeyValueTuple; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.KeyValueUtil; + + +public class UngroupedAggregatingResultIterator extends GroupedAggregatingResultIterator { + private boolean hasRows = false; + + public UngroupedAggregatingResultIterator( PeekingResultIterator resultIterator, Aggregators aggregators) { + super(resultIterator, aggregators); + } + + @Override + public Tuple next() throws SQLException { + Tuple result = super.next(); + // Ensure ungrouped aggregregation always returns a row, even if the underlying iterator doesn't. + if (result == null && !hasRows) { + // Generate value using unused ClientAggregators + byte[] value = aggregators.toBytes(aggregators.getAggregators()); + result = new SingleKeyValueTuple( + KeyValueUtil.newKeyValue(UNGROUPED_AGG_ROW_KEY, + SINGLE_COLUMN_FAMILY, + SINGLE_COLUMN, + AGG_TIMESTAMP, + value)); + } + hasRows = true; + return result; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/Jdbc7Shim.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/Jdbc7Shim.java new file mode 100644 index 00000000..7a73a4ea --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/Jdbc7Shim.java @@ -0,0 +1,66 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; + +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.concurrent.Executor; +import java.util.logging.Logger; + +/** + * Interfaces to be implemented by classes that need to be "JDK7" compliant, + * but also run in JDK6 + */ +public final class Jdbc7Shim { + + public interface Statement { // Note: do not extend "regular" statement or else eclipse 3.7 complains + void closeOnCompletion() throws SQLException; + boolean isCloseOnCompletion() throws SQLException; + } + + public interface CallableStatement extends Statement { + public T getObject(int columnIndex, Class type) throws SQLException; + public T getObject(String columnLabel, Class type) throws SQLException; + } + + public interface Connection { + void setSchema(String schema) throws SQLException; + String getSchema() throws SQLException; + void abort(Executor executor) throws SQLException; + void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException; + int getNetworkTimeout() throws SQLException; + } + + public interface ResultSet { + public T getObject(int columnIndex, Class type) throws SQLException; + public T getObject(String columnLabel, Class type) throws SQLException; + } + + public interface DatabaseMetaData { + java.sql.ResultSet getPseudoColumns(String catalog, String schemaPattern, + String tableNamePattern, String columnNamePattern) + throws SQLException; + boolean generatedKeyAlwaysReturned() throws SQLException; + } + + public interface Driver { + public Logger getParentLogger() throws SQLFeatureNotSupportedException; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixConnection.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java similarity index 87% rename from phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixConnection.java rename to phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java index ad74281a..ac92570b 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixConnection.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.jdbc; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; import java.io.EOFException; import java.io.IOException; @@ -63,30 +55,30 @@ import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.salesforce.phoenix.client.KeyValueBuilder; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.jdbc.PhoenixStatement.PhoenixStatementParser; -import com.salesforce.phoenix.query.ConnectionQueryServices; -import com.salesforce.phoenix.query.DelegateConnectionQueryServices; -import com.salesforce.phoenix.query.MetaDataMutated; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.PArrayDataType; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PMetaData; -import com.salesforce.phoenix.schema.PMetaDataImpl; -import com.salesforce.phoenix.schema.PName; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.util.DateUtil; -import com.salesforce.phoenix.util.JDBCUtil; -import com.salesforce.phoenix.util.PhoenixRuntime; -import com.salesforce.phoenix.util.ReadOnlyProps; -import com.salesforce.phoenix.util.SQLCloseable; -import com.salesforce.phoenix.util.SQLCloseables; +import org.apache.phoenix.client.KeyValueBuilder; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.jdbc.PhoenixStatement.PhoenixStatementParser; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.query.DelegateConnectionQueryServices; +import org.apache.phoenix.query.MetaDataMutated; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.PArrayDataType; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PMetaData; +import org.apache.phoenix.schema.PMetaDataImpl; +import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.util.DateUtil; +import org.apache.phoenix.util.JDBCUtil; +import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.SQLCloseable; +import org.apache.phoenix.util.SQLCloseables; /** @@ -102,7 +94,7 @@ * @author jtaylor * @since 0.1 */ -public class PhoenixConnection implements Connection, com.salesforce.phoenix.jdbc.Jdbc7Shim.Connection, MetaDataMutated { +public class PhoenixConnection implements Connection, org.apache.phoenix.jdbc.Jdbc7Shim.Connection, MetaDataMutated { private final String url; private final ConnectionQueryServices services; private final Properties info; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixDatabaseMetaData.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java similarity index 93% rename from phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixDatabaseMetaData.java rename to phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java index 098b506a..f921e16c 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixDatabaseMetaData.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.jdbc; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; import java.sql.Connection; import java.sql.DatabaseMetaData; @@ -44,35 +36,35 @@ import org.apache.hadoop.hbase.util.Bytes; import com.google.common.collect.Lists; -import com.salesforce.phoenix.compile.ColumnProjector; -import com.salesforce.phoenix.compile.ExpressionProjector; -import com.salesforce.phoenix.compile.RowProjector; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.expression.BaseTerminalExpression; -import com.salesforce.phoenix.expression.RowKeyColumnExpression; -import com.salesforce.phoenix.expression.function.IndexStateNameFunction; -import com.salesforce.phoenix.expression.function.SQLTableTypeFunction; -import com.salesforce.phoenix.expression.function.SQLViewTypeFunction; -import com.salesforce.phoenix.expression.function.SqlTypeNameFunction; -import com.salesforce.phoenix.iterate.DelegateResultIterator; -import com.salesforce.phoenix.iterate.MaterializedResultIterator; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.parse.HintNode.Hint; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PDatum; -import com.salesforce.phoenix.schema.PName; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.RowKeyValueAccessor; -import com.salesforce.phoenix.schema.tuple.SingleKeyValueTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.KeyValueUtil; -import com.salesforce.phoenix.util.MetaDataUtil; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.compile.ColumnProjector; +import org.apache.phoenix.compile.ExpressionProjector; +import org.apache.phoenix.compile.RowProjector; +import org.apache.phoenix.coprocessor.MetaDataProtocol; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.expression.BaseTerminalExpression; +import org.apache.phoenix.expression.RowKeyColumnExpression; +import org.apache.phoenix.expression.function.IndexStateNameFunction; +import org.apache.phoenix.expression.function.SQLTableTypeFunction; +import org.apache.phoenix.expression.function.SQLViewTypeFunction; +import org.apache.phoenix.expression.function.SqlTypeNameFunction; +import org.apache.phoenix.iterate.DelegateResultIterator; +import org.apache.phoenix.iterate.MaterializedResultIterator; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.parse.HintNode.Hint; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PDatum; +import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.RowKeyValueAccessor; +import org.apache.phoenix.schema.tuple.SingleKeyValueTuple; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.KeyValueUtil; +import org.apache.phoenix.util.MetaDataUtil; +import org.apache.phoenix.util.SchemaUtil; /** @@ -100,7 +92,7 @@ * @author jtaylor * @since 0.1 */ -public class PhoenixDatabaseMetaData implements DatabaseMetaData, com.salesforce.phoenix.jdbc.Jdbc7Shim.DatabaseMetaData { +public class PhoenixDatabaseMetaData implements DatabaseMetaData, org.apache.phoenix.jdbc.Jdbc7Shim.DatabaseMetaData { public static final int INDEX_NAME_INDEX = 4; // Shared with FAMILY_NAME_INDEX public static final int FAMILY_NAME_INDEX = 4; public static final int COLUMN_NAME_INDEX = 3; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixDriver.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDriver.java similarity index 60% rename from phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixDriver.java rename to phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDriver.java index 934d8820..590b29f9 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixDriver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDriver.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.jdbc; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; import java.sql.DriverManager; import java.sql.SQLException; @@ -33,8 +25,8 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import com.salesforce.phoenix.query.*; -import com.salesforce.phoenix.util.SQLCloseables; +import org.apache.phoenix.query.*; +import org.apache.phoenix.util.SQLCloseables; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixEmbeddedDriver.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java similarity index 84% rename from phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixEmbeddedDriver.java rename to phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java index 7422697a..3550584b 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixEmbeddedDriver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java @@ -1,43 +1,35 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.jdbc; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; import java.sql.*; import java.util.*; import java.util.logging.Logger; import com.google.common.collect.Maps; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.query.ConnectionQueryServices; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.util.*; +import org.apache.phoenix.coprocessor.MetaDataProtocol; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.util.*; @@ -48,7 +40,7 @@ * @author jtaylor * @since 0.1 */ -public abstract class PhoenixEmbeddedDriver implements Driver, com.salesforce.phoenix.jdbc.Jdbc7Shim.Driver, SQLCloseable { +public abstract class PhoenixEmbeddedDriver implements Driver, org.apache.phoenix.jdbc.Jdbc7Shim.Driver, SQLCloseable { /** * The protocol for Phoenix Network Client */ diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixParameterMetaData.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixParameterMetaData.java similarity index 67% rename from phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixParameterMetaData.java rename to phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixParameterMetaData.java index 57a00cff..830e0547 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixParameterMetaData.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixParameterMetaData.java @@ -1,43 +1,35 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.jdbc; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; import java.sql.ParameterMetaData; import java.sql.ResultSetMetaData; import java.sql.SQLException; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.parse.BindParseNode; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PDatum; -import com.salesforce.phoenix.schema.TypeMismatchException; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.parse.BindParseNode; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PDatum; +import org.apache.phoenix.schema.TypeMismatchException; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixPreparedStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java similarity index 87% rename from phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixPreparedStatement.java rename to phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java index da6a7ece..8582e749 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixPreparedStatement.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java @@ -1,19 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the following conditions are met: Redistributions of source code - * must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in - * binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of Salesforce.com nor the names - * of its contributors may be used to endorse or promote products derived from this software without specific prior - * written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.jdbc; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; import java.io.EOFException; import java.io.IOException; @@ -43,14 +47,14 @@ import java.util.Collections; import java.util.List; -import com.salesforce.phoenix.compile.BindManager; -import com.salesforce.phoenix.compile.QueryPlan; -import com.salesforce.phoenix.compile.StatementPlan; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.util.DateUtil; -import com.salesforce.phoenix.util.SQLCloseable; +import org.apache.phoenix.compile.BindManager; +import org.apache.phoenix.compile.QueryPlan; +import org.apache.phoenix.compile.StatementPlan; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.util.DateUtil; +import org.apache.phoenix.util.SQLCloseable; /** * JDBC PreparedStatement implementation of Phoenix. Currently only the following methods (in addition to the ones diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixResultSet.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixResultSet.java similarity index 94% rename from phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixResultSet.java rename to phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixResultSet.java index 0c79d7be..a5807aff 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixResultSet.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixResultSet.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.jdbc; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; import java.io.InputStream; import java.io.Reader; @@ -54,16 +46,16 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.compile.ColumnProjector; -import com.salesforce.phoenix.compile.RowProjector; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.tuple.ResultTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.DateUtil; -import com.salesforce.phoenix.util.SQLCloseable; +import org.apache.phoenix.compile.ColumnProjector; +import org.apache.phoenix.compile.RowProjector; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.tuple.ResultTuple; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.DateUtil; +import org.apache.phoenix.util.SQLCloseable; @@ -93,7 +85,7 @@ * @author jtaylor * @since 0.1 */ -public class PhoenixResultSet implements ResultSet, SQLCloseable, com.salesforce.phoenix.jdbc.Jdbc7Shim.ResultSet { +public class PhoenixResultSet implements ResultSet, SQLCloseable, org.apache.phoenix.jdbc.Jdbc7Shim.ResultSet { private final static String STRING_FALSE = "0"; private final static BigDecimal BIG_DECIMAL_FALSE = BigDecimal.valueOf(0); private final static Integer INTEGER_FALSE = Integer.valueOf(0); diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixResultSetMetaData.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixResultSetMetaData.java similarity index 75% rename from phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixResultSetMetaData.java rename to phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixResultSetMetaData.java index 68eeed3a..55d558a7 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixResultSetMetaData.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixResultSetMetaData.java @@ -1,40 +1,32 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.jdbc; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; import java.sql.*; -import com.salesforce.phoenix.compile.ColumnProjector; -import com.salesforce.phoenix.compile.RowProjector; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.PDataType; +import org.apache.phoenix.compile.ColumnProjector; +import org.apache.phoenix.compile.RowProjector; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.PDataType; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java similarity index 88% rename from phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixStatement.java rename to phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java index 361912f4..8592f498 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/jdbc/PhoenixStatement.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.jdbc; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; import java.io.IOException; import java.io.Reader; @@ -47,74 +39,74 @@ import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; -import com.salesforce.phoenix.compile.ColumnProjector; -import com.salesforce.phoenix.compile.CreateIndexCompiler; -import com.salesforce.phoenix.compile.CreateSequenceCompiler; -import com.salesforce.phoenix.compile.CreateTableCompiler; -import com.salesforce.phoenix.compile.DeleteCompiler; -import com.salesforce.phoenix.compile.DropSequenceCompiler; -import com.salesforce.phoenix.compile.ExplainPlan; -import com.salesforce.phoenix.compile.ExpressionProjector; -import com.salesforce.phoenix.compile.MutationPlan; -import com.salesforce.phoenix.compile.QueryCompiler; -import com.salesforce.phoenix.compile.QueryPlan; -import com.salesforce.phoenix.compile.RowProjector; -import com.salesforce.phoenix.compile.StatementPlan; -import com.salesforce.phoenix.compile.UpsertCompiler; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.expression.RowKeyColumnExpression; -import com.salesforce.phoenix.iterate.MaterializedResultIterator; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.parse.AddColumnStatement; -import com.salesforce.phoenix.parse.AliasedNode; -import com.salesforce.phoenix.parse.AlterIndexStatement; -import com.salesforce.phoenix.parse.BindableStatement; -import com.salesforce.phoenix.parse.ColumnDef; -import com.salesforce.phoenix.parse.ColumnName; -import com.salesforce.phoenix.parse.CreateIndexStatement; -import com.salesforce.phoenix.parse.CreateSequenceStatement; -import com.salesforce.phoenix.parse.CreateTableStatement; -import com.salesforce.phoenix.parse.DeleteStatement; -import com.salesforce.phoenix.parse.DropColumnStatement; -import com.salesforce.phoenix.parse.DropIndexStatement; -import com.salesforce.phoenix.parse.DropSequenceStatement; -import com.salesforce.phoenix.parse.DropTableStatement; -import com.salesforce.phoenix.parse.ExplainStatement; -import com.salesforce.phoenix.parse.HintNode; -import com.salesforce.phoenix.parse.LimitNode; -import com.salesforce.phoenix.parse.NamedNode; -import com.salesforce.phoenix.parse.NamedTableNode; -import com.salesforce.phoenix.parse.OrderByNode; -import com.salesforce.phoenix.parse.ParseNode; -import com.salesforce.phoenix.parse.ParseNodeFactory; -import com.salesforce.phoenix.parse.PrimaryKeyConstraint; -import com.salesforce.phoenix.parse.SQLParser; -import com.salesforce.phoenix.parse.SelectStatement; -import com.salesforce.phoenix.parse.TableName; -import com.salesforce.phoenix.parse.TableNode; -import com.salesforce.phoenix.parse.UpsertStatement; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.ExecuteQueryNotApplicableException; -import com.salesforce.phoenix.schema.ExecuteUpdateNotApplicableException; -import com.salesforce.phoenix.schema.MetaDataClient; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PDatum; -import com.salesforce.phoenix.schema.PIndexState; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.RowKeyValueAccessor; -import com.salesforce.phoenix.schema.tuple.SingleKeyValueTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.KeyValueUtil; -import com.salesforce.phoenix.util.SQLCloseable; -import com.salesforce.phoenix.util.SQLCloseables; -import com.salesforce.phoenix.util.ServerUtil; +import org.apache.phoenix.compile.ColumnProjector; +import org.apache.phoenix.compile.CreateIndexCompiler; +import org.apache.phoenix.compile.CreateSequenceCompiler; +import org.apache.phoenix.compile.CreateTableCompiler; +import org.apache.phoenix.compile.DeleteCompiler; +import org.apache.phoenix.compile.DropSequenceCompiler; +import org.apache.phoenix.compile.ExplainPlan; +import org.apache.phoenix.compile.ExpressionProjector; +import org.apache.phoenix.compile.MutationPlan; +import org.apache.phoenix.compile.QueryCompiler; +import org.apache.phoenix.compile.QueryPlan; +import org.apache.phoenix.compile.RowProjector; +import org.apache.phoenix.compile.StatementPlan; +import org.apache.phoenix.compile.UpsertCompiler; +import org.apache.phoenix.coprocessor.MetaDataProtocol; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.expression.RowKeyColumnExpression; +import org.apache.phoenix.iterate.MaterializedResultIterator; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.parse.AddColumnStatement; +import org.apache.phoenix.parse.AliasedNode; +import org.apache.phoenix.parse.AlterIndexStatement; +import org.apache.phoenix.parse.BindableStatement; +import org.apache.phoenix.parse.ColumnDef; +import org.apache.phoenix.parse.ColumnName; +import org.apache.phoenix.parse.CreateIndexStatement; +import org.apache.phoenix.parse.CreateSequenceStatement; +import org.apache.phoenix.parse.CreateTableStatement; +import org.apache.phoenix.parse.DeleteStatement; +import org.apache.phoenix.parse.DropColumnStatement; +import org.apache.phoenix.parse.DropIndexStatement; +import org.apache.phoenix.parse.DropSequenceStatement; +import org.apache.phoenix.parse.DropTableStatement; +import org.apache.phoenix.parse.ExplainStatement; +import org.apache.phoenix.parse.HintNode; +import org.apache.phoenix.parse.LimitNode; +import org.apache.phoenix.parse.NamedNode; +import org.apache.phoenix.parse.NamedTableNode; +import org.apache.phoenix.parse.OrderByNode; +import org.apache.phoenix.parse.ParseNode; +import org.apache.phoenix.parse.ParseNodeFactory; +import org.apache.phoenix.parse.PrimaryKeyConstraint; +import org.apache.phoenix.parse.SQLParser; +import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.parse.TableName; +import org.apache.phoenix.parse.TableNode; +import org.apache.phoenix.parse.UpsertStatement; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.ExecuteQueryNotApplicableException; +import org.apache.phoenix.schema.ExecuteUpdateNotApplicableException; +import org.apache.phoenix.schema.MetaDataClient; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PDatum; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.RowKeyValueAccessor; +import org.apache.phoenix.schema.tuple.SingleKeyValueTuple; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.KeyValueUtil; +import org.apache.phoenix.util.SQLCloseable; +import org.apache.phoenix.util.SQLCloseables; +import org.apache.phoenix.util.ServerUtil; /** @@ -135,7 +127,7 @@ * @author jtaylor * @since 0.1 */ -public class PhoenixStatement implements Statement, SQLCloseable, com.salesforce.phoenix.jdbc.Jdbc7Shim.Statement { +public class PhoenixStatement implements Statement, SQLCloseable, org.apache.phoenix.jdbc.Jdbc7Shim.Statement { public enum UpdateOperation { DELETED("deleted"), UPSERTED("upserted"); diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatementFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatementFactory.java new file mode 100644 index 00000000..50810496 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatementFactory.java @@ -0,0 +1,24 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; + +public interface PhoenixStatementFactory { + public PhoenixStatement newStatement(PhoenixConnection connection); +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/job/AbstractRoundRobinQueue.java b/phoenix-core/src/main/java/org/apache/phoenix/job/AbstractRoundRobinQueue.java similarity index 84% rename from phoenix-core/src/main/java/com/salesforce/phoenix/job/AbstractRoundRobinQueue.java rename to phoenix-core/src/main/java/org/apache/phoenix/job/AbstractRoundRobinQueue.java index 3f70622c..e77e4cac 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/job/AbstractRoundRobinQueue.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/job/AbstractRoundRobinQueue.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.job; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.job; import java.util.*; import java.util.concurrent.BlockingQueue; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/job/JobManager.java b/phoenix-core/src/main/java/org/apache/phoenix/job/JobManager.java similarity index 66% rename from phoenix-core/src/main/java/com/salesforce/phoenix/job/JobManager.java rename to phoenix-core/src/main/java/org/apache/phoenix/job/JobManager.java index 8c1fc3eb..7d17a6d9 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/job/JobManager.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/job/JobManager.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.job; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.job; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicLong; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/join/HashCacheClient.java b/phoenix-core/src/main/java/org/apache/phoenix/join/HashCacheClient.java similarity index 65% rename from phoenix-core/src/main/java/com/salesforce/phoenix/join/HashCacheClient.java rename to phoenix-core/src/main/java/org/apache/phoenix/join/HashCacheClient.java index c26c3879..c3746183 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/join/HashCacheClient.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/join/HashCacheClient.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.join; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.join; import java.io.DataOutputStream; import java.io.IOException; @@ -37,20 +29,20 @@ import org.apache.hadoop.io.WritableUtils; import org.xerial.snappy.Snappy; -import com.salesforce.phoenix.cache.ServerCacheClient; -import com.salesforce.phoenix.cache.ServerCacheClient.ServerCache; -import com.salesforce.phoenix.compile.ScanRanges; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.ExpressionType; -import com.salesforce.phoenix.iterate.ResultIterator; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ServerUtil; -import com.salesforce.phoenix.util.TrustedByteArrayOutputStream; -import com.salesforce.phoenix.util.TupleUtil; +import org.apache.phoenix.cache.ServerCacheClient; +import org.apache.phoenix.cache.ServerCacheClient.ServerCache; +import org.apache.phoenix.compile.ScanRanges; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.ExpressionType; +import org.apache.phoenix.iterate.ResultIterator; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ServerUtil; +import org.apache.phoenix.util.TrustedByteArrayOutputStream; +import org.apache.phoenix.util.TupleUtil; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/join/HashCacheFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/join/HashCacheFactory.java similarity index 64% rename from phoenix-core/src/main/java/com/salesforce/phoenix/join/HashCacheFactory.java rename to phoenix-core/src/main/java/org/apache/phoenix/join/HashCacheFactory.java index ed0dab27..6c3f69b2 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/join/HashCacheFactory.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/join/HashCacheFactory.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.join; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.join; import java.io.*; import java.sql.SQLException; @@ -39,15 +31,15 @@ import org.apache.hadoop.io.WritableUtils; import org.xerial.snappy.Snappy; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.cache.HashCache; -import com.salesforce.phoenix.coprocessor.ServerCachingProtocol.ServerCacheFactory; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.ExpressionType; -import com.salesforce.phoenix.memory.MemoryManager.MemoryChunk; -import com.salesforce.phoenix.schema.tuple.ResultTuple; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.*; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.cache.HashCache; +import org.apache.phoenix.coprocessor.ServerCachingProtocol.ServerCacheFactory; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.ExpressionType; +import org.apache.phoenix.memory.MemoryManager.MemoryChunk; +import org.apache.phoenix.schema.tuple.ResultTuple; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.*; public class HashCacheFactory implements ServerCacheFactory { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/join/HashJoinInfo.java b/phoenix-core/src/main/java/org/apache/phoenix/join/HashJoinInfo.java similarity index 76% rename from phoenix-core/src/main/java/com/salesforce/phoenix/join/HashJoinInfo.java rename to phoenix-core/src/main/java/org/apache/phoenix/join/HashJoinInfo.java index 47a8c2f7..efeb7175 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/join/HashJoinInfo.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/join/HashJoinInfo.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.join; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.join; import java.io.*; import java.util.ArrayList; @@ -34,15 +26,15 @@ import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.ExpressionType; -import com.salesforce.phoenix.parse.JoinTableNode.JoinType; -import com.salesforce.phoenix.schema.KeyValueSchema; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.KeyValueSchema.KeyValueSchemaBuilder; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.ExpressionType; +import org.apache.phoenix.parse.JoinTableNode.JoinType; +import org.apache.phoenix.schema.KeyValueSchema; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.KeyValueSchema.KeyValueSchemaBuilder; +import org.apache.phoenix.util.SchemaUtil; public class HashJoinInfo { private static final String HASH_JOIN = "HashJoin"; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/join/MaxServerCacheSizeExceededException.java b/phoenix-core/src/main/java/org/apache/phoenix/join/MaxServerCacheSizeExceededException.java new file mode 100644 index 00000000..e72d6284 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/join/MaxServerCacheSizeExceededException.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.join; + +/** + * + * Exception thrown when the size of the hash cache exceeds the + * maximum size as specified by the phoenix.query.maxHashCacheBytes + * parameter in the {@link org.apache.hadoop.conf.Configuration} + * + * @author jtaylor + * @since 0.1 + */ +public class MaxServerCacheSizeExceededException extends RuntimeException { + private static final long serialVersionUID = 1L; + + public MaxServerCacheSizeExceededException() { + } + + public MaxServerCacheSizeExceededException(String message) { + super(message); + } + + public MaxServerCacheSizeExceededException(Throwable cause) { + super(cause); + } + + public MaxServerCacheSizeExceededException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/join/ScanProjector.java b/phoenix-core/src/main/java/org/apache/phoenix/join/ScanProjector.java similarity index 77% rename from phoenix-core/src/main/java/com/salesforce/phoenix/join/ScanProjector.java rename to phoenix-core/src/main/java/org/apache/phoenix/join/ScanProjector.java index 0da487df..9f8777da 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/join/ScanProjector.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/join/ScanProjector.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.join; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.join; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -40,16 +32,16 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.phoenix.compile.JoinCompiler.ProjectedPTableWrapper; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.ExpressionType; -import com.salesforce.phoenix.schema.KeyValueSchema; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.ValueBitSet; -import com.salesforce.phoenix.schema.KeyValueSchema.KeyValueSchemaBuilder; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.KeyValueUtil; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.compile.JoinCompiler.ProjectedPTableWrapper; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.ExpressionType; +import org.apache.phoenix.schema.KeyValueSchema; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.ValueBitSet; +import org.apache.phoenix.schema.KeyValueSchema.KeyValueSchemaBuilder; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.KeyValueUtil; +import org.apache.phoenix.util.SchemaUtil; public class ScanProjector { public static final byte[] VALUE_COLUMN_FAMILY = Bytes.toBytes("_v"); diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/map/reduce/CSVBulkLoader.java b/phoenix-core/src/main/java/org/apache/phoenix/map/reduce/CSVBulkLoader.java similarity index 86% rename from phoenix-core/src/main/java/com/salesforce/phoenix/map/reduce/CSVBulkLoader.java rename to phoenix-core/src/main/java/org/apache/phoenix/map/reduce/CSVBulkLoader.java index d7461a4b..e7c61596 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/map/reduce/CSVBulkLoader.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/map/reduce/CSVBulkLoader.java @@ -1,31 +1,23 @@ -/******************************************************************************* -* Copyright (c) 2013, Salesforce.com, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* Neither the name of Salesforce.com nor the names of its contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -******************************************************************************/ -package com.salesforce.phoenix.map.reduce; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.map.reduce; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -60,11 +52,11 @@ import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import com.google.common.io.Closeables; -import com.salesforce.phoenix.map.reduce.util.ConfigReader; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.util.PhoenixRuntime; -import com.salesforce.phoenix.util.SchemaUtil; -import com.salesforce.phoenix.util.StringUtil; +import org.apache.phoenix.map.reduce.util.ConfigReader; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.StringUtil; public class CSVBulkLoader { private static final String UNDERSCORE = "_"; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/map/reduce/MapReduceJob.java b/phoenix-core/src/main/java/org/apache/phoenix/map/reduce/MapReduceJob.java similarity index 76% rename from phoenix-core/src/main/java/com/salesforce/phoenix/map/reduce/MapReduceJob.java rename to phoenix-core/src/main/java/org/apache/phoenix/map/reduce/MapReduceJob.java index 89e4ceaa..6dd9910e 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/map/reduce/MapReduceJob.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/map/reduce/MapReduceJob.java @@ -1,31 +1,23 @@ -/******************************************************************************* -* Copyright (c) 2013, Salesforce.com, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* Neither the name of Salesforce.com nor the names of its contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -******************************************************************************/ -package com.salesforce.phoenix.map.reduce; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.map.reduce; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -52,9 +44,9 @@ import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Mapper; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.util.PhoenixRuntime; -import com.salesforce.phoenix.util.QueryUtil; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.QueryUtil; public class MapReduceJob { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/map/reduce/util/ConfigReader.java b/phoenix-core/src/main/java/org/apache/phoenix/map/reduce/util/ConfigReader.java similarity index 54% rename from phoenix-core/src/main/java/com/salesforce/phoenix/map/reduce/util/ConfigReader.java rename to phoenix-core/src/main/java/org/apache/phoenix/map/reduce/util/ConfigReader.java index 46664eb5..8f739f5c 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/map/reduce/util/ConfigReader.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/map/reduce/util/ConfigReader.java @@ -1,31 +1,23 @@ -/******************************************************************************* -* Copyright (c) 2013, Salesforce.com, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* Neither the name of Salesforce.com nor the names of its contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -******************************************************************************/ -package com.salesforce.phoenix.map.reduce.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.map.reduce.util; import java.util.Enumeration; import java.util.HashMap; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/memory/ChildMemoryManager.java b/phoenix-core/src/main/java/org/apache/phoenix/memory/ChildMemoryManager.java similarity index 67% rename from phoenix-core/src/main/java/com/salesforce/phoenix/memory/ChildMemoryManager.java rename to phoenix-core/src/main/java/org/apache/phoenix/memory/ChildMemoryManager.java index f4912fa5..925cdfd3 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/memory/ChildMemoryManager.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/memory/ChildMemoryManager.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.memory; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.memory; import org.apache.http.annotation.GuardedBy; import org.apache.http.annotation.ThreadSafe; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/memory/DelegatingMemoryManager.java b/phoenix-core/src/main/java/org/apache/phoenix/memory/DelegatingMemoryManager.java new file mode 100644 index 00000000..f50c43d9 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/memory/DelegatingMemoryManager.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.memory; + +/** + * + * Memory manager that delegates through to another memory manager. + * + * @author jtaylor + * @since 0.1 + */ +public class DelegatingMemoryManager implements MemoryManager { + private final MemoryManager parent; + + public DelegatingMemoryManager(MemoryManager globalMemoryManager){ + this.parent = globalMemoryManager; + } + + @Override + public long getAvailableMemory() { + return parent.getAvailableMemory(); + } + + @Override + public long getMaxMemory() { + return parent.getMaxMemory(); + } + + @Override + public MemoryChunk allocate(long minBytes, long reqBytes) { + return parent.allocate(minBytes, reqBytes); + } + + + @Override + public MemoryChunk allocate(long nBytes) { + return allocate(nBytes, nBytes); + } + + public MemoryManager getParent() { + return parent; + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/memory/GlobalMemoryManager.java b/phoenix-core/src/main/java/org/apache/phoenix/memory/GlobalMemoryManager.java similarity index 76% rename from phoenix-core/src/main/java/com/salesforce/phoenix/memory/GlobalMemoryManager.java rename to phoenix-core/src/main/java/org/apache/phoenix/memory/GlobalMemoryManager.java index fc79e823..38a3cd98 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/memory/GlobalMemoryManager.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/memory/GlobalMemoryManager.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.memory; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.memory; import org.apache.http.annotation.GuardedBy; import org.slf4j.Logger; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/memory/InsufficientMemoryException.java b/phoenix-core/src/main/java/org/apache/phoenix/memory/InsufficientMemoryException.java new file mode 100644 index 00000000..8e7eaff6 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/memory/InsufficientMemoryException.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.memory; + +/** + * + * Exception thrown by MemoryManager when insufficient memory is available + * + * @author jtaylor + * @since 0.1 + */ +public class InsufficientMemoryException extends RuntimeException { + private static final long serialVersionUID = 1L; + + public InsufficientMemoryException() { + } + + public InsufficientMemoryException(String message) { + super(message); + } + + public InsufficientMemoryException(Throwable cause) { + super(cause); + } + + public InsufficientMemoryException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/memory/MemoryManager.java b/phoenix-core/src/main/java/org/apache/phoenix/memory/MemoryManager.java similarity index 58% rename from phoenix-core/src/main/java/com/salesforce/phoenix/memory/MemoryManager.java rename to phoenix-core/src/main/java/org/apache/phoenix/memory/MemoryManager.java index 5fdd043c..e9b93557 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/memory/MemoryManager.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/memory/MemoryManager.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.memory; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.memory; import java.io.Closeable; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/optimize/QueryOptimizer.java b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java similarity index 91% rename from phoenix-core/src/main/java/com/salesforce/phoenix/optimize/QueryOptimizer.java rename to phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java index 329da991..b60f742c 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/optimize/QueryOptimizer.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.optimize; +package org.apache.phoenix.optimize; import java.sql.SQLException; import java.util.Collections; @@ -6,25 +6,25 @@ import java.util.List; import com.google.common.collect.Lists; -import com.salesforce.phoenix.compile.ColumnProjector; -import com.salesforce.phoenix.compile.IndexStatementRewriter; -import com.salesforce.phoenix.compile.QueryCompiler; -import com.salesforce.phoenix.compile.QueryPlan; -import com.salesforce.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; -import com.salesforce.phoenix.jdbc.PhoenixStatement; -import com.salesforce.phoenix.parse.HintNode; -import com.salesforce.phoenix.parse.HintNode.Hint; -import com.salesforce.phoenix.parse.ParseNodeFactory; -import com.salesforce.phoenix.parse.SelectStatement; -import com.salesforce.phoenix.parse.TableNode; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PDatum; -import com.salesforce.phoenix.schema.PIndexState; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTableType; +import org.apache.phoenix.compile.ColumnProjector; +import org.apache.phoenix.compile.IndexStatementRewriter; +import org.apache.phoenix.compile.QueryCompiler; +import org.apache.phoenix.compile.QueryPlan; +import org.apache.phoenix.iterate.ParallelIterators.ParallelIteratorFactory; +import org.apache.phoenix.jdbc.PhoenixStatement; +import org.apache.phoenix.parse.HintNode; +import org.apache.phoenix.parse.HintNode.Hint; +import org.apache.phoenix.parse.ParseNodeFactory; +import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.parse.TableNode; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PDatum; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableType; public class QueryOptimizer { private static final ParseNodeFactory FACTORY = new ParseNodeFactory(); diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/AddColumnStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/AddColumnStatement.java new file mode 100644 index 00000000..1059fce7 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/AddColumnStatement.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.apache.phoenix.schema.PTableType; + +public class AddColumnStatement extends AlterTableStatement { + private final List columnDefs; + private final boolean ifNotExists; + private final Map props; + + protected AddColumnStatement(NamedTableNode table, PTableType tableType, List columnDefs, boolean ifNotExists, Map props) { + super(table, tableType); + this.columnDefs = columnDefs; + this.props = props == null ? Collections.emptyMap() : props; + this.ifNotExists = ifNotExists; + } + + public List getColumnDefs() { + return columnDefs; + } + + public boolean ifNotExists() { + return ifNotExists; + } + + public Map getProps() { + return props; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/AddParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/AddParseNode.java new file mode 100644 index 00000000..f4ae4910 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/AddParseNode.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + +/** + * + * Node representing addition in a SQL expression + * + * @author jtaylor + * @since 0.1 + */ +public class AddParseNode extends ArithmeticParseNode { + + AddParseNode(List children) { + super(children); + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/AggregateFunctionParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/AggregateFunctionParseNode.java new file mode 100644 index 00000000..a715dd75 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/AggregateFunctionParseNode.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.List; + + +public class AggregateFunctionParseNode extends FunctionParseNode { + + public AggregateFunctionParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + /** + * Aggregate function are not stateless, even though all the args may be stateless, + * for example, COUNT(1) + */ + @Override + public boolean isStateless() { + return false; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/AliasedNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/AliasedNode.java new file mode 100644 index 00000000..d2302fde --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/AliasedNode.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import org.apache.phoenix.util.SchemaUtil; + +/** + * + * Node representing an aliased parse node in a SQL select clause + * + * @author jtaylor + * @since 0.1 + */ +public class AliasedNode { + private final String alias; + private final ParseNode node; + private final boolean isCaseSensitve; + + public AliasedNode(String alias, ParseNode node) { + this.isCaseSensitve = alias != null && SchemaUtil.isCaseSensitive(alias); + this.alias = alias == null ? null : SchemaUtil.normalizeIdentifier(alias); + this.node = node; + } + + public String getAlias() { + return alias; + } + + public ParseNode getNode() { + return node; + } + + public boolean isCaseSensitve() { + return isCaseSensitve; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/AlterIndexStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/AlterIndexStatement.java new file mode 100644 index 00000000..bee74989 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/AlterIndexStatement.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import org.apache.phoenix.schema.PIndexState; + +public class AlterIndexStatement extends SingleTableSQLStatement { + private final String dataTableName; + private final boolean ifExists; + private final PIndexState indexState; + + public AlterIndexStatement(NamedTableNode indexTableNode, String dataTableName, boolean ifExists, PIndexState indexState) { + super(indexTableNode,0); + this.dataTableName = dataTableName; + this.ifExists = ifExists; + this.indexState = indexState; + } + + public String getTableName() { + return dataTableName; + } + + @Override + public int getBindCount() { + return 0; + } + + public boolean ifExists() { + return ifExists; + } + + public PIndexState getIndexState() { + return indexState; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/AlterTableStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/AlterTableStatement.java new file mode 100644 index 00000000..e6d4c807 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/AlterTableStatement.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import org.apache.phoenix.schema.PTableType; + +public abstract class AlterTableStatement extends SingleTableSQLStatement { + private final PTableType tableType; + + AlterTableStatement(NamedTableNode table, PTableType tableType) { + super(table, 0); + this.tableType = tableType; + } + + public PTableType getTableType() { + return tableType; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/AndParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/AndParseNode.java new file mode 100644 index 00000000..452d8935 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/AndParseNode.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + + +/** + * + * Node representing AND in a SQL expression + * + * @author jtaylor + * @since 0.1 + */ +public class AndParseNode extends CompoundParseNode { + + AndParseNode(List children) { + super(children); + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ArithmeticParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ArithmeticParseNode.java new file mode 100644 index 00000000..4e909608 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ArithmeticParseNode.java @@ -0,0 +1,30 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.List; + +public abstract class ArithmeticParseNode extends CompoundParseNode { + + public ArithmeticParseNode(List children) { + super(children); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ArrayConstructorNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ArrayConstructorNode.java new file mode 100644 index 00000000..7d62b32c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ArrayConstructorNode.java @@ -0,0 +1,44 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + +/** + * Holds the list of array elements that will be used by the upsert stmt with ARRAY column + * + */ +public class ArrayConstructorNode extends CompoundParseNode { + + public ArrayConstructorNode(List children) { + super(children); + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/AvgAggregateParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/AvgAggregateParseNode.java new file mode 100644 index 00000000..0b944c0d --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/AvgAggregateParseNode.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.function.*; + + +public class AvgAggregateParseNode extends AggregateFunctionParseNode { + + public AvgAggregateParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + @Override + public FunctionExpression create(List children, StatementContext context) throws SQLException { + SumAggregateFunction sumFunc; + CountAggregateFunction countFunc = (CountAggregateFunction)context.getExpressionManager().addIfAbsent(new CountAggregateFunction(children)); + if (!countFunc.isConstantExpression()) { + sumFunc = (SumAggregateFunction)context.getExpressionManager().addIfAbsent(new SumAggregateFunction(countFunc.getChildren(),null)); + } else { + sumFunc = null; + } + + return new AvgAggregateFunction(children, countFunc, sumFunc); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/BaseParseNodeVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/BaseParseNodeVisitor.java new file mode 100644 index 00000000..233d5ec8 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BaseParseNodeVisitor.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.List; + + + +/** + * + * Base class for parse node visitors. + * + * @author jtaylor + * @since 0.1 + */ +public abstract class BaseParseNodeVisitor implements ParseNodeVisitor { + + /** + * Fall through visitEnter method. Anything coming through + * here means that a more specific method wasn't found + * and thus this CompoundNode is not yet supported. + */ + @Override + public boolean visitEnter(CompoundParseNode expressionNode) throws SQLException { + throw new SQLFeatureNotSupportedException(expressionNode.toString()); + } + + @Override + public E visitLeave(CompoundParseNode expressionNode, List l) throws SQLException { + throw new SQLFeatureNotSupportedException(expressionNode.toString()); + } + + /** + * Fall through visit method. Anything coming through + * here means that a more specific method wasn't found + * and thus this Node is not yet supported. + */ + @Override + public E visit(ParseNode expressionNode) throws SQLException { + throw new SQLFeatureNotSupportedException(expressionNode.toString()); + } + + @Override + public List newElementList(int size) { + return null; + } + + @Override + public void addElement(List l, E element) { + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/BetweenParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/BetweenParseNode.java new file mode 100644 index 00000000..6306d67e --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BetweenParseNode.java @@ -0,0 +1,54 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.*; + + + +/** + * + * Node representing BETWEEN in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class BetweenParseNode extends CompoundParseNode { + private final boolean negate; + + BetweenParseNode(ParseNode l, ParseNode r1, ParseNode r2, boolean negate) { + super(Arrays.asList(l, r1, r2)); + this.negate = negate; + } + + public boolean isNegate() { + return negate; + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/BinaryParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/BinaryParseNode.java new file mode 100644 index 00000000..82695f52 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BinaryParseNode.java @@ -0,0 +1,44 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.Arrays; + +/** + * + * Abstract class for operators that operate on exactly two nodes + * + * @author jtaylor + * @since 0.1 + */ +public abstract class BinaryParseNode extends CompoundParseNode { + + BinaryParseNode(ParseNode lhs, ParseNode rhs) { + super(Arrays.asList(lhs, rhs)); + } + + public ParseNode getLHS() { + return getChildren().get(0); + } + + public ParseNode getRHS() { + return getChildren().get(1); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/BindParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/BindParseNode.java new file mode 100644 index 00000000..5d4f1734 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BindParseNode.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; + + + +/** + * + * Node representing a bind variable in a SQL expression + * + * @author jtaylor + * @since 0.1 + */ +public class BindParseNode extends NamedParseNode { + private final int index; + + BindParseNode(String name) { + super(name); + index = Integer.parseInt(name); + } + + public int getIndex() { + return index-1; + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + return visitor.visit(this); + } + + + @Override + public boolean isStateless() { + return true; + } + + @Override + public String toString() { + return ":" + index; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/BindTableNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/BindTableNode.java new file mode 100644 index 00000000..7aca261e --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BindTableNode.java @@ -0,0 +1,44 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; + + + +/** + * + * Node representing a TABLE bound using an ARRAY variable + * TODO: modify grammar to support this + * @author jtaylor + * @since 0.1 + */ +public class BindTableNode extends ConcreteTableNode { + + BindTableNode(String alias, TableName name) { + super(alias, name); + } + + @Override + public void accept(TableNodeVisitor visitor) throws SQLException { + visitor.visit(this); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/BindableStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/BindableStatement.java new file mode 100644 index 00000000..7ce9162f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BindableStatement.java @@ -0,0 +1,25 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + + +public interface BindableStatement { + public int getBindCount(); +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CaseParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CaseParseNode.java new file mode 100644 index 00000000..bd044900 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CaseParseNode.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + +/** + * + * Node representing a CASE in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class CaseParseNode extends CompoundParseNode { + + CaseParseNode(List children) { + super(children); + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CastParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CastParseNode.java new file mode 100644 index 00000000..24cae703 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CastParseNode.java @@ -0,0 +1,80 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.function.RoundDecimalExpression; +import org.apache.phoenix.expression.function.RoundTimestampExpression; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.TypeMismatchException; + +/** + * + * Node representing the CAST operator in SQL. + * + * @author samarth.jain + * @since 0.1 + * + */ +public class CastParseNode extends UnaryParseNode { + + private final PDataType dt; + + CastParseNode(ParseNode expr, String dataType) { + super(expr); + dt = PDataType.fromSqlTypeName(dataType); + } + + CastParseNode(ParseNode expr, PDataType dataType) { + super(expr); + dt = dataType; + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } + + public PDataType getDataType() { + return dt; + } + + public static Expression convertToRoundExpressionIfNeeded(PDataType fromDataType, PDataType targetDataType, List expressions) throws SQLException { + Expression firstChildExpr = expressions.get(0); + if(fromDataType == targetDataType) { + return firstChildExpr; + } else if(fromDataType == PDataType.DECIMAL && targetDataType.isCoercibleTo(PDataType.LONG)) { + return new RoundDecimalExpression(expressions); + } else if((fromDataType == PDataType.TIMESTAMP || fromDataType == PDataType.UNSIGNED_TIMESTAMP) && targetDataType.isCoercibleTo(PDataType.DATE)) { + return RoundTimestampExpression.create(expressions); + } else if(!fromDataType.isCoercibleTo(targetDataType)) { + throw TypeMismatchException.newException(fromDataType, targetDataType, firstChildExpr.toString()); + } + return firstChildExpr; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CeilParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CeilParseNode.java new file mode 100644 index 00000000..b041c843 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CeilParseNode.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.function.CeilDateExpression; +import org.apache.phoenix.expression.function.CeilDecimalExpression; +import org.apache.phoenix.expression.function.CeilFunction; +import org.apache.phoenix.expression.function.CeilTimestampExpression; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.TypeMismatchException; + +/** + * Parse node corresponding to {@link CeilFunction}. + * It also acts as a factory for creating the right kind of + * ceil expression according to the data type of the + * first child. + * + * @author samarth.jain + * @since 3.0.0 + */ +public class CeilParseNode extends FunctionParseNode { + + CeilParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + @Override + public Expression create(List children, StatementContext context) throws SQLException { + return getCeilExpression(children); + } + + public static Expression getCeilExpression(List children) throws SQLException { + final Expression firstChild = children.get(0); + final PDataType firstChildDataType = firstChild.getDataType(); + if(firstChildDataType.isCoercibleTo(PDataType.DATE)) { + return CeilDateExpression.create(children); + } else if (firstChildDataType == PDataType.TIMESTAMP || firstChildDataType == PDataType.UNSIGNED_TIMESTAMP) { + return CeilTimestampExpression.create(children); + } else if(firstChildDataType.isCoercibleTo(PDataType.DECIMAL)) { + return new CeilDecimalExpression(children); + } else { + throw TypeMismatchException.newException(firstChildDataType, "1"); + } + } + + /** + * When ceiling off decimals, user need not specify the scale. In such cases, + * we need to prevent the function from getting evaluated as null. This is really + * a hack. A better way would have been if {@link org.apache.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo} provided a + * way of associating default values for each permissible data type. + * Something like: @ Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValues = {"null", "1"} isConstant=true) + * Till then, this will have to do. + */ + @Override + public boolean evalToNullIfParamIsNull(StatementContext context, int index) throws SQLException { + return index == 0; + } + + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ColumnDef.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnDef.java similarity index 75% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/ColumnDef.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnDef.java index 1bdffe91..fb1b8702 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ColumnDef.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnDef.java @@ -1,39 +1,31 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.sql.SQLException; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.util.SchemaUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnFamilyDef.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnFamilyDef.java new file mode 100644 index 00000000..53230664 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnFamilyDef.java @@ -0,0 +1,57 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.*; + + +import com.google.common.collect.ImmutableList; +import org.apache.phoenix.util.SchemaUtil; + +/** + * + * Definition of a Column Family at DDL time + * + * @author jtaylor + * @since 0.1 + */ +public class ColumnFamilyDef { + private final String name; + private final List columnDefs; + private final Map props; + + ColumnFamilyDef(String name, List columnDefs, Map props) { + this.name = SchemaUtil.normalizeIdentifier(name); + this.columnDefs = ImmutableList.copyOf(columnDefs); + this.props = props == null ? Collections.emptyMap() : props; + } + + public String getName() { + return name; + } + + public List getColumnDefs() { + return columnDefs; + } + + public Map getProps() { + return props; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ColumnName.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnName.java similarity index 57% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/ColumnName.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnName.java index ae7804dd..34511c7e 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ColumnName.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnName.java @@ -1,33 +1,25 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.SchemaUtil; public class ColumnName { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ColumnParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnParseNode.java similarity index 50% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/ColumnParseNode.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnParseNode.java index 88229cbb..33058e99 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ColumnParseNode.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnParseNode.java @@ -1,23 +1,27 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the following conditions are met: Redistributions of source code - * must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in - * binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. Neither the name of Salesforce.com nor the names - * of its contributors may be used to endorse or promote products derived from this software without specific prior - * written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.sql.SQLException; -import com.salesforce.phoenix.query.QueryConstants; +import org.apache.phoenix.query.QueryConstants; /** * Node representing a reference to a column in a SQL expression diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ComparisonParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ComparisonParseNode.java new file mode 100644 index 00000000..1a50fb73 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ComparisonParseNode.java @@ -0,0 +1,59 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + +import org.apache.hadoop.hbase.filter.CompareFilter; + +/** + * + * Common base class for =, >, >=, <, <=, != + * + * @author jtaylor + * @since 0.1 + */ +public abstract class ComparisonParseNode extends BinaryParseNode { + + ComparisonParseNode(ParseNode lhs, ParseNode rhs) { + super(lhs, rhs); + } + + @Override + public final T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } + + /** + * Return the comparison operator associated with the given comparison expression node + */ + public abstract CompareFilter.CompareOp getFilterOp(); + + /** + * Return the inverted operator for the CompareOp + */ + public abstract CompareFilter.CompareOp getInvertFilterOp(); +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CompoundParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CompoundParseNode.java new file mode 100644 index 00000000..45c196e0 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CompoundParseNode.java @@ -0,0 +1,75 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + +/** + * + * Abstract node representing an expression node that has children + * + * @author jtaylor + * @since 0.1 + */ +public abstract class CompoundParseNode extends ParseNode { + private final List children; + private final boolean isStateless; + + CompoundParseNode(List children) { + this.children = Collections.unmodifiableList(children); + boolean isStateless = true; + for (ParseNode child : children) { + isStateless &= child.isStateless(); + if (!isStateless) { + break; + } + } + this.isStateless = isStateless; + } + + @Override + public boolean isStateless() { + return isStateless; + } + + @Override + public final List getChildren() { + return children; + } + + + final List acceptChildren(ParseNodeVisitor visitor) throws SQLException { + List l = visitor.newElementList(children.size()); + for (int i = 0; i < children.size(); i++) { + T e = children.get(i).accept(visitor); + visitor.addElement(l, e); + } + return l; + } + + @Override + public String toString() { + return this.getClass().getName() + children.toString(); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ConcreteTableNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ConcreteTableNode.java new file mode 100644 index 00000000..cd00316f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ConcreteTableNode.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import org.apache.phoenix.util.SchemaUtil; + +/** + * + * Abstract node representing a table reference in the FROM clause in SQL + * + * @author jtaylor + * @since 0.1 + */ +public abstract class ConcreteTableNode extends TableNode { + private final TableName name; + + ConcreteTableNode(String alias, TableName name) { + super(SchemaUtil.normalizeIdentifier(alias)); + this.name = name; + } + + public TableName getName() { + return name; + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CreateIndexStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateIndexStatement.java similarity index 50% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/CreateIndexStatement.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/CreateIndexStatement.java index 0e66534f..95d3233b 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CreateIndexStatement.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateIndexStatement.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.util.Collections; import java.util.List; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateSequenceStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateSequenceStatement.java new file mode 100644 index 00000000..b24c0767 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateSequenceStatement.java @@ -0,0 +1,64 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +public class CreateSequenceStatement implements BindableStatement { + + private final TableName sequenceName; + private final ParseNode startWith; + private final ParseNode incrementBy; + private final ParseNode cacheSize; + private final boolean ifNotExists; + private final int bindCount; + + protected CreateSequenceStatement(TableName sequenceName, ParseNode startsWith, ParseNode incrementBy, ParseNode cacheSize, boolean ifNotExists, int bindCount) { + this.sequenceName = sequenceName; + this.startWith = startsWith == null ? LiteralParseNode.ONE : startsWith; + this.incrementBy = incrementBy == null ? LiteralParseNode.ONE : incrementBy; + this.cacheSize = cacheSize == null ? null : cacheSize; + this.ifNotExists = ifNotExists; + this.bindCount = bindCount; + } + + @Override + public int getBindCount() { + return this.bindCount; + } + + public ParseNode getIncrementBy() { + return incrementBy; + } + + public TableName getSequenceName() { + return sequenceName; + } + + public ParseNode getCacheSize() { + return cacheSize; + } + + public ParseNode getStartWith() { + return startWith; + } + + public boolean ifNotExists() { + return ifNotExists; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CreateTableStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateTableStatement.java similarity index 58% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/CreateTableStatement.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/CreateTableStatement.java index 155f6132..9d6d551b 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/CreateTableStatement.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateTableStatement.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.util.Collections; import java.util.List; @@ -35,8 +27,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ListMultimap; -import com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData; -import com.salesforce.phoenix.schema.PTableType; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.schema.PTableType; public class CreateTableStatement implements BindableStatement { private final TableName tableName; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentDateParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentDateParseNode.java new file mode 100644 index 00000000..4ad29bc4 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentDateParseNode.java @@ -0,0 +1,41 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.function.CurrentDateFunction; +import org.apache.phoenix.expression.function.FunctionExpression; + + +public class CurrentDateParseNode extends FunctionParseNode { + + public CurrentDateParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + @Override + public FunctionExpression create(List children, StatementContext context) throws SQLException { + return new CurrentDateFunction(context.getCurrentTime()); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentTimeParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentTimeParseNode.java new file mode 100644 index 00000000..ede88a2c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentTimeParseNode.java @@ -0,0 +1,41 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.function.CurrentTimeFunction; +import org.apache.phoenix.expression.function.FunctionExpression; + + +public class CurrentTimeParseNode extends FunctionParseNode { + + public CurrentTimeParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + @Override + public FunctionExpression create(List children, StatementContext context) throws SQLException { + return new CurrentTimeFunction(context.getCurrentTime()); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DelegateConstantToCountParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DelegateConstantToCountParseNode.java new file mode 100644 index 00000000..8e436ce5 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DelegateConstantToCountParseNode.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.function.CountAggregateFunction; +import org.apache.phoenix.expression.function.FunctionExpression; + + +public abstract class DelegateConstantToCountParseNode extends AggregateFunctionParseNode { + + public DelegateConstantToCountParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + protected CountAggregateFunction getDelegateFunction(List children, StatementContext context) { + CountAggregateFunction countFunc = null; + if (getChildren().get(0).isStateless()) { + countFunc = (CountAggregateFunction)context.getExpressionManager().addIfAbsent(new CountAggregateFunction(children)); + } + return countFunc; + } + + @Override + public abstract FunctionExpression create(List children, StatementContext context) throws SQLException; + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DeleteStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DeleteStatement.java new file mode 100644 index 00000000..8b23c9a0 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DeleteStatement.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.Collections; +import java.util.List; + +public class DeleteStatement extends SingleTableSQLStatement implements FilterableStatement { + private final ParseNode whereNode; + private final List orderBy; + private final LimitNode limit; + private final HintNode hint; + + public DeleteStatement(NamedTableNode table, HintNode hint, ParseNode whereNode, List orderBy, LimitNode limit, int bindCount) { + super(table, bindCount); + this.whereNode = whereNode; + this.orderBy = orderBy == null ? Collections.emptyList() : orderBy; + this.limit = limit; + this.hint = hint == null ? HintNode.EMPTY_HINT_NODE : hint; + } + + @Override + public ParseNode getWhere() { + return whereNode; + } + + @Override + public List getOrderBy() { + return orderBy; + } + + @Override + public LimitNode getLimit() { + return limit; + } + + @Override + public HintNode getHint() { + return hint; + } + + @Override + public boolean isDistinct() { + return false; + } + + @Override + public boolean isAggregate() { + return false; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DerivedTableNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DerivedTableNode.java new file mode 100644 index 00000000..3d76698a --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DerivedTableNode.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; + + + +/** + * + * Node representing a subselect in the FROM clause of SQL + * + * @author jtaylor + * @since 0.1 + */ +public class DerivedTableNode extends TableNode { + + private final SelectStatement select; + + DerivedTableNode(String alias, SelectStatement select) { + super(alias); + this.select = select; + } + + public SelectStatement getSelect() { + return select; + } + + @Override + public void accept(TableNodeVisitor visitor) throws SQLException { + visitor.visit(this); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DistinctCountParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DistinctCountParseNode.java new file mode 100644 index 00000000..d270f2ba --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DistinctCountParseNode.java @@ -0,0 +1,46 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.function.DistinctCountAggregateFunction; +import org.apache.phoenix.expression.function.FunctionExpression; + +/** + * + * @author anoopsjohn + * @since 1.2.1 + */ +public class DistinctCountParseNode extends DelegateConstantToCountParseNode { + + public DistinctCountParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + @Override + public FunctionExpression create(List children, StatementContext context) + throws SQLException { + return new DistinctCountAggregateFunction(children, getDelegateFunction(children, context)); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DivideParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DivideParseNode.java new file mode 100644 index 00000000..bef0d8c6 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DivideParseNode.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + +/** + * + * Node representing division in a SQL expression + * + * @author jtaylor + * @since 0.1 + */ +public class DivideParseNode extends ArithmeticParseNode { + + DivideParseNode(List children) { + super(children); + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DropColumnStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropColumnStatement.java new file mode 100644 index 00000000..71cf099f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropColumnStatement.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.List; + +import org.apache.phoenix.schema.PTableType; + +public class DropColumnStatement extends AlterTableStatement { + private final List columnRefs; + private final boolean ifExists; + + protected DropColumnStatement(NamedTableNode table, PTableType tableType, List columnRefs, boolean ifExists) { + super(table, tableType); + this.columnRefs = columnRefs; + this.ifExists = ifExists; + } + + public List getColumnRefs() { + return columnRefs; + } + + public boolean ifExists() { + return ifExists; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DropIndexStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropIndexStatement.java new file mode 100644 index 00000000..8a01622d --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropIndexStatement.java @@ -0,0 +1,50 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +public class DropIndexStatement implements BindableStatement { + private final TableName tableName; + private final NamedNode indexName; + private final boolean ifExists; + + public DropIndexStatement(NamedNode indexName, TableName tableName, boolean ifExists) { + this.indexName = indexName; + this.tableName = tableName; + this.ifExists = ifExists; + } + + public TableName getTableName() { + return tableName; + } + + public NamedNode getIndexName() { + return indexName; + } + + @Override + public int getBindCount() { + return 0; + } + + public boolean ifExists() { + return ifExists; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DropSequenceStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropSequenceStatement.java new file mode 100644 index 00000000..6ae9652d --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropSequenceStatement.java @@ -0,0 +1,46 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +public class DropSequenceStatement implements BindableStatement { + + private final TableName sequenceName; + private final boolean ifExists; + private final int bindCount; + + protected DropSequenceStatement(TableName sequenceName, boolean ifExists, int bindCount) { + this.sequenceName = sequenceName; + this.ifExists = ifExists; + this.bindCount = bindCount; + } + + @Override + public int getBindCount() { + return bindCount; + } + + public TableName getSequenceName() { + return sequenceName; + } + + public boolean ifExists() { + return ifExists; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DropTableStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropTableStatement.java new file mode 100644 index 00000000..22c4530e --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropTableStatement.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import org.apache.phoenix.schema.PTableType; + +public class DropTableStatement implements BindableStatement { + private final TableName tableName; + private final boolean ifExists; + private final PTableType tableType; + + protected DropTableStatement(TableName tableName, PTableType tableType, boolean ifExists) { + this.tableName = tableName; + this.tableType = tableType; + this.ifExists = ifExists; + } + + @Override + public int getBindCount() { + return 0; // No binds for DROP + } + + public TableName getTableName() { + return tableName; + } + + public PTableType getTableType() { + return tableType; + } + + public boolean ifExists() { + return ifExists; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/EqualParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/EqualParseNode.java new file mode 100644 index 00000000..bdefff9c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/EqualParseNode.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; + + +/** + * + * Node representing the equal operator in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class EqualParseNode extends ComparisonParseNode { + + EqualParseNode(ParseNode lhs, ParseNode rhs) { + super(lhs, rhs); + } + + @Override + public CompareOp getFilterOp() { + return CompareOp.EQUAL; + } + + @Override + public CompareOp getInvertFilterOp() { + return CompareOp.EQUAL; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ExistsParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ExistsParseNode.java new file mode 100644 index 00000000..aaa1a738 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ExistsParseNode.java @@ -0,0 +1,55 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + +/** + * + * Node representing EXISTS and NOT EXISTS expressions in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class ExistsParseNode extends BinaryParseNode { + private final boolean negate; + + ExistsParseNode(ParseNode l, ParseNode r, boolean negate) { + super(l, r); + this.negate = negate; + } + + public boolean isNegate() { + return negate; + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ExplainStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ExplainStatement.java new file mode 100644 index 00000000..fc437c54 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ExplainStatement.java @@ -0,0 +1,37 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +public class ExplainStatement implements BindableStatement { + private final BindableStatement statement; + + public ExplainStatement(BindableStatement statement) { + this.statement = statement; + } + + public BindableStatement getStatement() { + return statement; + } + + @Override + public int getBindCount() { + return statement.getBindCount(); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/FamilyWildcardParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/FamilyWildcardParseNode.java new file mode 100644 index 00000000..438146cb --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/FamilyWildcardParseNode.java @@ -0,0 +1,55 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.phoenix.parse; + +import java.sql.SQLException; + +/** + * + * Node representing the selection of all columns of a family (cf.*) in the SELECT clause of SQL + * + * @author nmaillard + * @since 1.2 + */ + +public class FamilyWildcardParseNode extends NamedParseNode { + private final boolean isRewrite; + + public FamilyWildcardParseNode(String familyName, boolean isRewrite){ + super(familyName); + this.isRewrite = isRewrite; + } + + public FamilyWildcardParseNode(FamilyWildcardParseNode familyName, boolean isRewrite){ + super(familyName); + this.isRewrite = isRewrite; + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + return visitor.visit(this); + } + + public boolean isRewrite() { + return isRewrite; + } +} + diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/FilterableStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/FilterableStatement.java new file mode 100644 index 00000000..47969d91 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/FilterableStatement.java @@ -0,0 +1,31 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.List; + +public interface FilterableStatement extends BindableStatement { + public HintNode getHint(); + public ParseNode getWhere(); + public boolean isDistinct(); + public boolean isAggregate(); + public List getOrderBy(); + public LimitNode getLimit(); +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/FloorParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/FloorParseNode.java new file mode 100644 index 00000000..2f88bf2f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/FloorParseNode.java @@ -0,0 +1,81 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.function.FloorDateExpression; +import org.apache.phoenix.expression.function.FloorDecimalExpression; +import org.apache.phoenix.expression.function.FloorFunction; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.TypeMismatchException; + +/** + * Parse node corresponding to {@link FloorFunction}. + * It also acts as a factory for creating the right kind of + * floor expression according to the data type of the + * first child. + * + * @author samarth.jain + * @since 3.0.0 + */ +public class FloorParseNode extends FunctionParseNode { + + FloorParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + @Override + public Expression create(List children, StatementContext context) throws SQLException { + return getFloorExpression(children); + } + + public static Expression getFloorExpression(List children) throws SQLException { + final Expression firstChild = children.get(0); + final PDataType firstChildDataType = firstChild.getDataType(); + + //FLOOR on timestamp doesn't really care about the nanos part i.e. it just sets it to zero. + //Which is exactly what FloorDateExpression does too. + if(firstChildDataType.isCoercibleTo(PDataType.TIMESTAMP)) { + return FloorDateExpression.create(children); + } else if(firstChildDataType.isCoercibleTo(PDataType.DECIMAL)) { + return new FloorDecimalExpression(children); + } else { + throw TypeMismatchException.newException(firstChildDataType, "1"); + } + } + + /** + * When rounding off decimals, user need not specify the scale. In such cases, + * we need to prevent the function from getting evaluated as null. This is really + * a hack. A better way would have been if {@link org.apache.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo} provided a + * way of associating default values for each permissible data type. + * Something like: @ Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValues = {"null", "1"} isConstant=true) + * Till then, this will have to do. + */ + @Override + public boolean evalToNullIfParamIsNull(StatementContext context, int index) throws SQLException { + return index == 0; + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/FunctionParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/FunctionParseNode.java similarity index 87% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/FunctionParseNode.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/FunctionParseNode.java index 9fb052ff..e31a19e3 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/FunctionParseNode.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/FunctionParseNode.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -43,15 +35,15 @@ import org.apache.http.annotation.Immutable; import com.google.common.collect.ImmutableSet; -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.expression.function.AggregateFunction; -import com.salesforce.phoenix.expression.function.FunctionExpression; -import com.salesforce.phoenix.schema.ArgumentTypeMismatchException; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.ValueRangeExcpetion; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.function.AggregateFunction; +import org.apache.phoenix.expression.function.FunctionExpression; +import org.apache.phoenix.schema.ArgumentTypeMismatchException; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.ValueRangeExcpetion; +import org.apache.phoenix.util.SchemaUtil; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/GreaterThanOrEqualParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/GreaterThanOrEqualParseNode.java new file mode 100644 index 00000000..4780d560 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/GreaterThanOrEqualParseNode.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import org.apache.hadoop.hbase.filter.CompareFilter; +import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; + + +/** + * + * Node representing the greater than or equal to operator (>=) in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class GreaterThanOrEqualParseNode extends ComparisonParseNode { + + GreaterThanOrEqualParseNode(ParseNode lhs, ParseNode rhs) { + super(lhs, rhs); + } + + @Override + public CompareOp getFilterOp() { + return CompareFilter.CompareOp.GREATER_OR_EQUAL; + } + + + @Override + public CompareOp getInvertFilterOp() { + return CompareOp.LESS_OR_EQUAL; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/GreaterThanParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/GreaterThanParseNode.java new file mode 100644 index 00000000..ff0442bc --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/GreaterThanParseNode.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import org.apache.hadoop.hbase.filter.CompareFilter; +import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; + + +/** + * + * Node representing the greater than operator (>) in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class GreaterThanParseNode extends ComparisonParseNode { + + GreaterThanParseNode(ParseNode lhs, ParseNode rhs) { + super(lhs, rhs); + } + + @Override + public CompareOp getFilterOp() { + return CompareFilter.CompareOp.GREATER; + } + + @Override + public CompareOp getInvertFilterOp() { + return CompareOp.LESS; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/HintNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/HintNode.java similarity index 72% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/HintNode.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/HintNode.java index 809a1f73..fa823829 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/HintNode.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/HintNode.java @@ -1,37 +1,29 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.util.HashMap; import java.util.Map; import com.google.common.collect.ImmutableMap; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.SchemaUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/InListParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/InListParseNode.java new file mode 100644 index 00000000..7632de7e --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/InListParseNode.java @@ -0,0 +1,66 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + + + +/** + * + * Node representing the IN literal list expression in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class InListParseNode extends CompoundParseNode { + private final boolean negate; + + InListParseNode(List children, boolean negate) { + super(children); + // All values in the IN must be constant. First child is the LHS + for (int i = 1; i < children.size(); i++) { + ParseNode child = children.get(i); + if (!child.isStateless()) { + throw new ParseException(new SQLExceptionInfo.Builder(SQLExceptionCode.VALUE_IN_LIST_NOT_CONSTANT) + .build().buildException()); + } + } + this.negate = negate; + } + + public boolean isNegate() { + return negate; + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/InParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/InParseNode.java new file mode 100644 index 00000000..d7708fc0 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/InParseNode.java @@ -0,0 +1,55 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + +/** + * + * Node representing IN subquery expression in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class InParseNode extends BinaryParseNode { + private final boolean negate; + + InParseNode(ParseNode l, ParseNode r, boolean negate) { + super(l, r); + this.negate = negate; + } + + public boolean isNegate() { + return negate; + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/IndexKeyConstraint.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/IndexKeyConstraint.java new file mode 100644 index 00000000..6dfc7448 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/IndexKeyConstraint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.List; + +import org.apache.hadoop.hbase.util.Pair; + +import com.google.common.collect.ImmutableList; +import org.apache.phoenix.schema.ColumnModifier; + +public class IndexKeyConstraint { + private final List> columnNameToModifier; + + IndexKeyConstraint(List> columnNameAndModifier) { + this.columnNameToModifier = ImmutableList.copyOf(columnNameAndModifier); + } + + public List> getColumns() { + return columnNameToModifier; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/IsNullParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/IsNullParseNode.java new file mode 100644 index 00000000..a1afc2e4 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/IsNullParseNode.java @@ -0,0 +1,55 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + +/** + * + * Node representing the IS NULL and IS NOT NULL expressions in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class IsNullParseNode extends UnaryParseNode { + private final boolean negate; + + IsNullParseNode(ParseNode expr, boolean negate) { + super(expr); + this.negate = negate; + } + + public boolean isNegate() { + return negate; + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/JoinTableNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/JoinTableNode.java new file mode 100644 index 00000000..d6f7f820 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/JoinTableNode.java @@ -0,0 +1,64 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; + + + +/** + * + * Node representing the join specified in the FROM clause of SQL + * + * @author jtaylor + * @since 0.1 + */ +public class JoinTableNode extends TableNode { + public enum JoinType {Inner, Left, Right, Full}; + + private final JoinType type; + private final ParseNode on; + private final TableNode table; + + JoinTableNode(JoinType type, ParseNode on, TableNode table) { + super(table.getAlias()); + this.type = type; + this.on = on; + this.table = table; + } + + public JoinType getType() { + return type; + } + + public ParseNode getOnNode() { + return on; + } + + public TableNode getTable() { + return table; + } + + @Override + public void accept(TableNodeVisitor visitor) throws SQLException { + visitor.visit(this); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/LessThanOrEqualParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/LessThanOrEqualParseNode.java new file mode 100644 index 00000000..4fb91ddf --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/LessThanOrEqualParseNode.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import org.apache.hadoop.hbase.filter.CompareFilter; +import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; + + +/** + * + * Node representing the less than or equal to operator (<=) in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class LessThanOrEqualParseNode extends ComparisonParseNode { + + LessThanOrEqualParseNode(ParseNode lhs, ParseNode rhs) { + super(lhs, rhs); + } + + @Override + public CompareOp getFilterOp() { + return CompareFilter.CompareOp.LESS_OR_EQUAL; + } + + @Override + public CompareOp getInvertFilterOp() { + return CompareOp.GREATER_OR_EQUAL; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/LessThanParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/LessThanParseNode.java new file mode 100644 index 00000000..c9f69dc3 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/LessThanParseNode.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import org.apache.hadoop.hbase.filter.CompareFilter; +import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; + + +/** + * + * Node representing the less than operator (<) in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class LessThanParseNode extends ComparisonParseNode { + + LessThanParseNode(ParseNode lhs, ParseNode rhs) { + super(lhs, rhs); + } + + @Override + public CompareOp getFilterOp() { + return CompareFilter.CompareOp.LESS; + } + + @Override + public CompareOp getInvertFilterOp() { + return CompareOp.GREATER; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/LikeParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/LikeParseNode.java new file mode 100644 index 00000000..b941d569 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/LikeParseNode.java @@ -0,0 +1,55 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + +/** + * + * Node representing LIKE and NOT LIKE in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class LikeParseNode extends BinaryParseNode { + private final boolean negate; + + LikeParseNode(ParseNode lhs, ParseNode rhs, boolean negate) { + super(lhs, rhs); + this.negate = negate; + } + + public boolean isNegate() { + return negate; + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/LimitNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/LimitNode.java new file mode 100644 index 00000000..cd4d6a9f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/LimitNode.java @@ -0,0 +1,40 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + + +public class LimitNode { + private final BindParseNode bindNode; + private final LiteralParseNode limitNode; + + LimitNode(BindParseNode bindNode) { + this.bindNode = bindNode; + limitNode = null; + } + + LimitNode(LiteralParseNode limitNode) { + this.limitNode = limitNode; + this.bindNode = null; + } + + public ParseNode getLimitParseNode() { + return bindNode == null ? limitNode : bindNode; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/LiteralParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/LiteralParseNode.java new file mode 100644 index 00000000..25247ee8 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/LiteralParseNode.java @@ -0,0 +1,77 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + +import org.apache.phoenix.schema.PDataType; + + + +/** + * + * Node representing literal expressions such as 1,2.5,'foo', and NULL in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class LiteralParseNode extends TerminalParseNode { + public static final List STAR = Collections.singletonList(new LiteralParseNode(1)); + public static final ParseNode NULL = new LiteralParseNode(null); + public static final ParseNode ZERO = new LiteralParseNode(0); + public static final ParseNode ONE = new LiteralParseNode(1); + + private final Object value; + private final PDataType type; + + public LiteralParseNode(Object value) { + this.value = value; + this.type = PDataType.fromLiteral(value); + } + + public PDataType getType() { + return type; + } + + public Object getValue() { + return value; + } + + @Override + public boolean isStateless() { + return true; + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + return visitor.visit(this); + } + + public byte[] getBytes() { + return type == null ? null : type.toBytes(value); + } + + @Override + public String toString() { + return type == PDataType.VARCHAR ? ("'" + value.toString() + "'") : value == null ? "null" : value.toString(); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/MaxAggregateParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/MaxAggregateParseNode.java new file mode 100644 index 00000000..6f59a72b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/MaxAggregateParseNode.java @@ -0,0 +1,41 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.function.FunctionExpression; +import org.apache.phoenix.expression.function.MaxAggregateFunction; + + +public class MaxAggregateParseNode extends DelegateConstantToCountParseNode { + + public MaxAggregateParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + @Override + public FunctionExpression create(List children, StatementContext context) throws SQLException { + return new MaxAggregateFunction(children, getDelegateFunction(children,context)); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/MinAggregateParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/MinAggregateParseNode.java new file mode 100644 index 00000000..f6450dd1 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/MinAggregateParseNode.java @@ -0,0 +1,41 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.function.FunctionExpression; +import org.apache.phoenix.expression.function.MinAggregateFunction; + + +public class MinAggregateParseNode extends DelegateConstantToCountParseNode { + + public MinAggregateParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + @Override + public FunctionExpression create(List children, StatementContext context) throws SQLException { + return new MinAggregateFunction(children, getDelegateFunction(children,context)); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/MultiplyParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/MultiplyParseNode.java new file mode 100644 index 00000000..1b100e93 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/MultiplyParseNode.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + +/** + * + * Node representing multiplication in a SQL expression + * + * @author jtaylor + * @since 0.1 + */ +public class MultiplyParseNode extends ArithmeticParseNode { + + MultiplyParseNode(List children) { + super(children); + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NamedNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/NamedNode.java similarity index 92% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/NamedNode.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/NamedNode.java index 54586db9..9c687aad 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/NamedNode.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/NamedNode.java @@ -1,6 +1,6 @@ -package com.salesforce.phoenix.parse; +package org.apache.phoenix.parse; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.SchemaUtil; public class NamedNode { private final String name; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/NamedParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/NamedParseNode.java new file mode 100644 index 00000000..bd1c6cfb --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/NamedParseNode.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + + +/** + * + * Abstract node representing named nodes such as binds and column expressions in SQL + * + * @author jtaylor + * @since 0.1 + */ +public abstract class NamedParseNode extends TerminalParseNode{ + private final NamedNode namedNode; + + NamedParseNode(NamedParseNode node) { + this.namedNode = node.namedNode; + } + + NamedParseNode(String name) { + this.namedNode = new NamedNode(name); + } + + public String getName() { + return namedNode.getName(); + } + + public boolean isCaseSensitive() { + return namedNode.isCaseSensitive(); + } + + @Override + public String toString() { + return getName(); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/NamedTableNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/NamedTableNode.java new file mode 100644 index 00000000..4be546db --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/NamedTableNode.java @@ -0,0 +1,64 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + +import com.google.common.collect.ImmutableList; + +/** + * Node representing an explicit table reference in the FROM clause of SQL + * + * @author jtaylor + * @since 0.1 + */ +public class NamedTableNode extends ConcreteTableNode { + + private final List dynColumns; + + public static NamedTableNode create (String alias, TableName name, List dynColumns) { + return new NamedTableNode(alias, name, dynColumns); + } + + NamedTableNode(String alias, TableName name) { + super(alias, name); + dynColumns = Collections. emptyList(); + } + + NamedTableNode(String alias, TableName name, List dynColumns) { + super(alias, name); + if (dynColumns != null) { + this.dynColumns = ImmutableList.copyOf(dynColumns); + } else { + this.dynColumns = Collections. emptyList(); + } + } + + @Override + public void accept(TableNodeVisitor visitor) throws SQLException { + visitor.visit(this); + } + + public List getDynamicColumns() { + return dynColumns; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/NotEqualParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/NotEqualParseNode.java new file mode 100644 index 00000000..7872275c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/NotEqualParseNode.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; + + + +/** + * + * Node representing a not equal expression (!=,<>) in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class NotEqualParseNode extends ComparisonParseNode { + + NotEqualParseNode(ParseNode lhs, ParseNode rhs) { + super(lhs, rhs); + } + + @Override + public CompareOp getFilterOp() { + return CompareOp.NOT_EQUAL; + } + + @Override + public CompareOp getInvertFilterOp() { + return CompareOp.NOT_EQUAL; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/NotParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/NotParseNode.java new file mode 100644 index 00000000..580e7ca9 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/NotParseNode.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + +/** + * + * Node representing the NOT in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class NotParseNode extends UnaryParseNode { + + NotParseNode(ParseNode expr) { + super(expr); + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/OrParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/OrParseNode.java new file mode 100644 index 00000000..0fe869ff --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/OrParseNode.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + +/** + * + * Node representing an OR in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class OrParseNode extends CompoundParseNode { + + OrParseNode(List children) { + super(children); + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/OrderByNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/OrderByNode.java new file mode 100644 index 00000000..6a48d10b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/OrderByNode.java @@ -0,0 +1,57 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + + +/** + * + * Node representing an ORDER BY clause (including asc/desc and nulls first/last) in SQL + * + * @author jtaylor + * @since 0.1 + */ +public final class OrderByNode { + private final ParseNode child; + private final boolean nullsLast; + private final boolean orderAscending; + + OrderByNode(ParseNode child, boolean nullsLast, boolean orderAscending) { + this.child = child; + this.nullsLast = nullsLast; + this.orderAscending = orderAscending; + } + + public boolean isNullsLast() { + return nullsLast; + } + + public boolean isAscending() { + return orderAscending; + } + + public ParseNode getNode() { + return child; + } + + @Override + public String toString() { + return child.toString() + (orderAscending ? " asc" : " desc") + " nulls " + (nullsLast ? "last" : "first"); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/OuterJoinParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/OuterJoinParseNode.java new file mode 100644 index 00000000..12ed92bb --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/OuterJoinParseNode.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + +/** + * + * Node representing an outer join qualifier (+) in SQL + * TODO: remove Oracle specific syntax + * + * @author jtaylor + * @since 0.1 + */ +public class OuterJoinParseNode extends UnaryParseNode{ + OuterJoinParseNode(ParseNode node) { + super(node); + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseContext.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseContext.java new file mode 100644 index 00000000..275ceb2a --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseContext.java @@ -0,0 +1,60 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.List; + +import com.google.common.collect.Lists; + +public class ParseContext { + private boolean isAggregate; + + public ParseContext() { + } + + public boolean isAggregate() { + return isAggregate; + } + + public void setAggregate(boolean isAggregate) { + this.isAggregate |= isAggregate; + } + + public static class Stack { + private final List stack = Lists.newArrayListWithExpectedSize(5); + + public void push(ParseContext context) { + stack.add(context); + } + + public ParseContext pop() { + return stack.remove(stack.size()-1); + } + + public ParseContext peek() { + return stack.get(stack.size()-1); + } + + public boolean isEmpty() { + return stack.isEmpty(); + } + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseException.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseException.java new file mode 100644 index 00000000..010dd883 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseException.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +/** + * + * RuntimeException for exceptions occurring during parsing, + * since ANTLR doesn't handle typed exceptions well. + * + * @author jtaylor + * @since 2.0 + */ +public class ParseException extends RuntimeException { + + public ParseException() { + } + + public ParseException(String msg) { + super(msg); + } + + public ParseException(Throwable t) { + super(t); + } + + public ParseException(String msg, Throwable t) { + super(msg, t); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNode.java new file mode 100644 index 00000000..46a385cc --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNode.java @@ -0,0 +1,52 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.List; + + + + +/** + * + * Abstract base class for a parse node in SQL + * + * @author jtaylor + * @since 0.1 + */ +public abstract class ParseNode { + public abstract List getChildren(); + public abstract T accept(ParseNodeVisitor visitor) throws SQLException; + + public boolean isStateless() { + return false; + } + + /** + * Allows node to override what the alias is for a given node. + * Useful for a column reference, as JDBC says that the alias + * name for "a.b" should be "b" + * @return the alias to use for this node or null for no alias + */ + public String getAlias() { + return null; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseNodeFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeFactory.java similarity index 87% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseNodeFactory.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeFactory.java index 0a1b8500..20082a2d 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseNodeFactory.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeFactory.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.lang.reflect.Constructor; import java.sql.SQLException; @@ -40,24 +32,24 @@ import com.google.common.collect.ListMultimap; import com.google.common.collect.Maps; -import com.salesforce.phoenix.exception.UnknownFunctionException; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.ExpressionType; -import com.salesforce.phoenix.expression.function.AvgAggregateFunction; -import com.salesforce.phoenix.expression.function.CountAggregateFunction; -import com.salesforce.phoenix.expression.function.CurrentDateFunction; -import com.salesforce.phoenix.expression.function.CurrentTimeFunction; -import com.salesforce.phoenix.expression.function.DistinctCountAggregateFunction; -import com.salesforce.phoenix.expression.function.FunctionExpression; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo; -import com.salesforce.phoenix.parse.JoinTableNode.JoinType; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PIndexState; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.TypeMismatchException; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.exception.UnknownFunctionException; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.ExpressionType; +import org.apache.phoenix.expression.function.AvgAggregateFunction; +import org.apache.phoenix.expression.function.CountAggregateFunction; +import org.apache.phoenix.expression.function.CurrentDateFunction; +import org.apache.phoenix.expression.function.CurrentTimeFunction; +import org.apache.phoenix.expression.function.DistinctCountAggregateFunction; +import org.apache.phoenix.expression.function.FunctionExpression; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo; +import org.apache.phoenix.parse.JoinTableNode.JoinType; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.TypeMismatchException; +import org.apache.phoenix.util.SchemaUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseNodeRewriter.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeRewriter.java similarity index 91% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseNodeRewriter.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeRewriter.java index 716abdc3..504b4968 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseNodeRewriter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeRewriter.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.sql.SQLException; import java.util.ArrayList; @@ -36,9 +28,9 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.salesforce.phoenix.compile.ColumnResolver; -import com.salesforce.phoenix.schema.AmbiguousColumnException; -import com.salesforce.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.compile.ColumnResolver; +import org.apache.phoenix.schema.AmbiguousColumnException; +import org.apache.phoenix.schema.ColumnNotFoundException; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseNodeVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeVisitor.java similarity index 69% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseNodeVisitor.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeVisitor.java index 27a58b94..f300173b 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ParseNodeVisitor.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeVisitor.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.sql.SQLException; import java.util.List; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/PrimaryKeyConstraint.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/PrimaryKeyConstraint.java new file mode 100644 index 00000000..97c99cb1 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/PrimaryKeyConstraint.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; + +import org.apache.hadoop.hbase.util.Pair; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Maps; +import org.apache.phoenix.schema.ColumnModifier; + +public class PrimaryKeyConstraint extends NamedNode { + public static final PrimaryKeyConstraint EMPTY = new PrimaryKeyConstraint(null, Collections.>emptyList()); + + private final List> columns; + private final HashMap> columnNameToModifier; + + PrimaryKeyConstraint(String name, List> columns) { + super(name); + this.columns = columns == null ? Collections.>emptyList() : ImmutableList.copyOf(columns); + this.columnNameToModifier = Maps.newHashMapWithExpectedSize(this.columns.size()); + for (Pair p : this.columns) { + this.columnNameToModifier.put(p.getFirst(), p); + } + } + + public List> getColumnNames() { + return columns; + } + + public Pair getColumn(ColumnName columnName) { + return columnNameToModifier.get(columnName); + } + + public boolean contains(ColumnName columnName) { + return columnNameToModifier.containsKey(columnName); + } + + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return super.equals(obj); + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/PropertyName.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/PropertyName.java similarity index 87% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/PropertyName.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/PropertyName.java index 4fc040df..167b3232 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/PropertyName.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/PropertyName.java @@ -1,6 +1,6 @@ -package com.salesforce.phoenix.parse; +package org.apache.phoenix.parse; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.SchemaUtil; public class PropertyName { private final NamedNode familyName; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/RoundParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/RoundParseNode.java new file mode 100644 index 00000000..b7e2c0c8 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/RoundParseNode.java @@ -0,0 +1,83 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.function.RoundDateExpression; +import org.apache.phoenix.expression.function.RoundDecimalExpression; +import org.apache.phoenix.expression.function.RoundFunction; +import org.apache.phoenix.expression.function.RoundTimestampExpression; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.TypeMismatchException; + +/** + * + * Parse node corresponding to {@link RoundFunction}. + * It also acts as a factory for creating the right kind of + * round expression according to the data type of the + * first child. + * + * @author samarth.jain + * @since 3.0.0 + */ +public class RoundParseNode extends FunctionParseNode { + + RoundParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + @Override + public Expression create(List children, StatementContext context) throws SQLException { + return getRoundExpression(children); + } + + public static Expression getRoundExpression(List children) throws SQLException { + final Expression firstChild = children.get(0); + final PDataType firstChildDataType = firstChild.getDataType(); + + if(firstChildDataType.isCoercibleTo(PDataType.DATE)) { + return RoundDateExpression.create(children); // FIXME: remove cast + } else if (firstChildDataType.isCoercibleTo(PDataType.TIMESTAMP)) { + return RoundTimestampExpression.create(children); // FIXME: remove cast + } else if(firstChildDataType.isCoercibleTo(PDataType.DECIMAL)) { + return new RoundDecimalExpression(children); + } else { + throw TypeMismatchException.newException(firstChildDataType, "1"); + } + } + + /** + * When rounding off decimals, user need not specify the scale. In such cases, + * we need to prevent the function from getting evaluated as null. This is really + * a hack. A better way would have been if {@link org.apache.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo} provided a + * way of associating default values for each permissible data type. + * Something like: @ Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValues = {"null", "1"} isConstant=true) + * Till then, this will have to do. + */ + @Override + public boolean evalToNullIfParamIsNull(StatementContext context, int index) throws SQLException { + return index == 0; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/RowValueConstructorParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/RowValueConstructorParseNode.java new file mode 100644 index 00000000..e35646ce --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/RowValueConstructorParseNode.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + +/** + * + * Node representing a row value constructor in SQL. + * + * @author samarth.jain + * @since 0.1 + */ +public class RowValueConstructorParseNode extends CompoundParseNode { + + public RowValueConstructorParseNode(List l) { + super(l); + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SQLParser.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/SQLParser.java similarity index 77% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/SQLParser.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/SQLParser.java index 7513b129..4a0139e0 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SQLParser.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/SQLParser.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.io.IOException; import java.io.Reader; @@ -38,7 +30,7 @@ import org.antlr.runtime.CommonTokenStream; import org.antlr.runtime.RecognitionException; -import com.salesforce.phoenix.exception.PhoenixParserException; +import org.apache.phoenix.exception.PhoenixParserException; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SelectStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/SelectStatement.java similarity index 73% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/SelectStatement.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/SelectStatement.java index 3725014a..0f22af72 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SelectStatement.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/SelectStatement.java @@ -1,39 +1,31 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.util.Arrays; import java.util.Collections; import java.util.List; -import com.salesforce.phoenix.expression.function.CountAggregateFunction; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction; -import com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo; +import org.apache.phoenix.expression.function.CountAggregateFunction; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; +import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo; /** * diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SelectStatementRewriter.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/SelectStatementRewriter.java similarity index 76% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/SelectStatementRewriter.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/SelectStatementRewriter.java index d79f67f4..1d181540 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SelectStatementRewriter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/SelectStatementRewriter.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.sql.SQLException; import java.util.ArrayList; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SequenceValueParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/SequenceValueParseNode.java similarity index 94% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/SequenceValueParseNode.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/SequenceValueParseNode.java index 7fef793b..f72d60d0 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/SequenceValueParseNode.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/SequenceValueParseNode.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.parse; +package org.apache.phoenix.parse; import java.sql.SQLException; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/SingleTableSQLStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/SingleTableSQLStatement.java new file mode 100644 index 00000000..ec5976ea --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/SingleTableSQLStatement.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +public abstract class SingleTableSQLStatement implements BindableStatement { + private final NamedTableNode table; + private final int bindCount; + + public SingleTableSQLStatement(NamedTableNode table, int bindCount) { + this.table = table; + this.bindCount = bindCount; + } + + public NamedTableNode getTable() { + return table; + } + + @Override + public int getBindCount() { + return bindCount; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/StatelessTraverseAllParseNodeVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/StatelessTraverseAllParseNodeVisitor.java similarity index 98% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/StatelessTraverseAllParseNodeVisitor.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/StatelessTraverseAllParseNodeVisitor.java index f886945a..beaa2df5 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/StatelessTraverseAllParseNodeVisitor.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/StatelessTraverseAllParseNodeVisitor.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.parse; +package org.apache.phoenix.parse; import java.sql.SQLException; import java.util.List; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/StringConcatParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/StringConcatParseNode.java new file mode 100644 index 00000000..b5134d25 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/StringConcatParseNode.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + + +/** + * + * Node representing || String concatenation in a SQL expression + * + * @author kmahadik + * @since 0.1 + */ +public class StringConcatParseNode extends CompoundParseNode { + + StringConcatParseNode(List children) { + super(children); + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/SubqueryParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/SubqueryParseNode.java new file mode 100644 index 00000000..b2073df9 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/SubqueryParseNode.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; + + + +/** + * + * Node representing a subquery in SQL + * + * @author jtaylor + * @since 0.1 + */ +public class SubqueryParseNode extends TerminalParseNode { + private final SelectStatement select; + + SubqueryParseNode(SelectStatement select) { + this.select = select; + } + + public SelectStatement getSelectNode() { + return select; + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + return visitor.visit(this); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/SubtractParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/SubtractParseNode.java new file mode 100644 index 00000000..c12efef1 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/SubtractParseNode.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; + + + +/** + * + * Node representing subtraction in a SQL expression + * + * @author jtaylor + * @since 0.1 + */ +public class SubtractParseNode extends ArithmeticParseNode { + SubtractParseNode(List children) { + super(children); + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + List l = Collections.emptyList(); + if (visitor.visitEnter(this)) { + l = acceptChildren(visitor); + } + return visitor.visitLeave(this, l); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/SumAggregateParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/SumAggregateParseNode.java new file mode 100644 index 00000000..8669b8d0 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/SumAggregateParseNode.java @@ -0,0 +1,41 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.function.FunctionExpression; +import org.apache.phoenix.expression.function.SumAggregateFunction; + + +public class SumAggregateParseNode extends DelegateConstantToCountParseNode { + + public SumAggregateParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + @Override + public FunctionExpression create(List children, StatementContext context) throws SQLException { + return new SumAggregateFunction(children, getDelegateFunction(children,context)); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/TableName.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/TableName.java new file mode 100644 index 00000000..e5525928 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/TableName.java @@ -0,0 +1,89 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.util.SchemaUtil; + +public class TableName { + private final String tableName; + private final String schemaName; + + public static TableName createNormalized(String schemaName, String tableName) { + schemaName = schemaName == null ? null : SchemaUtil.normalizeIdentifier(schemaName); + tableName = SchemaUtil.normalizeIdentifier(tableName); + return new TableName(schemaName, tableName); + } + + public static TableName create(String schemaName, String tableName) { + return new TableName(schemaName,tableName); + } + + private TableName(String schemaName, String tableName) { + this.schemaName = schemaName; + this.tableName = tableName; + } + + public String getTableName() { + return tableName; + } + + public String getSchemaName() { + return schemaName; + } + + @Override + public String toString() { + return (schemaName == null ? "" : schemaName + QueryConstants.NAME_SEPARATOR) + tableName; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((schemaName == null) ? 0 : schemaName.hashCode()); + result = prime * result + + ((tableName == null) ? 0 : tableName.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TableName other = (TableName) obj; + if (schemaName == null) { + if (other.schemaName != null) + return false; + } else if (!schemaName.equals(other.schemaName)) + return false; + if (tableName == null) { + if (other.tableName != null) + return false; + } else if (!tableName.equals(other.tableName)) + return false; + return true; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/TableNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/TableNode.java new file mode 100644 index 00000000..0eaf140f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/TableNode.java @@ -0,0 +1,45 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; + + + +/** + * + * Abstract base class for FROM clause data sources + * + * @author jtaylor + * @since 0.1 + */ +public abstract class TableNode { + private final String alias; + + TableNode(String alias) { + this.alias = alias; + } + + public String getAlias() { + return alias; + } + + public abstract void accept(TableNodeVisitor visitor) throws SQLException; +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/TableNodeVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/TableNodeVisitor.java new file mode 100644 index 00000000..6a14da83 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/TableNodeVisitor.java @@ -0,0 +1,37 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; + + +/** + * + * Visitor for nodes in the FROM clause + * + * @author jtaylor + * @since 0.1 + */ +public interface TableNodeVisitor { + void visit(BindTableNode boundTableNode) throws SQLException; + void visit(JoinTableNode joinNode) throws SQLException; + void visit(NamedTableNode namedTableNode) throws SQLException; + void visit(DerivedTableNode subselectNode) throws SQLException; +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/TerminalParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/TerminalParseNode.java new file mode 100644 index 00000000..2c31341c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/TerminalParseNode.java @@ -0,0 +1,37 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.Collections; +import java.util.List; + +/** + * + * Abstract node for expressions that have no children + * + * @author jtaylor + * @since 0.1 + */ +public abstract class TerminalParseNode extends ParseNode { + @Override + public final List getChildren() { + return Collections.emptyList(); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ToCharParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ToCharParseNode.java new file mode 100644 index 00000000..ef4d390b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ToCharParseNode.java @@ -0,0 +1,67 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.text.Format; +import java.util.List; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.function.FunctionArgumentType; +import org.apache.phoenix.expression.function.FunctionExpression; +import org.apache.phoenix.expression.function.ToCharFunction; +import org.apache.phoenix.schema.PDataType; + + +public class ToCharParseNode extends FunctionParseNode { + + public ToCharParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + @Override + public FunctionExpression create(List children, StatementContext context) throws SQLException { + PDataType dataType = children.get(0).getDataType(); + String formatString = (String)((LiteralExpression)children.get(1)).getValue(); // either date or number format string + Format formatter; + FunctionArgumentType type; + if (dataType.isCoercibleTo(PDataType.TIMESTAMP)) { + if (formatString == null) { + formatString = context.getDateFormat(); + formatter = context.getDateFormatter(); + } else { + formatter = FunctionArgumentType.TEMPORAL.getFormatter(formatString); + } + type = FunctionArgumentType.TEMPORAL; + } + else if (dataType.isCoercibleTo(PDataType.DECIMAL)) { + if (formatString == null) + formatString = context.getNumberFormat(); + formatter = FunctionArgumentType.NUMERIC.getFormatter(formatString); + type = FunctionArgumentType.NUMERIC; + } + else { + throw new SQLException(dataType + " type is unsupported for TO_CHAR(). Numeric and temporal types are supported."); + } + return new ToCharFunction(children, type, formatString, formatter); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ToDateParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ToDateParseNode.java new file mode 100644 index 00000000..9863902d --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ToDateParseNode.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; +import java.text.Format; +import java.util.List; + +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.function.FunctionExpression; +import org.apache.phoenix.expression.function.ToDateFunction; +import org.apache.phoenix.util.DateUtil; + + +public class ToDateParseNode extends FunctionParseNode { + public ToDateParseNode(String name, List children, BuiltInFunctionInfo info) { + super(name, children, info); + } + + @Override + public FunctionExpression create(List children, StatementContext context) throws SQLException { + Format dateParser; + String dateFormat = (String)((LiteralExpression)children.get(1)).getValue(); + if (dateFormat == null) { + dateFormat = context.getDateFormat(); + dateParser = context.getDateParser(); + } else { + dateParser = DateUtil.getDateParser(dateFormat); + } + return new ToDateFunction(children, dateFormat, dateParser); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ToNumberParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ToNumberParseNode.java similarity index 77% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/ToNumberParseNode.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/ToNumberParseNode.java index 00d9d405..cb2d1491 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/ToNumberParseNode.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ToNumberParseNode.java @@ -1,16 +1,16 @@ -package com.salesforce.phoenix.parse; +package org.apache.phoenix.parse; import java.sql.SQLException; import java.text.Format; import java.util.List; -import com.salesforce.phoenix.compile.StatementContext; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.expression.LiteralExpression; -import com.salesforce.phoenix.expression.function.FunctionArgumentType; -import com.salesforce.phoenix.expression.function.FunctionExpression; -import com.salesforce.phoenix.expression.function.ToNumberFunction; -import com.salesforce.phoenix.schema.PDataType; +import org.apache.phoenix.compile.StatementContext; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.function.FunctionArgumentType; +import org.apache.phoenix.expression.function.FunctionExpression; +import org.apache.phoenix.expression.function.ToNumberFunction; +import org.apache.phoenix.schema.PDataType; public class ToNumberParseNode extends FunctionParseNode { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TraverseAllParseNodeVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/TraverseAllParseNodeVisitor.java similarity index 63% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/TraverseAllParseNodeVisitor.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/TraverseAllParseNodeVisitor.java index 2615324a..1a4a4e64 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TraverseAllParseNodeVisitor.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/TraverseAllParseNodeVisitor.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.sql.SQLException; import java.util.List; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TraverseNoParseNodeVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/TraverseNoParseNodeVisitor.java similarity index 74% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/TraverseNoParseNodeVisitor.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/TraverseNoParseNodeVisitor.java index 34983c68..c3d62fd0 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/TraverseNoParseNodeVisitor.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/TraverseNoParseNodeVisitor.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.sql.SQLException; import java.util.List; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/UnaryParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/UnaryParseNode.java new file mode 100644 index 00000000..356d0476 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/UnaryParseNode.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.Collections; + +/** + * + * Abstract node representing an expression that has a single child in SQL + * + * @author jtaylor + * @since 0.1 + */ +public abstract class UnaryParseNode extends CompoundParseNode { + UnaryParseNode(ParseNode expr) { + super(Collections.singletonList(expr)); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/UnsupportedAllParseNodeVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/UnsupportedAllParseNodeVisitor.java similarity index 78% rename from phoenix-core/src/main/java/com/salesforce/phoenix/parse/UnsupportedAllParseNodeVisitor.java rename to phoenix-core/src/main/java/org/apache/phoenix/parse/UnsupportedAllParseNodeVisitor.java index 6f71937d..24bfcf56 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/parse/UnsupportedAllParseNodeVisitor.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/UnsupportedAllParseNodeVisitor.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.parse; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/UpsertStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/UpsertStatement.java new file mode 100644 index 00000000..777a64c9 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/UpsertStatement.java @@ -0,0 +1,54 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.util.Collections; +import java.util.List; + +public class UpsertStatement extends SingleTableSQLStatement { + private final List columns; + private final List values; + private final SelectStatement select; + private final HintNode hint; + + public UpsertStatement(NamedTableNode table, HintNode hint, List columns, List values, SelectStatement select, int bindCount) { + super(table, bindCount); + this.columns = columns == null ? Collections.emptyList() : columns; + this.values = values; + this.select = select; + this.hint = hint == null ? HintNode.EMPTY_HINT_NODE : hint; + } + + public List getColumns() { + return columns; + } + + public List getValues() { + return values; + } + + public SelectStatement getSelect() { + return select; + } + + public HintNode getHint() { + return hint; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/WildcardParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/WildcardParseNode.java new file mode 100644 index 00000000..a0e3b6e1 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/WildcardParseNode.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.parse; + +import java.sql.SQLException; + + + +/** + * + * Node representing the selection of all columns (*) in the SELECT clause of SQL + * + * @author jtaylor + * @since 0.1 + */ +public class WildcardParseNode extends TerminalParseNode { + private final boolean isRewrite; + public static final WildcardParseNode INSTANCE = new WildcardParseNode(false); + public static final WildcardParseNode REWRITE_INSTANCE = new WildcardParseNode(true); + + private WildcardParseNode(boolean isRewrite) { + this.isRewrite = isRewrite; + } + + @Override + public T accept(ParseNodeVisitor visitor) throws SQLException { + return visitor.visit(this); + } + + @Override + public String toString() { + return "*"; + } + + public boolean isRewrite() { + return isRewrite; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/BaseQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/BaseQueryServicesImpl.java new file mode 100644 index 00000000..27fa10e6 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/BaseQueryServicesImpl.java @@ -0,0 +1,80 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; + +import java.util.concurrent.ExecutorService; + +import org.apache.phoenix.job.JobManager; +import org.apache.phoenix.memory.GlobalMemoryManager; +import org.apache.phoenix.memory.MemoryManager; +import org.apache.phoenix.optimize.QueryOptimizer; +import org.apache.phoenix.util.ReadOnlyProps; + + + +/** + * + * Base class for QueryService implementors. + * + * @author jtaylor + * @since 0.1 + */ +public abstract class BaseQueryServicesImpl implements QueryServices { + private final ExecutorService executor; + private final MemoryManager memoryManager; + private final ReadOnlyProps props; + private final QueryOptimizer queryOptimizer; + + public BaseQueryServicesImpl(QueryServicesOptions options) { + this.executor = JobManager.createThreadPoolExec( + options.getKeepAliveMs(), + options.getThreadPoolSize(), + options.getQueueSize()); + this.memoryManager = new GlobalMemoryManager( + Runtime.getRuntime().totalMemory() * options.getMaxMemoryPerc() / 100, + options.getMaxMemoryWaitMs()); + this.props = options.getProps(); + this.queryOptimizer = new QueryOptimizer(this); + } + + @Override + public ExecutorService getExecutor() { + return executor; + } + + @Override + public MemoryManager getMemoryManager() { + return memoryManager; + } + + @Override + public final ReadOnlyProps getProps() { + return props; + } + + @Override + public void close() { + } + + @Override + public QueryOptimizer getOptimizer() { + return queryOptimizer; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ChildQueryServices.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ChildQueryServices.java new file mode 100644 index 00000000..93613d6c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ChildQueryServices.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; + +import org.apache.phoenix.memory.ChildMemoryManager; +import org.apache.phoenix.memory.MemoryManager; + +/** + * + * Child QueryServices that delegates through to global QueryService. + * Used to track memory used by each org to allow a max percentage threshold. + * + * @author jtaylor + * @since 0.1 + */ +public class ChildQueryServices extends DelegateConnectionQueryServices { + private final MemoryManager memoryManager; + private static final int DEFAULT_MAX_ORG_MEMORY_PERC = 30; + + public ChildQueryServices(ConnectionQueryServices services) { + super(services); + int maxOrgMemPerc = getProps().getInt(MAX_TENANT_MEMORY_PERC_ATTRIB, DEFAULT_MAX_ORG_MEMORY_PERC); + this.memoryManager = new ChildMemoryManager(services.getMemoryManager(), maxOrgMemPerc); + } + + @Override + public MemoryManager getMemoryManager() { + return memoryManager; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConfigurationFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConfigurationFactory.java new file mode 100644 index 00000000..77d737ed --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConfigurationFactory.java @@ -0,0 +1,46 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HBaseConfiguration; + +/** + * Creates {@link Configuration} instances that contain HBase/Hadoop settings. + * + * @author aaraujo + * @since 2.0 + */ +public interface ConfigurationFactory { + /** + * @return Configuration containing HBase/Hadoop settings + */ + Configuration getConfiguration(); + + /** + * Default implementation uses {@link org.apache.hadoop.hbase.HBaseConfiguration#create()}. + */ + static class ConfigurationFactoryImpl implements ConfigurationFactory { + @Override + public Configuration getConfiguration() { + return HBaseConfiguration.create(); + } + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/ConnectionQueryServices.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java similarity index 64% rename from phoenix-core/src/main/java/com/salesforce/phoenix/query/ConnectionQueryServices.java rename to phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java index b992e946..bb371b63 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/ConnectionQueryServices.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; import java.sql.SQLException; import java.util.List; @@ -40,13 +32,13 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Pair; -import com.salesforce.phoenix.client.KeyValueBuilder; -import com.salesforce.phoenix.compile.MutationPlan; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.schema.SequenceKey; -import com.salesforce.phoenix.schema.PTableType; +import org.apache.phoenix.client.KeyValueBuilder; +import org.apache.phoenix.compile.MutationPlan; +import org.apache.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.SequenceKey; public interface ConnectionQueryServices extends QueryServices, MetaDataMutated { @@ -105,4 +97,7 @@ public interface ConnectionQueryServices extends QueryServices, MetaDataMutated * @return the {@link KeyValueBuilder} that is valid for the locally installed version of HBase. */ public KeyValueBuilder getKeyValueBuilder(); -} + + public enum Feature {REVERSE_SCAN}; + public boolean supportsFeature(Feature feature); +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java similarity index 93% rename from phoenix-core/src/main/java/com/salesforce/phoenix/query/ConnectionQueryServicesImpl.java rename to phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java index c58c4ac4..857859c9 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/ConnectionQueryServicesImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java @@ -1,34 +1,26 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_TABLE_NAME_BYTES; -import static com.salesforce.phoenix.query.QueryServicesOptions.DEFAULT_DROP_METADATA; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_TABLE_NAME_BYTES; +import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_DROP_METADATA; import java.io.IOException; import java.sql.SQLException; @@ -69,48 +61,48 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import com.salesforce.hbase.index.Indexer; -import com.salesforce.hbase.index.covered.CoveredColumnsIndexBuilder; -import com.salesforce.phoenix.client.KeyValueBuilder; -import com.salesforce.phoenix.compile.MutationPlan; -import com.salesforce.phoenix.coprocessor.GroupedAggregateRegionObserver; -import com.salesforce.phoenix.coprocessor.MetaDataEndpointImpl; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol.MutationCode; -import com.salesforce.phoenix.coprocessor.MetaDataRegionObserver; -import com.salesforce.phoenix.coprocessor.ScanRegionObserver; -import com.salesforce.phoenix.coprocessor.SequenceRegionObserver; -import com.salesforce.phoenix.coprocessor.ServerCachingEndpointImpl; -import com.salesforce.phoenix.coprocessor.UngroupedAggregateRegionObserver; -import com.salesforce.phoenix.exception.PhoenixIOException; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.index.PhoenixIndexBuilder; -import com.salesforce.phoenix.index.PhoenixIndexCodec; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData; -import com.salesforce.phoenix.jdbc.PhoenixEmbeddedDriver.ConnectionInfo; -import com.salesforce.phoenix.schema.EmptySequenceCacheException; -import com.salesforce.phoenix.schema.MetaDataSplitPolicy; -import com.salesforce.phoenix.schema.NewerTableAlreadyExistsException; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PMetaData; -import com.salesforce.phoenix.schema.PMetaDataImpl; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.ReadOnlyTableException; -import com.salesforce.phoenix.schema.Sequence; -import com.salesforce.phoenix.schema.SequenceKey; -import com.salesforce.phoenix.schema.TableNotFoundException; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.JDBCUtil; -import com.salesforce.phoenix.util.MetaDataUtil; -import com.salesforce.phoenix.util.PhoenixRuntime; -import com.salesforce.phoenix.util.ReadOnlyProps; -import com.salesforce.phoenix.util.SchemaUtil; -import com.salesforce.phoenix.util.ServerUtil; +import org.apache.hadoop.hbase.index.Indexer; +import org.apache.hadoop.hbase.index.covered.CoveredColumnsIndexBuilder; +import org.apache.phoenix.client.KeyValueBuilder; +import org.apache.phoenix.compile.MutationPlan; +import org.apache.phoenix.coprocessor.GroupedAggregateRegionObserver; +import org.apache.phoenix.coprocessor.MetaDataEndpointImpl; +import org.apache.phoenix.coprocessor.MetaDataProtocol; +import org.apache.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; +import org.apache.phoenix.coprocessor.MetaDataProtocol.MutationCode; +import org.apache.phoenix.coprocessor.MetaDataRegionObserver; +import org.apache.phoenix.coprocessor.ScanRegionObserver; +import org.apache.phoenix.coprocessor.SequenceRegionObserver; +import org.apache.phoenix.coprocessor.ServerCachingEndpointImpl; +import org.apache.phoenix.coprocessor.UngroupedAggregateRegionObserver; +import org.apache.phoenix.exception.PhoenixIOException; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.index.PhoenixIndexBuilder; +import org.apache.phoenix.index.PhoenixIndexCodec; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver.ConnectionInfo; +import org.apache.phoenix.schema.EmptySequenceCacheException; +import org.apache.phoenix.schema.MetaDataSplitPolicy; +import org.apache.phoenix.schema.NewerTableAlreadyExistsException; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PMetaData; +import org.apache.phoenix.schema.PMetaDataImpl; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.ReadOnlyTableException; +import org.apache.phoenix.schema.Sequence; +import org.apache.phoenix.schema.SequenceKey; +import org.apache.phoenix.schema.TableNotFoundException; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.JDBCUtil; +import org.apache.phoenix.util.MetaDataUtil; +import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.ServerUtil; public class ConnectionQueryServicesImpl extends DelegateQueryServices implements ConnectionQueryServices { private static final Logger logger = LoggerFactory.getLogger(ConnectionQueryServicesImpl.class); @@ -1436,4 +1428,11 @@ public void removeConnection(PhoenixConnection connection) throws SQLException { public KeyValueBuilder getKeyValueBuilder() { return this.kvBuilder; } + + @Override + public boolean supportsFeature(Feature feature) { + // TODO: Keep map of Feature -> min HBase version + // For now, only Feature is REVERSE_SCAN and it's not supported in any version yet + return false; + } } diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/ConnectionlessQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java similarity index 78% rename from phoenix-core/src/main/java/com/salesforce/phoenix/query/ConnectionlessQueryServicesImpl.java rename to phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java index f4cfc0aa..e586d35f 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/ConnectionlessQueryServicesImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java @@ -1,33 +1,25 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; - -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; + +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES; import java.sql.SQLException; import java.util.Collections; @@ -49,32 +41,32 @@ import org.apache.hadoop.hbase.util.VersionInfo; import com.google.common.collect.Maps; -import com.salesforce.phoenix.client.KeyValueBuilder; -import com.salesforce.phoenix.compile.MutationPlan; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol.MutationCode; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData; -import com.salesforce.phoenix.schema.NewerTableAlreadyExistsException; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PIndexState; -import com.salesforce.phoenix.schema.PMetaData; -import com.salesforce.phoenix.schema.PMetaDataImpl; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTableImpl; -import com.salesforce.phoenix.schema.PTableType; -import com.salesforce.phoenix.schema.SequenceAlreadyExistsException; -import com.salesforce.phoenix.schema.SequenceKey; -import com.salesforce.phoenix.schema.SequenceNotFoundException; -import com.salesforce.phoenix.schema.TableAlreadyExistsException; -import com.salesforce.phoenix.schema.TableNotFoundException; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.PhoenixRuntime; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.client.KeyValueBuilder; +import org.apache.phoenix.compile.MutationPlan; +import org.apache.phoenix.coprocessor.MetaDataProtocol; +import org.apache.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; +import org.apache.phoenix.coprocessor.MetaDataProtocol.MutationCode; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.schema.NewerTableAlreadyExistsException; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.schema.PMetaData; +import org.apache.phoenix.schema.PMetaDataImpl; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableImpl; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.SequenceAlreadyExistsException; +import org.apache.phoenix.schema.SequenceKey; +import org.apache.phoenix.schema.SequenceNotFoundException; +import org.apache.phoenix.schema.TableAlreadyExistsException; +import org.apache.phoenix.schema.TableNotFoundException; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.SchemaUtil; /** @@ -360,4 +352,9 @@ public void removeConnection(PhoenixConnection connection) throws SQLException { public KeyValueBuilder getKeyValueBuilder() { return this.kvBuilder; } -} + + @Override + public boolean supportsFeature(Feature feature) { + return false; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/DelegateConnectionQueryServices.java b/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java similarity index 75% rename from phoenix-core/src/main/java/com/salesforce/phoenix/query/DelegateConnectionQueryServices.java rename to phoenix-core/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java index 52b6e596..08f954e0 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/DelegateConnectionQueryServices.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; import java.sql.SQLException; import java.util.List; @@ -40,16 +32,16 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Pair; -import com.salesforce.phoenix.client.KeyValueBuilder; -import com.salesforce.phoenix.compile.MutationPlan; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PMetaData; -import com.salesforce.phoenix.schema.SequenceKey; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.PTableType; +import org.apache.phoenix.client.KeyValueBuilder; +import org.apache.phoenix.compile.MutationPlan; +import org.apache.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PMetaData; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.SequenceKey; public class DelegateConnectionQueryServices extends DelegateQueryServices implements ConnectionQueryServices { @@ -228,4 +220,9 @@ public void removeConnection(PhoenixConnection connection) throws SQLException { public KeyValueBuilder getKeyValueBuilder() { return getDelegate().getKeyValueBuilder(); } + + @Override + public boolean supportsFeature(Feature feature) { + return getDelegate().supportsFeature(feature); + } } \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateQueryServices.java b/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateQueryServices.java new file mode 100644 index 00000000..6ddf5c58 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateQueryServices.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; + +import java.sql.SQLException; +import java.util.concurrent.ExecutorService; + +import org.apache.phoenix.memory.MemoryManager; +import org.apache.phoenix.optimize.QueryOptimizer; +import org.apache.phoenix.util.ReadOnlyProps; + + + +/** + * + * Class that delegates QueryService calls through to + * a parent QueryService. + * + * @author jtaylor + * @since 0.1 + */ +public class DelegateQueryServices implements QueryServices { + private final QueryServices parent; + + public DelegateQueryServices(QueryServices queryServices) { + parent = queryServices; + } + + protected QueryServices getDelegate() { + return parent; + } + + @Override + public ExecutorService getExecutor() { + return parent.getExecutor(); + } + + @Override + public MemoryManager getMemoryManager() { + return parent.getMemoryManager(); + } + + @Override + public void close() throws SQLException { + parent.close(); + } + + @Override + public ReadOnlyProps getProps() { + return parent.getProps(); + } + + @Override + public QueryOptimizer getOptimizer() { + return parent.getOptimizer(); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/HBaseFactoryProvider.java b/phoenix-core/src/main/java/org/apache/phoenix/query/HBaseFactoryProvider.java new file mode 100644 index 00000000..08e85759 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/HBaseFactoryProvider.java @@ -0,0 +1,57 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; + +import org.apache.phoenix.util.InstanceResolver; + +/** + * Manages factories that provide extension points for HBase. + *

+ * Dependent modules may register their own implementations of the following using {@link java.util.ServiceLoader}: + *

    + *
  • {@link ConfigurationFactory}
  • + *
  • {@link HTableFactory}
  • + *
  • {@link HConnectionFactory}
  • + *
+ * + * If a custom implementation is not registered, the default implementations will be used. + * + * @author aaraujo + * @since 0.2 + */ +public class HBaseFactoryProvider { + + private static final HTableFactory DEFAULT_HTABLE_FACTORY = new HTableFactory.HTableFactoryImpl(); + private static final HConnectionFactory DEFAULT_HCONNECTION_FACTORY = + new HConnectionFactory.HConnectionFactoryImpl(); + private static final ConfigurationFactory DEFAULT_CONFIGURATION_FACTORY = new ConfigurationFactory.ConfigurationFactoryImpl(); + + public static HTableFactory getHTableFactory() { + return InstanceResolver.getSingleton(HTableFactory.class, DEFAULT_HTABLE_FACTORY); + } + + public static HConnectionFactory getHConnectionFactory() { + return InstanceResolver.getSingleton(HConnectionFactory.class, DEFAULT_HCONNECTION_FACTORY); + } + + public static ConfigurationFactory getConfigurationFactory() { + return InstanceResolver.getSingleton(ConfigurationFactory.class, DEFAULT_CONFIGURATION_FACTORY); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/HConnectionFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/query/HConnectionFactory.java new file mode 100644 index 00000000..d40c5400 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/HConnectionFactory.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.ZooKeeperConnectionException; +import org.apache.hadoop.hbase.client.HConnection; +import org.apache.hadoop.hbase.client.HConnectionManager; + +/** + * Factory for creating {@link HConnection} + * + * @author ukuchibhotla + */ +public interface HConnectionFactory { + + /** + * Creates HConnection to access HBase clusters. + * + * @param configuration object + * @return A HConnection instance + */ + HConnection createConnection(Configuration conf) throws ZooKeeperConnectionException; + + /** + * Default implementation. Uses standard HBase HConnections. + */ + static class HConnectionFactoryImpl implements HConnectionFactory { + @Override + public HConnection createConnection(Configuration conf) throws ZooKeeperConnectionException { + return HConnectionManager.createConnection(conf); + } + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/HTableFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/query/HTableFactory.java new file mode 100644 index 00000000..cf5b4dad --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/HTableFactory.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; + +import java.io.IOException; +import java.util.concurrent.ExecutorService; + +import org.apache.hadoop.hbase.client.HConnection; +import org.apache.hadoop.hbase.client.HTable; +import org.apache.hadoop.hbase.client.HTableInterface; + +/** + * Creates clients to access HBase tables. + * + * @author aaraujo + * @since 0.2 + */ +public interface HTableFactory { + /** + * Creates an HBase client using an externally managed HConnection and Thread pool. + * + * @param tableName Name of the table. + * @param connection HConnection to use. + * @param pool ExecutorService to use. + * @return An client to access an HBase table. + * @throws IOException if a server or network exception occurs + */ + HTableInterface getTable(byte[] tableName, HConnection connection, ExecutorService pool) throws IOException; + + /** + * Default implementation. Uses standard HBase HTables. + */ + static class HTableFactoryImpl implements HTableFactory { + @Override + public HTableInterface getTable(byte[] tableName, HConnection connection, ExecutorService pool) throws IOException { + return new HTable(tableName, connection, pool); + } + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/KeyRange.java b/phoenix-core/src/main/java/org/apache/phoenix/query/KeyRange.java similarity index 91% rename from phoenix-core/src/main/java/com/salesforce/phoenix/query/KeyRange.java rename to phoenix-core/src/main/java/org/apache/phoenix/query/KeyRange.java index ba6b52f7..bc37c57c 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/KeyRange.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/KeyRange.java @@ -1,33 +1,25 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; - -import static com.salesforce.phoenix.query.QueryConstants.SEPARATOR_BYTE_ARRAY; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; + +import static org.apache.phoenix.query.QueryConstants.SEPARATOR_BYTE_ARRAY; import java.io.DataInput; import java.io.DataOutput; @@ -46,8 +38,8 @@ import com.google.common.base.Function; import com.google.common.collect.ComparisonChain; import com.google.common.collect.Lists; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.util.ByteUtil; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.util.ByteUtil; import edu.umd.cs.findbugs.annotations.NonNull; @@ -127,7 +119,7 @@ public static KeyRange getKeyRange(byte[] lowerRange, byte[] upperRange) { return getKeyRange(lowerRange, true, upperRange, false); } - // TODO: make non public and move to com.salesforce.phoenix.type soon + // TODO: make non public and move to org.apache.phoenix.type soon public static KeyRange getKeyRange(byte[] lowerRange, boolean lowerInclusive, byte[] upperRange, boolean upperInclusive) { if (lowerRange == null || upperRange == null) { diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/MetaDataMutated.java b/phoenix-core/src/main/java/org/apache/phoenix/query/MetaDataMutated.java new file mode 100644 index 00000000..0ed1d564 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/MetaDataMutated.java @@ -0,0 +1,42 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PMetaData; +import org.apache.phoenix.schema.PTable; + + +/** + * + * Interface for applying schema mutations to our client-side schema cache + * + * @author jtaylor + * @since 0.1 + */ +public interface MetaDataMutated { + PMetaData addTable(PTable table) throws SQLException; + PMetaData removeTable(String tableName) throws SQLException; + PMetaData addColumn(String tableName, List columns, long tableTimeStamp, long tableSeqNum, boolean isImmutableRows) throws SQLException; + PMetaData removeColumn(String tableName, String familyName, String columnName, long tableTimeStamp, long tableSeqNum) throws SQLException; +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/QueryConstants.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java similarity index 51% rename from phoenix-core/src/main/java/com/salesforce/phoenix/query/QueryConstants.java rename to phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java index ffacef00..8bc34a6e 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/QueryConstants.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java @@ -1,84 +1,76 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.BASE_SCHEMA_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.BASE_TABLE_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.BUFFER_LENGTH; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.CACHE_SIZE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.CHAR_OCTET_LENGTH; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_COUNT; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_DEF; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_MODIFIER; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_SIZE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.CURRENT_VALUE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TABLE_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TYPE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DECIMAL_DIGITS; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DISABLE_WAL; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.IMMUTABLE_ROWS; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.INCREMENT_BY; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_STATE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.IS_AUTOINCREMENT; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.IS_NULLABLE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.MULTI_TENANT; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.NULLABLE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.NUM_PREC_RADIX; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.ORDINAL_POSITION; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.PK_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.REF_GENERATION_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.REMARKS_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SALT_BUCKETS; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SCOPE_CATALOG; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SCOPE_SCHEMA; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SCOPE_TABLE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SELF_REFERENCING_COL_NAME_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SEQUENCE_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SEQUENCE_SCHEMA; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SOURCE_DATA_TYPE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SQL_DATA_TYPE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SQL_DATETIME_SUB; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.START_WITH; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_CAT_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_NAME_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SCHEM_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SEQ_NUM; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_TYPE_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TENANT_ID; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_SCHEMA; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_SEQUENCE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_TABLE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_EXPRESSION; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_TYPE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.BASE_SCHEMA_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.BASE_TABLE_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.BUFFER_LENGTH; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CACHE_SIZE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHAR_OCTET_LENGTH; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_COUNT; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_DEF; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_MODIFIER; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_SIZE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CURRENT_VALUE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TABLE_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TYPE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DECIMAL_DIGITS; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DISABLE_WAL; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IMMUTABLE_ROWS; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INCREMENT_BY; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_STATE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_AUTOINCREMENT; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_NULLABLE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MULTI_TENANT; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.NULLABLE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.NUM_PREC_RADIX; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ORDINAL_POSITION; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.PK_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.REF_GENERATION_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.REMARKS_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SALT_BUCKETS; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SCOPE_CATALOG; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SCOPE_SCHEMA; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SCOPE_TABLE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SELF_REFERENCING_COL_NAME_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SEQUENCE_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SEQUENCE_SCHEMA; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SOURCE_DATA_TYPE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SQL_DATA_TYPE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SQL_DATETIME_SUB; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.START_WITH; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_CAT_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_NAME_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SCHEM_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SEQ_NUM; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_TYPE_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TENANT_ID; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_SCHEMA; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_SEQUENCE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_TABLE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_EXPRESSION; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_TYPE; import java.math.BigDecimal; @@ -86,11 +78,11 @@ import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol; -import com.salesforce.phoenix.schema.MetaDataSplitPolicy; -import com.salesforce.phoenix.schema.PName; -import com.salesforce.phoenix.schema.PNormalizedName; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.coprocessor.MetaDataProtocol; +import org.apache.phoenix.schema.MetaDataSplitPolicy; +import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.PNormalizedName; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/QueryServices.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java similarity index 70% rename from phoenix-core/src/main/java/com/salesforce/phoenix/query/QueryServices.java rename to phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java index 9691bee9..320bac08 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/QueryServices.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java @@ -1,41 +1,33 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; import java.util.concurrent.ExecutorService; import org.apache.http.annotation.Immutable; -import com.salesforce.phoenix.iterate.SpoolTooBigToDiskException; -import com.salesforce.phoenix.memory.MemoryManager; -import com.salesforce.phoenix.optimize.QueryOptimizer; -import com.salesforce.phoenix.util.ReadOnlyProps; -import com.salesforce.phoenix.util.SQLCloseable; +import org.apache.phoenix.iterate.SpoolTooBigToDiskException; +import org.apache.phoenix.memory.MemoryManager; +import org.apache.phoenix.optimize.QueryOptimizer; +import org.apache.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.SQLCloseable; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesImpl.java new file mode 100644 index 00000000..5ebde598 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesImpl.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; + + + + + +/** + * + * Real implementation of QueryServices for use in runtime and perf testing + * + * @author jtaylor + * @since 0.1 + */ +public final class QueryServicesImpl extends BaseQueryServicesImpl { + + public QueryServicesImpl() { + super(QueryServicesOptions.withDefaults()); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/QueryServicesOptions.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java similarity index 75% rename from phoenix-core/src/main/java/com/salesforce/phoenix/query/QueryServicesOptions.java rename to phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java index 94041db9..7f3025c5 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/QueryServicesOptions.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java @@ -1,66 +1,58 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; -import static com.salesforce.phoenix.query.QueryServices.CALL_QUEUE_PRODUCER_ATTRIB_NAME; -import static com.salesforce.phoenix.query.QueryServices.CALL_QUEUE_ROUND_ROBIN_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.DATE_FORMAT_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.DROP_METADATA_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.GROUPBY_MAX_CACHE_SIZE_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.GROUPBY_SPILL_FILES_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.GROUPBY_SPILLABLE_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.IMMUTABLE_ROWS_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.INDEX_MUTATE_BATCH_SIZE_THRESHOLD_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.KEEP_ALIVE_MS_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.MASTER_INFO_PORT_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.MAX_INTRA_REGION_PARALLELIZATION_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.MAX_MEMORY_PERC_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.MAX_MEMORY_WAIT_MS_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.MAX_MUTATION_SIZE_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.MAX_QUERY_CONCURRENCY_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.MAX_SERVER_CACHE_SIZE_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.MAX_SERVER_CACHE_TIME_TO_LIVE_MS; -import static com.salesforce.phoenix.query.QueryServices.MAX_SPOOL_TO_DISK_BYTES_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.MAX_TENANT_MEMORY_PERC_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.MUTATE_BATCH_SIZE_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.QUEUE_SIZE_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.REGIONSERVER_INFO_PORT_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.REGIONSERVER_LEASE_PERIOD_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.ROW_KEY_ORDER_SALTED_TABLE_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.RPC_TIMEOUT_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.SCAN_CACHE_SIZE_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.SEQUENCE_CACHE_SIZE_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.TARGET_QUERY_CONCURRENCY_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.THREAD_POOL_SIZE_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.THREAD_TIMEOUT_MS_ATTRIB; -import static com.salesforce.phoenix.query.QueryServices.USE_INDEXES_ATTRIB; +import static org.apache.phoenix.query.QueryServices.CALL_QUEUE_PRODUCER_ATTRIB_NAME; +import static org.apache.phoenix.query.QueryServices.CALL_QUEUE_ROUND_ROBIN_ATTRIB; +import static org.apache.phoenix.query.QueryServices.DATE_FORMAT_ATTRIB; +import static org.apache.phoenix.query.QueryServices.DROP_METADATA_ATTRIB; +import static org.apache.phoenix.query.QueryServices.GROUPBY_MAX_CACHE_SIZE_ATTRIB; +import static org.apache.phoenix.query.QueryServices.GROUPBY_SPILL_FILES_ATTRIB; +import static org.apache.phoenix.query.QueryServices.GROUPBY_SPILLABLE_ATTRIB; +import static org.apache.phoenix.query.QueryServices.IMMUTABLE_ROWS_ATTRIB; +import static org.apache.phoenix.query.QueryServices.INDEX_MUTATE_BATCH_SIZE_THRESHOLD_ATTRIB; +import static org.apache.phoenix.query.QueryServices.KEEP_ALIVE_MS_ATTRIB; +import static org.apache.phoenix.query.QueryServices.MASTER_INFO_PORT_ATTRIB; +import static org.apache.phoenix.query.QueryServices.MAX_INTRA_REGION_PARALLELIZATION_ATTRIB; +import static org.apache.phoenix.query.QueryServices.MAX_MEMORY_PERC_ATTRIB; +import static org.apache.phoenix.query.QueryServices.MAX_MEMORY_WAIT_MS_ATTRIB; +import static org.apache.phoenix.query.QueryServices.MAX_MUTATION_SIZE_ATTRIB; +import static org.apache.phoenix.query.QueryServices.MAX_QUERY_CONCURRENCY_ATTRIB; +import static org.apache.phoenix.query.QueryServices.MAX_SERVER_CACHE_SIZE_ATTRIB; +import static org.apache.phoenix.query.QueryServices.MAX_SERVER_CACHE_TIME_TO_LIVE_MS; +import static org.apache.phoenix.query.QueryServices.MAX_SPOOL_TO_DISK_BYTES_ATTRIB; +import static org.apache.phoenix.query.QueryServices.MAX_TENANT_MEMORY_PERC_ATTRIB; +import static org.apache.phoenix.query.QueryServices.MUTATE_BATCH_SIZE_ATTRIB; +import static org.apache.phoenix.query.QueryServices.QUEUE_SIZE_ATTRIB; +import static org.apache.phoenix.query.QueryServices.REGIONSERVER_INFO_PORT_ATTRIB; +import static org.apache.phoenix.query.QueryServices.REGIONSERVER_LEASE_PERIOD_ATTRIB; +import static org.apache.phoenix.query.QueryServices.ROW_KEY_ORDER_SALTED_TABLE_ATTRIB; +import static org.apache.phoenix.query.QueryServices.RPC_TIMEOUT_ATTRIB; +import static org.apache.phoenix.query.QueryServices.SCAN_CACHE_SIZE_ATTRIB; +import static org.apache.phoenix.query.QueryServices.SEQUENCE_CACHE_SIZE_ATTRIB; +import static org.apache.phoenix.query.QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB; +import static org.apache.phoenix.query.QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB; +import static org.apache.phoenix.query.QueryServices.TARGET_QUERY_CONCURRENCY_ATTRIB; +import static org.apache.phoenix.query.QueryServices.THREAD_POOL_SIZE_ATTRIB; +import static org.apache.phoenix.query.QueryServices.THREAD_TIMEOUT_MS_ATTRIB; +import static org.apache.phoenix.query.QueryServices.USE_INDEXES_ATTRIB; import java.util.Map.Entry; @@ -68,8 +60,8 @@ import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.regionserver.wal.WALEditCodec; -import com.salesforce.phoenix.util.DateUtil; -import com.salesforce.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.DateUtil; +import org.apache.phoenix.util.ReadOnlyProps; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/StatsManager.java b/phoenix-core/src/main/java/org/apache/phoenix/query/StatsManager.java new file mode 100644 index 00000000..7d02e021 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/StatsManager.java @@ -0,0 +1,59 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; + +import java.sql.SQLException; + +import org.apache.phoenix.schema.TableRef; + + +/** + * + * Interface for managing and caching table statistics. + * The frequency of updating the table statistics are controlled + * by {@link org.apache.phoenix.query.QueryServices#STATS_UPDATE_FREQ_MS_ATTRIB}. + * Table stats may also be manually updated through {@link #updateStats(TableRef)}. + * + * + * @author jtaylor + * @since 0.1 + */ +public interface StatsManager { + /** + * Get the minimum key for the given table + * @param table the table + * @return the minimum key or null if unknown + */ + byte[] getMinKey(TableRef table); + + /** + * Get the maximum key for the given table + * @param table the table + * @return the maximum key or null if unknown + */ + byte[] getMaxKey(TableRef table); + + /** + * Manually update the cached table statistics + * @param table the table + * @throws SQLException + */ + void updateStats(TableRef table) throws SQLException; +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/query/StatsManagerImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/StatsManagerImpl.java similarity index 79% rename from phoenix-core/src/main/java/com/salesforce/phoenix/query/StatsManagerImpl.java rename to phoenix-core/src/main/java/org/apache/phoenix/query/StatsManagerImpl.java index 374ec5eb..a36f275a 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/query/StatsManagerImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/StatsManagerImpl.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.query; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.query; import java.io.IOException; import java.sql.SQLException; @@ -41,9 +33,9 @@ import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.filter.KeyOnlyFilter; -import com.salesforce.phoenix.schema.TableRef; -import com.salesforce.phoenix.util.SchemaUtil; -import com.salesforce.phoenix.util.ServerUtil; +import org.apache.phoenix.schema.TableRef; +import org.apache.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.ServerUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/AmbiguousColumnException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/AmbiguousColumnException.java new file mode 100644 index 00000000..f460d639 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/AmbiguousColumnException.java @@ -0,0 +1,52 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.sql.SQLException; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + +/** + * + * Exception thrown when a column name is used without being qualified with an alias + * and more than one table contains that column. + * + * @author jtaylor + * @since 0.1 + */ +public class AmbiguousColumnException extends SQLException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.AMBIGUOUS_COLUMN; + + public AmbiguousColumnException() { + super(new SQLExceptionInfo.Builder(code).build().toString(), code.getSQLState(), code.getErrorCode()); + } + + public AmbiguousColumnException(String columnName) { + super(new SQLExceptionInfo.Builder(code).setColumnName(columnName).build().toString(), + code.getSQLState(), code.getErrorCode()); + } + + public AmbiguousColumnException(String columnName, Throwable cause) { + super(new SQLExceptionInfo.Builder(code).setColumnName(columnName).build().toString(), + code.getSQLState(), code.getErrorCode(), cause); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/AmbiguousTableException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/AmbiguousTableException.java new file mode 100644 index 00000000..56815f96 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/AmbiguousTableException.java @@ -0,0 +1,52 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.sql.SQLException; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + +/** + * + * Exception thrown when a table name is used without being qualified with an alias + * and more than one schema contains that table. + * + * @author jtaylor + * @since 0.1 + */ +public class AmbiguousTableException extends SQLException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.AMBIGUOUS_TABLE; + + public AmbiguousTableException() { + super(new SQLExceptionInfo.Builder(code).build().toString(), code.getSQLState(), code.getErrorCode(), null); + } + + public AmbiguousTableException(String tableName) { + super(new SQLExceptionInfo.Builder(code).setTableName(tableName).toString(), + code.getSQLState(), code.getErrorCode(), null); + } + + public AmbiguousTableException(String tableName, Throwable cause) { + super(new SQLExceptionInfo.Builder(code).setTableName(tableName).toString(), + code.getSQLState(), code.getErrorCode(), cause); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/ArgumentTypeMismatchException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ArgumentTypeMismatchException.java new file mode 100644 index 00000000..51cea073 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ArgumentTypeMismatchException.java @@ -0,0 +1,44 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.sql.SQLException; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + +/** + * Exception thrown when we try to use use an argument that has the wrong type. + * + * @author zhuang + * @since 1.0 + */ +public class ArgumentTypeMismatchException extends SQLException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.TYPE_MISMATCH; + + public ArgumentTypeMismatchException(PDataType expected, PDataType actual, String location) { + super(new SQLExceptionInfo.Builder(code).setMessage("expected: " + expected + " but was: " + actual + " at " + location).build().toString(), code.getSQLState(), code.getErrorCode()); + } + + public ArgumentTypeMismatchException(String expected, String actual, String location) { + super(new SQLExceptionInfo.Builder(code).setMessage("expected: " + expected + " but was: " + actual + " at " + location).build().toString(), code.getSQLState(), code.getErrorCode()); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnAlreadyExistsException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnAlreadyExistsException.java new file mode 100644 index 00000000..6c270c17 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnAlreadyExistsException.java @@ -0,0 +1,62 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.sql.SQLException; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + + +/** + * + * Exception thrown when a column already exists. + * + * @author jtaylor + * @since 0.1 + */ +public class ColumnAlreadyExistsException extends SQLException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.COLUMN_EXIST_IN_DEF; + private final String schemaName; + private final String tableName; + private final String columnName; + + public ColumnAlreadyExistsException(String schemaName, String tableName, String columnName) { + super(new SQLExceptionInfo.Builder(code).setColumnName(columnName) + .setSchemaName(schemaName).setTableName(tableName).build().toString(), + code.getSQLState(), code.getErrorCode(), null); + this.schemaName = schemaName; + this.tableName = tableName; + this.columnName = columnName; + } + + public String getTableName() { + return tableName; + } + + public String getSchemaName() { + return schemaName; + } + + public String getColumnName() { + return columnName; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnFamilyNotFoundException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnFamilyNotFoundException.java new file mode 100644 index 00000000..a450b71b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnFamilyNotFoundException.java @@ -0,0 +1,46 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + +/** + * + * Exception thrown when a family name could not be found in the schema + * + * @author jtaylor + * @since 0.1 + */ +public class ColumnFamilyNotFoundException extends MetaDataEntityNotFoundException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.COLUMN_FAMILY_NOT_FOUND; + private final String familyName; + + public ColumnFamilyNotFoundException(String familyName) { + super(new SQLExceptionInfo.Builder(code).setFamilyName(familyName).build().toString(), + code.getSQLState(), code.getErrorCode(), null); + this.familyName = familyName; + } + + public String getFamilyName() { + return familyName; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnModifier.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnModifier.java similarity index 72% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnModifier.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnModifier.java index c48ede85..7b4bc3da 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnModifier.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnModifier.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnNotFoundException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnNotFoundException.java new file mode 100644 index 00000000..c3b331b6 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnNotFoundException.java @@ -0,0 +1,65 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + + +/** + * + * Exception thrown when a column name referenced in a select + * statement cannot be found in any table. + * + * @author jtaylor + * @since 0.1 + */ +public class ColumnNotFoundException extends MetaDataEntityNotFoundException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.COLUMN_NOT_FOUND; + private final String schemaName; + private final String tableName; + private final String columnName; + + public ColumnNotFoundException(String columnName) { + this(null, null, null, columnName); + } + + public ColumnNotFoundException(String schemaName, String tableName, String familyName, String columnName) { + super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName) + .setFamilyName(familyName).setColumnName(columnName).build().toString(), + code.getSQLState(), code.getErrorCode(), null); + this.schemaName = schemaName; + this.tableName = tableName; + this.columnName = columnName; + } + + public String getTableName() { + return tableName; + } + + public String getSchemaName() { + return schemaName; + } + + public String getColumnName() { + return columnName; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnRef.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnRef.java similarity index 60% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnRef.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnRef.java index e8b4b03c..ed033b77 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ColumnRef.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ColumnRef.java @@ -1,41 +1,33 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import org.apache.http.annotation.Immutable; -import com.salesforce.phoenix.expression.ColumnExpression; -import com.salesforce.phoenix.expression.IndexKeyValueColumnExpression; -import com.salesforce.phoenix.expression.KeyValueColumnExpression; -import com.salesforce.phoenix.expression.ProjectedColumnExpression; -import com.salesforce.phoenix.expression.RowKeyColumnExpression; -import com.salesforce.phoenix.util.IndexUtil; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.expression.ColumnExpression; +import org.apache.phoenix.expression.IndexKeyValueColumnExpression; +import org.apache.phoenix.expression.KeyValueColumnExpression; +import org.apache.phoenix.expression.ProjectedColumnExpression; +import org.apache.phoenix.expression.RowKeyColumnExpression; +import org.apache.phoenix.util.IndexUtil; +import org.apache.phoenix.util.SchemaUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/ConcurrentTableMutationException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ConcurrentTableMutationException.java new file mode 100644 index 00000000..c3b540b3 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ConcurrentTableMutationException.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.sql.SQLException; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + + +public class ConcurrentTableMutationException extends SQLException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.CONCURRENT_TABLE_MUTATION; + private final String schemaName; + private final String tableName; + + public ConcurrentTableMutationException(String schemaName, String tableName) { + super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).build().toString(), + code.getSQLState(), code.getErrorCode()); + this.schemaName = schemaName; + this.tableName = tableName; + } + + public String getTableName() { + return tableName; + } + + public String getSchemaName() { + return schemaName; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/ConstraintViolationException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ConstraintViolationException.java new file mode 100644 index 00000000..5a8b2607 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ConstraintViolationException.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +/** + * + * Exception thrown when a schema constraint is violated at the + * time of data insertion. + * + * @author jtaylor + * @since 180 + */ +public class ConstraintViolationException extends RuntimeException { + private static final long serialVersionUID = 1L; + + public ConstraintViolationException() { + } + + public ConstraintViolationException(String message) { + super(message); + } + + public ConstraintViolationException(Throwable cause) { + super(cause); + } + + public ConstraintViolationException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateColumn.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateColumn.java new file mode 100644 index 00000000..6290b163 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateColumn.java @@ -0,0 +1,64 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.io.*; + +public class DelegateColumn extends DelegateDatum implements PColumn { + + public DelegateColumn(PColumn delegate) { + super(delegate); + } + + @Override + protected PColumn getDelegate() { + return (PColumn)super.getDelegate(); + } + + @Override + public PName getName() { + return getDelegate().getName(); + } + + @Override + public ColumnModifier getColumnModifier() { + return getDelegate().getColumnModifier(); + } + + @Override + public PName getFamilyName() { + return getDelegate().getFamilyName(); + } + + @Override + public void readFields(DataInput input) throws IOException { + getDelegate().readFields(input); + } + + @Override + public void write(DataOutput output) throws IOException { + getDelegate().write(output); + } + + @Override + public int getPosition() { + return getDelegate().getPosition(); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateDatum.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateDatum.java new file mode 100644 index 00000000..86e4cc9d --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateDatum.java @@ -0,0 +1,62 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +public class DelegateDatum implements PDatum { + private final PDatum delegate; + + public DelegateDatum(PDatum delegate) { + this.delegate = delegate; + } + + @Override + public boolean isNullable() { + return delegate.isNullable(); + } + + @Override + public PDataType getDataType() { + return delegate.getDataType(); + } + + @Override + public Integer getByteSize() { + return delegate.getByteSize(); + } + + @Override + public Integer getMaxLength() { + return delegate.getByteSize(); + } + + @Override + public Integer getScale() { + return delegate.getScale(); + } + + @Override + public ColumnModifier getColumnModifier() { + return delegate.getColumnModifier(); + } + + protected PDatum getDelegate() { + return delegate; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/EmptySequenceCacheException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/EmptySequenceCacheException.java similarity index 79% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/EmptySequenceCacheException.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/EmptySequenceCacheException.java index 6fb95a2b..1964983a 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/EmptySequenceCacheException.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/EmptySequenceCacheException.java @@ -1,9 +1,9 @@ -package com.salesforce.phoenix.schema; +package org.apache.phoenix.schema; import java.sql.SQLException; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; public class EmptySequenceCacheException extends SQLException { private static final long serialVersionUID = 1L; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/ExecuteQueryNotApplicableException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ExecuteQueryNotApplicableException.java new file mode 100644 index 00000000..8812bf85 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ExecuteQueryNotApplicableException.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.sql.SQLException; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + +public class ExecuteQueryNotApplicableException extends SQLException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.EXECUTE_QUERY_NOT_APPLICABLE; + + public ExecuteQueryNotApplicableException(String query) { + super(new SQLExceptionInfo.Builder(code).setMessage("Query: " + query).build().toString(), code.getSQLState(), code.getErrorCode()); + } + + public ExecuteQueryNotApplicableException(String command, String statement) { + super(new SQLExceptionInfo.Builder(code).setMessage("Command: " + command + ". Statement: " + statement).build().toString(), code.getSQLState(), code.getErrorCode()); + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/ExecuteUpdateNotApplicableException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ExecuteUpdateNotApplicableException.java new file mode 100644 index 00000000..b99d87bf --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ExecuteUpdateNotApplicableException.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.sql.SQLException; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + +public class ExecuteUpdateNotApplicableException extends SQLException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.EXECUTE_QUERY_NOT_APPLICABLE; + + public ExecuteUpdateNotApplicableException(String query) { + super(new SQLExceptionInfo.Builder(code).setMessage("Query: " + query).build().toString(), code.getSQLState(), code.getErrorCode()); + } + + public ExecuteUpdateNotApplicableException(String command, String statement) { + super(new SQLExceptionInfo.Builder(code).setMessage("Command: " + command + ". Statement: " + statement).build().toString(), code.getSQLState(), code.getErrorCode()); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/IllegalDataException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/IllegalDataException.java new file mode 100644 index 00000000..83ae565a --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/IllegalDataException.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +/** + * + * Exception thrown when an invalid or illegal data value is found + * + * @author jtaylor + * @since 0.1 + */ +public class IllegalDataException extends ConstraintViolationException { + private static final long serialVersionUID = 1L; + + public IllegalDataException() { + } + + public IllegalDataException(String message) { + super(message); + } + + public IllegalDataException(Throwable cause) { + super(cause); + } + + public IllegalDataException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/KeyValueSchema.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/KeyValueSchema.java similarity index 79% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/KeyValueSchema.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/KeyValueSchema.java index 323f3007..bca09a95 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/KeyValueSchema.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/KeyValueSchema.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import java.util.List; @@ -33,9 +25,9 @@ import org.apache.hadoop.io.WritableUtils; import org.apache.http.annotation.Immutable; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.schema.tuple.Tuple; -import com.salesforce.phoenix.util.ByteUtil; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.util.ByteUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/MetaDataClient.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java similarity index 93% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/MetaDataClient.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java index 39e940b0..9547dc0e 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/MetaDataClient.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java @@ -1,67 +1,59 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import static com.google.common.collect.Lists.newArrayListWithExpectedSize; import static com.google.common.collect.Sets.newLinkedHashSet; import static com.google.common.collect.Sets.newLinkedHashSetWithExpectedSize; -import static com.salesforce.phoenix.exception.SQLExceptionCode.INSUFFICIENT_MULTI_TENANT_COLUMNS; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.BASE_SCHEMA_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.BASE_TABLE_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_COUNT; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_MODIFIER; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_SIZE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TABLE_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TYPE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DECIMAL_DIGITS; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.DISABLE_WAL; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.IMMUTABLE_ROWS; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_STATE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.MULTI_TENANT; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.NULLABLE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.ORDINAL_POSITION; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.PK_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SALT_BUCKETS; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_CAT_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_NAME_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SCHEM_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SEQ_NUM; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_TYPE_NAME; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TENANT_ID; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_SCHEMA; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_TABLE; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_EXPRESSION; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_TYPE; -import static com.salesforce.phoenix.query.QueryServices.DROP_METADATA_ATTRIB; -import static com.salesforce.phoenix.query.QueryServicesOptions.DEFAULT_DROP_METADATA; -import static com.salesforce.phoenix.schema.PDataType.VARCHAR; +import static org.apache.phoenix.exception.SQLExceptionCode.INSUFFICIENT_MULTI_TENANT_COLUMNS; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.BASE_SCHEMA_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.BASE_TABLE_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_COUNT; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_MODIFIER; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_SIZE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TABLE_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TYPE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DECIMAL_DIGITS; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DISABLE_WAL; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IMMUTABLE_ROWS; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_STATE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MULTI_TENANT; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.NULLABLE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ORDINAL_POSITION; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.PK_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SALT_BUCKETS; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_CAT_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_NAME_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SCHEM_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SEQ_NUM; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_TYPE_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TENANT_ID; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_SCHEMA; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_TABLE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_EXPRESSION; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_TYPE; +import static org.apache.phoenix.query.QueryServices.DROP_METADATA_ATTRIB; +import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_DROP_METADATA; +import static org.apache.phoenix.schema.PDataType.VARCHAR; import java.sql.DriverManager; import java.sql.PreparedStatement; @@ -94,45 +86,45 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.primitives.Ints; -import com.salesforce.phoenix.compile.ColumnResolver; -import com.salesforce.phoenix.compile.FromCompiler; -import com.salesforce.phoenix.compile.MutationPlan; -import com.salesforce.phoenix.compile.PostDDLCompiler; -import com.salesforce.phoenix.compile.PostIndexDDLCompiler; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol.MutationCode; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.execute.MutationState; -import com.salesforce.phoenix.expression.AndExpression; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData; -import com.salesforce.phoenix.parse.AddColumnStatement; -import com.salesforce.phoenix.parse.AlterIndexStatement; -import com.salesforce.phoenix.parse.ColumnDef; -import com.salesforce.phoenix.parse.ColumnName; -import com.salesforce.phoenix.parse.CreateIndexStatement; -import com.salesforce.phoenix.parse.CreateSequenceStatement; -import com.salesforce.phoenix.parse.CreateTableStatement; -import com.salesforce.phoenix.parse.DropColumnStatement; -import com.salesforce.phoenix.parse.DropIndexStatement; -import com.salesforce.phoenix.parse.DropSequenceStatement; -import com.salesforce.phoenix.parse.DropTableStatement; -import com.salesforce.phoenix.parse.NamedTableNode; -import com.salesforce.phoenix.parse.ParseNodeFactory; -import com.salesforce.phoenix.parse.PrimaryKeyConstraint; -import com.salesforce.phoenix.parse.TableName; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.PTable.ViewType; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.IndexUtil; -import com.salesforce.phoenix.util.MetaDataUtil; -import com.salesforce.phoenix.util.PhoenixRuntime; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.compile.ColumnResolver; +import org.apache.phoenix.compile.FromCompiler; +import org.apache.phoenix.compile.MutationPlan; +import org.apache.phoenix.compile.PostDDLCompiler; +import org.apache.phoenix.compile.PostIndexDDLCompiler; +import org.apache.phoenix.coprocessor.MetaDataProtocol; +import org.apache.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult; +import org.apache.phoenix.coprocessor.MetaDataProtocol.MutationCode; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.expression.AndExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.parse.AddColumnStatement; +import org.apache.phoenix.parse.AlterIndexStatement; +import org.apache.phoenix.parse.ColumnDef; +import org.apache.phoenix.parse.ColumnName; +import org.apache.phoenix.parse.CreateIndexStatement; +import org.apache.phoenix.parse.CreateSequenceStatement; +import org.apache.phoenix.parse.CreateTableStatement; +import org.apache.phoenix.parse.DropColumnStatement; +import org.apache.phoenix.parse.DropIndexStatement; +import org.apache.phoenix.parse.DropSequenceStatement; +import org.apache.phoenix.parse.DropTableStatement; +import org.apache.phoenix.parse.NamedTableNode; +import org.apache.phoenix.parse.ParseNodeFactory; +import org.apache.phoenix.parse.PrimaryKeyConstraint; +import org.apache.phoenix.parse.TableName; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.PTable.ViewType; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.IndexUtil; +import org.apache.phoenix.util.MetaDataUtil; +import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.SchemaUtil; public class MetaDataClient { private static final Logger logger = LoggerFactory.getLogger(MetaDataClient.class); diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataEntityNotFoundException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataEntityNotFoundException.java new file mode 100644 index 00000000..e304e4f6 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataEntityNotFoundException.java @@ -0,0 +1,30 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.sql.SQLException; + +public abstract class MetaDataEntityNotFoundException extends SQLException { + private static final long serialVersionUID = 1L; + + public MetaDataEntityNotFoundException(String reason, String sqlState, int code, Throwable cause) { + super(reason, sqlState, code, cause); + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataSplitPolicy.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataSplitPolicy.java new file mode 100644 index 00000000..a5a9bd28 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataSplitPolicy.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import org.apache.hadoop.hbase.regionserver.ConstantSizeRegionSplitPolicy; + +import org.apache.phoenix.util.SchemaUtil; + + +public class MetaDataSplitPolicy extends ConstantSizeRegionSplitPolicy { + + @Override + protected byte[] getSplitPoint() { + byte[] splitPoint = super.getSplitPoint(); + int offset = SchemaUtil.getVarCharLength(splitPoint, 0, splitPoint.length); + // Split only on Phoenix schema name, so this is ok b/c we won't be splitting + // in the middle of a Phoenix table. + if (offset == splitPoint.length) { + return splitPoint; + } +// offset = SchemaUtil.getVarCharLength(splitPoint, offset+1, splitPoint.length-offset-1); +// // Split only on Phoenix schema and table name, so this is ok b/c we won't be splitting +// // in the middle of a Phoenix table. +// if (offset == splitPoint.length) { +// return splitPoint; +// } + // Otherwise, an attempt is being made to split in the middle of a table. + // Just return a split point at the schema boundary instead + byte[] newSplitPoint = new byte[offset + 1]; + System.arraycopy(splitPoint, 0, newSplitPoint, 0, offset+1); + return newSplitPoint; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/NewerTableAlreadyExistsException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/NewerTableAlreadyExistsException.java new file mode 100644 index 00000000..b5979e81 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/NewerTableAlreadyExistsException.java @@ -0,0 +1,29 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +public class NewerTableAlreadyExistsException extends TableAlreadyExistsException { + private static final long serialVersionUID = 1L; + + public NewerTableAlreadyExistsException(String schemaName, String tableName) { + super(schemaName, tableName); + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PArrayDataType.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PArrayDataType.java similarity index 87% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/PArrayDataType.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/PArrayDataType.java index 8889e2f8..dbff35b9 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PArrayDataType.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PArrayDataType.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import java.nio.ByteBuffer; import java.sql.Types; @@ -33,7 +25,7 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.phoenix.util.ByteUtil; +import org.apache.phoenix.util.ByteUtil; /** * The datatype for PColummns that are Arrays @@ -391,4 +383,4 @@ public static int getArrayLength(ImmutableBytesWritable ptr, return Bytes.toInt(bytes, ptr.getOffset() + Bytes.SIZEOF_BYTE); } -} +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PBaseColumn.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PBaseColumn.java new file mode 100644 index 00000000..5169e295 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PBaseColumn.java @@ -0,0 +1,52 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + + +/** + * + * Base class for PColumn implementors that provides + * some reasonable default implementations. + * + * @author jtaylor + * @since 0.1 + */ +public abstract class PBaseColumn implements PColumn { + + @Override + public final Integer getByteSize() { + return getDataType().getByteSize(); + } + + @Override + public final Integer getMaxLength() { + return null; + } + + @Override + public final Integer getScale() { + return null; + } + + @Override + public boolean isNullable() { + return false; + } + } diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumn.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumn.java new file mode 100644 index 00000000..6f76ec2d --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumn.java @@ -0,0 +1,46 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import org.apache.hadoop.io.Writable; + +/** + * Definition of a Phoenix column + * + * @author wmacklem,jtaylor + * @since 0.1 + */ +public interface PColumn extends PDatum, Writable { + + /** + * @return the name of the column qualifier + */ + PName getName(); + + /** + * @return the name of the column family + */ + PName getFamilyName(); + + /** + * @return the zero-based ordinal position of the column + */ + int getPosition(); +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnFamily.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnFamily.java new file mode 100644 index 00000000..6927c63c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnFamily.java @@ -0,0 +1,54 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.util.Collection; + +/** + * + * Definition of a Phoenix Column Family + * + * @author jtaylor + * @since 0.1 + */ +public interface PColumnFamily { + + /** + * @return The column family name. + */ + PName getName(); + + /** + * @return All the PColumns in this column family. + */ + Collection getColumns(); + + /** + * @return The PColumn for the specified column qualifier. + * @throws ColumnNotFoundException if the column cannot be found + */ + PColumn getColumn(byte[] qualifier) throws ColumnNotFoundException; + + /** + * @return The PColumn for the specified column qualifier. + * @throws ColumnNotFoundException if the column cannot be found + */ + PColumn getColumn(String name) throws ColumnNotFoundException; +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumnFamilyImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnFamilyImpl.java similarity index 50% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumnFamilyImpl.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnFamilyImpl.java index 3c01c5cc..4b097620 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumnFamilyImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnFamilyImpl.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import java.util.List; import java.util.Map; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumnImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnImpl.java similarity index 76% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumnImpl.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnImpl.java index fed452de..9a0d64b9 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PColumnImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnImpl.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import java.io.DataInput; import java.io.DataOutput; @@ -35,8 +27,8 @@ import org.apache.hadoop.io.WritableUtils; import com.google.common.base.Preconditions; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.util.ByteUtil; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.util.ByteUtil; public class PColumnImpl implements PColumn { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PDataType.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PDataType.java similarity index 99% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/PDataType.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/PDataType.java index 4de4bfd5..8d14fb0c 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PDataType.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PDataType.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import java.math.BigDecimal; import java.math.BigInteger; @@ -47,12 +39,12 @@ import com.google.common.primitives.Booleans; import com.google.common.primitives.Doubles; import com.google.common.primitives.Longs; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.DateUtil; -import com.salesforce.phoenix.util.NumberUtil; -import com.salesforce.phoenix.util.StringUtil; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.DateUtil; +import org.apache.phoenix.util.NumberUtil; +import org.apache.phoenix.util.StringUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PDateColumn.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PDateColumn.java new file mode 100644 index 00000000..8ed6c4a5 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PDateColumn.java @@ -0,0 +1,27 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +abstract public class PDateColumn extends PBaseColumn { + @Override + public PDataType getDataType() { + return PDataType.DATE; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PDatum.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PDatum.java new file mode 100644 index 00000000..e1946f5c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PDatum.java @@ -0,0 +1,54 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + + +public interface PDatum { + /** + * @return is this column nullable? + */ + boolean isNullable(); + + /** + * @return data type of the column + */ + PDataType getDataType(); + + /** + * @return maximum byte length of the column + */ + Integer getByteSize(); + + /** + * @return the actual length of the column. For decimal, it would be its precision. For char or + * varchar, it would be the maximum length as specified during schema definition. + */ + Integer getMaxLength(); + + /** + * @return scale of a decimal number. + */ + Integer getScale(); + + /** + * @return The modifier for this column or null if it doesn't have a modifier + */ + ColumnModifier getColumnModifier(); +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PIndexState.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PIndexState.java similarity index 56% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/PIndexState.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/PIndexState.java index bcea82b5..330c5c91 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PIndexState.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PIndexState.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; public enum PIndexState { diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PIntegerColumn.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PIntegerColumn.java new file mode 100644 index 00000000..5c00117b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PIntegerColumn.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + + +/** + * + * Base class for PColumn implementors of type Integer. + * + * @author jtaylor + * @since 0.1 + */ +public abstract class PIntegerColumn extends PBaseColumn { + @Override + public final PDataType getDataType() { + return PDataType.INTEGER; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PLongColumn.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PLongColumn.java new file mode 100644 index 00000000..69fd7e95 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PLongColumn.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + + +/** + * + * Base class for PColumn implementors of type Long. + * + * @author jtaylor + * @since 0.1 + */ +public abstract class PLongColumn extends PBaseColumn { + @Override + public final PDataType getDataType() { + return PDataType.LONG; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaData.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaData.java new file mode 100644 index 00000000..1af5c4ab --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaData.java @@ -0,0 +1,30 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.util.Map; + +import org.apache.phoenix.query.MetaDataMutated; + + +public interface PMetaData extends MetaDataMutated { + public PTable getTable(String name) throws TableNotFoundException; + public Map getTables(); +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PMetaDataImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java similarity index 80% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/PMetaDataImpl.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java index 5b9f9972..0c4eed05 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PMetaDataImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import java.sql.SQLException; import java.util.Collections; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PName.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PName.java new file mode 100644 index 00000000..97d8989f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PName.java @@ -0,0 +1,96 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.util.ByteUtil; + + +/** + * + * Interface to encapsulate both the client-side name + * together with the server-side name for a named object + * + * @author jtaylor + * @since 0.1 + */ +public interface PName { + public static PName EMPTY_NAME = new PName() { + @Override + public String getString() { + return ""; + } + + @Override + public byte[] getBytes() { + return ByteUtil.EMPTY_BYTE_ARRAY; + } + + @Override + public String toString() { + return getString(); + } + + @Override + public ImmutableBytesPtr getBytesPtr() { + return ByteUtil.EMPTY_BYTE_ARRAY_PTR; + } + }; + public static PName EMPTY_COLUMN_NAME = new PName() { + @Override + public String getString() { + return QueryConstants.EMPTY_COLUMN_NAME; + } + + @Override + public byte[] getBytes() { + return QueryConstants.EMPTY_COLUMN_BYTES; + } + + @Override + public String toString() { + return getString(); + } + + @Override + public ImmutableBytesPtr getBytesPtr() { + return QueryConstants.EMPTY_COLUMN_BYTES_PTR; + } + }; + /** + * Get the client-side, normalized name as referenced + * in a SQL statement. + * @return the normalized string name + */ + String getString(); + + /** + * Get the server-side name as referenced in HBase-related + * APIs such as Scan, Filter, etc. + * @return the name as a byte array + */ + byte[] getBytes(); + + /** + * @return a pointer to the underlying bytes + */ + ImmutableBytesPtr getBytesPtr(); +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PNameFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PNameFactory.java similarity index 87% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/PNameFactory.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/PNameFactory.java index 5e8ac0c8..cbea54c9 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PNameFactory.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PNameFactory.java @@ -1,8 +1,8 @@ -package com.salesforce.phoenix.schema; +package org.apache.phoenix.schema; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.phoenix.query.QueryConstants; +import org.apache.phoenix.query.QueryConstants; public class PNameFactory { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PNameImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PNameImpl.java similarity index 96% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/PNameImpl.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/PNameImpl.java index caeefb66..8feca89e 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PNameImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PNameImpl.java @@ -15,12 +15,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.salesforce.phoenix.schema; +package org.apache.phoenix.schema; import org.apache.hadoop.hbase.util.Bytes; import org.apache.http.annotation.Immutable; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; @Immutable public class PNameImpl implements PName { diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PNormalizedName.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PNormalizedName.java new file mode 100644 index 00000000..4876de98 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PNormalizedName.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import org.apache.http.annotation.Immutable; + +import org.apache.phoenix.util.SchemaUtil; + + +@Immutable +public class PNormalizedName extends PNameImpl { + + public PNormalizedName(String nonNormalizedName) { + super(SchemaUtil.normalizeIdentifier(nonNormalizedName)); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + getString().hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + PNormalizedName other = (PNormalizedName)obj; + // Compare normalized stringName for equality, since bytesName + // may differ since it remains case sensitive. + if (!getString().equals(other.getString())) return false; + return true; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PRow.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PRow.java new file mode 100644 index 00000000..22decfc7 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PRow.java @@ -0,0 +1,75 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.util.List; +import java.util.Map; + +import org.apache.hadoop.hbase.client.Mutation; + +import com.google.common.collect.ImmutableMap; + +/** + * + * Provide a client API for updating rows. The updates are processed in + * the calling order. Calling setValue after calling delete will cause the + * delete to be canceled. Conversely, calling delete after calling + * setValue will cause all prior setValue calls to be canceled. + * + * @author jtaylor + * @since 0.1 + */ +public interface PRow { + Map DELETE_MARKER = ImmutableMap.of(); + + /** + * Get the list of {@link org.apache.hadoop.hbase.client.Mutation} used to + * update an HTable after all mutations through calls to + * {@link #setValue(PColumn, Object)} or {@link #delete()}. + * @return the list of mutations representing all changes made to a row + * @throws ConstraintViolationException if row data violates schema + * constraint + */ + public List toRowMutations(); + + /** + * Set a column value in the row + * @param col the column for which the value is being set + * @param value the value + * @throws ConstraintViolationException if row data violates schema + * constraint + */ + public void setValue(PColumn col, Object value); + + /** + * Set a column value in the row + * @param col the column for which the value is being set + * @param value the value + * @throws ConstraintViolationException if row data violates schema + * constraint + */ + public void setValue(PColumn col, byte[] value); + + /** + * Delete the row. Note that a delete take precedence over any + * values that may have been set before or after the delete call. + */ + public void delete(); +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PStringColumn.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PStringColumn.java new file mode 100644 index 00000000..606b5415 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PStringColumn.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +/** + * + * Abstract class for columns of type {@link org.apache.phoenix.schema.PDataType#VARCHAR} + * + * @author jtaylor + * @since 0.1 + */ +public abstract class PStringColumn extends PBaseColumn { + + @Override + public PDataType getDataType() { + return PDataType.VARCHAR; + } + +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PTable.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTable.java similarity index 77% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/PTable.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/PTable.java index ae544c07..e0519b6e 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PTable.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTable.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import java.util.List; @@ -35,9 +27,9 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.io.Writable; -import com.salesforce.phoenix.client.KeyValueBuilder; -import com.salesforce.phoenix.index.IndexMaintainer; -import com.salesforce.phoenix.schema.stat.PTableStats; +import org.apache.phoenix.client.KeyValueBuilder; +import org.apache.phoenix.index.IndexMaintainer; +import org.apache.phoenix.schema.stat.PTableStats; /** @@ -168,7 +160,7 @@ public static ViewType combine(ViewType type1, ViewType type2) { * @param ts the timestamp that the key value will have when committed * @param key the row key of the key value * @param values the optional key values - * @return the new row. Use {@link com.salesforce.phoenix.schema.PRow#toRowMutations()} to + * @return the new row. Use {@link org.apache.phoenix.schema.PRow#toRowMutations()} to * generate the Row to send to the HBase server. * @throws ConstraintViolationException if row data violates schema * constraint @@ -181,7 +173,7 @@ public static ViewType combine(ViewType type1, ViewType type2) { * will be set by the HBase server. * @param key the row key of the key value * @param values the optional key values - * @return the new row. Use {@link com.salesforce.phoenix.schema.PRow#toRowMutations()} to + * @return the new row. Use {@link org.apache.phoenix.schema.PRow#toRowMutations()} to * generate the row to send to the HBase server. * @throws ConstraintViolationException if row data violates schema * constraint diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PTableImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java similarity index 93% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/PTableImpl.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java index 1be6e390..ef0ed86b 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PTableImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java @@ -1,36 +1,28 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; - -import static com.salesforce.phoenix.client.KeyValueBuilder.addQuietly; -import static com.salesforce.phoenix.client.KeyValueBuilder.deleteQuietly; -import static com.salesforce.phoenix.query.QueryConstants.SEPARATOR_BYTE; -import static com.salesforce.phoenix.schema.SaltingUtil.SALTING_COLUMN; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import static org.apache.phoenix.client.KeyValueBuilder.addQuietly; +import static org.apache.phoenix.client.KeyValueBuilder.deleteQuietly; +import static org.apache.phoenix.query.QueryConstants.SEPARATOR_BYTE; +import static org.apache.phoenix.schema.SaltingUtil.SALTING_COLUMN; import java.io.DataInput; import java.io.DataOutput; @@ -60,17 +52,17 @@ import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.client.KeyValueBuilder; -import com.salesforce.phoenix.index.IndexMaintainer; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.RowKeySchema.RowKeySchemaBuilder; -import com.salesforce.phoenix.schema.stat.PTableStats; -import com.salesforce.phoenix.schema.stat.PTableStatsImpl; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.SchemaUtil; -import com.salesforce.phoenix.util.StringUtil; -import com.salesforce.phoenix.util.TrustedByteArrayOutputStream; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.client.KeyValueBuilder; +import org.apache.phoenix.index.IndexMaintainer; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.RowKeySchema.RowKeySchemaBuilder; +import org.apache.phoenix.schema.stat.PTableStats; +import org.apache.phoenix.schema.stat.PTableStatsImpl; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.StringUtil; +import org.apache.phoenix.util.TrustedByteArrayOutputStream; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PTableType.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableType.java similarity index 63% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/PTableType.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/PTableType.java index 684165c6..f079a92c 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PTableType.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableType.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import java.util.Map; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PhoenixArray.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PhoenixArray.java similarity index 86% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/PhoenixArray.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/PhoenixArray.java index 5834f2d7..e58cb507 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/PhoenixArray.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PhoenixArray.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import java.sql.Array; import java.sql.ResultSet; @@ -33,7 +25,7 @@ import java.util.Arrays; import java.util.Map; -import com.salesforce.phoenix.util.SQLCloseable; +import org.apache.phoenix.util.SQLCloseable; /** * java.sql.Array implementation for Phoenix diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/ReadOnlyTableException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ReadOnlyTableException.java new file mode 100644 index 00000000..8672f8fa --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ReadOnlyTableException.java @@ -0,0 +1,57 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.sql.SQLException; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + +/** + * + * Exception thrown when an attempt is made to modify or write to a read-only table. + * + * @author jtaylor + * @since 0.1 + */ +public class ReadOnlyTableException extends SQLException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.READ_ONLY_TABLE; + + public ReadOnlyTableException(String schemaName, String tableName) { + super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).toString(), + code.getSQLState(), code.getErrorCode()); + } + + public ReadOnlyTableException(String message, String schemaName, String tableName) { + super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).setMessage(message).toString(), + code.getSQLState(), code.getErrorCode()); + } + + public ReadOnlyTableException(String message, String schemaName, String tableName, Throwable cause) { + super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).setRootCause(cause).setMessage(message).toString(), + code.getSQLState(), code.getErrorCode(), cause); + } + + public ReadOnlyTableException(String message, String schemaName, String tableName, String familyName) { + super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).setFamilyName(familyName).setMessage(message).toString(), + code.getSQLState(), code.getErrorCode()); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/RowKeySchema.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/RowKeySchema.java similarity index 82% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/RowKeySchema.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/RowKeySchema.java index b3cee889..ec5fd1b2 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/RowKeySchema.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/RowKeySchema.java @@ -1,40 +1,32 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; -import static com.salesforce.phoenix.query.QueryConstants.SEPARATOR_BYTE; +import static org.apache.phoenix.query.QueryConstants.SEPARATOR_BYTE; import java.util.Collections; import java.util.List; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import com.salesforce.phoenix.query.QueryConstants; +import org.apache.phoenix.query.QueryConstants; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/RowKeyValueAccessor.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/RowKeyValueAccessor.java similarity index 77% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/RowKeyValueAccessor.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/RowKeyValueAccessor.java index 78442c23..01f51c7f 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/RowKeyValueAccessor.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/RowKeyValueAccessor.java @@ -1,33 +1,25 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; -import static com.salesforce.phoenix.query.QueryConstants.SEPARATOR_BYTE; +import static org.apache.phoenix.query.QueryConstants.SEPARATOR_BYTE; import java.io.DataInput; import java.io.DataOutput; @@ -39,7 +31,7 @@ import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.phoenix.util.ByteUtil; +import org.apache.phoenix.util.ByteUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/SaltingUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/SaltingUtil.java similarity index 76% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/SaltingUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/SaltingUtil.java index 44b69b9c..50ec4b6a 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/SaltingUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/SaltingUtil.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import java.util.Arrays; import java.util.Collections; @@ -34,10 +26,10 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import com.google.common.collect.Lists; -import com.salesforce.phoenix.compile.ScanRanges; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.query.KeyRange.Bound; -import com.salesforce.phoenix.util.ScanUtil; +import org.apache.phoenix.compile.ScanRanges; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.query.KeyRange.Bound; +import org.apache.phoenix.util.ScanUtil; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/Sequence.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/Sequence.java similarity index 95% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/Sequence.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/Sequence.java index a362aed3..f88475d9 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/Sequence.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/Sequence.java @@ -1,9 +1,9 @@ -package com.salesforce.phoenix.schema; +package org.apache.phoenix.schema; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.CACHE_SIZE_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.CURRENT_VALUE_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.INCREMENT_BY_BYTES; -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.SEQUENCE_FAMILY_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CACHE_SIZE_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CURRENT_VALUE_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INCREMENT_BY_BYTES; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SEQUENCE_FAMILY_BYTES; import java.io.IOException; import java.sql.SQLException; @@ -21,15 +21,15 @@ import org.apache.hadoop.hbase.util.Bytes; import com.google.common.collect.Lists; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol; -import com.salesforce.phoenix.coprocessor.SequenceRegionObserver; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.util.ByteUtil; -import com.salesforce.phoenix.util.KeyValueUtil; -import com.salesforce.phoenix.util.SchemaUtil; +import org.apache.phoenix.coprocessor.MetaDataProtocol; +import org.apache.phoenix.coprocessor.SequenceRegionObserver; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.KeyValueUtil; +import org.apache.phoenix.util.SchemaUtil; public class Sequence { public static final int SUCCESS = 0; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceAlreadyExistsException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceAlreadyExistsException.java new file mode 100644 index 00000000..cdb7bdb3 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceAlreadyExistsException.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.sql.SQLException; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + + +public class SequenceAlreadyExistsException extends SQLException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.SEQUENCE_ALREADY_EXIST; + private final String schemaName; + private final String sequenceName; + + + public SequenceAlreadyExistsException(String schemaName, String sequenceName) { + super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(sequenceName).build().toString(), + code.getSQLState(), code.getErrorCode()); + this.schemaName = schemaName; + this.sequenceName = sequenceName; + } + + public String getSequenceName() { + return sequenceName; + } + + public String getSchemaName() { + return schemaName; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/SequenceKey.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceKey.java similarity index 50% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/SequenceKey.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceKey.java index bfc33b60..2be5acef 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/SequenceKey.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceKey.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; public class SequenceKey implements Comparable { diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceNotFoundException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceNotFoundException.java new file mode 100644 index 00000000..466a3b97 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceNotFoundException.java @@ -0,0 +1,50 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + + +public class SequenceNotFoundException extends MetaDataEntityNotFoundException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.SEQUENCE_UNDEFINED; + private final String schemaName; + private final String tableName; + + public SequenceNotFoundException(String tableName) { + this(null, tableName); + } + + public SequenceNotFoundException(String schemaName, String tableName) { + super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).build().toString(), + code.getSQLState(), code.getErrorCode(), null); + this.tableName = tableName; + this.schemaName = schemaName; + } + + public String getTableName() { + return tableName; + } + + public String getSchemaName() { + return schemaName; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/TableAlreadyExistsException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableAlreadyExistsException.java new file mode 100644 index 00000000..7781ba22 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableAlreadyExistsException.java @@ -0,0 +1,55 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.sql.SQLException; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + + +/** + * + * Exception thrown when a table name could not be found in the schema + * + * @author jtaylor + * @since 0.1 + */ +public class TableAlreadyExistsException extends SQLException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.TABLE_ALREADY_EXIST; + private final String schemaName; + private final String tableName; + + public TableAlreadyExistsException(String schemaName, String tableName) { + super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).build().toString(), + code.getSQLState(), code.getErrorCode()); + this.schemaName = schemaName; + this.tableName = tableName; + } + + public String getTableName() { + return tableName; + } + + public String getSchemaName() { + return schemaName; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/TableNotFoundException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableNotFoundException.java new file mode 100644 index 00000000..7b66603c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableNotFoundException.java @@ -0,0 +1,73 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import org.apache.hadoop.hbase.HConstants; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + + +/** + * + * Exception thrown when a table name could not be found in the schema + * + * @author jtaylor + * @since 0.1 + */ +public class TableNotFoundException extends MetaDataEntityNotFoundException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.TABLE_UNDEFINED; + private final String schemaName; + private final String tableName; + private final long timestamp; + + public TableNotFoundException(TableNotFoundException e, long timestamp) { + this(e.schemaName,e.tableName, timestamp); + } + + public TableNotFoundException(String tableName) { + this(null, tableName); + } + + public TableNotFoundException(String schemaName, String tableName) { + this(schemaName, tableName, HConstants.LATEST_TIMESTAMP); + } + + public TableNotFoundException(String schemaName, String tableName, long timestamp) { + super(new SQLExceptionInfo.Builder(code).setSchemaName(schemaName).setTableName(tableName).build().toString(), + code.getSQLState(), code.getErrorCode(), null); + this.tableName = tableName; + this.schemaName = schemaName; + this.timestamp = timestamp; + } + + public String getTableName() { + return tableName; + } + + public String getSchemaName() { + return schemaName; + } + + public long getTimeStamp() { + return timestamp; + } +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java new file mode 100644 index 00000000..14705cac --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import org.apache.hadoop.hbase.HConstants; + + + +public final class TableRef { + private final PTable table; + private final String alias; + private final long timeStamp; + private final boolean hasDynamicCols; + + public TableRef(TableRef tableRef, long timeStamp) { + this(tableRef.alias, tableRef.table, timeStamp, tableRef.hasDynamicCols); + } + + public TableRef(PTable table) { + this(null, table, HConstants.LATEST_TIMESTAMP, false); + } + + public TableRef(String alias, PTable table, long timeStamp, boolean hasDynamicCols) { + this.alias = alias; + this.table = table; + this.timeStamp = timeStamp; + this.hasDynamicCols = hasDynamicCols; + } + + public PTable getTable() { + return table; + } + + public String getTableAlias() { + return alias; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = alias == null ? 0 : alias.hashCode(); + result = prime * result + this.table.getName().getString().hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + TableRef other = (TableRef)obj; + if ((alias == null && other.alias != null) || (alias != null && !alias.equals(other.alias))) return false; + if (!table.getName().getString().equals(other.table.getName().getString())) return false; + return true; + } + + public long getTimeStamp() { + return timeStamp; + } + + public boolean hasDynamicCols() { + return hasDynamicCols; + } + +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/TypeMismatchException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/TypeMismatchException.java new file mode 100644 index 00000000..ae248738 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/TypeMismatchException.java @@ -0,0 +1,60 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.sql.SQLException; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + +/** + * Exception thrown when we try to convert one type into a different incompatible type. + * + * @author zhuang + * @since 1.0 + */ +public class TypeMismatchException extends SQLException { + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.TYPE_MISMATCH; + + public TypeMismatchException(String msg) { + super(new SQLExceptionInfo.Builder(code).setMessage(msg).build().toString(), code.getSQLState(), code.getErrorCode()); + } + + public static TypeMismatchException newException(PDataType lhs) { + return new TypeMismatchException(getMessage(lhs,null,null)); + } + + public static TypeMismatchException newException(PDataType lhs, String location) { + return new TypeMismatchException(getMessage(lhs,null,location)); + } + + public static TypeMismatchException newException(PDataType lhs, PDataType rhs) { + return new TypeMismatchException(getMessage(lhs,rhs,null)); + } + + public static TypeMismatchException newException(PDataType lhs, PDataType rhs, String location) { + return new TypeMismatchException(getMessage(lhs,rhs,location)); + } + + public static String getMessage(PDataType lhs, PDataType rhs, String location) { + return lhs + (rhs == null ? "" : " and " + rhs) + (location == null ? "" : " for " + location); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ValueBitSet.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ValueBitSet.java similarity index 77% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/ValueBitSet.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/ValueBitSet.java index 61315bd0..2b1937ba 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ValueBitSet.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ValueBitSet.java @@ -1,38 +1,30 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import java.util.Arrays; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.phoenix.util.SizedUtil; +import org.apache.phoenix.util.SizedUtil; /** diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/ValueRangeExcpetion.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ValueRangeExcpetion.java new file mode 100644 index 00000000..aff2ef78 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ValueRangeExcpetion.java @@ -0,0 +1,40 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; + +import java.sql.SQLException; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; + +/** + * Exception thrown when we try to use use an argument that has the wrong type. + * + * @author anoopsjohn + * @since 1.1.2 + */ +public class ValueRangeExcpetion extends SQLException{ + private static final long serialVersionUID = 1L; + private static SQLExceptionCode code = SQLExceptionCode.VALUE_OUTSIDE_RANGE; + + public ValueRangeExcpetion(Object minValue, Object maxValue, Object actualValue, String location){ + super(new SQLExceptionInfo.Builder(code).setMessage("expected: [" + minValue + " , " + maxValue + "] but was: " + actualValue + " at " + location).build().toString(), code.getSQLState(), code.getErrorCode()); + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ValueSchema.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ValueSchema.java similarity index 85% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/ValueSchema.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/ValueSchema.java index 88172195..41daf2a7 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/ValueSchema.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ValueSchema.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema; import java.io.DataInput; import java.io.DataOutput; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stat/PTableStats.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/stat/PTableStats.java new file mode 100644 index 00000000..5e38a275 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stat/PTableStats.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema.stat; + +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.hadoop.hbase.HRegionInfo; + + +/** + * Interface for Phoenix table statistics. Statistics is collected on the server + * side and can be used for various purpose like splitting region for scanning, etc. + * + * The table is defined on the client side, but it is populated on the server side. The client + * should not populate any data to the statistics object. + */ +public interface PTableStats { + + /** + * Given the region info, returns an array of bytes that is the current estimate of key + * distribution inside that region. The keys should split that region into equal chunks. + * + * @param region + * @return array of keys + */ + byte[][] getRegionGuidePosts(HRegionInfo region); + + void write(DataOutput output) throws IOException; +} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stat/PTableStatsImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/stat/PTableStatsImpl.java new file mode 100644 index 00000000..27bb6650 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stat/PTableStatsImpl.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema.stat; + +import java.io.DataOutput; +import java.io.IOException; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.io.WritableUtils; + +import com.google.common.collect.ImmutableMap; + + +/** + * Implementation for PTableStats. + */ +public class PTableStatsImpl implements PTableStats { + + // The map for guide posts should be immutable. We only take the current snapshot from outside + // method call and store it. + private Map regionGuidePosts; + + public PTableStatsImpl() { } + + public PTableStatsImpl(Map stats) { + regionGuidePosts = ImmutableMap.copyOf(stats); + } + + @Override + public byte[][] getRegionGuidePosts(HRegionInfo region) { + return regionGuidePosts.get(region.getRegionNameAsString()); + } + + @Override + public void write(DataOutput output) throws IOException { + if (regionGuidePosts == null) { + WritableUtils.writeVInt(output, 0); + return; + } + WritableUtils.writeVInt(output, regionGuidePosts.size()); + for (Entry entry : regionGuidePosts.entrySet()) { + WritableUtils.writeString(output, entry.getKey()); + byte[][] value = entry.getValue(); + WritableUtils.writeVInt(output, value.length); + for (int i=0; i values; + + public MultiKeyValueTuple(List values) { + setKeyValues(values); + } + + public MultiKeyValueTuple() { + } + + public void setKeyValues(List values) { + this.values = ImmutableList.copyOf(values); + } + + @Override + public void getKey(ImmutableBytesWritable ptr) { + KeyValue value = values.get(0); + ptr.set(value.getBuffer(), value.getRowOffset(), value.getRowLength()); + } + + @Override + public boolean isImmutable() { + return true; + } + + @Override + public KeyValue getValue(byte[] family, byte[] qualifier) { + return KeyValueUtil.getColumnLatest(values, family, qualifier); + } + + @Override + public String toString() { + return values.toString(); + } + + @Override + public int size() { + return values.size(); + } + + @Override + public KeyValue getValue(int index) { + return values.get(index); + } + + @Override + public boolean getValue(byte[] family, byte[] qualifier, + ImmutableBytesWritable ptr) { + KeyValue kv = getValue(family, qualifier); + if (kv == null) + return false; + ptr.set(kv.getBuffer(), kv.getValueOffset(), kv.getValueLength()); + return true; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/tuple/ResultTuple.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/ResultTuple.java similarity index 51% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/tuple/ResultTuple.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/ResultTuple.java index 1b28c48b..c99a9906 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/tuple/ResultTuple.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/ResultTuple.java @@ -1,38 +1,30 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema.tuple; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema.tuple; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.phoenix.util.ResultUtil; +import org.apache.phoenix.util.ResultUtil; public class ResultTuple implements Tuple { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/tuple/SingleKeyValueTuple.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/SingleKeyValueTuple.java similarity index 59% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/tuple/SingleKeyValueTuple.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/SingleKeyValueTuple.java index f08b0786..5d76604b 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/tuple/SingleKeyValueTuple.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/SingleKeyValueTuple.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema.tuple; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema.tuple; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/tuple/Tuple.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/Tuple.java similarity index 56% rename from phoenix-core/src/main/java/com/salesforce/phoenix/schema/tuple/Tuple.java rename to phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/Tuple.java index ee3781bb..ffa3f72e 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/schema/tuple/Tuple.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/Tuple.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.schema.tuple; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.schema.tuple; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/BigDecimalUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/BigDecimalUtil.java new file mode 100644 index 00000000..4b49f0fa --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/BigDecimalUtil.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; + +import org.apache.hadoop.hbase.util.Pair; + +/** + * + * @author anoopsjohn + * @since 1.2.1 + */ +public class BigDecimalUtil { + + /** + * Calculates the precision and scale for BigDecimal arithmetic operation results. It uses the algorithm mentioned + * here + * @param lp precision of the left operand + * @param ls scale of the left operand + * @param rp precision of the right operand + * @param rs scale of the right operand + * @param op The operation type + * @return {@link Pair} comprising of the precision and scale. + */ + public static Pair getResultPrecisionScale(int lp, int ls, int rp, int rs, Operation op) { + int resultPrec = 0, resultScale = 0; + switch (op) { + case MULTIPLY: + resultPrec = lp + rp; + resultScale = ls + rs; + break; + case DIVIDE: + resultPrec = lp - ls + rp + Math.max(ls + rp - rs + 1, 4); + resultScale = 31 - lp + ls - rs; + break; + case ADD: + resultPrec = 2 * (lp - ls) + ls; // Is this correct? The page says addition -> 2 * (p - s) + s. + resultScale = Math.max(ls, rs); + break; + case AVG: + resultPrec = Math.max(lp - ls, rp - rs) + 1 + Math.max(ls, rs); + resultScale = Math.max(Math.max(ls, rs), 4); + break; + case OTHERS: + resultPrec = Math.max(lp - ls, rp - rs) + 1 + Math.max(ls, rs); + resultScale = Math.max(ls, rs); + } + return new Pair(resultPrec, resultScale); + } + + public static enum Operation { + MULTIPLY, DIVIDE, ADD, AVG, OTHERS; + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/BitSet.java b/phoenix-core/src/main/java/org/apache/phoenix/util/BitSet.java similarity index 98% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/BitSet.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/BitSet.java index 58221471..7cdbe6a1 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/BitSet.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/BitSet.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.util; +package org.apache.phoenix.util; import java.io.*; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/ByteUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ByteUtil.java similarity index 90% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/ByteUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/ByteUtil.java index 82e52b32..93c4df2c 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/ByteUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ByteUtil.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import java.io.ByteArrayInputStream; import java.io.DataInput; @@ -41,10 +33,10 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.PDataType; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.PDataType; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/CSVLoader.java b/phoenix-core/src/main/java/org/apache/phoenix/util/CSVLoader.java similarity index 80% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/CSVLoader.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/CSVLoader.java index 400cb9c7..508818d4 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/CSVLoader.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/CSVLoader.java @@ -1,38 +1,30 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import au.com.bytecode.opencsv.CSVReader; import com.google.common.collect.Maps; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.schema.PDataType; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.schema.PDataType; import java.io.FileReader; import java.sql.DatabaseMetaData; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/Closeables.java b/phoenix-core/src/main/java/org/apache/phoenix/util/Closeables.java similarity index 66% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/Closeables.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/Closeables.java index 925d1d2f..b09ebe0f 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/Closeables.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/Closeables.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import java.io.Closeable; import java.io.IOException; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/ColumnInfo.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ColumnInfo.java similarity index 91% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/ColumnInfo.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/ColumnInfo.java index edaae90c..9ca05e76 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/ColumnInfo.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ColumnInfo.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.util; +package org.apache.phoenix.util; /** * ColumnInfo used to store Column Name and its associated PDataType diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/DateUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/DateUtil.java similarity index 71% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/DateUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/DateUtil.java index 197e8676..b7460f8a 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/DateUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/DateUtil.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import java.math.BigDecimal; import java.sql.Date; @@ -38,8 +30,8 @@ import org.apache.commons.lang.time.FastDateFormat; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.IllegalDataException; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.IllegalDataException; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/IndexUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java similarity index 76% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/IndexUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java index 0c7291c1..a7c975ce 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/IndexUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import java.io.IOException; import java.sql.SQLException; @@ -39,20 +31,20 @@ import org.apache.hadoop.hbase.util.Bytes; import com.google.common.collect.Lists; -import com.salesforce.hbase.index.ValueGetter; -import com.salesforce.hbase.index.covered.update.ColumnReference; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.client.KeyValueBuilder; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.index.IndexMaintainer; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.ColumnFamilyNotFoundException; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PColumnFamily; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PTable; +import org.apache.hadoop.hbase.index.ValueGetter; +import org.apache.hadoop.hbase.index.covered.update.ColumnReference; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.client.KeyValueBuilder; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.index.IndexMaintainer; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.ColumnFamilyNotFoundException; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PColumnFamily; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PTable; public class IndexUtil { public static final String INDEX_COLUMN_NAME_SEP = ":"; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/InstanceResolver.java b/phoenix-core/src/main/java/org/apache/phoenix/util/InstanceResolver.java similarity index 50% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/InstanceResolver.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/InstanceResolver.java index 9b06e719..85cf54d0 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/InstanceResolver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/InstanceResolver.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. +/* + * Copyright 2010 The Apache Software Foundation * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import java.util.ServiceLoader; import java.util.concurrent.ConcurrentHashMap; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/JDBCUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/JDBCUtil.java similarity index 51% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/JDBCUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/JDBCUtil.java index 24e2a298..eb973cc7 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/JDBCUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/JDBCUtil.java @@ -1,41 +1,33 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import java.sql.SQLException; import java.util.Properties; import javax.annotation.Nullable; -import com.salesforce.phoenix.query.QueryServices; -import com.salesforce.phoenix.query.QueryServicesOptions; -import com.salesforce.phoenix.schema.PName; -import com.salesforce.phoenix.schema.PNameFactory; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.PNameFactory; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/KeyValueUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/KeyValueUtil.java similarity index 74% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/KeyValueUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/KeyValueUtil.java index 7d496229..657845da 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/KeyValueUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/KeyValueUtil.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import java.util.Collections; import java.util.Comparator; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/MetaDataUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java similarity index 82% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/MetaDataUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java index 4f69a902..9eb35701 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/MetaDataUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java @@ -1,33 +1,25 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; - -import static com.salesforce.phoenix.util.SchemaUtil.getVarChars; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; + +import static org.apache.phoenix.util.SchemaUtil.getVarChars; import java.util.Collection; import java.util.List; @@ -37,11 +29,11 @@ import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol; -import com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PTableType; +import org.apache.phoenix.coprocessor.MetaDataProtocol; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PTableType; public class MetaDataUtil { diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/NumberUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/NumberUtil.java new file mode 100644 index 00000000..ece1104a --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/NumberUtil.java @@ -0,0 +1,54 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; + +import java.math.BigDecimal; + +import org.apache.phoenix.schema.PDataType; + +/** + * Utility methods for numbers like decimal, long, etc. + * + * @author elevine + * @since 0.1 + */ +public class NumberUtil { + + public static final String DEFAULT_NUMBER_FORMAT = "#,##0.###"; + + /** + * Strip all trailing zeros to ensure that no digit will be zero and + * round using our default context to ensure precision doesn't exceed max allowed. + * @return new {@link BigDecimal} instance + */ + public static BigDecimal normalize(BigDecimal bigDecimal) { + return bigDecimal.stripTrailingZeros().round(PDataType.DEFAULT_MATH_CONTEXT); + } + + public static BigDecimal setDecimalWidthAndScale(BigDecimal decimal, int precision, int scale) { + // If we could not fit all the digits before decimal point into the new desired precision and + // scale, return null and the caller method should handle the error. + if (((precision - scale) < (decimal.precision() - decimal.scale()))){ + return null; + } + decimal = decimal.setScale(scale, BigDecimal.ROUND_DOWN); + return decimal; + } +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/PhoenixRuntime.java b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java similarity index 86% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/PhoenixRuntime.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java index 07283bd3..102a0f3e 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/PhoenixRuntime.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import java.io.File; import java.io.FileReader; @@ -46,7 +38,7 @@ import org.apache.hadoop.hbase.util.Pair; import com.google.common.collect.Lists; -import com.salesforce.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixConnection; /** * @@ -87,7 +79,7 @@ public class PhoenixRuntime { * Use this connection property to help with fairness of resource allocation * for the client and server. The value of the attribute determines the * bucket used to rollup resource usage for a particular tenant/organization. Each tenant - * may only use a percentage of total resources, governed by the {@link com.salesforce.phoenix.query.QueryServices} + * may only use a percentage of total resources, governed by the {@link org.apache.phoenix.query.QueryServices} * configuration properties */ public static final String TENANT_ID_ATTRIB = "TenantId"; @@ -232,7 +224,7 @@ private PhoenixRuntime() { /** * Runs a series of semicolon-terminated SQL statements using the connection provided, returning * the number of SQL statements executed. Note that if the connection has specified an SCN through - * the {@link com.salesforce.phoenix.util.PhoenixRuntime#CURRENT_SCN_ATTRIB} connection property, then the timestamp + * the {@link org.apache.phoenix.util.PhoenixRuntime#CURRENT_SCN_ATTRIB} connection property, then the timestamp * is bumped up by one after each statement execution. * @param conn an open JDBC connection * @param reader a reader for semicolumn separated SQL statements diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/QueryUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java similarity index 98% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/QueryUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java index 0c18fec8..bb0c9cc4 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/QueryUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.util; +package org.apache.phoenix.util; import java.sql.DatabaseMetaData; import java.sql.ResultSet; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/ReadOnlyProps.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ReadOnlyProps.java similarity index 99% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/ReadOnlyProps.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/ReadOnlyProps.java index cd047f8a..6fcbc3d6 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/ReadOnlyProps.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ReadOnlyProps.java @@ -1,4 +1,4 @@ -package com.salesforce.phoenix.util; +package org.apache.phoenix.util; import java.util.*; import java.util.Map.Entry; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/ResultUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ResultUtil.java similarity index 77% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/ResultUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/ResultUtil.java index 1427daa8..8339cc0a 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/ResultUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ResultUtil.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import java.util.Arrays; import java.util.Comparator; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/SQLCloseable.java b/phoenix-core/src/main/java/org/apache/phoenix/util/SQLCloseable.java new file mode 100644 index 00000000..11cf02f6 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/SQLCloseable.java @@ -0,0 +1,34 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; + +import java.sql.SQLException; + +/** + * + * Interface for a SQL resource that should be closed + * after it is no longer in use. + * + * @author jtaylor + * @since 0.1 + */ +public interface SQLCloseable { + void close() throws SQLException; +} diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/SQLCloseables.java b/phoenix-core/src/main/java/org/apache/phoenix/util/SQLCloseables.java similarity index 68% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/SQLCloseables.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/SQLCloseables.java index 455da245..c255c1da 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/SQLCloseables.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/SQLCloseables.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import java.sql.SQLException; import java.util.*; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/ScanUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java similarity index 88% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/ScanUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java index 5d59cb70..4ea8a114 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/ScanUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import java.io.IOException; import java.sql.SQLException; @@ -45,15 +37,15 @@ import org.apache.hadoop.hbase.util.Bytes; import com.google.common.collect.Lists; -import com.salesforce.phoenix.compile.ScanRanges; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol; -import com.salesforce.phoenix.filter.SkipScanFilter; -import com.salesforce.phoenix.query.KeyRange; -import com.salesforce.phoenix.query.KeyRange.Bound; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.RowKeySchema; +import org.apache.phoenix.compile.ScanRanges; +import org.apache.phoenix.coprocessor.MetaDataProtocol; +import org.apache.phoenix.filter.SkipScanFilter; +import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.query.KeyRange.Bound; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.RowKeySchema; /** @@ -430,4 +422,26 @@ public static byte[] nextKey(byte[] key, PTable table, ImmutableBytesWritable pt ByteUtil.nextKey(key, key.length); return key; } -} + + private static final String REVERSED_ATTR = "_reversed_"; + + public static void setReversed(Scan scan) { + // TODO: set attribute dynamically here to prevent dependency on newer HBase release + scan.setAttribute(REVERSED_ATTR, PDataType.TRUE_BYTES); + } + + // Start/stop row must be swapped if scan is being done in reverse + public static void swapStartStopRowIfReversed(Scan scan) { + if (isReversed(scan)) { + byte[] startRow = scan.getStartRow(); + byte[] stopRow = scan.getStopRow(); + scan.setStartRow(stopRow); + scan.setStopRow(startRow); + } + } + + public static boolean isReversed(Scan scan) { + byte[] reversed = scan.getAttribute(REVERSED_ATTR); + return (PDataType.TRUE_BYTES.equals(reversed)); + } +} \ No newline at end of file diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/SchemaUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java similarity index 89% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/SchemaUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java index 7a2a85dc..2c988179 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/SchemaUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java @@ -1,33 +1,25 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; - -import static com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_TABLE_NAME_BYTES; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; + +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_TABLE_NAME_BYTES; import java.io.IOException; import java.sql.SQLException; @@ -52,27 +44,27 @@ import org.apache.hadoop.hbase.util.Bytes; import com.google.common.collect.Lists; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.coprocessor.MetaDataProtocol; -import com.salesforce.phoenix.exception.SQLExceptionCode; -import com.salesforce.phoenix.exception.SQLExceptionInfo; -import com.salesforce.phoenix.jdbc.PhoenixConnection; -import com.salesforce.phoenix.jdbc.PhoenixDatabaseMetaData; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.AmbiguousColumnException; -import com.salesforce.phoenix.schema.ColumnFamilyNotFoundException; -import com.salesforce.phoenix.schema.ColumnModifier; -import com.salesforce.phoenix.schema.ColumnNotFoundException; -import com.salesforce.phoenix.schema.PColumn; -import com.salesforce.phoenix.schema.PColumnFamily; -import com.salesforce.phoenix.schema.PDataType; -import com.salesforce.phoenix.schema.PDatum; -import com.salesforce.phoenix.schema.PMetaData; -import com.salesforce.phoenix.schema.PName; -import com.salesforce.phoenix.schema.PTable; -import com.salesforce.phoenix.schema.RowKeySchema; -import com.salesforce.phoenix.schema.RowKeySchema.RowKeySchemaBuilder; -import com.salesforce.phoenix.schema.SaltingUtil; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.coprocessor.MetaDataProtocol; +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.AmbiguousColumnException; +import org.apache.phoenix.schema.ColumnFamilyNotFoundException; +import org.apache.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.ColumnNotFoundException; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PColumnFamily; +import org.apache.phoenix.schema.PDataType; +import org.apache.phoenix.schema.PDatum; +import org.apache.phoenix.schema.PMetaData; +import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.RowKeySchema; +import org.apache.phoenix.schema.RowKeySchema.RowKeySchemaBuilder; +import org.apache.phoenix.schema.SaltingUtil; diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/ServerUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java similarity index 69% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/ServerUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java index 1c716fee..819bcc48 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/ServerUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import java.io.IOException; import java.sql.SQLException; @@ -36,8 +28,8 @@ import org.apache.hadoop.hbase.DoNotRetryIOException; -import com.salesforce.phoenix.exception.PhoenixIOException; -import com.salesforce.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.exception.PhoenixIOException; +import org.apache.phoenix.exception.SQLExceptionCode; public class ServerUtil { diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/SizedUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/SizedUtil.java similarity index 54% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/SizedUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/SizedUtil.java index f60ad1e6..62f08165 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/SizedUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/SizedUtil.java @@ -1,31 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; /** diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/StringUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/StringUtil.java similarity index 82% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/StringUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/StringUtil.java index 6a953ccf..1e9d961d 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/StringUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/StringUtil.java @@ -1,38 +1,30 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; import java.io.UnsupportedEncodingException; import java.util.Arrays; import org.apache.hadoop.hbase.util.Bytes; -import com.salesforce.phoenix.schema.ColumnModifier; +import org.apache.phoenix.schema.ColumnModifier; public class StringUtil { diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/TrustedByteArrayOutputStream.java b/phoenix-core/src/main/java/org/apache/phoenix/util/TrustedByteArrayOutputStream.java new file mode 100644 index 00000000..f503cb35 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/TrustedByteArrayOutputStream.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +/** + * + * Derived version of {@link java.io.ByteArrayOutputStream} that provides access + * to underlying byte array buffer so that it doesn't have to be copied + * + * @author jtaylor + * @since 0.1 + */ +public class TrustedByteArrayOutputStream extends ByteArrayOutputStream { + public TrustedByteArrayOutputStream(int initialSize) { + super(initialSize); + } + public byte[] getBuffer() { + return buf; + } + @Override + public byte[] toByteArray() { + if (buf.length == size()) { + return buf; + } + return super.toByteArray(); + } + @Override + public void write(byte[] b) { + try { + super.write(b); + } catch (IOException e) { + throw new RuntimeException(e); // Impossible + } + } +} + diff --git a/phoenix-core/src/main/java/com/salesforce/phoenix/util/TupleUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/TupleUtil.java similarity index 71% rename from phoenix-core/src/main/java/com/salesforce/phoenix/util/TupleUtil.java rename to phoenix-core/src/main/java/org/apache/phoenix/util/TupleUtil.java index ac65e44f..9a8608ad 100644 --- a/phoenix-core/src/main/java/com/salesforce/phoenix/util/TupleUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/TupleUtil.java @@ -1,34 +1,26 @@ -/******************************************************************************* - * Copyright (c) 2013, Salesforce.com, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Salesforce.com nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.salesforce.phoenix.util; +/* + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.util; -import static com.salesforce.phoenix.query.QueryConstants.SINGLE_COLUMN; -import static com.salesforce.phoenix.query.QueryConstants.SINGLE_COLUMN_FAMILY; +import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN; +import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN_FAMILY; import java.io.DataOutput; import java.io.IOException; @@ -40,10 +32,10 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.io.WritableUtils; -import com.salesforce.hbase.index.util.ImmutableBytesPtr; -import com.salesforce.phoenix.expression.Expression; -import com.salesforce.phoenix.query.QueryConstants; -import com.salesforce.phoenix.schema.tuple.Tuple; +import org.apache.hadoop.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.tuple.Tuple; /** diff --git a/phoenix-core/src/main/resources/java.sql.Driver b/phoenix-core/src/main/resources/java.sql.Driver index 8067ad71..fc51a045 100644 --- a/phoenix-core/src/main/resources/java.sql.Driver +++ b/phoenix-core/src/main/resources/java.sql.Driver @@ -1 +1 @@ -com.salesforce.phoenix.jdbc.PhoenixDriver +org.apache.phoenix.jdbc.PhoenixDriver diff --git a/phoenix-core/src/site/bin/merge.jar b/phoenix-core/src/site/bin/merge.jar new file mode 100644 index 0000000000000000000000000000000000000000..2b329d698e087318a5a99e908101af1811767fea GIT binary patch literal 1347 zcmWIWW@Zs#-~htTFg+IrBp|}T!r-O&y1H)(EGpBvL zb@eXtdh2SPJ9B<>kiiw>2TzO6dFtq04rrS_5C_2B5RK*rexPh_YEgP>MoDgtUUE)iadBzL+c4=+ zk-O7b)Hs9fnl3nHw@$m{u)uLe6!)T}^APKvGq_!k%}csXU52vv#!E zHU8^)dunc#s{Y?OQ_Gh$edn6CIsfOjN$00NT#$2}rOH_R<%HlJNjKLW@Obn=E16a7 zc1`Srs|VDInUk5EZ=L!U^zzM7Umm9IK6|=vKM9(2aN64wSEGzO4umZ7eX@F$#IeHT z2aYWLW%l0Z&QTTaq}{GRt*Uhl?&zgNxy~>ul;@mwW@4VE#_LHhyCsD^&up5$wQ674 zxg3j$?;M^qZt`2XY02%GE+6b(N30iH>mWCEss7aSi#pqXG?>&zmabvq-gnWfcyG?n z-Je2Zcd_og;(32s-vM_uxrfPO-`(%?J=vBOA1E66pl-I;mi&|(pS<7v3z%)kU2;2b z>p9ClwtJS<%=5YK{8)dJODCE?!&y8tG%4cXs#*KC@}0dAE_%~oW2bH-M|#p*UjI^3=9*r;d)#ktSlFyJo%&msJ*Y6fCB=H4cZv7D ziOE8@H)@5n_3d4CAYz&DQ&r|QO*gA#56gw|%5cQwhc3T6%_jaqz|)_-2NE6y<;;C7 zw=bBve97}SD>rTPc@mhgs6>C>@~L6sH#sbJ-mTubcBlI)i&W8TY9_i?C2u0O?|5&t z=2VF7d@{x6(t+x%o!>V#zVtDg((^s&@`0E%wKX~0(jR|5$tJcfee0ix z(I0Nl%C^7Gc!(!y(k+#hI+G41PYPIaY<9tv={uxrHk_VSGRbcKhbu?d{JgYIK=-nL zW#8PyrwWx_=Q-{lsABd{lm5~4f9`f0w;3icBDA~&0 z-+AWq`cum@!c0%Cu4e?55&>%dA73&vFj%sKN(n|L5e7tAgp91ytG~ e+W;zU5TFIfL@Rp&yjj^m3YdVf8Az`J+X?{nQ(1}t literal 0 HcmV?d00001 diff --git a/phoenix-core/src/site/bin/merge.sh b/phoenix-core/src/site/bin/merge.sh new file mode 100755 index 00000000..5ac0641a --- /dev/null +++ b/phoenix-core/src/site/bin/merge.sh @@ -0,0 +1,10 @@ +current_dir=$(cd $(dirname $0);pwd) +cd $current_dir +SITE_TARGET="../../../target/site" +java -jar merge.jar ../language_reference_source/index.html $SITE_TARGET/language/index.html +java -jar merge.jar ../language_reference_source/functions.html $SITE_TARGET/language/functions.html +java -jar merge.jar ../language_reference_source/datatypes.html $SITE_TARGET/language/datatypes.html +cd $SITE_TARGET + +grep -rl class=\"nav-collapse\" . | xargs sed -i 's/class=\"nav-collapse\"/class=\"nav-collapse collapse\"/g';grep -rl class=\"active\" . | xargs sed -i 's/class=\"active\"/class=\"divider\"/g' +grep -rl "dropdown active" . | xargs sed -i 's/dropdown active/dropdown/g' diff --git a/phoenix-core/src/site/language_reference_source/datatypes.html b/phoenix-core/src/site/language_reference_source/datatypes.html new file mode 100644 index 00000000..9efca102 --- /dev/null +++ b/phoenix-core/src/site/language_reference_source/datatypes.html @@ -0,0 +1,493 @@ + + + +Data Types + + + + + + +

Index

+ + + + + + +
+ + INTEGER Type
+ + UNSIGNED_INT Type
+ + BIGINT Type
+ + UNSIGNED_LONG Type
+ + TINYINT Type
+ + UNSIGNED_TINYINT Type
+ + SMALLINT Type
+
+ + UNSIGNED_SMALLINT Type
+ + FLOAT Type
+ + UNSIGNED_FLOAT Type
+ + DOUBLE Type
+ + UNSIGNED_DOUBLE Type
+ + DECIMAL Type
+ + BOOLEAN Type
+
+ + TIME Type
+ + DATE Type
+ + TIMESTAMP Type
+ + VARCHAR Type
+ + CHAR Type
+ + BINARY Type
+ + VARBINARY Type
+
+ + + +

INTEGER Type

+ +
+INTEGER
+
+
+INTEGER +
+ + +

Possible values: -2147483648 to 2147483647.

Mapped to java.lang.Integer. The binary representation is a 4 byte integer with the sign bit flipped (so that negative values sorts before positive values).

+

Example:

+

INTEGER

+ +

UNSIGNED_INT Type

+ +
+UNSIGNED_INT
+
+
+UNSIGNED_INT +
+ + +

Possible values: 0 to 2147483647. Mapped to java.lang.Integer. The binary representation is a 4 byte integer, matching the HBase Bytes.toBytes(int) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.

+

Example:

+

UNSIGNED_INT

+ +

BIGINT Type

+ +
+BIGINT
+
+
+BIGINT +
+ + +

Possible values: -9223372036854775807 to 9223372036854775807. Mapped to java.lang.Long. The binary representation is an 8 byte long with the sign bit flipped (so that negative values sorts before positive values).

+

Example:

+

BIGINT

+ +

UNSIGNED_LONG Type

+ +
+UNSIGNED_LONG
+
+
+UNSIGNED_LONG +
+ + +

Possible values: 0 to 9223372036854775807. Mapped to java.lang.Long. The binary representation is an 8 byte integer, matching the HBase Bytes.toBytes(long) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.

+

Example:

+

UNSIGNED_LONG

+ +

TINYINT Type

+ +
+TINYINT
+
+
+TINYINT +
+ + +

Possible values: -128 to 127. Mapped to java.lang.Byte. The binary representation is a single byte, with the sign bit flipped (so that negative values sorts before positive values).

+

Example:

+

TINYINT

+ +

UNSIGNED_TINYINT Type

+ +
+UNSIGNED_TINYINT
+
+
+UNSIGNED_TINYINT +
+ + +

Possible values: 0 to 127. Mapped to java.lang.Byte. The binary representation is a single byte, matching the HBase Bytes.toBytes(byte) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.

+

Example:

+

UNSIGNED_TINYINT

+ +

SMALLINT Type

+ +
+SMALLINT
+
+
+SMALLINT +
+ + +

Possible values: -32768 to 32767. Mapped to java.lang.Short. The binary representation is a 2 byte short with the sign bit flipped (so that negative values sort before positive values).

+

Example:

+

SMALLINT

+ +

UNSIGNED_SMALLINT Type

+ +
+UNSIGNED_SMALLINT
+
+
+UNSIGNED_SMALLINT +
+ + +

Possible values: 0 to 32767. Mapped to java.lang.Short. The binary representation is an 2 byte integer, matching the HBase Bytes.toBytes(short) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.

+

Example:

+

UNSIGNED_SMALLINT

+ +

FLOAT Type

+ +
+FLOAT
+
+
+FLOAT +
+ + +

Possible values: -3.402823466 E + 38 to 3.402823466 E + 38. Mapped to java.lang.Float. The binary representation is an 4 byte float with the sign bit flipped (so that negative values sort before positive values).

+

Example:

+

FLOAT

+ +

UNSIGNED_FLOAT Type

+ +
+UNSIGNED_FLOAT
+
+
+UNSIGNED_FLOAT +
+ + +

Possible values: 0 to 3.402823466 E + 38. Mapped to java.lang.Float. The binary representation is an 4 byte float matching the HBase Bytes.toBytes(float) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.

+

Example:

+

UNSIGNED_FLOAT

+ +

DOUBLE Type

+ +
+DOUBLE
+
+
+DOUBLE +
+ + +

Possible values: -1.7976931348623158 E + 308 to 1.7976931348623158 E + 308. Mapped to java.lang.Double. The binary representation is an 8 byte double with the sign bit flipped (so that negative values sort before positive value).

+

Example:

+

DOUBLE

+ +

UNSIGNED_DOUBLE Type

+ +
+UNSIGNED_DOUBLE
+
+
+UNSIGNED_DOUBLE +
+ + +

Possible values: 0 to  1.7976931348623158 E + 308. Mapped to java.lang.Double. The binary representation is an 8 byte double matching the HBase Bytes.toBytes(double) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.

+

Example:

+

UNSIGNED_DOUBLE

+ +

DECIMAL Type

+ +
+DECIMAL
+
+
+DECIMAL +
+ + +

Data type with fixed precision and scale. The maximum precision is 18 digits. Mapped to java.math.BigDecimal. The binary representation is binary comparable, variable length format. When used in a row key, it is terminated with a null byte unless it is the last column.

+

Example:

+

DECIMAL

+ +

BOOLEAN Type

+ +
+BOOLEAN
+
+
+BOOLEAN +
+ + +

Possible values: TRUE and FALSE.

Mapped to java.lang.Boolean. The binary representation is a single byte with 0 for false and 1 for true

+

Example:

+

BOOLEAN

+ +

TIME Type

+ +
+TIME
+
+
+TIME +
+ + +

The time data type. The format is yyyy-MM-dd hh:mm:ss, with both the date and time parts maintained. Mapped to java.sql.Time. The binary representation is an 8 byte long (the number of milliseconds from the epoch).

+

Example:

+

TIME

+ +

DATE Type

+ +
+DATE
+
+
+DATE +
+ + +

The date data type. The format is yyyy-MM-dd hh:mm:ss, with both the date and time parts maintained to a millisecond accuracy. Mapped to java.sql.Date. The binary representation is an 8 byte long (the number of milliseconds from the epoch).

+

Example:

+

DATE

+ +

TIMESTAMP Type

+ +
+TIMESTAMP
+
+
+TIMESTAMP +
+ + +

The timestamp data type. The format is yyyy-MM-dd hh:mm:ss[.nnnnnnnnn]. Mapped to java.sql.Timestamp with an internal representation of the number of nanos from the epoch. The binary representation is 12 bytes: an 8 byte long for the epoch time plus a 4 byte integer for the nanos.

+

Example:

+

TIMESTAMP

+ +

VARCHAR Type

+ +
+VARCHAR  [ ( precisionInt ) ]
+
+
+
VARCHAR
 
( precisionInt )
+
+ + +

A variable length String with an optional max byte length. The binary representation is UTF8 matching the HBase Bytes.toBytes(String) method. When used in a row key, it is terminated with a null byte unless it is the last column.

Mapped to java.lang.String.

+

Example:

+

VARCHAR
VARCHAR(255)

+ +

CHAR Type

+ +
+CHAR ( precisionInt )
+
+
+
CHAR ( precisionInt )
+
+ + +

A fixed length String with single-byte characters. The binary representation is UTF8 matching the HBase Bytes.toBytes(String) method.

Mapped to java.lang.String.

+

Example:

+

CHAR(10)

+ +

BINARY Type

+ +
+BINARY ( precisionInt )
+
+
+
BINARY ( precisionInt )
+
+ + +

Raw fixed length byte array.

Mapped to byte[].

+

Example:

+

BINARY

+ +

VARBINARY Type

+ +
+VARBINARY
+
+
+VARBINARY +
+ + +

Raw variable length byte array.

Mapped to byte[].

+

Example:

+

VARBINARY

+ + + + + diff --git a/phoenix-core/src/site/language_reference_source/functions.html b/phoenix-core/src/site/language_reference_source/functions.html new file mode 100644 index 00000000..53056290 --- /dev/null +++ b/phoenix-core/src/site/language_reference_source/functions.html @@ -0,0 +1,740 @@ + + + +Functions + + + + + + +

Aggregate Functions

+ + + + + + +
+ + AVG
+ + COUNT
+ + MAX
+ + MIN
+
+ + SUM
+ + PERCENTILE_CONT
+ + PERCENTILE_DISC
+ + PERCENT_RANK
+
+ + STDDEV_POP
+ + STDDEV_SAMP
+
+ + +

String Functions

+ + + + + + +
+ + SUBSTR
+ + TRIM
+ + LTRIM
+ + RTRIM
+
+ + LENGTH
+ + REGEXP_SUBSTR
+ + REGEXP_REPLACE
+ + UPPER
+
+ + LOWER
+ + REVERSE
+ + TO_CHAR
+
+ + +

Time and Date Functions

+ + + + + + +
+ + ROUND
+ + TRUNCATE
+
+ + TO_DATE
+ + CURRENT_DATE
+
+ + CURRENT_TIME
+
+ + +

Other Functions

+ + + + + + +
+ + MD5
+ + INVERT
+
+ + TO_NUMBER
+ + COALESCE
+
+
+ + + + +

AVG

+ +
+AVG ( { numericTerm } )
+
+
+
AVG ( numericTerm )
+
+ + +

The average (mean) value. If no rows are selected, the result is NULL. Aggregates are only allowed in select statements. The returned value is of the same data type as the parameter.

+

Example:

+

AVG(X)

+ +

COUNT

+ +
+COUNT( [ DISTINCT ] { * | { term } } )
+
+
+
COUNT (
 
DISTINCT
*
term
)
+
+ + +

The count of all row, or of the non-null values. This method returns a long. When DISTINCT is used, it counts only distinct values. If no rows are selected, the result is 0. Aggregates are only allowed in select statements.

+

Example:

+

COUNT(*)

+ +

MAX

+ +
+MAX(term)
+
+
+
MAX ( term )
+
+ + +

The highest value. If no rows are selected, the result is NULL. Aggregates are only allowed in select statements. The returned value is of the same data type as the parameter.

+

Example:

+

MAX(NAME)

+ +

MIN

+ +
+MIN(term)
+
+
+
MIN ( term )
+
+ + +

The lowest value. If no rows are selected, the result is NULL. Aggregates are only allowed in select statements. The returned value is of the same data type as the parameter.

+

Example:

+

MIN(NAME)

+ +

SUM

+ +
+SUM( { numericTerm } )
+
+
+
SUM ( numericTerm )
+
+ + +

The sum of all values. If no rows are selected, the result is NULL. Aggregates are only allowed in select statements. The returned value is of the same data type as the parameter.

+

Example:

+

SUM(X)

+ +

PERCENTILE_CONT

+ +
+PERCENTILE_CONT( { numeric } ) WITHIN GROUP (ORDER BY { numericTerm } { ASC | DESC } )
+
+
+
PERCENTILE_CONT ( numeric ) WITHIN GROUP ( ORDER BY numericTerm
ASC
DESC
)
+
+ + +

The nth percentile of values in the column. The percentile value can be between 0 and 1 inclusive. Aggregates are only allowed in select statements. The returned value is of decimal data type.

+

Example:

+

PERCENTILE_CONT( 0.9 ) WITHIN GROUP (ORDER BY X ASC)

+ +

PERCENTILE_DISC

+ +
+PERCENTILE_DIST( { numeric } ) WITHIN GROUP (ORDER BY { numericTerm } { ASC | DESC } )
+
+
+
PERCENTILE_DIST ( numeric ) WITHIN GROUP ( ORDER BY numericTerm
ASC
DESC
)
+
+ + +

PERCENTILE_DISC is an inverse distribution function that assumes a discrete distribution model. It takes a percentile value and a sort specification and returns an element from the set. Nulls are ignored in the calculation.

+

Example:

+

PERCENTILE_DISC( 0.9 ) WITHIN GROUP (ORDER BY X DESC)

+ +

PERCENT_RANK

+ +
+PERCENT_RANK( { numeric } ) WITHIN GROUP (ORDER BY { numericTerm } { ASC | DESC } )
+
+
+
PERCENT_RANK ( numeric ) WITHIN GROUP ( ORDER BY numericTerm
ASC
DESC
)
+
+ + +

The percentile rank for a hypothetical value, if inserted into the column. Aggregates are only allowed in select statements. The returned value is of decimal data type.

+

Example:

+

PERCENT_RANK( 100 ) WITHIN GROUP (ORDER BY X ASC)

+ +

STDDEV_POP

+ +
+STDDEV_POP( { numericTerm } )
+
+
+
STDDEV_POP ( numericTerm )
+
+ + +

The population standard deviation of all values. Aggregates are only allowed in select statements. The returned value is of decimal data type.

+

Example:

+

STDDEV_POP( X )

+ +

STDDEV_SAMP

+ +
+STDDEV_SAMP( { numericTerm } )
+
+
+
STDDEV_SAMP ( numericTerm )
+
+ + +

The sample standard deviation of all values. Aggregates are only allowed in select statements. The returned value is of decimal data type.

+

Example:

+

STDDEV_SAMP( X )

+ +

MD5

+ +
+MD5( term )
+
+
+
MD5 ( term )
+
+ + +

Computes the MD5 hash of the argument, returning the result as a BINARY(16).

+

Example:

+

MD5(my_column)

+ +

INVERT

+ +
+INVERT( term )
+
+
+
INVERT ( term )
+
+ + +

Inverts the bits of the argument. The return type will be the same as the argument.

+

Example:

+

INVERT(my_column)

+ +

TO_NUMBER

+ +
+TO_NUMBER( stringTerm | timeStampTerm [, formatString] )
+
+ + + +

Formats a string or date/time/timeStamp as a number, optionally accepting a format string. For details on the format, see java.text.DecimalFormat. For date, time, and timeStamp terms, the result is the time in milliseconds since the epoch. This method returns a decimal number.

+

Example:

+

TO_NUMBER('$123.33', '\u00A4###.##')

+ +

COALESCE

+ +
+COALESCE( firstTerm, secondTerm )
+
+
+
COALESCE ( firstTerm , secondTerm )
+
+ + +

Returns the value of the first argument if not null and the second argument otherwise. Useful to guarantee that a column in an UPSERT SELECT command will evaluate to a non null value.

+

Example:

+

COALESCE(last_update_date, CURRENT_DATE())

+ +

SUBSTR

+ +
+SUBSTR( stringTerm, startInt [, lengthInt ] )
+
+
+
SUBSTR ( stringTerm , startInt
 
, lengthInt
)
+
+ + +

Returns a substring of a string starting at the one-based position. If zero is used, the position is zero-based. If the start index is negative, then the start index is relative to the end of the string. The length is optional and if not supplied, the rest of the string will be returned.

+

Example:

+

SUBSTR('[Hello]', 2, 5)
SUBSTR('Hello World', -5)

+ +

TRIM

+ +
+TRIM( stringTerm )
+
+
+
TRIM ( stringTerm )
+
+ + +

Removes leading and trailing spaces from the input string.

+

Example:

+

TRIM('  Hello  ')

+ +

LTRIM

+ +
+LTRIM( stringTerm )
+
+
+
LTRIM ( stringTerm )
+
+ + +

Removes leading spaces from the input string.

+

Example:

+

LTRIM('  Hello')

+ +

RTRIM

+ +
+RTRIM( stringTerm )
+
+
+
RTRIM ( stringTerm )
+
+ + +

Removes trailing spaces from the input string.

+

Example:

+

RTRIM('Hello   ')

+ +

LENGTH

+ +
+LENGTH( stringTerm )
+
+
+
LENGTH ( stringTerm )
+
+ + +

Returns the length of the string in characters.

+

Example:

+

LENGTH('Hello')

+ +

REGEXP_SUBSTR

+ +
+REGEXP_SUBSTR( stringTerm, patternString [, startInt ] )
+
+
+
REGEXP_SUBSTR ( stringTerm , patternString
 
, startInt
)
+
+ + +

Returns a substring of a string by applying a regular expression start from the offset of a one-based position. Just like with SUBSTR, if the start index is negative, then it is relative to the end of the string. If not specified, the start index defaults to 1.

+

Example:

+

REGEXP_SUBSTR('na1-appsrv35-sj35', '[^-]+') evaluates to 'na1'

+ +

REGEXP_REPLACE

+ +
+REGEXP_REPLACE( stringTerm, patternString [, replacementString ] )
+
+
+
REGEXP_REPLACE ( stringTerm , patternString
 
, replacementString
)
+
+ + +

Returns a string by applying a regular expression and replacing the matches with the replacement string. If the replacement string is not specified, it defaults to an empty string.

+

Example:

+

REGEXP_REPLACE('abc123ABC', '[0-9]+', '#') evaluates to 'abc#ABC'

+ +

UPPER

+ +
+UPPER( stringTerm )
+
+
+
UPPER ( stringTerm )
+
+ + +

Returns upper case string of the string argument.

+

Example:

+

UPPER('Hello')

+ +

LOWER

+ +
+LOWER( stringTerm )
+
+
+
LOWER ( stringTerm )
+
+ + +

Returns lower case string of the string argument.

+

Example:

+

LOWER('HELLO')

+ +

REVERSE

+ +
+REVERSE( stringTerm )
+
+
+
REVERSE ( stringTerm )
+
+ + +

Returns reversed string of the string argument.

+

Example:

+

REVERSE('Hello')

+ +

TO_CHAR

+ +
+TO_CHAR( timestampTerm | numberTerm [, formatString] )
+
+ + + +

Formats a date, time, timestamp, or number as a string. The default date format is yyyy-MM-dd HH:mm:ss and the default number format is #,##0.###. For details, see java.text.SimpleDateFormat for date/time values and java.text.DecimalFormat for numbers. This method returns a string.

+

Example:

+

TO_CHAR(myDate, '2001-02-03 04:05:06')
TO_CHAR(myDecimal, '#,##0.###')

+ +

ROUND

+ +
+ROUND(timestampTerm, {'DAY' | 'HOUR' | 'MINUTE' | 'SECOND' | 'MILLISECOND'} [, multiplierNumber])
+
+
+
ROUND ( timestampTerm ,
' DAY '
' HOUR '
' MINUTE '
' SECOND '
' MILLISECOND '
 
, multiplierNumber
)
+
+ + +

Rounds the timestamp to the nearest time unit specified. The multiplier is used to round to a multiple of a time unit (i.e. 10 minute) and defaults to 1 if not specified. This method returns a date.

+

Example:

+

ROUND(date, 'MINUTE', 30)
ROUND(time, 'HOUR')

+ +

TRUNCATE

+ +
+TRUNC(timestampTerm, {'DAY' | 'HOUR' | 'MINUTE' | 'SECOND' | 'MILLISECOND'} [, multiplierInt])
+
+
+
TRUNC ( timestampTerm ,
' DAY '
' HOUR '
' MINUTE '
' SECOND '
' MILLISECOND '
 
, multiplierInt
)
+
+ + +

Truncates the timestamp to the next time unit closer to 0. The multiplier is used to truncate to a multiple of a time unit (i.e. 10 minute) and defaults to 1 if not specified. This method returns a date.

+

Example:

+

TRUNCATE(timestamp, 'SECOND', 30)
TRUNCATE(date, 'DAY', 7)

+ +

TO_DATE

+ +
+TO_DATE( stringTerm [, formatString] )
+
+
+
TO_DATE ( stringTerm
 
, formatString
)
+
+ + +

Parses a string and returns a date. The most important format characters are: y year, M month, d day, H hour, m minute, s second. The default format string is yyyy-MM-dd HH:mm:ss. For details of the format, see java.text.SimpleDateFormat.

+

Example:

+

TO_DATE('Sat, 3 Feb 2001 03:05:06 GMT', 'EEE, d MMM yyyy HH:mm:ss z')

+ +

CURRENT_DATE

+ +
+CURRENT_DATE()
+
+
+
CURRENT_DATE ( )
+
+ + +

Returns the current server-side date, bound at the start of the execution of a query based on the current time on the region server owning the metadata of the table being queried.

+

Example:

+

CURRENT_DATE()

+ +

CURRENT_TIME

+ +
+CURRENT_TIME()
+
+
+
CURRENT_TIME ( )
+
+ + +

Same as CURRENT_DATE(), except returns a value of type TIME. In either case, the underlying representation is the epoch time as a long value.

+

Example:

+

CURRENT_TIME()

+ + + + + diff --git a/phoenix-core/src/site/language_reference_source/index.html b/phoenix-core/src/site/language_reference_source/index.html new file mode 100644 index 00000000..04bcec67 --- /dev/null +++ b/phoenix-core/src/site/language_reference_source/index.html @@ -0,0 +1,947 @@ + + + + +SQL Grammar + + + + + + +

Commands

+ + + + + + +
+ + SELECT
+ + UPSERT VALUES
+ + UPSERT SELECT
+ + DELETE
+
+ + CREATE
+ + DROP
+ + ALTER TABLE
+ + CREATE INDEX
+
+ + DROP INDEX
+ + ALTER INDEX
+ + EXPLAIN
+
+ + +

Other Grammar

+ + + + + + +
+ + Constraint
+ + Options
+ + Hint
+ + Column Def
+ + Table Ref
+ + Column Ref
+ + Select Expression
+ + Split Point
+ + Table Expression
+ + Order
+ + Expression
+ + And Condition
+
+ + Condition
+ + Compare
+ + Operand
+ + Summand
+ + Factor
+ + Term
+ + Row Value Constructor
+ + Bind Parameter
+ + Value
+ + Case
+ + Case When
+ + Name
+
+ + Quoted Name
+ + Alias
+ + Null
+ + Data Type
+ + String
+ + Boolean
+ + Numeric
+ + Int
+ + Long
+ + Decimal
+ + Number
+ + Comments
+
+ + + +

SELECT

+ +
+SELECT [/*+ hint */] [DISTINCT | ALL] selectExpression [,...]
+FROM tableExpression [( columnDef [,...] )] [ WHERE expression ]
+[ GROUP BY expression [,...] ] [ HAVING expression ]
+[ ORDER BY order [,...] ] [ LIMIT {bindParameter | number} ]
+
+
+
SELECT
 
/ * + hint * /
 
DISTINCT
ALL
selectExpression
 
, ...

FROM tableExpression
 
( columnDef
 
, ...
)
 
WHERE expression

 
GROUP BY expression
 
, ...
 
HAVING expression

 
ORDER BY order
 
, ...
 
LIMIT
bindParameter
number
+
+ + +

Selects data from a table. DISTINCT filters out duplicate results while ALL, the default, includes all results. FROM identifies the table being queried (single table only currently - no joins or derived tables yet). Dynamic columns not declared at create time may be defined in parenthesis after the table name and then used in the query. GROUP BY groups the the result by the given expression(s). HAVING filter rows after grouping. ORDER BY sorts the result by the given column(s) or expression(s) and is only allowed for aggregate queries or queries with a LIMIT clause. LIMIT limits the number of rows returned by the query with no limit applied if specified as null or less than zero. The LIMIT clause is executed after the ORDER BY clause to support TopN type queries. An optional hint overrides the default query plan.

+

Example:

+

+SELECT * FROM TEST;
SELECT a.* FROM TEST;
SELECT DISTINCT NAME FROM TEST;
SELECT ID, COUNT(1) FROM TEST GROUP BY ID;
SELECT NAME, SUM(VAL) FROM TEST GROUP BY NAME HAVING COUNT(1) > 2;
SELECT 'ID' COL, MAX(ID) AS MAX FROM TEST;
SELECT * FROM TEST LIMIT 1000;

+ +

UPSERT VALUES

+ +
+UPSERT INTO tableName [( { columnRef | columnDef } [,...] )] VALUES ( constantTerm [,...] )
+
+
+
UPSERT INTO tableName
 
(
columnRef
columnDef
 
, ...
)
VALUES ( constantTerm
 
, ...
)
+
+ + +

Inserts if not present and updates otherwise the value in the table. The list of columns is optional and if not present, the values will map to the column in the order they are declared in the schema. The values must evaluate to constants.

+

Example:

+

+UPSERT INTO TEST VALUES('foo','bar',3);
UPSERT INTO TEST(NAME,ID) VALUES('foo',123);

+ +

UPSERT SELECT

+ +
+UPSERT [/*+ hint */] INTO tableName [( { columnRef | columnDef } [,...] )] select
+
+
+
UPSERT
 
/ * + hint * /
INTO tableName
 
(
columnRef
columnDef
 
, ...
)
select
+
+ + +

Inserts if not present and updates otherwise rows in the table based on the results of running another query. The values are set based on their matching position between the source and target tables. The list of columns is optional and if not present will map to the column in the order they are declared in the schema. If auto commit is on, and both a) the target table matches the source table, and b) the select performs no aggregation, then the population of the target table will be done completely on the server-side (with constraint violations logged, but otherwise ignored). Otherwise, data is buffered on the client and, if auto commit is on, committed in row batches as specified by the UpsertBatchSize connection property (or the phoenix.mutate.upsertBatchSize HBase config property which defaults to 10000 rows)

+

Example:

+

+UPSERT INTO test.targetTable(col1, col2) SELECT col3, col4 FROM test.sourceTable WHERE col5 < 100
UPSERT INTO foo SELECT * FROM bar;

+ +

DELETE

+ +
+DELETE [/*+ hint */] FROM tableName [ WHERE expression ]
+[ ORDER BY order [,...] ] [ LIMIT {bindParameter | number} ]
+
+
+
DELETE
 
/ * + hint * /
FROM tableName
 
WHERE expression

 
ORDER BY order
 
, ...
 
LIMIT
bindParameter
number
+
+ + +

Deletes the rows selected by the where clause. If auto commit is on, the deletion is performed completely server-side.

+

Example:

+

+DELETE FROM TEST;
DELETE FROM TEST WHERE ID=123;
DELETE FROM TEST WHERE NAME LIKE 'foo%';

+ +

CREATE

+ +
+CREATE { TABLE | VIEW } [IF NOT EXISTS] tableRef
+( columnDef [,...] [constraint] )
+[tableOptions] [ SPLIT ON ( splitPoint [,...] ) ]
+
+
+
CREATE
TABLE
VIEW
 
IF NOT EXISTS
tableRef

( columnDef
 
, ...
 
constraint
)

 
tableOptions
 
SPLIT ON ( splitPoint
 
, ...
)
+
+ + +

Creates a new table or view. For the creation of a table, the HBase table and any column families referenced are created if they don't already exist (using uppercase names unless they are double quoted in which case they are case sensitive). Column families outside of the ones listed are not affected. At create time, an empty key value is added to the first column family of any existing rows. Upserts will also add this empty key value. This is done to improve query performance by having a key value column we can guarantee always being there (minimizing the amount of data that must be projected). Alternately, if a view is created, the HBase table and column families must already exist. No empty key value is added to existing rows and no data mutations are allowed - the view is read-only. Query performance for a view will not be as good as performance for a table. For a table only, HBase table and column configuration options may be passed through as key/value pairs to setup the HBase table as needed.

+

Example:

+

+CREATE TABLE my_schema.my_table ( id BIGINT not null primary key, date DATE not null)
CREATE TABLE my_table ( id INTEGER not null primary key desc, date DATE not null,
    m.db_utilization DECIMAL, i.db_utilization)
    m.DATA_BLOCK_ENCODING='DIFF'
CREATE TABLE stats.prod_metrics ( host char(50) not null, created_date date not null,
    txn_count bigint CONSTRAINT pk PRIMARY KEY (host, created_date) )
CREATE TABLE IF NOT EXISTS my_table ( id char(10) not null primary key, value integer)
    DATA_BLOCK_ENCODING='NONE',VERSIONS=?,MAX_FILESIZE=2000000 split on (?, ?, ?)

+ +

DROP

+ +
+DROP {TABLE | VIEW} [IF EXISTS] tableRef
+
+
+
DROP
TABLE
VIEW
 
IF EXISTS
tableRef
+
+ + +

Drops a table or view. When dropping a table, the data in the table is deleted. For a view, on the other hand, the data is not affected. Note that the schema is versioned, such that snapshot queries connecting at an earlier time stamp may still query against the dropped table, as the HBase table itself is not deleted.

+

Example:

+

+DROP TABLE my_schema.my_table
DROP VIEW my_view

+ +

ALTER TABLE

+ +
+ALTER TABLE tableRef { { ADD [IF NOT EXISTS] columnDef [options] } | { DROP COLUMN [IF EXISTS] columnRef } | { SET options } }
+
+
+
ALTER TABLE tableRef
ADD
 
IF NOT EXISTS
columnDef
 
options
DROP COLUMN
 
IF EXISTS
columnRef
SET options
+
+ + +

Alters an existing table by adding or removing a column or updating table options. When a column is dropped from a table, the data in that column is deleted as well. PK columns may not be dropped, and only nullable PK columns may be added. For a view, the data is not affected when a column is dropped. Note that creating or dropping columns only affects subsequent queries and data modifications. Snapshot queries that are connected at an earlier timestamp will still use the prior schema that was in place when the data was written.

+

Example:

+

+ALTER TABLE my_schema.my_table ADD d.dept_id char(10) VERSIONS=10
ALTER TABLE my_table ADD dept_name char(50)
ALTER TABLE my_table ADD parent_id char(15) null primary key
ALTER TABLE my_table DROP COLUMN d.dept_id
ALTER TABLE my_table DROP COLUMN dept_name
ALTER TABLE my_table DROP COLUMN parent_id
ALTER TABLE my_table SET IMMUTABLE_ROWS=true

+ +

CREATE INDEX

+ +
+CREATE INDEX [IF NOT EXISTS] indexName
+ON tableRef ( columnRef [ASC | DESC] [,...] )
+[ INCLUDE ( columnRef [,...] ) ]
+[indexOptions] [ SPLIT ON ( splitPoint [,...] ) ]
+
+
+
CREATE INDEX
 
IF NOT EXISTS
indexName

ON tableRef ( columnRef
 
ASC
DESC
 
, ...
)

 
INCLUDE ( columnRef
 
, ...
)

 
indexOptions
 
SPLIT ON ( splitPoint
 
, ...
)
+
+ + +

Creates a new secondary index on a table or view. The index will be automatically kept in sync with the table as the data changes. At query time, the optimizer will use the index if it contains all columns referenced in the query and produces the most efficient execution plan. If a table has rows that are write-once and append-only, then the table may set the IMMUTABLE_ROWS property to true (either up-front in the CREATE TABLE statement or afterwards in an ALTER TABLE statement). This reduces the overhead at write time to maintain the index. Otherwise, if this property is not set on the table, then incremental index maintenance will be performed on the server side when the data changes.

+

Example:

+

+CREATE INDEX my_idx ON sales.opportunity(last_updated_date DESC)
CREATE INDEX my_idx ON log.event(created_date DESC) INCLUDE (name, payload) SALT_BUCKETS=10
CREATE INDEX IF NOT EXISTS my_comp_idx ON server_metrics ( gc_time DESC, created_date DESC )
    DATA_BLOCK_ENCODING='NONE',VERSIONS=?,MAX_FILESIZE=2000000 split on (?, ?, ?)

+ +

DROP INDEX

+ +
+DROP INDEX [IF EXISTS] indexName ON tableRef
+
+
+
DROP INDEX
 
IF EXISTS
indexName ON tableRef
+
+ + +

Drops an index from a table. When dropping an index, the data in the index is deleted. Note that since metadata is versioned, snapshot queries connecting at an earlier time stamp may still use the index, as the HBase table backing the index is not deleted.

+

Example:

+

+DROP INDEX my_idx ON sales.opportunity
DROP INDEX IF EXISTS my_idx ON server_metrics

+ +

ALTER INDEX

+ +
+ALTER INDEX [IF EXISTS] indexName ON tableRef { DISABLE | REBUILD | UNUSABLE | USABLE }
+
+
+
ALTER INDEX
 
IF EXISTS
indexName ON tableRef
DISABLE
REBUILD
UNUSABLE
USABLE
+
+ + +

Alters the state of an existing index.  DISABLE will cause the no further index maintenance to be performed on the index and it will no longer be considered for use in queries. REBUILD will completely rebuild the index and upon completion will enable the index to be used in queries again. UNUSABLE will cause the index to no longer be considered for use in queries, however index maintenance will continue to be performed. USABLE will cause the index to again be considered for use in queries. Note that a disabled index must be rebuild and cannot be set as USABLE.

+

Example:

+

+ALTER INDEX my_idx ON sales.opportunity DISABLE
ALTER INDEX IF EXISTS my_idx ON server_metrics REBUILD

+ +

EXPLAIN

+ +
+EXPLAIN {select|upsertSelect|delete}
+
+ + + +

Computes the logical steps necessary to execute the given command. Each step is represented as a string in a single column result set row.

+

Example:

+

+EXPLAIN SELECT NAME, COUNT(*) FROM TEST GROUP BY NAME HAVING COUNT(*) > 2;
EXPLAIN SELECT entity_id FROM CORE.CUSTOM_ENTITY_DATA WHERE organization_id='00D300000000XHP' AND SUBSTR(entity_id,1,3) = '002' AND created_date < CURRENT_DATE()-1;

+ + +

Constraint

+ +
CONSTRAINT constraintName PRIMARY KEY ( columnName
 
ASC
DESC
 
, ...
)
+ + +

Defines a multi-part primary key constraint. Each column may be declared to be sorted in ascending or descending ordering. The default is ascending.

+

Example:

+

CONSTRAINT my_pk PRIMARY KEY (host,created_date)
CONSTRAINT my_pk PRIMARY KEY (host ASC,created_date DESC)

+ +

Options

+ +
 
familyName .
name =
value
bindParameter
 
, ...
+ + +

Sets an option on an HBase table or column by modifying the respective HBase metadata. The option applies to the named family or if omitted to all families if the name references an HColumnDescriptor property. Otherwise, the option applies to the HTableDescriptor.

One built-in option is SALT_BUCKETS. This option causes an extra byte to be transparently prepended to every row key to ensure an even distribution of write load across all your region servers. This is useful when your row key is always monotonically increasing causing hot spotting on a single region server. The byte is determined by hashing the row key and modding it with the SALT_BUCKETS value. The value may be from 1 to 256. If not split points are defined for the table, it will automatically be pre-split at each possible salt bucket value. For an excellent write-up of this technique, see http://blog.sematext.com/2012/04/09/hbasewd-avoid-regionserver-hotspotting-despite-writing-records-with-sequential-keys/

Another built-in options is IMMUTABLE_ROWS. Only tables with immutable rows are allowed to have indexes. Immutable rows are expected to be inserted once in their entirety and then never updated. This limitation will be removed once incremental index maintenance has been implemented. The current implementation inserts the index rows when the data row is inserted.

+

Example:

+

IMMUTABLE_ROWS=true
SALT_BUCKETS=10
DATA_BLOCK_ENCODING='NONE',a.VERSIONS=10
MAX_FILESIZE=2000000000,MEMSTORE_FLUSHSIZE=80000000

+ +

Hint

+ +
name
 
, ...
+ + +

Advanced features that overrides default query processing behavior. The supported hints include 1) SKIP_SCAN to force a skip scan to be performed on the query when it otherwise would not be. This option may improve performance if a query does not include the leading primary key column, but does include other, very selective primary key columns. 2) RANGE_SCAN to force a range scan to be performed on the query. This option may improve performance if a query filters on a range for non selective leading primary key column along with other primary key columns 3) NO_INTRA_REGION_PARALLELIZATION to prevent the spawning of multiple threads to process data within a single region. This option is useful when the overall data set being queries is known to be small. 4) NO_INDEX to force the data table to be used for a query, and 5) INDEX(<table_name> <index_name>...) to suggest which index to use for a given query. Double quotes may be used to surround a table_name and/or index_name that is case sensitive.

+

Example:

+

/*+ SKIP_SCAN */
/*+ RANGE_SCAN */
/*+ NO_INTRA_REGION_PARALLELIZATION */
/*+ NO_INDEX */
/*+ INDEX(employee emp_name_idx emp_start_date_idx) */

+ +

Column Def

+ +
columnRef dataType
 
 
NOT
NULL
 
PRIMARY KEY
 
ASC
DESC
+ + +

Define a new primary key column. The column name is case insensitive by default and case sensitive if double quoted. The sort order of a primary key may be ascending (ASC) or descending. The default is ascending.

+

Example:

+

id char(15) not null primary key
key integer null
m.response_time bigint

+ +

Table Ref

+ +
 
schemaName .
tableName
+ + +

References a table with an optional schema name qualifier

+

Example:

+

Sales.Contact
HR.Employee
Department

+ +

Column Ref

+ +
 
familyName .
columnName
+ + +

References a column with an optional family name qualifier

+

Example:

+

e.salary
dept_name

+ +

Select Expression

+ +
*
( familyName . * )
term
 
 
AS
columnAlias
+ + +

An expression in a SELECT statement. All columns in a table may be selected using *, and all columns in a column family may be selected using <familyName>.*.

+

Example:

+

*
cf.*
ID AS VALUE
VALUE + 1 VALUE_PLUS_ONE

+ +

Split Point

+ +
value
bindParameter
+ + +

Defines a split point for a table. Use a bind parameter with preparedStatement.setBinary(int,byte[]) to supply arbitrary bytes.

+

Example:

+

'A'

+ +

Table Expression

+ +
 
schemaName .
tableName
 
 
AS
tableAlias
+ + +

A reference to a table. Joins and sub queries are not currently supported.

+

Example:

+

PRODUCT_METRICS AS PM

+ +

Order

+ +
expression
 
ASC
DESC
 
NULLS
FIRST
LAST
+ + +

Sorts the result by an expression.

+

Example:

+

NAME DESC NULLS LAST

+ +

Expression

+ +
andCondition
 
OR andCondition
 
...
+ + +

Value or condition.

+

Example:

+

ID=1 OR NAME='Hi'

+ +

And Condition

+ +
condition
 
AND condition
 
...
+ + +

Value or condition.

+

Example:

+

ID=1 AND NAME='Hi'

+ +

Condition

+ +
operand
 
compare operand
 
NOT
IN ( constantOperand
 
, ...
)
 
NOT
LIKE operand
 
NOT
BETWEEN operand AND operand
IS
 
NOT
NULL
NOT expression
( expression )
+ + +

Boolean value or condition. When comparing with LIKE, the wildcards characters are _ (any one character) and % (any characters). To search for the characters % and _, the characters need to be escaped. The escape character is \ (backslash). Patterns that end with an escape character are invalid and the expression returns NULL. BETWEEN does an inclusive comparison for both operands.

+

Example:

+

NAME LIKE 'Jo%'

+ +

Compare

+ +
< >
< =
> =
=
<
>
! =
+ + +

Comparison operator. The operator != is the same as <>.

+

Example:

+

<>

+ +

Operand

+ +
summand
 
|| summand
 
...
+ + +

A string concatenation.

+

Example:

+

'foo'|| s

+ +

Summand

+ +
factor
 
+
-
factor
 
...
+ + +

An addition or subtraction of numeric or date type values

+

Example:

+

a + b
a - b

+ +

Factor

+ +
term
 
*
/
term
 
...
+ + +

A multiplication or division.

+

Example:

+

c * d
e / 5

+ +

Term

+ +
value
bindParameter
Function
case
caseWhen
( operand )
 
tableAlias .
columnRef
rowValueConstructor
+ + +

A value.

+

Example:

+

'Hello'

+ +

Row Value Constructor

+ +
( term , term
 
...
)
+ + +

A row value constructor is a list of other terms which are treated together as a kind of composite structure. They may be compared to each other or to other other terms. The main use case is 1) to enable efficiently stepping through a set of rows in support of query-more type functionality, or 2) to allow IN clause to perform point gets on composite row keys.

+

Example:

+

(col1, col2, 5)

+ +

Bind Parameter

+ +
?
: number
+ + +

A parameters can be indexed, for example :1 meaning the first parameter.

+

Example:

+

:1
?

+ +

Value

+ +
string
numeric
boolean
null
+ + +

A literal value of any data type, or null.

+

Example:

+

10

+ +

Case

+ +
CASE term WHEN expression THEN term
 
...

 
ELSE expression
END
+ + +

Returns the first expression where the value is equal to the test expression. If no else part is specified, return NULL.

+

Example:

+

CASE CNT WHEN 0 THEN 'No' WHEN 1 THEN 'One' ELSE 'Some' END

+ +

Case When

+ +
CASE WHEN expression THEN term
 
...

 
ELSE term
END
+ + +

Returns the first expression where the condition is true. If no else part is specified, return NULL.

+

Example:

+

CASE WHEN CNT<10 THEN 'Low' ELSE 'High' END

+ +

Name

+ +
A-Z | _
 
A-Z | _
0-9
 
...
quotedName
+ + +

Unquoted names are not case sensitive. There is no maximum name length.

+

Example:

+

my_column

+ +

Quoted Name

+ +
" anything "
+ + +

Quoted names are case sensitive, and can contain spaces. There is no maximum name length. Two double quotes can be used to create a single double quote inside an identifier.

+

Example:

+

"first-name"

+ +

Alias

+ +name + + +

An alias is a name that is only valid in the context of the statement.

+

Example:

+

A

+ +

Null

+ +NULL + + +

NULL is a value without data type and means 'unknown value'.

+

Example:

+

NULL

+ +

Data Type

+ +
charType
varcharType
decimalType
tinyintType
smallintType
integerType
bigintType
floatType
doubleType
timestampType
dateType
timeType
unsignedTinyintType
unsignedSmallintType
unsignedIntType
unsignedLongType
unsignedFloatType
unsignedDoubleType
binaryType
varbinaryType
+ + +

A type name.

+

Example:

+

CHAR(15)
VARCHAR
VARCHAR(1000)
INTEGER
BINARY(200)

+ +

String

+ +
' anything '
+ + +

A string starts and ends with a single quote. Two single quotes can be used to create a single quote inside a string.

+

Example:

+

'John''s car'

+ +

Boolean

+ +
TRUE
FALSE
+ + +

A boolean value.

+

Example:

+

TRUE

+ +

Numeric

+ +
int
long
decimal
+ + +

The data type of a numeric value is always the lowest possible for the given value. If the number contains a dot this is decimal; otherwise it is int, long, or decimal (depending on the value).

+

Example:

+

SELECT -10.05
SELECT 5
SELECT 12345678912345

+ +

Int

+ +
 
-
number
+ + +

The maximum integer number is 2147483647, the minimum is -2147483648.

+

Example:

+

10

+ +

Long

+ +
 
-
number
+ + +

Long numbers are between -9223372036854775808 and 9223372036854775807.

+

Example:

+

100000

+ +

Decimal

+ +
 
-
number
 
. number
+ + +

A decimal number with fixed precision and scale. Internally, java.lang.BigDecimal is used.

+

Example:

+

SELECT -10.5

+ +

Number

+ +
0-9
 
...
+ + +

The maximum length of the number depends on the data type used.

+

Example:

+

100

+ +

Comments

+ +
- - anything
/ / anything
/ * anything * /
+ + +

Comments can be used anywhere in a command and are ignored by the database. Line comments end with a newline. Block comments cannot be nested, but can be multiple lines long.

+

Example:

+

// This is a comment

+ + + + diff --git a/phoenix-core/src/site/markdown/Phoenix-in-15-minutes-or-less.md b/phoenix-core/src/site/markdown/Phoenix-in-15-minutes-or-less.md new file mode 100644 index 00000000..bc01b185 --- /dev/null +++ b/phoenix-core/src/site/markdown/Phoenix-in-15-minutes-or-less.md @@ -0,0 +1,80 @@ +# Phoenix in 15 minutes or less + +*What is this new [Phoenix](index.html) thing I've been hearing about?*
+Phoenix is an open source SQL skin for HBase. You use the standard JDBC APIs instead of the regular HBase client APIs to create tables, insert data, and query your HBase data. + +*Doesn't putting an extra layer between my application and HBase just slow things down?*
+Actually, no. Phoenix achieves as good or likely better [performance](performance.html) than if you hand-coded it yourself (not to mention with a heck of a lot less code) by: +* compiling your SQL queries to native HBase scans +* determining the optimal start and stop for your scan key +* orchestrating the parallel execution of your scans +* bringing the computation to the data by + * pushing the predicates in your where clause to a server-side filter + * executing aggregate queries through server-side hooks (called co-processors) + +In addition to these items, we've got some interesting enhancements in the works to further optimize performance: +* secondary indexes to improve performance for queries on non row key columns +* stats gathering to improve parallelization and guide choices between optimizations +* skip scan filter to optimize IN, LIKE, and OR queries +* optional salting of row keys to evenly distribute write load + +*Ok, so it's fast. But why SQL? It's so 1970s*
+Well, that's kind of the point: give folks something with which they're already familiar. What better way to spur the adoption of HBase? On top of that, using JDBC and SQL: +* Reduces the amount of code users need to write +* Allows for performance optimizations transparent to the user +* Opens the door for leveraging and integrating lots of existing tooling + +*But how can SQL support my favorite HBase technique of x,y,z*
+Didn't make it to the last HBase Meetup did you? SQL is just a way of expressing *what you want to get* not *how you want to get it*. Check out my [presentation](http://files.meetup.com/1350427/IntelPhoenixHBaseMeetup.ppt) for various existing and to-be-done Phoenix features to support your favorite HBase trick. Have ideas of your own? We'd love to hear about them: file an [issue](issues.html) for us and/or join our [mailing list](mailing_list.html). + +*Blah, blah, blah - I just want to get started!*
+Ok, great! Just follow our [install instructions](download.html#Installation): +* [download](download.html) and expand our installation tar +* copy the phoenix jar into the HBase lib directory of every region server +* restart the region servers +* add the phoenix client jar to the classpath of your HBase client +* download and [setup SQuirrel](download.html#SQL-Client) as your SQL client so you can issue adhoc SQL against your HBase cluster + +*I don't want to download and setup anything else!*
+Ok, fair enough - you can create your own SQL scripts and execute them using our command line tool instead. Let's walk through an example now. In the bin directory of your install location: +* Create us_population.sql file +
CREATE TABLE IF NOT EXISTS us_population (
+      state CHAR(2) NOT NULL,
+      city VARCHAR NOT NULL,
+      population BIGINT
+      CONSTRAINT my_pk PRIMARY KEY (state, city));
+* Create us_population.csv file +
NY,New York,8143197
+CA,Los Angeles,3844829
+IL,Chicago,2842518
+TX,Houston,2016582
+PA,Philadelphia,1463281
+AZ,Phoenix,1461575
+TX,San Antonio,1256509
+CA,San Diego,1255540
+TX,Dallas,1213825
+CA,San Jose,912332
+
+* Create us_population_queries.sql file +
SELECT state as "State",count(city) as "City Count",sum(population) as "Population Sum"
+FROM us_population
+GROUP BY state
+ORDER BY sum(population) DESC;
+
+* Execute the following command from a command terminal +
./psql.sh <your_zookeeper_quorum> us_population.sql us_population.csv us_population_queries.sql
+
+ +Congratulations! You've just created your first Phoenix table, inserted data into it, and executed an aggregate query with just a few lines of code in 15 minutes or less! + +*Big deal - 10 rows! What else you got?*
+Ok, ok - tough crowd. Check out our bin/performance.sh script to create as many rows as you want, for any schema you come up with, and run timed queries against it. + +*Why is it called Phoenix anyway? Did some other project crash and burn and this is the next generation?*
+I'm sorry, but we're out of time and space, so we'll have to answer that next time! + +Thanks for your time,
+James Taylor
+http://phoenix-hbase.blogspot.com/ +
+@JamesPlusPlus
diff --git a/phoenix-core/src/site/markdown/building.md b/phoenix-core/src/site/markdown/building.md new file mode 100644 index 00000000..92f9a6f2 --- /dev/null +++ b/phoenix-core/src/site/markdown/building.md @@ -0,0 +1,20 @@ +# Building Phoenix Project + +Phoenix is a fully mavenized project. That means you can build simply by doing: +``` + $ mvn package +``` + +builds, test and package Phoenix and put the resulting jars (phoenix-[version].jar and phoenix-[version]-client.jar) in the generated target/ directory. + +To build, but skip running the tests, you can do: +``` + $ mvn package -DskipTests +``` +To only build the generated parser (i.e. PhoenixSQLLexer and PhoenixSQLParser), you can do: +``` + $ mvn process-sources +``` + +To build an Eclipse project, install the m2e plugin and do an File->Import...->Import Existing Maven Projects selecting the root directory of Phoenix. + diff --git a/phoenix-core/src/site/markdown/download.md b/phoenix-core/src/site/markdown/download.md new file mode 100644 index 00000000..147bc789 --- /dev/null +++ b/phoenix-core/src/site/markdown/download.md @@ -0,0 +1,84 @@ +## Available Phoenix Downloads + +### Download link will be available soon. + +
+ +### Installation ### +To install a pre-built phoenix, use these directions: + +* Download and expand the latest phoenix-[version]-install.tar +* Add the phoenix-[version].jar to the classpath of every HBase region server. An easy way to do this is to copy it into the HBase lib directory. +* Restart all region servers. +* Add the phoenix-[version]-client.jar to the classpath of any Phoenix client. + +### Getting Started ### +Wanted to get started quickly? Take a look at our [FAQs](faq.html) and take our quick start guide [here](Phoenix-in-15-minutes-or-less.html). + +

Command Line

+ +A terminal interface to execute SQL from the command line is now bundled with Phoenix. To start it, execute the following from the bin directory: + + $ sqlline.sh localhost + +To execute SQL scripts from the command line, you can include a SQL file argument like this: + + $ sqlline.sh localhost ../examples/stock_symbol.sql + +![sqlline](images/sqlline.png) + +For more information, see the [manual](http://www.hydromatic.net/sqlline/manual.html). + +
Loading Data
+ +In addition, you can use the bin/psql.sh to load CSV data or execute SQL scripts. For example: + + $ psql.sh localhost ../examples/web_stat.sql ../examples/web_stat.csv ../examples/web_stat_queries.sql + +Other alternatives include: +* Using our [map-reduce based CSV loader](mr_dataload.html) for bigger data sets +* [Mapping an existing HBase table to a Phoenix table](index.html#Mapping-to-an-Existing-HBase-Table) and using the [UPSERT SELECT](language/index.html#upsert_select) command to populate a new table. +* Populating the table through our [UPSERT VALUES](language/index.html#upsert_values) command. + +

SQL Client

+ +If you'd rather use a client GUI to interact with Phoenix, download and install [SQuirrel](http://squirrel-sql.sourceforge.net/). Since Phoenix is a JDBC driver, integration with tools such as this are seamless. Here are the setup steps necessary: + +1. Remove prior phoenix-[version]-client.jar from the lib directory of SQuirrel +2. Copy the phoenix-[version]-client.jar into the lib directory of SQuirrel (Note that on a Mac, this is the *internal* lib directory). +3. Start SQuirrel and add new driver to SQuirrel (Drivers -> New Driver) +4. In Add Driver dialog box, set Name to Phoenix +5. Press List Drivers button and org.apache.phoenix.jdbc.PhoenixDriver should be automatically populated in the Class Name textbox. Press OK to close this dialog. +6. Switch to Alias tab and create the new Alias (Aliases -> New Aliases) +7. In the dialog box, Name: _any name_, Driver: Phoenix, User Name: _anything_, Password: _anything_ +8. Construct URL as follows: jdbc:phoenix: _zookeeper quorum server_. For example, to connect to a local HBase use: jdbc:phoenix:localhost +9. Press Test (which should succeed if everything is setup correctly) and press OK to close. +10. Now double click on your newly created Phoenix alias and click Connect. Now you are ready to run SQL queries against Phoenix. + +Through SQuirrel, you can issue SQL statements in the SQL tab (create tables, insert data, run queries), and inspect table metadata in the Object tab (i.e. list tables, their columns, primary keys, and types). + +![squirrel](images/squirrel.png) + +### Samples ### +The best place to see samples are in our unit tests under src/test/java. The ones in the endToEnd package are tests demonstrating how to use all aspects of the Phoenix JDBC driver. We also have some examples in the examples directory. + +### Phoenix Client - Server Compatibility + +Major and minor version should match between client and server (patch version can mismatch). Following is the list of compatible client and server version(s). It is recommended that same client and server version are used. + +Phoenix Client Version | Compatible Server Versions +-----------------------|--- +1.0.0 | 1.0.0 +1.1.0 | 1.1.0 +1.2.0 | 1.2.0, 1.2.1 +1.2.1 | 1.2.0, 1.2.1 +2.0.0 | 2.0.0, 2.0.1, 2.0.2 +2.0.1 | 2.0.0, 2.0.1, 2.0.2 +2.0.2 | 2.0.0, 2.0.1, 2.0.2 +2.1.0 | 2.1.0, 2.1.1, 2.1.2 +2.1.1 | 2.1.0, 2.1.1, 2.1.2 +2.1.2 | 2.1.0, 2.1.1, 2.1.2 +2.2.0 | 2.2.0, 2.2.1 +2.2.1 | 2.2.0, 2.2.1 + +[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/33878dc7c0522eed32d2d54db9c59f78 "githalytics.com")](http://githalytics.com/forcedotcom/phoenix.git) diff --git a/phoenix-core/src/site/markdown/dynamic_columns.md b/phoenix-core/src/site/markdown/dynamic_columns.md new file mode 100644 index 00000000..0c7d9ce2 --- /dev/null +++ b/phoenix-core/src/site/markdown/dynamic_columns.md @@ -0,0 +1,17 @@ +# Dynamic Columns + +Sometimes defining a static schema up front is not feasible. Instead, a subset of columns may be specified at table [create](language/index.html#create) time while the rest would be specified at [query](language/index.html#select) time. As of Phoenix 1.2, specifying columns dynamically is now supported by allowing column definitions to included in parenthesis after the table in the FROM clause on a SELECT statement. Although this is not standard SQL, it is useful to surface this type of functionality to leverage the late binding ability of HBase. + +For example: + + SELECT eventTime, lastGCTime, usedMemory, maxMemory + FROM EventLog(lastGCTime TIME, usedMemory BIGINT, maxMemory BIGINT) + WHERE eventType = 'OOM' AND lastGCTime < eventTime - 1 + +Where you may have defined only a subset of your event columns at create time, since each event type may have different properties: + + CREATE TABLE EventLog ( + eventId BIGINT NOT NULL, + eventTime TIME NOT NULL, + eventType CHAR(3) NOT NULL + CONSTRAINT pk PRIMARY KEY (eventId, eventTime)) diff --git a/phoenix-core/src/site/markdown/faq.md b/phoenix-core/src/site/markdown/faq.md new file mode 100644 index 00000000..cbcfc0a1 --- /dev/null +++ b/phoenix-core/src/site/markdown/faq.md @@ -0,0 +1,279 @@ +# F.A.Q. + +* [I want to get started. Is there a Phoenix Hello World?](#I_want_to_get_started_Is_there_a_Phoenix_Hello_World) +* [Is there a way to bulk load in Phoenix?](#Is_there_a_way_to_bulk_load_in_Phoenix) +* [How do I create a VIEW in Phoenix? What's the difference between a VIEW and a TABLE?](#How_I_create_Views_in_Phoenix_Whatnulls_the_difference_between_ViewsTables) +* [Are there any tips for optimizing Phoenix?](#Are_there_any_tips_for_optimizing_Phoenix) +* [How do I create Secondary Index on a table?](#How_do_I_create_Secondary_Index_on_a_table) +* [Why isn't my secondary index being used?](#Why_isnnullt_my_secondary_index_being_used) +* [How fast is Phoenix? Why is it so fast?](#How_fast_is_Phoenix_Why_is_it_so_fast) +* [How do I connect to secure HBase cluster?](#How_do_I_connect_to_secure_HBase_cluster) +* [How do I connect with HBase running on Hadoop-2?](#How_do_I_connect_with_HBase_running_on_Hadoop-2) +* [Can phoenix work on tables with arbitrary timestamp as flexible as HBase API?](#Can_phoenix_work_on_tables_with_arbitrary_timestamp_as_flexible_as_HBase_API) +* [Why isn't my query doing a RANGE SCAN?](#Why_isnnullt_my_query_doing_a_RANGE_SCAN) + + +### I want to get started. Is there a Phoenix _Hello World_? + +*Pre-requisite:* Download latest Phoenix from [here](download.html) +and copy phoenix-*.jar to HBase lib folder and restart HBase. + +**1. Using console** + +1. Start Sqlline: `$ sqlline.sh [zookeeper]` +2. Execute the following statements when Sqlline connects: + +``` +create table test (mykey integer not null primary key, mycolumn varchar); +upsert into test values (1,'Hello'); +upsert into test values (2,'World!'); +select * from test; +``` + +3. You should get the following output + +``` ++-------+------------+ +| MYKEY | MYCOLUMN | ++-------+------------+ +| 1 | Hello | +| 2 | World! | ++-------+------------+ +``` + + +**2. Using java** + +Create test.java file with the following content: + +``` +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.PreparedStatement; +import java.sql.Statement; + +public class test { + + public static void main(String[] args) throws SQLException { + Statement stmt = null; + ResultSet rset = null; + + Connection con = DriverManager.getConnection("jdbc:phoenix:[zookeeper]"); + stmt = con.createStatement(); + + stmt.executeUpdate("create table test (mykey integer not null primary key, mycolumn varchar)"); + stmt.executeUpdate("upsert into test values (1,'Hello')"); + stmt.executeUpdate("upsert into test values (2,'World!')"); + con.commit(); + + PreparedStatement statement = con.prepareStatement("select * from test"); + rset = statement.executeQuery(); + while (rset.next()) { + System.out.println(rset.getString("mycolumn")); + } + statement.close(); + con.close(); + } +} +``` +Compile and execute on command line + +`$ javac test.java` + +`$ java -cp "../phoenix-[version]-client.jar:." test` + + +You should get the following output + +`Hello` +`World!` + + + +### Is there a way to bulk load in Phoenix? + +**Map Reduce** + +See the example [here](mr_dataload.html) Credit: Arun Singh + +**CSV** + +CSV data can be bulk loaded with built in utility named psql. Typical upsert rates are 20K - 50K rows per second (depends on how wide are the rows). + +Usage example: +Create table using psql +`$ psql.sh [zookeeper] ../examples/web_stat.sql` + +Upsert CSV bulk data +`$ psql.sh [zookeeper] ../examples/web_stat.csv` + + + +### How I create Views in Phoenix? What's the difference between Views/Tables? + +You can create both a Phoenix table or view through the CREATE TABLE/CREATE VIEW DDL statement on a pre-existing HBase table. In both cases, we'll leave the HBase metadata as-is, except for with a TABLE we turn KEEP_DELETED_CELLS on. For CREATE TABLE, we'll create any metadata (table, column families) that doesn't already exist. We'll also add an empty key value for each row so that queries behave as expected (without requiring all columns to be projected during scans). + +The other caveat is that the way the bytes were serialized must match the way the bytes are serialized by Phoenix. For VARCHAR,CHAR, and UNSIGNED_* types, we use the HBase Bytes methods. The CHAR type expects only single-byte characters and the UNSIGNED types expect values greater than or equal to zero. + +Our composite row keys are formed by simply concatenating the values together, with a zero byte character used as a separator after a variable length type. + +If you create an HBase table like this: + +`create 't1', {NAME => 'f1', VERSIONS => 5}` + +then you have an HBase table with a name of 't1' and a column family with a name of 'f1'. Remember, in HBase, you don't model the possible KeyValues or the structure of the row key. This is the information you specify in Phoenix above and beyond the table and column family. + +So in Phoenix, you'd create a view like this: + +`CREATE VIEW "t1" ( pk VARCHAR PRIMARY KEY, "f1".val VARCHAR )` + +The "pk" column declares that your row key is a VARCHAR (i.e. a string) while the "f1".val column declares that your HBase table will contain KeyValues with a column family and column qualifier of "f1":VAL and that their value will be a VARCHAR. + +Note that you don't need the double quotes if you create your HBase table with all caps names (since this is how Phoenix normalizes strings, by upper casing them). For example, with: + +`create 'T1', {NAME => 'F1', VERSIONS => 5}` + +you could create this Phoenix view: + +`CREATE VIEW t1 ( pk VARCHAR PRIMARY KEY, f1.val VARCHAR )` + +Or if you're creating new HBase tables, just let Phoenix do everything for you like this (No need to use the HBase shell at all.): + +`CREATE TABLE t1 ( pk VARCHAR PRIMARY KEY, val VARCHAR )` + + + +### Are there any tips for optimizing Phoenix? + +* Use **Salting** to increase read/write performance +Salting can significantly increase read/write performance by pre-splitting the data into multiple regions. Although Salting will yield better performance in most scenarios. + +Example: + +` CREATE TABLE TEST (HOST VARCHAR NOT NULL PRIMARY KEY, DESCRIPTION VARCHAR) SALT_BUCKETS=16` + +Note: Ideally for a 16 region server cluster with quad-core CPUs, choose salt buckets between 32-64 for optimal performance. + +* **Per-split** table +Salting does automatic table splitting but in case you want to exactly control where table split occurs with out adding extra byte or change row key order then you can pre-split a table. + +Example: + +` CREATE TABLE TEST (HOST VARCHAR NOT NULL PRIMARY KEY, DESCRIPTION VARCHAR) SPLIT ON ('CS','EU','NA')` + +* Use **multiple column families** + +Column family contains related data in separate files. If you query use selected columns then it make sense to group those columns together in a column family to improve read performance. + +Example: + +Following create table DDL will create two column familes A and B. + +` CREATE TABLE TEST (MYKEY VARCHAR NOT NULL PRIMARY KEY, A.COL1 VARCHAR, A.COL2 VARCHAR, B.COL3 VARCHAR)` + +* Use **compression** +On disk compression improves performance on large tables + +Example: + +` CREATE TABLE TEST (HOST VARCHAR NOT NULL PRIMARY KEY, DESCRIPTION VARCHAR) COMPRESSION='GZ'` + +* Create **indexes** +See [faq.html#/How_do_I_create_Secondary_Index_on_a_table](faq.html#/How_do_I_create_Secondary_Index_on_a_table) + +* **Optimize cluster** parameters +See http://hbase.apache.org/book/performance.html + +* **Optimize Phoenix** parameters +See [tuning.html](tuning.html) + + + +### How do I create Secondary Index on a table? + +Starting with Phoenix version 2.1, Phoenix supports index over mutable and immutable data. Note that Phoenix 2.0.x only supports Index over immutable data. Index write performance index with immutable table is slightly faster than mutable table however data in immutable table cannot be updated. + +Example + +* Create table + +Immutable table: `create table test (mykey varchar primary key, col1 varchar, col2 varchar) IMMUTABLE_ROWS=true;` + +Mutable table: `create table test (mykey varchar primary key, col1 varchar, col2 varchar);` + +* Creating index on col2 + +`create index idx on test (col2)` + +* Creating index on col1 and a covered index on col2 + +`create index idx on test (col1) include (col2)` + +Upsert rows in this test table and Phoenix query optimizer will choose correct index to use. You can see in [explain plan](language/index.html#explain) if Phoenix is using the index table. You can also give a [hint](language/index.html#hint) in Phoenix query to use a specific index. + + + +### Why isn't my secondary index being used? + +The secondary index won't be used unless all columns used in the query are in it ( as indexed or covered columns). All columns making up the primary key of the data table will automatically be included in the index. + +Example: DDL `create table usertable (id varchar primary key, firstname varchar, lastname varchar); create index idx_name on usertable (firstname);` + +Query: DDL `select id, firstname, lastname from usertable where firstname = 'foo';` + +Index would not be used in this case as lastname is not part of indexed or covered column. This can be verified by looking at the explain plan. To fix this create index that has either lastname part of index or covered column. Example: `create idx_name on usertable (firstname) include (lastname);` + + +### How fast is Phoenix? Why is it so fast? + +Phoenix is fast. Full table scan of 100M rows usually completes in 20 seconds (narrow table on a medium sized cluster). This time come down to few milliseconds if query contains filter on key columns. For filters on non-key columns or non-leading key columns, you can add index on these columns which leads to performance equivalent to filtering on key column by making copy of table with indexed column(s) part of key. + +Why is Phoenix fast even when doing full scan: + +1. Phoenix chunks up your query using the region boundaries and runs them in parallel on the client using a configurable number of threads +2. The aggregation will be done in a coprocessor on the server-side, collapsing the amount of data that gets returned back to the client rather than returning it all. + + + +### How do I connect to secure HBase cluster? +Check out excellent post by Anil Gupta +http://bigdatanoob.blogspot.com/2013/09/connect-phoenix-to-secure-hbase-cluster.html + + + +### How do I connect with HBase running on Hadoop-2? +Hadoop-2 profile exists in Phoenix pom.xml. + + +### Can phoenix work on tables with arbitrary timestamp as flexible as HBase API? +By default, Phoenix let's HBase manage the timestamps and just shows you the latest values for everything. However, Phoenix also allows arbitrary timestamps to be supplied by the user. To do that you'd specify a "CurrentSCN" (or PhoenixRuntime.CURRENT_SCN_ATTRIB if you want to use our constant) at connection time, like this: + + Properties props = new Properties(); + props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts)); + Connection conn = DriverManager.connect(myUrl, props); + + conn.createStatement().execute("UPSERT INTO myTable VALUES ('a')"); + conn.commit(); +The above is equivalent to doing this with the HBase API: + + myTable.put(Bytes.toBytes('a'),ts); +By specifying a CurrentSCN, you're telling Phoenix that you want everything for that connection to be done at that timestamp. Note that this applies to queries done on the connection as well - for example, a query over myTable above would not see the data it just upserted, since it only sees data that was created before its CurrentSCN property. This provides a way of doing snapshot, flashback, or point-in-time queries. + +Keep in mind that creating a new connection is *not* an expensive operation. The same underlying HConnection is used for all connections to the same cluster, so it's more or less like instantiating a few objects. + + +### Why isn't my query doing a RANGE SCAN? + +`DDL: CREATE TABLE TEST (pk1 char(1) not null, pk2 char(1) not null, pk3 char(1) not null, non-pk varchar CONSTRAINT PK PRIMARY KEY(pk1, pk2, pk3));` + +RANGE SCAN means that only a subset of the rows in your table will be scanned over. This occurs if you use one or more leading columns from your primary key constraint. Query that is not filtering on leading PK columns ex. `select * from test where pk2='x' and pk3='y';` will result in full scan whereas the following query will result in range scan `select * from test where pk1='x' and pk2='y';`. Note that you can add a secondary index on your "pk2" and "pk3" columns and that would cause a range scan to be done for the first query (over the index table). + +DEGENERATE SCAN means that a query can't possibly return any rows. If we can determine that at compile time, then we don't bother to even run the scan. + +FULL SCAN means that all rows of the table will be scanned over (potentially with a filter applied if you have a WHERE clause) + +SKIP SCAN means that either a subset or all rows in your table will be scanned over, however it will skip large groups of rows depending on the conditions in your filter. See this blog for more detail. We don't do a SKIP SCAN if you have no filter on the leading primary key columns, but you can force a SKIP SCAN by using the /*+ SKIP_SCAN */ hint. Under some conditions, namely when the cardinality of your leading primary key columns is low, it will be more efficient than a FULL SCAN. + + diff --git a/phoenix-core/src/site/markdown/flume.md b/phoenix-core/src/site/markdown/flume.md new file mode 100644 index 00000000..6cc9251a --- /dev/null +++ b/phoenix-core/src/site/markdown/flume.md @@ -0,0 +1,42 @@ +# Apache Flume Plugin + +The plugin enables us to reliably and efficiently stream large amounts of data/logs onto HBase using the Phoenix API. The necessary configuration of the custom Phoenix sink and the Event Serializer has to be configured in the Flume configuration file for the Agent. Currently, the only supported Event serializer is a RegexEventSerializer which primarily breaks the Flume Event body based on the regex specified in the configuration file. + +#### Prerequisites: + +* Phoenix v 3.0.0 SNAPSHOT + +* Flume 1.4.0 + + +#### Installation & Setup: + +1. Download and build Phoenix v 0.3.0 SNAPSHOT +2. Follow the instructions as specified [here](building.html) to build the project as the Flume plugin is still under beta +3. Create a directory plugins.d within $FLUME_HOME directory. Within that, create a sub-directories phoenix-sink/lib +4. Copy the generated phoenix-3.0.0-SNAPSHOT-client.jar onto $FLUME_HOME/plugins.d/phoenix-sink/lib + +#### Configuration: + +Property Name |Default| Description +--------------------------|-------|--- +type | |org.apache.phoenix.flume.sink.PhoenixSink +batchSize |100 |Default number of events per transaction +zookeeperQuorum | |Zookeeper quorum of the HBase cluster +table | |The name of the table in HBase to write to. +ddl | |The CREATE TABLE query for the HBase table where the events will be upserted to. If specified, the query will be executed. Recommended to include the IF NOT EXISTS clause in the ddl. +serializer |regex |Event serializers for processing the Flume Event . Currently , only regex is supported. +serializer.regex |(.*) |The regular expression for parsing the event. +serializer.columns | |The columns that will be extracted from the Flume event for inserting into HBase. +serializer.headers | |Headers of the Flume Events that go as part of the UPSERT query. The data type for these columns are VARCHAR by default. +serializer.rowkeyType | |A custom row key generator . Can be one of timestamp,date,uuid,random and nanotimestamp. This should be configured in cases where we need a custom row key value to be auto generated and set for the primary key column. + + +For an example configuration for ingesting Apache access logs onto Phoenix, see [this](https://github.com/forcedotcom/phoenix/blob/master/src/main/config/apache-access-logs.properties) property file. Here we are using UUID as a row key generator for the primary key. + +#### Starting the agent: + $ bin/flume-ng agent -f conf/flume-conf.properties -c ./conf -n agent + +#### Monitoring: + For monitoring the agent and the sink process , enable JMX via flume-env.sh($FLUME_HOME/conf/flume-env.sh) script. Ensure you have the following line uncommented. + + JAVA_OPTS="-Xms1g -Xmx1g -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=3141 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" + diff --git a/phoenix-core/src/site/markdown/index.md b/phoenix-core/src/site/markdown/index.md new file mode 100644 index 00000000..8b9f0b04 --- /dev/null +++ b/phoenix-core/src/site/markdown/index.md @@ -0,0 +1,69 @@ +# Overview + +Apache Phoenix is a SQL skin over HBase delivered as a client-embedded JDBC driver targeting low latency queries over HBase data. Apache Phoenix takes your SQL query, compiles it into a series of HBase scans, and orchestrates the running of those scans to produce regular JDBC result sets. The table metadata is stored in an HBase table and versioned, such that snapshot queries over prior versions will automatically use the correct schema. Direct use of the HBase API, along with coprocessors and custom filters, results in [performance](performance.html) on the order of milliseconds for small queries, or seconds for tens of millions of rows. + +## Mission +Become the standard means of accessing HBase data through a well-defined, industry standard API. + +## Quick Start +Tired of reading already and just want to get started? Take a look at our [FAQs](faq.html), listen to the Apache Phoenix talks from [Hadoop Summit 2013](http://www.youtube.com/watch?v=YHsHdQ08trg) and [HBaseConn 2013](http://www.cloudera.com/content/cloudera/en/resources/library/hbasecon/hbasecon-2013--how-and-why-phoenix-puts-the-sql-back-into-nosql-video.html), and jump over to our quick start guide [here](Phoenix-in-15-minutes-or-less.html). + +##SQL Support## +To see what's supported, go to our [language reference](language/index.html). It includes all typical SQL query statement clauses, including `SELECT`, `FROM`, `WHERE`, `GROUP BY`, `HAVING`, `ORDER BY`, etc. It also supports a full set of DML commands as well as table creation and versioned incremental alterations through our DDL commands. We try to follow the SQL standards wherever possible. + +Use JDBC to get a connection to an HBase cluster like this: + + Connection conn = DriverManager.getConnection("jdbc:phoenix:server1,server2:3333"); +where the connection string is composed of: +jdbc:phoenix [ :<zookeeper quorum> [ :<port number> ] [ :<root node> ] ] + +For any omitted part, the relevant property value, hbase.zookeeper.quorum, hbase.zookeeper.property.clientPort, and zookeeper.znode.parent will be used from hbase-site.xml configuration file. + +Here's a list of what is currently **not** supported: + +* **Full Transaction Support**. Although we allow client-side batching and rollback as described [here](#transactions), we do not provide transaction semantics above and beyond what HBase gives you out-of-the-box. +* **Derived tables**. Nested queries are coming soon. +* **Relational operators**. Union, Intersect, Minus. +* **Miscellaneous built-in functions**. These are easy to add - read this [blog](http://phoenix-hbase.blogspot.com/2013/04/how-to-add-your-own-built-in-function.html) for step by step instructions. + +##Schema## + +Apache Phoenix supports table creation and versioned incremental alterations through DDL commands. The table metadata is stored in an HBase table. + +A Phoenix table is created through the [CREATE TABLE](language/index.html#create) DDL command and can either be: + +1. **built from scratch**, in which case the HBase table and column families will be created automatically. +2. **mapped to an existing HBase table**, by creating either a read-write TABLE or a read-only VIEW, with the caveat that the binary representation of the row key and key values must match that of the Phoenix data types (see [Data Types reference](datatypes.html) for the detail on the binary representation). + * For a read-write TABLE, column families will be created automatically if they don't already exist. An empty key value will be added to the first column family of each existing row to minimize the size of the projection for queries. + * For a read-only VIEW, all column families must already exist. The only change made to the HBase table will be the addition of the Phoenix coprocessors used for query processing. The primary use case for a VIEW is to transfer existing data into a Phoenix table, since data modification are not allowed on a VIEW and query performance will likely be less than as with a TABLE. + +All schema is versioned, and prior versions are stored forever. Thus, snapshot queries over older data will pick up and use the correct schema for each row. + +####Salting +A table could also be declared as salted to prevent HBase region hot spotting. You just need to declare how many salt buckets your table has, and Phoenix will transparently manage the salting for you. You'll find more detail on this feature [here](salted.html), along with a nice comparison on write throughput between salted and unsalted tables [here](performance.htm#salting). + +####Schema at Read-time +Another schema-related feature allows columns to be defined dynamically at query time. This is useful in situations where you don't know in advance all of the columns at create time. You'll find more details on this feature [here](dynamic_columns.html). + +####Mapping to an Existing HBase Table +Apache Phoenix supports mapping to an existing HBase table through the [CREATE TABLE](language/index.html#create) and [CREATE VIEW](language/index.html#create) DDL statements. In both cases, the HBase metadata is left as-is, except for with CREATE TABLE the [KEEP_DELETED_CELLS](http://hbase.apache.org/book/cf.keep.deleted.html) option is enabled to allow for flashback queries to work correctly. For CREATE TABLE, any HBase metadata (table, column families) that doesn't already exist will be created. Note that the table and column family names are case sensitive, with Phoenix upper-casing all names. To make a name case sensitive in the DDL statement, surround it with double quotes as shown below: +
CREATE VIEW "MyTable" ("a".ID VARCHAR PRIMARY KEY)
+ +For CREATE TABLE, an empty key value will also be added for each row so that queries behave as expected (without requiring all columns to be projected during scans). For CREATE VIEW, this will not be done, nor will any HBase metadata be created. Instead the existing HBase metadata must match the metadata specified in the DDL statement or a ERROR 505 (42000): Table is read only will be thrown. + +The other caveat is that the way the bytes were serialized in HBase must match the way the bytes are expected to be serialized by Phoenix. For VARCHAR,CHAR, and UNSIGNED_* types, Phoenix uses the HBase Bytes utility methods to perform serialization. The CHAR type expects only single-byte characters and the UNSIGNED types expect values greater than or equal to zero. + +Our composite row keys are formed by simply concatenating the values together, with a zero byte character used as a separator after a variable length type. For more information on our type system, see the [Data Type](datatypes.html). + +##Transactions## +The DML commands of Apache Phoenix, [UPSERT VALUES](language/index.html#upsert_values), [UPSERT SELECT](language/index.html#upsert_select) and [DELETE](language/index.html#delete), batch pending changes to HBase tables on the client side. The changes are sent to the server when the transaction is committed and discarded when the transaction is rolled back. The only transaction isolation level we support is TRANSACTION_READ_COMMITTED. This includes not being able to see your own uncommitted data as well. Phoenix does not providing any additional transactional semantics beyond what HBase supports when a batch of mutations is submitted to the server. If auto commit is turned on for a connection, then Phoenix will, whenever possible, execute the entire DML command through a coprocessor on the server-side, so performance will improve. + +Most commonly, an application will let HBase manage timestamps. However, under some circumstances, an application needs to control the timestamps itself. In this case, a long-valued "CurrentSCN" property may be specified at connection time to control timestamps for any DDL, DML, or query. This capability may be used to run snapshot queries against prior row values, since Phoenix uses the value of this connection property as the max timestamp of scans. + +## Metadata ## +The catalog of tables, their columns, primary keys, and types may be retrieved via the java.sql metadata interfaces: `DatabaseMetaData`, `ParameterMetaData`, and `ResultSetMetaData`. For retrieving schemas, tables, and columns through the DatabaseMetaData interface, the schema pattern, table pattern, and column pattern are specified as in a LIKE expression (i.e. % and _ are wildcards escaped through the \ character). The table catalog argument to the metadata APIs deviates from a more standard relational database model, and instead is used to specify a column family name (in particular to see all columns in a given column family). + +
+## Disclaimer ## +Apache Phoenix is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the [Apache Incubator PMC](http://incubator.apache.org/). Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF. +

diff --git a/phoenix-core/src/site/markdown/issues.md b/phoenix-core/src/site/markdown/issues.md new file mode 100644 index 00000000..64ea3ca4 --- /dev/null +++ b/phoenix-core/src/site/markdown/issues.md @@ -0,0 +1,9 @@ +# Issue Tracking + +This project uses JIRA issue tracking and project management application. Issues, bugs, and feature requests should be submitted to the following: + +
+ +https://issues.apache.org/jira/browse/PHOENIX + +
diff --git a/phoenix-core/src/site/markdown/mailing_list.md b/phoenix-core/src/site/markdown/mailing_list.md new file mode 100644 index 00000000..fbe9e43c --- /dev/null +++ b/phoenix-core/src/site/markdown/mailing_list.md @@ -0,0 +1,14 @@ +# Mailing Lists + +These are the mailing lists that have been established for this project. For each list, there is a subscribe, unsubscribe and post link. + +
+ +Name| Subscribe| Unsubscribe| Post +--------------------------|----|----|---- +User List | [Subscribe](mailto:user-subscribe@phoenix.incubator.apache.org) | [Unsubscribe](mailto:user-unsubscribe@phoenix.incubator.apache.org) | [Post](mailto:user@phoenix.incubator.apache.org) +Developer List | [Subscribe](mailto:dev-subscribe@phoenix.incubator.apache.org) | [Unsubscribe](mailto:dev-unsubscribe@phoenix.incubator.apache.org) | [Post](mailto:dev@phoenix.incubator.apache.org) +Private List | [Subscribe](mailto:private-subscribe@phoenix.incubator.apache.org) | [Unsubscribe](mailto:private-unsubscribe@phoenix.incubator.apache.org) | [Post](mailto:private@phoenix.incubator.apache.org) +Commits List | [Subscribe](mailto:commits-subscribe@phoenix.incubator.apache.org) | [Unsubscribe](mailto:commits-unsubscribe@phoenix.incubator.apache.org) | [Post](mailto:commits@phoenix.incubator.apache.org) + +
diff --git a/phoenix-core/src/site/markdown/mr_dataload.md b/phoenix-core/src/site/markdown/mr_dataload.md new file mode 100644 index 00000000..b0053ac1 --- /dev/null +++ b/phoenix-core/src/site/markdown/mr_dataload.md @@ -0,0 +1,63 @@ +# Bulk CSV Data Load using Map-Reduce + +Phoenix v 2.1 provides support for loading CSV data into a new/existing Phoenix table using Hadoop Map-Reduce. This provides a means of bulk loading CSV data in parallel through map-reduce, yielding better performance in comparison with the existing [psql csv loader](download.html#Loading-Data). + +####Sample input CSV data: + +``` +12345, John, Doe +67890, Mary, Poppins +``` + +####Compatible Phoenix schema to hold the above CSV data: + + CREATE TABLE ns.example ( + my_pk bigint not null, + m.first_name varchar(50), + m.last_name varchar(50) + CONSTRAINT pk PRIMARY KEY (my_pk)) + + + + + + +
Row Key
Column Family (m)
my_pk BIGINTfirst_name VARCHAR(50)last_name VARCHAR(50)
12345JohnDoe
67890MaryPoppins
+ + +####How to run? + +1- Please make sure that Hadoop cluster is working correctly and you are able to run any job like [this](http://wiki.apache.org/hadoop/WordCount). + +2- Copy latest phoenix-[version].jar to hadoop/lib folder on each node or add it to Hadoop classpath. + +3- Run the bulk loader job using the script /bin/csv-bulk-loader.sh as below: + +``` +./csv-bulk-loader.sh