You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by xi...@apache.org on 2021/08/18 07:17:33 UTC
[pinot] branch master updated: Fix pinot-common code styling (#7311)
This is an automated email from the ASF dual-hosted git repository.
xiangfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new a539958 Fix pinot-common code styling (#7311)
a539958 is described below
commit a539958eef8480cf95e39ed4788543e3d094c7bf
Author: Xiang Fu <xi...@gmail.com>
AuthorDate: Wed Aug 18 00:17:19 2021 -0700
Fix pinot-common code styling (#7311)
* Enable maven checkstyle plugins by default for all new pinot components and fix pinot-spi styling (#7308)
* Adding checkstyle plugins
* Fix pinot-spi styling
* Fix json resources objects
* reformat
---
config/codestyle-intellij.xml | 1 +
config/suppressions.xml | 3 +
pinot-common/pom.xml | 3 -
.../main/java/org/apache/pinot/common/Utils.java | 7 +-
.../assignment/InstanceAssignmentConfigUtils.java | 33 +-
.../common/assignment/InstancePartitions.java | 6 +-
.../common/assignment/InstancePartitionsUtils.java | 26 +-
.../pinot/common/exception/QueryException.java | 33 +-
.../common/function/DateTimePatternHandler.java | 3 +
.../pinot/common/function/DateTimeUtils.java | 9 +-
.../function/FunctionDefinitionRegistry.java | 2 +
.../pinot/common/function/FunctionInvoker.java | 10 +-
.../pinot/common/function/FunctionRegistry.java | 10 +-
.../apache/pinot/common/function/TimeZoneKey.java | 43 +-
.../scalar/DataTypeConversionFunctions.java | 6 +-
.../common/function/scalar/DateTimeFunctions.java | 14 +-
.../common/function/scalar/HashFunctions.java | 1 +
.../common/function/scalar/JsonFunctions.java | 8 +-
.../apache/pinot/common/lineage/LineageEntry.java | 4 +-
.../common/lineage/SegmentLineageAccessHelper.java | 13 +-
.../messages/RoutingTableRebuildMessage.java | 1 +
.../pinot/common/metadata/ZKMetadataProvider.java | 72 +-
.../metadata/instance/InstanceZKMetadata.java | 6 +-
.../metadata/segment/SegmentPartitionMetadata.java | 3 +-
.../common/metadata/segment/SegmentZKMetadata.java | 10 +-
.../pinot/common/metrics/AbstractMetrics.java | 43 +-
.../apache/pinot/common/metrics/BrokerGauge.java | 18 +-
.../apache/pinot/common/metrics/BrokerMeter.java | 18 +-
.../apache/pinot/common/metrics/BrokerMetrics.java | 3 +-
.../pinot/common/metrics/BrokerQueryPhase.java | 15 +-
.../apache/pinot/common/metrics/BrokerTimer.java | 19 +-
.../pinot/common/metrics/ControllerGauge.java | 18 +-
.../pinot/common/metrics/ControllerMeter.java | 18 +-
.../pinot/common/metrics/ControllerTimer.java | 12 +-
.../apache/pinot/common/metrics/MinionGauge.java | 3 +-
.../pinot/common/metrics/MinionQueryPhase.java | 3 +-
.../apache/pinot/common/metrics/MinionTimer.java | 3 +
.../pinot/common/metrics/PinotMetricUtils.java | 36 +-
.../apache/pinot/common/metrics/ServerGauge.java | 18 +-
.../apache/pinot/common/metrics/ServerMeter.java | 18 +-
.../apache/pinot/common/metrics/ServerMetrics.java | 3 +-
.../pinot/common/metrics/ServerQueryPhase.java | 6 +-
.../apache/pinot/common/metrics/ServerTimer.java | 12 +-
.../pinot/common/metrics/ValidationMetrics.java | 27 +-
.../common/minion/MergeRollupTaskMetadata.java | 3 +-
.../apache/pinot/common/minion/MinionClient.java | 15 +-
.../common/minion/MinionTaskMetadataUtils.java | 40 +-
.../RealtimeToOfflineSegmentsTaskMetadata.java | 3 +-
.../protocols/SegmentCompletionProtocol.java | 71 +-
.../response/broker/BrokerResponseNative.java | 19 +-
.../common/response/broker/SelectionResults.java | 3 +-
.../common/restlet/resources/ResourceUtils.java | 4 +-
.../restlet/resources/SegmentConsumerInfo.java | 3 +-
.../common/restlet/resources/SegmentErrorInfo.java | 4 +-
.../restlet/resources/SegmentServerDebugInfo.java | 6 +-
.../common/restlet/resources/SegmentSizeInfo.java | 27 +-
.../resources/StartReplaceSegmentsRequest.java | 4 +-
.../restlet/resources/SystemResourceInfo.java | 6 +-
.../restlet/resources/TableMetadataInfo.java | 52 +-
.../common/restlet/resources/TableSegments.java | 10 +-
.../common/restlet/resources/TableSizeInfo.java | 28 +-
.../pinot/common/restlet/resources/TablesList.java | 2 +-
.../segment/generation/SegmentGenerationUtils.java | 13 +-
.../pinot/common/tier/TierSegmentSelector.java | 1 -
.../common/tier/TimeBasedTierSegmentSelector.java | 9 +-
.../common/utils/ClientSSLContextGenerator.java | 6 +-
.../org/apache/pinot/common/utils/DataSchema.java | 10 +-
.../org/apache/pinot/common/utils/DataTable.java | 6 +-
.../common/utils/FileUploadDownloadClient.java | 131 ++--
.../apache/pinot/common/utils/HLCSegmentName.java | 8 +-
.../org/apache/pinot/common/utils/HashUtil.java | 22 +-
.../apache/pinot/common/utils/LLCSegmentName.java | 6 +-
.../org/apache/pinot/common/utils/LLCUtils.java | 3 +
.../LikeToRegexpLikePatternConverterUtils.java | 3 +
.../pinot/common/utils/NamedThreadFactory.java | 17 +-
.../apache/pinot/common/utils/PinotAppConfigs.java | 54 +-
.../apache/pinot/common/utils/PinotDataType.java | 9 +-
.../pinot/common/utils/PrimitiveArrayUtils.java | 8 +-
.../org/apache/pinot/common/utils/SchemaUtils.java | 12 +-
.../apache/pinot/common/utils/SegmentUtils.java | 23 +-
.../apache/pinot/common/utils/ServiceStatus.java | 76 +-
.../org/apache/pinot/common/utils/StringUtil.java | 9 +-
.../pinot/common/utils/TarGzCompressionUtils.java | 22 +-
.../org/apache/pinot/common/utils/ZkStarter.java | 3 +
.../common/utils/config/TableConfigUtils.java | 28 +-
.../pinot/common/utils/config/TierConfigUtils.java | 16 +-
.../common/utils/fetcher/BaseSegmentFetcher.java | 5 +-
.../common/utils/fetcher/HttpSegmentFetcher.java | 17 +-
.../common/utils/fetcher/HttpsSegmentFetcher.java | 2 +-
.../utils/fetcher/SegmentFetcherFactory.java | 1 +
.../pinot/common/utils/grpc/GrpcQueryClient.java | 3 +-
.../common/utils/grpc/GrpcRequestBuilder.java | 7 +-
.../pinot/common/utils/helix/HelixHelper.java | 67 +-
.../common/utils/helix/LeadControllerUtils.java | 15 +-
.../PinotHelixPropertyStoreZnRecordProvider.java | 23 +-
.../common/utils/request/FilterQueryTree.java | 32 +-
.../pinot/common/utils/request/RequestUtils.java | 4 +-
.../common/utils/webhdfs/WebHdfsV1Client.java | 13 +-
.../utils/BrokerRequestComparisonUtils.java | 58 +-
.../parsers/PinotQuery2BrokerRequestConverter.java | 19 +-
.../pql/parsers/Pql2CompilationException.java | 3 +-
.../org/apache/pinot/pql/parsers/Pql2Compiler.java | 40 +-
.../parsers/pql2/ast/BetweenPredicateAstNode.java | 7 +-
.../pql2/ast/ComparisonPredicateAstNode.java | 8 +-
.../pinot/pql/parsers/pql2/ast/FilterKind.java | 4 +-
.../pql2/ast/FloatingPointLiteralAstNode.java | 10 +-
.../pql/parsers/pql2/ast/FunctionCallAstNode.java | 6 +-
.../pinot/pql/parsers/pql2/ast/OrderByAstNode.java | 15 +-
.../pql/parsers/pql2/ast/PredicateListAstNode.java | 3 +-
.../pinot/pql/parsers/pql2/ast/SelectAstNode.java | 4 +-
.../pql/parsers/pql2/ast/TableNameAstNode.java | 3 +-
.../pql2/ast/TextMatchPredicateAstNode.java | 3 +-
.../pinot/pql/parsers/pql2/ast/TopAstNode.java | 2 +-
.../org/apache/pinot/pql/parsers/utils/Pair.java | 16 +-
.../apache/pinot/sql/parsers/CalciteSqlParser.java | 74 +-
.../pinot/common/data/DateTimeFormatSpecTest.java | 138 ++--
.../apache/pinot/common/data/FieldSpecTest.java | 52 +-
.../org/apache/pinot/common/data/SchemaTest.java | 48 +-
.../function/AggregationFunctionTypeTest.java | 35 +-
.../pinot/common/function/JsonFunctionsTest.java | 67 +-
.../pinot/common/http/MultiGetRequestTest.java | 39 +-
.../pinot/common/lineage/SegmentLineageTest.java | 13 +-
.../metadata/MetadataEqualsHashCodeTest.java | 20 +-
.../pinot/common/metadata/MetadataUtils.java | 3 +
.../RealtimeToOfflineSegmentsTaskMetadataTest.java | 5 +-
.../common/metadata/SegmentZKMetadataTest.java | 39 +-
.../segment/ColumnPartitionMetadataTest.java | 3 +-
.../pinot/common/metrics/PinotMetricUtilsTest.java | 31 +-
.../pinot/common/minion/MinionClientTest.java | 11 +-
.../protocols/SegmentCompletionProtocolTest.java | 54 +-
.../transform/TransformExpressionTreeTest.java | 4 +-
.../generation/SegmentGenerationUtilsTest.java | 33 +-
.../pinot/common/tier/TierConfigUtilsTest.java | 41 +-
.../pinot/common/tier/TierSegmentSelectorTest.java | 10 +-
.../apache/pinot/common/utils/DataSchemaTest.java | 3 +-
.../pinot/common/utils/EqualityUtilsTest.java | 9 +-
.../common/utils/FileUploadDownloadClientTest.java | 26 +-
.../pinot/common/utils/PinotDataTypeTest.java | 40 +-
.../pinot/common/utils/SegmentNameBuilderTest.java | 14 +-
.../pinot/common/utils/ServiceStatusTest.java | 37 +-
.../apache/pinot/common/utils/URIUtilsTest.java | 16 +-
.../common/utils/config/InstanceUtilsTest.java | 3 +-
.../common/utils/config/TableConfigSerDeTest.java | 35 +-
.../common/utils/config/TableConfigUtilsTest.java | 25 +-
.../common/utils/config/TagNameUtilsTest.java | 7 +-
.../utils/fetcher/SegmentFetcherFactoryTest.java | 3 +-
.../apache/pinot/pql/parsers/Pql2CompilerTest.java | 128 ++-
.../request/BrokerRequestSerializationTest.java | 8 +-
.../pinot/request/BrokerResponseNativeTest.java | 7 +-
.../pinot/sql/parsers/CalciteSqlCompilerTest.java | 867 ++++++++-------------
.../test/java/org/apache/pinot/util/TestUtils.java | 6 +-
.../api/resources/ServerTableSizeReader.java | 2 +-
.../util/ServerSegmentMetadataReader.java | 34 +-
.../pinot/controller/util/TableSizeReader.java | 8 +-
.../controller/api/ServerTableSizeReaderTest.java | 18 +-
.../pinot/controller/api/TableSizeReaderTest.java | 7 +-
.../server/api/resources/TableSizeResource.java | 15 +-
.../pinot/server/api/resources/TablesResource.java | 19 +-
.../pinot/server/api/TableSizeResourceTest.java | 30 +-
.../org/apache/pinot/spi/config/ConfigUtils.java | 4 +-
.../org/apache/pinot/spi/config/TableConfigs.java | 3 +-
.../apache/pinot/spi/config/instance/Instance.java | 10 +-
.../pinot/spi/config/table/BloomFilterConfig.java | 3 +-
.../spi/config/table/StarTreeIndexConfig.java | 9 +-
.../apache/pinot/spi/config/table/TableConfig.java | 10 +-
.../apache/pinot/spi/config/table/TableStatus.java | 3 +-
.../pinot/spi/config/table/TableTaskConfig.java | 3 +-
.../apache/pinot/spi/config/table/TierConfig.java | 9 +-
.../table/assignment/InstanceAssignmentConfig.java | 9 +-
.../InstanceReplicaGroupPartitionConfig.java | 12 +-
.../table/assignment/InstanceTagPoolConfig.java | 11 +-
.../config/table/ingestion/TransformConfig.java | 3 +-
.../org/apache/pinot/spi/config/tenant/Tenant.java | 5 +-
.../apache/pinot/spi/data/DateTimeFieldSpec.java | 11 +-
.../pinot/spi/data/DateTimeFormatPatternSpec.java | 8 +-
.../apache/pinot/spi/data/DateTimeFormatSpec.java | 19 +-
.../pinot/spi/data/DateTimeFormatUnitSpec.java | 6 +-
.../pinot/spi/data/DateTimeGranularitySpec.java | 11 +-
.../apache/pinot/spi/data/DimensionFieldSpec.java | 8 +-
.../java/org/apache/pinot/spi/data/FieldSpec.java | 10 +-
.../org/apache/pinot/spi/data/MetricFieldSpec.java | 3 +-
.../java/org/apache/pinot/spi/data/Schema.java | 49 +-
.../pinot/spi/data/SchemaValidatorFactory.java | 12 +-
.../org/apache/pinot/spi/data/TimeFieldSpec.java | 5 +-
.../apache/pinot/spi/data/TimeGranularitySpec.java | 15 +-
.../apache/pinot/spi/data/readers/GenericRow.java | 6 +-
.../spi/data/readers/RecordReaderFactory.java | 31 +-
.../pinot/spi/env/CommonsConfigurationUtils.java | 3 +-
.../apache/pinot/spi/env/PinotConfiguration.java | 37 +-
.../PinotEnvironmentProviderFactory.java | 14 +-
.../pinot/spi/ingestion/batch/BatchConfig.java | 13 +-
.../spi/ingestion/batch/IngestionJobLauncher.java | 19 +-
.../org/apache/pinot/spi/plugin/PluginManager.java | 78 +-
.../apache/pinot/spi/stream/OffsetCriteria.java | 6 +-
.../stream/PartitionGroupConsumptionStatus.java | 3 +-
.../spi/stream/PartitionGroupMetadataFetcher.java | 7 +-
.../pinot/spi/stream/PartitionLevelConsumer.java | 3 +-
.../spi/stream/PartitionLevelStreamConfig.java | 12 +-
.../org/apache/pinot/spi/stream/StreamConfig.java | 78 +-
.../pinot/spi/stream/StreamConfigProperties.java | 3 +-
.../pinot/spi/stream/StreamConsumerFactory.java | 4 +-
.../pinot/spi/stream/StreamDecoderProvider.java | 3 +-
.../pinot/spi/stream/StreamMetadataProvider.java | 14 +-
.../apache/pinot/spi/utils/CommonConstants.java | 78 +-
.../org/apache/pinot/spi/utils/DataSizeUtils.java | 3 +-
.../pinot/spi/utils/IngestionConfigUtils.java | 31 +-
.../java/org/apache/pinot/spi/utils/JsonUtils.java | 51 +-
.../pinot/spi/utils/PinotReflectionUtils.java | 8 +-
.../java/org/apache/pinot/spi/utils/ReadMode.java | 3 +-
.../org/apache/pinot/spi/utils/TimeConverter.java | 8 +-
.../java/org/apache/pinot/spi/utils/TimeUtils.java | 10 +-
.../spi/utils/builder/TableConfigBuilder.java | 9 +-
.../apache/pinot/spi/config/ConfigUtilsTest.java | 40 +-
.../pinot/spi/config/table/IndexingConfigTest.java | 3 +-
.../pinot/spi/data/DateTimeFieldSpecUtilsTest.java | 44 +-
.../spi/data/readers/AbstractRecordReaderTest.java | 18 +-
.../spi/data/readers/RecordReaderFactoryTest.java | 12 +-
.../pinot/spi/env/PinotConfigurationTest.java | 3 +-
.../PinotEnvironmentProviderFactoryTest.java | 17 +-
.../pinot/spi/filesystem/LocalPinotFSTest.java | 13 +-
.../pinot/spi/ingestion/batch/BatchConfigTest.java | 9 +-
.../ingestion/batch/IngestionJobLauncherTest.java | 27 +-
.../apache/pinot/spi/plugin/PluginManagerTest.java | 50 +-
.../pinot/spi/utils/GroovyTemplateUtilsTest.java | 16 +-
.../pinot/spi/utils/IngestionConfigUtilsTest.java | 24 +-
.../org/apache/pinot/spi/utils/JsonUtilsTest.java | 80 +-
.../apache/pinot/spi/utils/TimeConverterTest.java | 15 +-
.../spi/utils/builder/TableNameBuilderTest.java | 3 +-
.../pinot/spi/utils/retry/RetryPolicyTest.java | 9 +-
229 files changed, 2282 insertions(+), 2779 deletions(-)
diff --git a/config/codestyle-intellij.xml b/config/codestyle-intellij.xml
index c02259a..d5ef7f1 100644
--- a/config/codestyle-intellij.xml
+++ b/config/codestyle-intellij.xml
@@ -436,6 +436,7 @@
<option name="TERNARY_OPERATION_WRAP" value="1"/>
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true"/>
<option name="FOR_STATEMENT_WRAP" value="1"/>
+ <option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
<option name="ARRAY_INITIALIZER_WRAP" value="1"/>
<option name="IF_BRACE_FORCE" value="3"/>
<option name="DOWHILE_BRACE_FORCE" value="3"/>
diff --git a/config/suppressions.xml b/config/suppressions.xml
index f7c3459..03e6c68 100644
--- a/config/suppressions.xml
+++ b/config/suppressions.xml
@@ -27,4 +27,7 @@
<!-- Suppress autogenerated files by thrift compiler -->
<suppress checks=".*" files="/common/request/.*.java"/>
<suppress checks=".*" files="/common/response/ProcessingException.java"/>
+
+ <!-- Suppress autogenerated parser files -->
+ <suppress checks=".*" files="target/generated-sources"/>
</suppressions>
diff --git a/pinot-common/pom.xml b/pinot-common/pom.xml
index b1ad508..32856d2 100644
--- a/pinot-common/pom.xml
+++ b/pinot-common/pom.xml
@@ -33,9 +33,6 @@
<url>https://pinot.apache.org/</url>
<properties>
<pinot.root>${basedir}/..</pinot.root>
-
- <!-- TODO: delete this prop once all the checkstyle warnings are fixed -->
- <checkstyle.fail.on.violation>false</checkstyle.fail.on.violation>
</properties>
<build>
<!-- Antlr stuff -->
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/Utils.java b/pinot-common/src/main/java/org/apache/pinot/common/Utils.java
index 313ac62..da4c1d6 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/Utils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/Utils.java
@@ -32,6 +32,9 @@ import org.slf4j.LoggerFactory;
public class Utils {
+ private Utils() {
+ }
+
private static final Logger LOGGER = LoggerFactory.getLogger(Utils.class);
/**
@@ -62,10 +65,10 @@ public class Utils {
}
}
- private static final AtomicLong _uniqueIdGen = new AtomicLong(1);
+ private static final AtomicLong UNIQUE_ID_GEN = new AtomicLong(1);
public static long getUniqueId() {
- return _uniqueIdGen.incrementAndGet();
+ return UNIQUE_ID_GEN.incrementAndGet();
}
/**
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/assignment/InstanceAssignmentConfigUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/assignment/InstanceAssignmentConfigUtils.java
index 8a8b08b..f3d0dab 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/assignment/InstanceAssignmentConfigUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/assignment/InstanceAssignmentConfigUtils.java
@@ -43,29 +43,25 @@ public class InstanceAssignmentConfigUtils {
* backward-compatibility) COMPLETED server tag is overridden to be different from the CONSUMING server tag.
*/
public static boolean shouldRelocateCompletedSegments(TableConfig tableConfig) {
- Map<InstancePartitionsType, InstanceAssignmentConfig> instanceAssignmentConfigMap =
- tableConfig.getInstanceAssignmentConfigMap();
- return (instanceAssignmentConfigMap != null
- && instanceAssignmentConfigMap.get(InstancePartitionsType.COMPLETED) != null) || TagNameUtils
- .isRelocateCompletedSegments(tableConfig.getTenantConfig());
+ Map<InstancePartitionsType, InstanceAssignmentConfig> instanceAssignmentConfigMap = tableConfig.getInstanceAssignmentConfigMap();
+ return (instanceAssignmentConfigMap != null && instanceAssignmentConfigMap.get(InstancePartitionsType.COMPLETED) != null)
+ || TagNameUtils.isRelocateCompletedSegments(tableConfig.getTenantConfig());
}
/**
* Returns whether the instance assignment is allowed for the given table config and instance partitions type.
*/
- public static boolean allowInstanceAssignment(TableConfig tableConfig,
- InstancePartitionsType instancePartitionsType) {
+ public static boolean allowInstanceAssignment(TableConfig tableConfig, InstancePartitionsType instancePartitionsType) {
TableType tableType = tableConfig.getTableType();
- Map<InstancePartitionsType, InstanceAssignmentConfig> instanceAssignmentConfigMap =
- tableConfig.getInstanceAssignmentConfigMap();
+ Map<InstancePartitionsType, InstanceAssignmentConfig> instanceAssignmentConfigMap = tableConfig.getInstanceAssignmentConfigMap();
switch (instancePartitionsType) {
// Allow OFFLINE instance assignment if the offline table has it configured or (for backward-compatibility) is
// using replica-group segment assignment
case OFFLINE:
- return tableType == TableType.OFFLINE && ((instanceAssignmentConfigMap != null
- && instanceAssignmentConfigMap.get(InstancePartitionsType.OFFLINE) != null)
- || AssignmentStrategy.REPLICA_GROUP_SEGMENT_ASSIGNMENT_STRATEGY
- .equalsIgnoreCase(tableConfig.getValidationConfig().getSegmentAssignmentStrategy()));
+ return tableType == TableType.OFFLINE && (
+ (instanceAssignmentConfigMap != null && instanceAssignmentConfigMap.get(InstancePartitionsType.OFFLINE) != null)
+ || AssignmentStrategy.REPLICA_GROUP_SEGMENT_ASSIGNMENT_STRATEGY
+ .equalsIgnoreCase(tableConfig.getValidationConfig().getSegmentAssignmentStrategy()));
// Allow CONSUMING/COMPLETED instance assignment if the real-time table has it configured
case CONSUMING:
case COMPLETED:
@@ -85,8 +81,7 @@ public class InstanceAssignmentConfigUtils {
"Instance assignment is not allowed for the given table config");
// Use the instance assignment config from the table config if it exists
- Map<InstancePartitionsType, InstanceAssignmentConfig> instanceAssignmentConfigMap =
- tableConfig.getInstanceAssignmentConfigMap();
+ Map<InstancePartitionsType, InstanceAssignmentConfig> instanceAssignmentConfigMap = tableConfig.getInstanceAssignmentConfigMap();
if (instanceAssignmentConfigMap != null) {
InstanceAssignmentConfig instanceAssignmentConfig = instanceAssignmentConfigMap.get(instancePartitionsType);
if (instanceAssignmentConfig != null) {
@@ -108,15 +103,15 @@ public class InstanceAssignmentConfigUtils {
String partitionColumn = replicaGroupStrategyConfig.getPartitionColumn();
if (partitionColumn != null) {
int numPartitions = tableConfig.getIndexingConfig().getSegmentPartitionConfig().getNumPartitions(partitionColumn);
- Preconditions.checkState(numPartitions > 0, "Number of partitions for column: %s is not properly configured",
- partitionColumn);
+ Preconditions.checkState(numPartitions > 0, "Number of partitions for column: %s is not properly configured", partitionColumn);
replicaGroupPartitionConfig = new InstanceReplicaGroupPartitionConfig(true, 0, numReplicaGroups, 0, numPartitions,
replicaGroupStrategyConfig.getNumInstancesPerPartition());
} else {
// If partition column is not configured, use replicaGroupStrategyConfig.getNumInstancesPerPartition() as
// number of instances per replica-group for backward-compatibility
- replicaGroupPartitionConfig = new InstanceReplicaGroupPartitionConfig(true, 0, numReplicaGroups,
- replicaGroupStrategyConfig.getNumInstancesPerPartition(), 0, 0);
+ replicaGroupPartitionConfig =
+ new InstanceReplicaGroupPartitionConfig(true, 0, numReplicaGroups, replicaGroupStrategyConfig.getNumInstancesPerPartition(), 0,
+ 0);
}
return new InstanceAssignmentConfig(tagPoolConfig, null, replicaGroupPartitionConfig);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/assignment/InstancePartitions.java b/pinot-common/src/main/java/org/apache/pinot/common/assignment/InstancePartitions.java
index 6c3df96..fd99e1a 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/assignment/InstancePartitions.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/assignment/InstancePartitions.java
@@ -70,8 +70,7 @@ public class InstancePartitions {
}
@JsonCreator
- private InstancePartitions(
- @JsonProperty(value = "instancePartitionsName", required = true) String instancePartitionsName,
+ private InstancePartitions(@JsonProperty(value = "instancePartitionsName", required = true) String instancePartitionsName,
@JsonProperty(value = "partitionToInstancesMap", required = true) Map<String, List<String>> partitionToInstancesMap) {
_instancePartitionsName = instancePartitionsName;
_partitionToInstancesMap = partitionToInstancesMap;
@@ -105,8 +104,7 @@ public class InstancePartitions {
}
public List<String> getInstances(int partitionId, int replicaGroupId) {
- return _partitionToInstancesMap
- .get(Integer.toString(partitionId) + PARTITION_REPLICA_GROUP_SEPARATOR + replicaGroupId);
+ return _partitionToInstancesMap.get(Integer.toString(partitionId) + PARTITION_REPLICA_GROUP_SEPARATOR + replicaGroupId);
}
public void setInstances(int partitionId, int replicaGroupId, List<String> instances) {
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/assignment/InstancePartitionsUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/assignment/InstancePartitionsUtils.java
index b6dd5a3..f2b06d4 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/assignment/InstancePartitionsUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/assignment/InstancePartitionsUtils.java
@@ -63,8 +63,8 @@ public class InstancePartitionsUtils {
// Fetch the instance partitions from property store if it exists
ZkHelixPropertyStore<ZNRecord> propertyStore = helixManager.getHelixPropertyStore();
- InstancePartitions instancePartitions = fetchInstancePartitions(propertyStore,
- getInstancePartitionsName(tableNameWithType, instancePartitionsType.toString()));
+ InstancePartitions instancePartitions =
+ fetchInstancePartitions(propertyStore, getInstancePartitionsName(tableNameWithType, instancePartitionsType.toString()));
if (instancePartitions != null) {
return instancePartitions;
}
@@ -77,8 +77,7 @@ public class InstancePartitionsUtils {
* Fetches the instance partitions from Helix property store.
*/
@Nullable
- public static InstancePartitions fetchInstancePartitions(HelixPropertyStore<ZNRecord> propertyStore,
- String instancePartitionsName) {
+ public static InstancePartitions fetchInstancePartitions(HelixPropertyStore<ZNRecord> propertyStore, String instancePartitionsName) {
String path = ZKMetadataProvider.constructPropertyStorePathForInstancePartitions(instancePartitionsName);
ZNRecord znRecord = propertyStore.get(path, null, AccessOption.PERSISTENT);
return znRecord != null ? InstancePartitions.fromZNRecord(znRecord) : null;
@@ -107,8 +106,7 @@ public class InstancePartitionsUtils {
default:
throw new IllegalStateException();
}
- return computeDefaultInstancePartitionsForTag(helixManager, tableConfig.getTableName(),
- instancePartitionsType.toString(), serverTag);
+ return computeDefaultInstancePartitionsForTag(helixManager, tableConfig.getTableName(), instancePartitionsType.toString(), serverTag);
}
/**
@@ -117,8 +115,8 @@ public class InstancePartitionsUtils {
* <p>Choose both enabled and disabled instances with the server tag as the qualified instances to avoid unexpected
* data shuffling when instances get disabled.
*/
- public static InstancePartitions computeDefaultInstancePartitionsForTag(HelixManager helixManager,
- String tableNameWithType, String instancePartitionsType, String serverTag) {
+ public static InstancePartitions computeDefaultInstancePartitionsForTag(HelixManager helixManager, String tableNameWithType,
+ String instancePartitionsType, String serverTag) {
List<String> instances = HelixHelper.getInstancesWithTag(helixManager, serverTag);
int numInstances = instances.size();
Preconditions.checkState(numInstances > 0, "No instance found with tag: %s", serverTag);
@@ -126,8 +124,7 @@ public class InstancePartitionsUtils {
// Sort the instances and rotate the list based on the table name
instances.sort(null);
Collections.rotate(instances, -(Math.abs(tableNameWithType.hashCode()) % numInstances));
- InstancePartitions instancePartitions =
- new InstancePartitions(getInstancePartitionsName(tableNameWithType, instancePartitionsType));
+ InstancePartitions instancePartitions = new InstancePartitions(getInstancePartitionsName(tableNameWithType, instancePartitionsType));
instancePartitions.setInstances(0, 0, instances);
return instancePartitions;
}
@@ -135,10 +132,8 @@ public class InstancePartitionsUtils {
/**
* Persists the instance partitions to Helix property store.
*/
- public static void persistInstancePartitions(HelixPropertyStore<ZNRecord> propertyStore,
- InstancePartitions instancePartitions) {
- String path = ZKMetadataProvider
- .constructPropertyStorePathForInstancePartitions(instancePartitions.getInstancePartitionsName());
+ public static void persistInstancePartitions(HelixPropertyStore<ZNRecord> propertyStore, InstancePartitions instancePartitions) {
+ String path = ZKMetadataProvider.constructPropertyStorePathForInstancePartitions(instancePartitions.getInstancePartitionsName());
if (!propertyStore.set(path, instancePartitions.toZNRecord(), AccessOption.PERSISTENT)) {
throw new ZkException("Failed to persist instance partitions: " + instancePartitions);
}
@@ -147,8 +142,7 @@ public class InstancePartitionsUtils {
/**
* Removes the instance partitions from Helix property store.
*/
- public static void removeInstancePartitions(HelixPropertyStore<ZNRecord> propertyStore,
- String instancePartitionsName) {
+ public static void removeInstancePartitions(HelixPropertyStore<ZNRecord> propertyStore, String instancePartitionsName) {
String path = ZKMetadataProvider.constructPropertyStorePathForInstancePartitions(instancePartitionsName);
if (!propertyStore.remove(path, AccessOption.PERSISTENT)) {
throw new ZkException("Failed to remove instance partitions: " + instancePartitionsName);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/exception/QueryException.java b/pinot-common/src/main/java/org/apache/pinot/common/exception/QueryException.java
index 9080d2b..35ffa92 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/exception/QueryException.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/exception/QueryException.java
@@ -69,38 +69,27 @@ public class QueryException {
public static final ProcessingException JSON_COMPILATION_ERROR = new ProcessingException(JSON_COMPILATION_ERROR_CODE);
public static final ProcessingException PQL_PARSING_ERROR = new ProcessingException(PQL_PARSING_ERROR_CODE);
public static final ProcessingException ACCESS_DENIED_ERROR = new ProcessingException(ACCESS_DENIED_ERROR_CODE);
- public static final ProcessingException SEGMENT_PLAN_EXECUTION_ERROR =
- new ProcessingException(SEGMENT_PLAN_EXECUTION_ERROR_CODE);
+ public static final ProcessingException SEGMENT_PLAN_EXECUTION_ERROR = new ProcessingException(SEGMENT_PLAN_EXECUTION_ERROR_CODE);
public static final ProcessingException COMBINE_SEGMENT_PLAN_TIMEOUT_ERROR =
new ProcessingException(COMBINE_SEGMENT_PLAN_TIMEOUT_ERROR_CODE);
- public static final ProcessingException TABLE_DOES_NOT_EXIST_ERROR =
- new ProcessingException(TABLE_DOES_NOT_EXIST_ERROR_CODE);
+ public static final ProcessingException TABLE_DOES_NOT_EXIST_ERROR = new ProcessingException(TABLE_DOES_NOT_EXIST_ERROR_CODE);
public static final ProcessingException QUERY_EXECUTION_ERROR = new ProcessingException(QUERY_EXECUTION_ERROR_CODE);
- public static final ProcessingException SERVER_SCHEDULER_DOWN_ERROR =
- new ProcessingException(SERVER_SHUTTING_DOWN_ERROR_CODE);
- public static final ProcessingException SERVER_OUT_OF_CAPACITY_ERROR =
- new ProcessingException(SERVER_OUT_OF_CAPACITY_ERROR_CODE);
- public static final ProcessingException SERVER_TABLE_MISSING_ERROR =
- new ProcessingException(SERVER_TABLE_MISSING_ERROR_CODE);
- public static final ProcessingException QUERY_SCHEDULING_TIMEOUT_ERROR =
- new ProcessingException(QUERY_SCHEDULING_TIMEOUT_ERROR_CODE);
- public static final ProcessingException EXECUTION_TIMEOUT_ERROR =
- new ProcessingException(EXECUTION_TIMEOUT_ERROR_CODE);
+ public static final ProcessingException SERVER_SCHEDULER_DOWN_ERROR = new ProcessingException(SERVER_SHUTTING_DOWN_ERROR_CODE);
+ public static final ProcessingException SERVER_OUT_OF_CAPACITY_ERROR = new ProcessingException(SERVER_OUT_OF_CAPACITY_ERROR_CODE);
+ public static final ProcessingException SERVER_TABLE_MISSING_ERROR = new ProcessingException(SERVER_TABLE_MISSING_ERROR_CODE);
+ public static final ProcessingException QUERY_SCHEDULING_TIMEOUT_ERROR = new ProcessingException(QUERY_SCHEDULING_TIMEOUT_ERROR_CODE);
+ public static final ProcessingException EXECUTION_TIMEOUT_ERROR = new ProcessingException(EXECUTION_TIMEOUT_ERROR_CODE);
public static final ProcessingException BROKER_GATHER_ERROR = new ProcessingException(BROKER_GATHER_ERROR_CODE);
- public static final ProcessingException DATA_TABLE_DESERIALIZATION_ERROR =
- new ProcessingException(DATA_TABLE_DESERIALIZATION_ERROR_CODE);
+ public static final ProcessingException DATA_TABLE_DESERIALIZATION_ERROR = new ProcessingException(DATA_TABLE_DESERIALIZATION_ERROR_CODE);
public static final ProcessingException FUTURE_CALL_ERROR = new ProcessingException(FUTURE_CALL_ERROR_CODE);
public static final ProcessingException BROKER_TIMEOUT_ERROR = new ProcessingException(BROKER_TIMEOUT_ERROR_CODE);
- public static final ProcessingException BROKER_RESOURCE_MISSING_ERROR =
- new ProcessingException(BROKER_RESOURCE_MISSING_ERROR_CODE);
- public static final ProcessingException BROKER_INSTANCE_MISSING_ERROR =
- new ProcessingException(BROKER_INSTANCE_MISSING_ERROR_CODE);
+ public static final ProcessingException BROKER_RESOURCE_MISSING_ERROR = new ProcessingException(BROKER_RESOURCE_MISSING_ERROR_CODE);
+ public static final ProcessingException BROKER_INSTANCE_MISSING_ERROR = new ProcessingException(BROKER_INSTANCE_MISSING_ERROR_CODE);
public static final ProcessingException INTERNAL_ERROR = new ProcessingException(INTERNAL_ERROR_CODE);
public static final ProcessingException MERGE_RESPONSE_ERROR = new ProcessingException(MERGE_RESPONSE_ERROR_CODE);
public static final ProcessingException FEDERATED_BROKER_UNAVAILABLE_ERROR =
new ProcessingException(FEDERATED_BROKER_UNAVAILABLE_ERROR_CODE);
- public static final ProcessingException COMBINE_GROUP_BY_EXCEPTION_ERROR =
- new ProcessingException(COMBINE_GROUP_BY_EXCEPTION_ERROR_CODE);
+ public static final ProcessingException COMBINE_GROUP_BY_EXCEPTION_ERROR = new ProcessingException(COMBINE_GROUP_BY_EXCEPTION_ERROR_CODE);
public static final ProcessingException QUERY_VALIDATION_ERROR = new ProcessingException(QUERY_VALIDATION_ERROR_CODE);
public static final ProcessingException UNKNOWN_ERROR = new ProcessingException(UNKNOWN_ERROR_CODE);
public static final ProcessingException QUOTA_EXCEEDED_ERROR = new ProcessingException(TOO_MANY_REQUESTS_ERROR_CODE);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/DateTimePatternHandler.java b/pinot-common/src/main/java/org/apache/pinot/common/function/DateTimePatternHandler.java
index 08f9bff..078c0ca 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/function/DateTimePatternHandler.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/function/DateTimePatternHandler.java
@@ -26,6 +26,9 @@ import org.joda.time.format.DateTimeFormatter;
* Handles DateTime conversions from long to strings and strings to longs based on passed patterns
*/
public class DateTimePatternHandler {
+ private DateTimePatternHandler() {
+ }
+
/**
* Converts the dateTimeString of passed pattern into a long of the millis since epoch
*/
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/DateTimeUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/function/DateTimeUtils.java
index 7bf3a6a..f1bdc25 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/function/DateTimeUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/function/DateTimeUtils.java
@@ -36,6 +36,8 @@ import org.slf4j.LoggerFactory;
* Helper methods and constructs for datetrunc function
*/
public class DateTimeUtils {
+ private DateTimeUtils() {
+ }
private static final Logger LOGGER = LoggerFactory.getLogger(DateTimeUtils.class);
private static final DateTimeFieldType QUARTER_OF_YEAR = new QuarterOfYearDateTimeField();
@@ -60,8 +62,9 @@ public class DateTimeUtils {
return QUARTER_OF_YEAR.getField(chronology);
case "year":
return chronology.year();
+ default:
+ throw new IllegalArgumentException("'" + unitString + "' is not a valid Timestamp field");
}
- throw new IllegalArgumentException("'" + unitString + "' is not a valid Timestamp field");
}
public static ISOChronology getChronology(TimeZoneKey timeZoneKey) {
@@ -132,8 +135,8 @@ public class DateTimeUtils {
@Override
public DateTimeField getField(Chronology chronology) {
- return new OffsetDateTimeField(
- new DividedDateTimeField(new OffsetDateTimeField(chronology.monthOfYear(), -1), QUARTER_OF_YEAR, 3), 1);
+ return new OffsetDateTimeField(new DividedDateTimeField(new OffsetDateTimeField(chronology.monthOfYear(), -1), QUARTER_OF_YEAR, 3),
+ 1);
}
private static class QuarterOfYearDurationFieldType extends DurationFieldType {
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionDefinitionRegistry.java b/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionDefinitionRegistry.java
index 79fb5cb..f934e9b 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionDefinitionRegistry.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionDefinitionRegistry.java
@@ -25,6 +25,8 @@ import org.apache.pinot.segment.spi.AggregationFunctionType;
* Place where all functions are registered.
*/
public class FunctionDefinitionRegistry {
+ private FunctionDefinitionRegistry() {
+ }
public static boolean isAggFunc(String functionName) {
try {
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionInvoker.java b/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionInvoker.java
index b185d26..92b02ad 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionInvoker.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionInvoker.java
@@ -89,8 +89,9 @@ public class FunctionInvoker {
*/
public void convertTypes(Object[] arguments) {
int numParameters = _parameterClasses.length;
- Preconditions.checkArgument(arguments.length == numParameters,
- "Wrong number of arguments for method: %s, expected: %s, actual: %s", _method, numParameters, arguments.length);
+ Preconditions
+ .checkArgument(arguments.length == numParameters, "Wrong number of arguments for method: %s, expected: %s, actual: %s", _method,
+ numParameters, arguments.length);
for (int i = 0; i < numParameters; i++) {
// Skip conversion for null
Object argument = arguments[i];
@@ -106,8 +107,9 @@ public class FunctionInvoker {
PinotDataType parameterType = _parameterTypes[i];
PinotDataType argumentType = FunctionUtils.getArgumentType(argumentClass);
- Preconditions.checkArgument(parameterType != null && argumentType != null,
- "Cannot convert value from class: %s to class: %s", argumentClass, parameterClass);
+ Preconditions
+ .checkArgument(parameterType != null && argumentType != null, "Cannot convert value from class: %s to class: %s", argumentClass,
+ parameterClass);
arguments[i] = parameterType.convert(argument, argumentType);
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java b/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java
index 2d71654..8cfbb88 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java
@@ -53,10 +53,8 @@ public class FunctionRegistry {
*/
static {
long startTimeMs = System.currentTimeMillis();
- Reflections reflections = new Reflections(
- new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.apache.pinot"))
- .filterInputsBy(new FilterBuilder.Include(".*\\.function\\..*"))
- .setScanners(new MethodAnnotationsScanner()));
+ Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.apache.pinot"))
+ .filterInputsBy(new FilterBuilder.Include(".*\\.function\\..*")).setScanners(new MethodAnnotationsScanner()));
Set<Method> methodSet = reflections.getMethodsAnnotatedWith(ScalarFunction.class);
for (Method method : methodSet) {
ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
@@ -68,8 +66,8 @@ public class FunctionRegistry {
}
}
}
- LOGGER.info("Initialized FunctionRegistry with {} functions: {} in {}ms", FUNCTION_INFO_MAP.size(),
- FUNCTION_INFO_MAP.keySet(), System.currentTimeMillis() - startTimeMs);
+ LOGGER.info("Initialized FunctionRegistry with {} functions: {} in {}ms", FUNCTION_INFO_MAP.size(), FUNCTION_INFO_MAP.keySet(),
+ System.currentTimeMillis() - startTimeMs);
}
/**
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/TimeZoneKey.java b/pinot-common/src/main/java/org/apache/pinot/common/function/TimeZoneKey.java
index a86f32a..b723b0b 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/function/TimeZoneKey.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/function/TimeZoneKey.java
@@ -20,8 +20,15 @@ package org.apache.pinot.common.function;
import java.io.IOException;
import java.io.InputStream;
-import java.util.*;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeMap;
import static java.lang.Character.isDigit;
import static java.lang.Math.abs;
@@ -29,8 +36,10 @@ import static java.lang.Math.max;
import static java.util.Locale.ENGLISH;
import static java.util.Objects.requireNonNull;
+
/**
- * Copied from the presto TimeZoneKey. It basically caches the Joda Chronologies corresponding to each of the timezones listed in the zone-index.properties
+ * Copied from the presto TimeZoneKey. It basically caches the Joda Chronologies corresponding to each of the
+ * timezones listed in the zone-index.properties
* The zone-index.properties is kept in sync with the presto zone index properties.
*/
public final class TimeZoneKey {
@@ -117,29 +126,29 @@ public final class TimeZoneKey {
return zoneKey;
}
- private final String id;
+ private final String _id;
- private final short key;
+ private final short _key;
TimeZoneKey(String id, short key) {
- this.id = requireNonNull(id, "id is null");
+ _id = requireNonNull(id, "id is null");
if (key < 0) {
throw new IllegalArgumentException("key is negative");
}
- this.key = key;
+ _key = key;
}
public String getId() {
- return id;
+ return _id;
}
public short getKey() {
- return key;
+ return _key;
}
@Override
public int hashCode() {
- return Objects.hash(id, key);
+ return Objects.hash(_id, _key);
}
@Override
@@ -151,12 +160,12 @@ public final class TimeZoneKey {
return false;
}
TimeZoneKey other = (TimeZoneKey) obj;
- return Objects.equals(this.id, other.id) && Objects.equals(this.key, other.key);
+ return Objects.equals(_id, other._id) && Objects.equals(_key, other._key);
}
@Override
public String toString() {
- return id;
+ return _id;
}
private static String normalizeZoneId(String originalZoneId) {
@@ -242,16 +251,8 @@ public final class TimeZoneKey {
}
private static boolean isUtcEquivalentName(String zoneId) {
- return zoneId.equals("utc") ||
- zoneId.equals("z") ||
- zoneId.equals("ut") ||
- zoneId.equals("uct") ||
- zoneId.equals("ut") ||
- zoneId.equals("gmt") ||
- zoneId.equals("gmt0") ||
- zoneId.equals("greenwich") ||
- zoneId.equals("universal") ||
- zoneId.equals("zulu");
+ return zoneId.equals("utc") || zoneId.equals("z") || zoneId.equals("ut") || zoneId.equals("uct") || zoneId.equals("ut") || zoneId
+ .equals("gmt") || zoneId.equals("gmt0") || zoneId.equals("greenwich") || zoneId.equals("universal") || zoneId.equals("zulu");
}
private static String zoneIdForOffset(long offset) {
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DataTypeConversionFunctions.java b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DataTypeConversionFunctions.java
index c981212..9758fc9 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DataTypeConversionFunctions.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DataTypeConversionFunctions.java
@@ -37,7 +37,8 @@ public class DataTypeConversionFunctions {
* Converts big decimal string representation to bytes.
* Only scale of upto 2 bytes is supported by the function
* @param number big decimal number in plain string. e.g. '1234.12121'
- * @return The result byte array contains the bytes of the unscaled value appended to bytes of the scale in BIG ENDIAN order.
+ * @return The result byte array contains the bytes of the unscaled value appended to bytes of the scale in BIG
+ * ENDIAN order.
*/
@ScalarFunction
public static byte[] bigDecimalToBytes(String number) {
@@ -46,7 +47,8 @@ public class DataTypeConversionFunctions {
/**
* Converts bytes value representation generated by {@link #bigDecimalToBytes(String)} back to string big decimal
- * @param bytes array that contains the bytes of the unscaled value appended to 2 bytes of the scale in BIG ENDIAN order.
+ * @param bytes array that contains the bytes of the unscaled value appended to 2 bytes of the scale in BIG ENDIAN
+ * order.
* @return plain string representation of big decimal
*/
@ScalarFunction
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DateTimeFunctions.java b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DateTimeFunctions.java
index a799d08..e063367 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DateTimeFunctions.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DateTimeFunctions.java
@@ -34,10 +34,12 @@ import org.joda.time.DateTimeZone;
* Inbuilt date time related transform functions
*
* NOTE:
- * <code>toEpochXXXBucket</code> methods are only needed to convert from TimeFieldSpec to DateTimeFieldSpec, to maintain the backward compatibility.
+ * <code>toEpochXXXBucket</code> methods are only needed to convert from TimeFieldSpec to DateTimeFieldSpec, to
+ * maintain the backward compatibility.
* Practically, we should only need the <code>toEpochXXXRounded</code> methods.
* Use of <code>toEpochXXXBucket</code> bucket functions is discouraged unless you know what you are doing -
- * (e.g. 5-minutes-since-epoch does not make sense to someone looking at the timestamp, or writing queries. instead, Millis-since-epoch rounded to 5 minutes makes a lot more sense)
+ * (e.g. 5-minutes-since-epoch does not make sense to someone looking at the timestamp, or writing queries. instead,
+ * Millis-since-epoch rounded to 5 minutes makes a lot more sense)
*
* An example timeFieldSpec that needs the bucketing function:
* <code>
@@ -600,7 +602,7 @@ public class DateTimeFunctions {
* @return truncated timeValue in TimeUnit.MILLISECONDS
*/
@ScalarFunction
- public long dateTrunc(String unit, long timeValue){
+ public long dateTrunc(String unit, long timeValue) {
return dateTrunc(unit, timeValue, TimeUnit.MILLISECONDS.name());
}
@@ -642,14 +644,12 @@ public class DateTimeFunctions {
*
*/
@ScalarFunction
- public static long dateTrunc(String unit, long timeValue, String inputTimeUnitStr, String timeZone,
- String outputTimeUnitStr) {
+ public static long dateTrunc(String unit, long timeValue, String inputTimeUnitStr, String timeZone, String outputTimeUnitStr) {
TimeUnit inputTimeUnit = TimeUnit.valueOf(inputTimeUnitStr);
TimeUnit outputTimeUnit = TimeUnit.valueOf(outputTimeUnitStr);
TimeZoneKey timeZoneKey = TimeZoneKey.getTimeZoneKey(timeZone);
DateTimeField dateTimeField = DateTimeUtils.getTimestampField(DateTimeUtils.getChronology(timeZoneKey), unit);
- return outputTimeUnit.convert(dateTimeField.roundFloor(TimeUnit.MILLISECONDS.convert(timeValue, inputTimeUnit)),
- TimeUnit.MILLISECONDS);
+ return outputTimeUnit.convert(dateTimeField.roundFloor(TimeUnit.MILLISECONDS.convert(timeValue, inputTimeUnit)), TimeUnit.MILLISECONDS);
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/HashFunctions.java b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/HashFunctions.java
index e442c6c..ccf14a1 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/HashFunctions.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/HashFunctions.java
@@ -21,6 +21,7 @@ package org.apache.pinot.common.function.scalar;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.pinot.spi.annotations.ScalarFunction;
+
/**
* Inbuilt Hash Transformation Functions
* The functions can be used as UDFs in Query when added in the FunctionRegistry.
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/JsonFunctions.java b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/JsonFunctions.java
index 82536d6..603827a 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/JsonFunctions.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/JsonFunctions.java
@@ -50,17 +50,17 @@ import org.apache.pinot.spi.utils.JsonUtils;
public class JsonFunctions {
static {
Configuration.setDefaults(new Configuration.Defaults() {
- private final JsonProvider jsonProvider = new ArrayAwareJacksonJsonProvider();
- private final MappingProvider mappingProvider = new JacksonMappingProvider();
+ private final JsonProvider _jsonProvider = new ArrayAwareJacksonJsonProvider();
+ private final MappingProvider _mappingProvider = new JacksonMappingProvider();
@Override
public JsonProvider jsonProvider() {
- return jsonProvider;
+ return _jsonProvider;
}
@Override
public MappingProvider mappingProvider() {
- return mappingProvider;
+ return _mappingProvider;
}
@Override
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/lineage/LineageEntry.java b/pinot-common/src/main/java/org/apache/pinot/common/lineage/LineageEntry.java
index 6cda88e..4eed031 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/lineage/LineageEntry.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/lineage/LineageEntry.java
@@ -64,8 +64,8 @@ public class LineageEntry {
return false;
}
LineageEntry that = (LineageEntry) o;
- return _timestamp == that._timestamp && _segmentsFrom.equals(that._segmentsFrom) && _segmentsTo.equals(
- that._segmentsTo) && _state == that._state;
+ return _timestamp == that._timestamp && _segmentsFrom.equals(that._segmentsFrom) && _segmentsTo.equals(that._segmentsTo)
+ && _state == that._state;
}
@Override
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/lineage/SegmentLineageAccessHelper.java b/pinot-common/src/main/java/org/apache/pinot/common/lineage/SegmentLineageAccessHelper.java
index de34a08..a88e6fd 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/lineage/SegmentLineageAccessHelper.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/lineage/SegmentLineageAccessHelper.java
@@ -29,6 +29,9 @@ import org.apache.zookeeper.data.Stat;
* Class to help to read, write segment lineage metadata
*/
public class SegmentLineageAccessHelper {
+ private SegmentLineageAccessHelper() {
+ }
+
/**
* Read the segment lineage ZNRecord from the property store
*
@@ -36,8 +39,7 @@ public class SegmentLineageAccessHelper {
* @param tableNameWithType a table name with type
* @return a ZNRecord of segment merge lineage, return null if znode does not exist
*/
- public static ZNRecord getSegmentLineageZNRecord(ZkHelixPropertyStore<ZNRecord> propertyStore,
- String tableNameWithType) {
+ public static ZNRecord getSegmentLineageZNRecord(ZkHelixPropertyStore<ZNRecord> propertyStore, String tableNameWithType) {
String path = ZKMetadataProvider.constructPropertyStorePathForSegmentLineage(tableNameWithType);
Stat stat = new Stat();
ZNRecord segmentLineageZNRecord = propertyStore.get(path, stat, AccessOption.PERSISTENT);
@@ -54,8 +56,7 @@ public class SegmentLineageAccessHelper {
* @param tableNameWithType a table name with type
* @return a segment lineage, return null if znode does not exist
*/
- public static SegmentLineage getSegmentLineage(ZkHelixPropertyStore<ZNRecord> propertyStore,
- String tableNameWithType) {
+ public static SegmentLineage getSegmentLineage(ZkHelixPropertyStore<ZNRecord> propertyStore, String tableNameWithType) {
ZNRecord znRecord = getSegmentLineageZNRecord(propertyStore, tableNameWithType);
SegmentLineage segmentMergeLineage = null;
if (znRecord != null) {
@@ -72,8 +73,8 @@ public class SegmentLineageAccessHelper {
* @param expectedVersion expected version of ZNRecord. -1 for indicating to match any version.
* @return true if update is successful. false otherwise.
*/
- public static boolean writeSegmentLineage(ZkHelixPropertyStore<ZNRecord> propertyStore,
- SegmentLineage segmentLineage, int expectedVersion) {
+ public static boolean writeSegmentLineage(ZkHelixPropertyStore<ZNRecord> propertyStore, SegmentLineage segmentLineage,
+ int expectedVersion) {
String tableNameWithType = segmentLineage.getTableNameWithType();
String path = ZKMetadataProvider.constructPropertyStorePathForSegmentLineage(tableNameWithType);
return propertyStore.set(path, segmentLineage.toZNRecord(), expectedVersion, AccessOption.PERSISTENT);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/messages/RoutingTableRebuildMessage.java b/pinot-common/src/main/java/org/apache/pinot/common/messages/RoutingTableRebuildMessage.java
index cda4247..7b36aa3 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/messages/RoutingTableRebuildMessage.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/messages/RoutingTableRebuildMessage.java
@@ -22,6 +22,7 @@ import java.util.UUID;
import org.apache.helix.ZNRecord;
import org.apache.helix.model.Message;
+
/**
* This (Helix) message is sent from the controller to brokers when a request is received to rebuild the routing table.
* When the broker receives this message, it will rebuild the routing table for the given table.
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metadata/ZKMetadataProvider.java b/pinot-common/src/main/java/org/apache/pinot/common/metadata/ZKMetadataProvider.java
index 1137ad6..27076d5 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metadata/ZKMetadataProvider.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metadata/ZKMetadataProvider.java
@@ -59,28 +59,23 @@ public class ZKMetadataProvider {
private static final String PROPERTYSTORE_SEGMENT_LINEAGE = "/SEGMENT_LINEAGE";
private static final String PROPERTYSTORE_MINION_TASK_METADATA_PREFIX = "/MINION_TASK_METADATA";
- public static void setRealtimeTableConfig(ZkHelixPropertyStore<ZNRecord> propertyStore, String realtimeTableName,
- ZNRecord znRecord) {
- propertyStore
- .set(constructPropertyStorePathForResourceConfig(realtimeTableName), znRecord, AccessOption.PERSISTENT);
+ public static void setRealtimeTableConfig(ZkHelixPropertyStore<ZNRecord> propertyStore, String realtimeTableName, ZNRecord znRecord) {
+ propertyStore.set(constructPropertyStorePathForResourceConfig(realtimeTableName), znRecord, AccessOption.PERSISTENT);
}
- public static void setOfflineTableConfig(ZkHelixPropertyStore<ZNRecord> propertyStore, String offlineTableName,
- ZNRecord znRecord) {
+ public static void setOfflineTableConfig(ZkHelixPropertyStore<ZNRecord> propertyStore, String offlineTableName, ZNRecord znRecord) {
propertyStore.set(constructPropertyStorePathForResourceConfig(offlineTableName), znRecord, AccessOption.PERSISTENT);
}
- public static void setInstanceZKMetadata(ZkHelixPropertyStore<ZNRecord> propertyStore,
- InstanceZKMetadata instanceZKMetadata) {
+ public static void setInstanceZKMetadata(ZkHelixPropertyStore<ZNRecord> propertyStore, InstanceZKMetadata instanceZKMetadata) {
ZNRecord znRecord = instanceZKMetadata.toZNRecord();
- propertyStore.set(StringUtil.join("/", PROPERTYSTORE_INSTANCE_CONFIGS_PREFIX, instanceZKMetadata.getId()), znRecord,
- AccessOption.PERSISTENT);
+ propertyStore
+ .set(StringUtil.join("/", PROPERTYSTORE_INSTANCE_CONFIGS_PREFIX, instanceZKMetadata.getId()), znRecord, AccessOption.PERSISTENT);
}
- public static InstanceZKMetadata getInstanceZKMetadata(ZkHelixPropertyStore<ZNRecord> propertyStore,
- String instanceId) {
- ZNRecord znRecord = propertyStore
- .get(StringUtil.join("/", PROPERTYSTORE_INSTANCE_CONFIGS_PREFIX, instanceId), null, AccessOption.PERSISTENT);
+ public static InstanceZKMetadata getInstanceZKMetadata(ZkHelixPropertyStore<ZNRecord> propertyStore, String instanceId) {
+ ZNRecord znRecord =
+ propertyStore.get(StringUtil.join("/", PROPERTYSTORE_INSTANCE_CONFIGS_PREFIX, instanceId), null, AccessOption.PERSISTENT);
if (znRecord == null) {
return null;
}
@@ -119,22 +114,18 @@ public class ZKMetadataProvider {
return StringUtil.join("/", PROPERTYSTORE_MINION_TASK_METADATA_PREFIX, taskType, tableNameWithType);
}
- public static boolean isSegmentExisted(ZkHelixPropertyStore<ZNRecord> propertyStore, String resourceNameForResource,
- String segmentName) {
- return propertyStore
- .exists(constructPropertyStorePathForSegment(resourceNameForResource, segmentName), AccessOption.PERSISTENT);
+ public static boolean isSegmentExisted(ZkHelixPropertyStore<ZNRecord> propertyStore, String resourceNameForResource, String segmentName) {
+ return propertyStore.exists(constructPropertyStorePathForSegment(resourceNameForResource, segmentName), AccessOption.PERSISTENT);
}
- public static void removeResourceSegmentsFromPropertyStore(ZkHelixPropertyStore<ZNRecord> propertyStore,
- String resourceName) {
+ public static void removeResourceSegmentsFromPropertyStore(ZkHelixPropertyStore<ZNRecord> propertyStore, String resourceName) {
String propertyStorePath = constructPropertyStorePathForResource(resourceName);
if (propertyStore.exists(propertyStorePath, AccessOption.PERSISTENT)) {
propertyStore.remove(propertyStorePath, AccessOption.PERSISTENT);
}
}
- public static void removeResourceConfigFromPropertyStore(ZkHelixPropertyStore<ZNRecord> propertyStore,
- String resourceName) {
+ public static void removeResourceConfigFromPropertyStore(ZkHelixPropertyStore<ZNRecord> propertyStore, String resourceName) {
String propertyStorePath = constructPropertyStorePathForResourceConfig(resourceName);
if (propertyStore.exists(propertyStorePath, AccessOption.PERSISTENT)) {
propertyStore.remove(propertyStorePath, AccessOption.PERSISTENT);
@@ -146,8 +137,8 @@ public class ZKMetadataProvider {
// NOTE: Helix will throw ZkBadVersionException if version does not match
try {
return propertyStore
- .set(constructPropertyStorePathForSegment(tableNameWithType, segmentZKMetadata.getSegmentName()),
- segmentZKMetadata.toZNRecord(), expectedVersion, AccessOption.PERSISTENT);
+ .set(constructPropertyStorePathForSegment(tableNameWithType, segmentZKMetadata.getSegmentName()), segmentZKMetadata.toZNRecord(),
+ expectedVersion, AccessOption.PERSISTENT);
} catch (ZkBadVersionException e) {
return false;
}
@@ -171,17 +162,16 @@ public class ZKMetadataProvider {
}
@Nullable
- public static SegmentZKMetadata getSegmentZKMetadata(ZkHelixPropertyStore<ZNRecord> propertyStore,
- String tableNameWithType, String segmentName) {
- ZNRecord znRecord = propertyStore
- .get(constructPropertyStorePathForSegment(tableNameWithType, segmentName), null, AccessOption.PERSISTENT);
+ public static SegmentZKMetadata getSegmentZKMetadata(ZkHelixPropertyStore<ZNRecord> propertyStore, String tableNameWithType,
+ String segmentName) {
+ ZNRecord znRecord =
+ propertyStore.get(constructPropertyStorePathForSegment(tableNameWithType, segmentName), null, AccessOption.PERSISTENT);
return znRecord != null ? new SegmentZKMetadata(znRecord) : null;
}
@Nullable
public static TableConfig getTableConfig(ZkHelixPropertyStore<ZNRecord> propertyStore, String tableNameWithType) {
- ZNRecord znRecord = propertyStore
- .get(constructPropertyStorePathForResourceConfig(tableNameWithType), null, AccessOption.PERSISTENT);
+ ZNRecord znRecord = propertyStore.get(constructPropertyStorePathForResourceConfig(tableNameWithType), null, AccessOption.PERSISTENT);
if (znRecord == null) {
return null;
}
@@ -205,15 +195,13 @@ public class ZKMetadataProvider {
}
public static void setSchema(ZkHelixPropertyStore<ZNRecord> propertyStore, Schema schema) {
- propertyStore.set(constructPropertyStorePathForSchema(schema.getSchemaName()), SchemaUtils.toZNRecord(schema),
- AccessOption.PERSISTENT);
+ propertyStore.set(constructPropertyStorePathForSchema(schema.getSchemaName()), SchemaUtils.toZNRecord(schema), AccessOption.PERSISTENT);
}
@Nullable
public static Schema getSchema(ZkHelixPropertyStore<ZNRecord> propertyStore, String schemaName) {
try {
- ZNRecord schemaZNRecord =
- propertyStore.get(constructPropertyStorePathForSchema(schemaName), null, AccessOption.PERSISTENT);
+ ZNRecord schemaZNRecord = propertyStore.get(constructPropertyStorePathForSchema(schemaName), null, AccessOption.PERSISTENT);
if (schemaZNRecord == null) {
return null;
}
@@ -262,8 +250,8 @@ public class ZKMetadataProvider {
}
}
if (schema != null) {
- LOGGER.warn("Schema name does not match raw table name, schema name: {}, raw table name: {}",
- schema.getSchemaName(), TableNameBuilder.extractRawTableName(tableName));
+ LOGGER.warn("Schema name does not match raw table name, schema name: {}, raw table name: {}", schema.getSchemaName(),
+ TableNameBuilder.extractRawTableName(tableName));
}
return schema;
}
@@ -272,8 +260,7 @@ public class ZKMetadataProvider {
* NOTE: this method is very expensive, use {@link #getSegments(ZkHelixPropertyStore, String)} instead if only segment
* names are needed.
*/
- public static List<SegmentZKMetadata> getSegmentsZKMetadata(ZkHelixPropertyStore<ZNRecord> propertyStore,
- String tableNameWithType) {
+ public static List<SegmentZKMetadata> getSegmentsZKMetadata(ZkHelixPropertyStore<ZNRecord> propertyStore, String tableNameWithType) {
String parentPath = constructPropertyStorePathForResource(tableNameWithType);
List<ZNRecord> znRecords = propertyStore
.getChildren(parentPath, null, AccessOption.PERSISTENT, CommonConstants.Helix.ZkClient.RETRY_COUNT,
@@ -289,8 +276,7 @@ public class ZKMetadataProvider {
}
int numNullZNRecords = numZNRecords - segmentsZKMetadata.size();
if (numNullZNRecords > 0) {
- LOGGER.warn("Failed to read {}/{} segment ZK metadata under path: {}", numNullZNRecords, numZNRecords,
- parentPath);
+ LOGGER.warn("Failed to read {}/{} segment ZK metadata under path: {}", numNullZNRecords, numZNRecords, parentPath);
}
return segmentsZKMetadata;
} else {
@@ -322,8 +308,7 @@ public class ZKMetadataProvider {
* @param realtimeTableName Realtime table name
* @return List of LLC realtime segment names
*/
- public static List<String> getLLCRealtimeSegments(ZkHelixPropertyStore<ZNRecord> propertyStore,
- String realtimeTableName) {
+ public static List<String> getLLCRealtimeSegments(ZkHelixPropertyStore<ZNRecord> propertyStore, String realtimeTableName) {
List<String> llcRealtimeSegments = new ArrayList<>();
String segmentsPath = constructPropertyStorePathForResource(realtimeTableName);
if (propertyStore.exists(segmentsPath, AccessOption.PERSISTENT)) {
@@ -337,8 +322,7 @@ public class ZKMetadataProvider {
return llcRealtimeSegments;
}
- public static void setClusterTenantIsolationEnabled(ZkHelixPropertyStore<ZNRecord> propertyStore,
- boolean isSingleTenantCluster) {
+ public static void setClusterTenantIsolationEnabled(ZkHelixPropertyStore<ZNRecord> propertyStore, boolean isSingleTenantCluster) {
final ZNRecord znRecord;
final String path = constructPropertyStorePathForControllerConfig(CLUSTER_TENANT_ISOLATION_ENABLED_KEY);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metadata/instance/InstanceZKMetadata.java b/pinot-common/src/main/java/org/apache/pinot/common/metadata/instance/InstanceZKMetadata.java
index 8ab499a..2c2f592 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metadata/instance/InstanceZKMetadata.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metadata/instance/InstanceZKMetadata.java
@@ -140,9 +140,9 @@ public final class InstanceZKMetadata implements ZKMetadata {
}
InstanceZKMetadata metadata = (InstanceZKMetadata) instanceMetadata;
- return isEqual(_id, metadata._id) && isEqual(_instanceName, metadata._instanceName) && isEqual(_instanceType,
- metadata._instanceType) && isEqual(_instancePort, metadata._instancePort) && isEqual(_groupIdMap,
- metadata._groupIdMap) && isEqual(_partitionMap, metadata._partitionMap);
+ return isEqual(_id, metadata._id) && isEqual(_instanceName, metadata._instanceName) && isEqual(_instanceType, metadata._instanceType)
+ && isEqual(_instancePort, metadata._instancePort) && isEqual(_groupIdMap, metadata._groupIdMap) && isEqual(_partitionMap,
+ metadata._partitionMap);
}
@Override
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metadata/segment/SegmentPartitionMetadata.java b/pinot-common/src/main/java/org/apache/pinot/common/metadata/segment/SegmentPartitionMetadata.java
index 22d4733..640b7ea 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metadata/segment/SegmentPartitionMetadata.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metadata/segment/SegmentPartitionMetadata.java
@@ -44,8 +44,7 @@ public class SegmentPartitionMetadata {
*
* @param columnPartitionMap Column name to ColumnPartitionMetadata map.
*/
- public SegmentPartitionMetadata(
- @Nonnull @JsonProperty("columnPartitionMap") Map<String, ColumnPartitionMetadata> columnPartitionMap) {
+ public SegmentPartitionMetadata(@Nonnull @JsonProperty("columnPartitionMap") Map<String, ColumnPartitionMetadata> columnPartitionMap) {
Preconditions.checkNotNull(columnPartitionMap);
_columnPartitionMap = columnPartitionMap;
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metadata/segment/SegmentZKMetadata.java b/pinot-common/src/main/java/org/apache/pinot/common/metadata/segment/SegmentZKMetadata.java
index 79f2a4f..b827afb 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metadata/segment/SegmentZKMetadata.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metadata/segment/SegmentZKMetadata.java
@@ -346,7 +346,12 @@ public class SegmentZKMetadata implements ZKMetadata {
if (o == null || getClass() != o.getClass()) {
return false;
}
- return _znRecord.equals(((SegmentZKMetadata) o)._znRecord);
+ return toMap().equals(((SegmentZKMetadata) o).toMap());
+ }
+
+ @Override
+ public int hashCode() {
+ return toMap().hashCode();
}
// TODO: Remove all deprecated fields after releasing 0.9.0
@@ -408,8 +413,7 @@ public class SegmentZKMetadata implements ZKMetadata {
if (startTimeString != null) {
String endTimeString = _simpleFields.get(Segment.END_TIME);
TimeUnit timeUnit = TimeUnit.valueOf(_simpleFields.get(Segment.TIME_UNIT));
- return new Interval(timeUnit.toMillis(Long.parseLong(startTimeString)),
- timeUnit.toMillis(Long.parseLong(endTimeString)));
+ return new Interval(timeUnit.toMillis(Long.parseLong(startTimeString)), timeUnit.toMillis(Long.parseLong(endTimeString)));
} else {
return null;
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/AbstractMetrics.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/AbstractMetrics.java
index 3d5299d..123751c 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/AbstractMetrics.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/AbstractMetrics.java
@@ -43,7 +43,8 @@ import org.slf4j.LoggerFactory;
* Common code for metrics implementations.
*
*/
-public abstract class AbstractMetrics<QP extends AbstractMetrics.QueryPhase, M extends AbstractMetrics.Meter, G extends AbstractMetrics.Gauge, T extends AbstractMetrics.Timer> {
+public abstract class AbstractMetrics<QP extends AbstractMetrics.QueryPhase, M extends AbstractMetrics.Meter,
+ G extends AbstractMetrics.Gauge, T extends AbstractMetrics.Timer> {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractMetrics.class);
@@ -64,8 +65,8 @@ public abstract class AbstractMetrics<QP extends AbstractMetrics.QueryPhase, M e
this(metricPrefix, metricsRegistry, clazz, true, Collections.emptySet());
}
- public AbstractMetrics(String metricPrefix, PinotMetricsRegistry metricsRegistry, Class clazz,
- boolean isTableLevelMetricsEnabled, Collection<String> allowedTables) {
+ public AbstractMetrics(String metricPrefix, PinotMetricsRegistry metricsRegistry, Class clazz, boolean isTableLevelMetricsEnabled,
+ Collection<String> allowedTables) {
_metricPrefix = metricPrefix;
_metricsRegistry = metricsRegistry;
_clazz = clazz;
@@ -151,8 +152,7 @@ public abstract class AbstractMetrics<QP extends AbstractMetrics.QueryPhase, M e
*/
private void addValueToTimer(String fullTimerName, final long duration, final TimeUnit timeUnit) {
final PinotMetricName metricName = PinotMetricUtils.makePinotMetricName(_clazz, fullTimerName);
- PinotTimer timer =
- PinotMetricUtils.makePinotTimer(_metricsRegistry, metricName, TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
+ PinotTimer timer = PinotMetricUtils.makePinotTimer(_metricsRegistry, metricName, TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
if (timer != null) {
timer.update(duration, timeUnit);
}
@@ -185,8 +185,7 @@ public abstract class AbstractMetrics<QP extends AbstractMetrics.QueryPhase, M e
fullMeterName = _metricPrefix + meterName;
final PinotMetricName metricName = PinotMetricUtils.makePinotMetricName(_clazz, fullMeterName);
- final PinotMeter newMeter =
- PinotMetricUtils.makePinotMeter(_metricsRegistry, metricName, meter.getUnit(), TimeUnit.SECONDS);
+ final PinotMeter newMeter = PinotMetricUtils.makePinotMeter(_metricsRegistry, metricName, meter.getUnit(), TimeUnit.SECONDS);
newMeter.mark(unitCount);
return newMeter;
}
@@ -210,8 +209,7 @@ public abstract class AbstractMetrics<QP extends AbstractMetrics.QueryPhase, M e
* @param unitCount The number of units to add to the meter
* @param reusedMeter The meter to reuse
*/
- public PinotMeter addMeteredTableValue(final String tableName, final M meter, final long unitCount,
- PinotMeter reusedMeter) {
+ public PinotMeter addMeteredTableValue(final String tableName, final M meter, final long unitCount, PinotMeter reusedMeter) {
if (reusedMeter != null) {
reusedMeter.mark(unitCount);
return reusedMeter;
@@ -221,8 +219,7 @@ public abstract class AbstractMetrics<QP extends AbstractMetrics.QueryPhase, M e
fullMeterName = _metricPrefix + getTableName(tableName) + "." + meterName;
final PinotMetricName metricName = PinotMetricUtils.makePinotMetricName(_clazz, fullMeterName);
- final PinotMeter newMeter =
- PinotMetricUtils.makePinotMeter(_metricsRegistry, metricName, meter.getUnit(), TimeUnit.SECONDS);
+ final PinotMeter newMeter = PinotMetricUtils.makePinotMeter(_metricsRegistry, metricName, meter.getUnit(), TimeUnit.SECONDS);
newMeter.mark(unitCount);
return newMeter;
}
@@ -463,17 +460,16 @@ public abstract class AbstractMetrics<QP extends AbstractMetrics.QueryPhase, M e
* @param valueCallback The callback function used to retrieve the value of the gauge
*/
public void addCallbackGauge(final String metricName, final Callable<Long> valueCallback) {
- PinotMetricUtils
- .makeGauge(_metricsRegistry, PinotMetricUtils.makePinotMetricName(_clazz, _metricPrefix + metricName),
- PinotMetricUtils.makePinotGauge(avoid -> {
- try {
- return valueCallback.call();
- } catch (Exception e) {
- LOGGER.error("Caught exception", e);
- Utils.rethrowException(e);
- throw new AssertionError("Should not reach this");
- }
- }));
+ PinotMetricUtils.makeGauge(_metricsRegistry, PinotMetricUtils.makePinotMetricName(_clazz, _metricPrefix + metricName),
+ PinotMetricUtils.makePinotGauge(avoid -> {
+ try {
+ return valueCallback.call();
+ } catch (Exception e) {
+ LOGGER.error("Caught exception", e);
+ Utils.rethrowException(e);
+ throw new AssertionError("Should not reach this");
+ }
+ }));
}
/**
@@ -504,8 +500,7 @@ public abstract class AbstractMetrics<QP extends AbstractMetrics.QueryPhase, M e
* @param metricName metric name
*/
private void removeCallbackGauge(String metricName) {
- PinotMetricUtils
- .removeMetric(_metricsRegistry, PinotMetricUtils.makePinotMetricName(_clazz, _metricPrefix + metricName));
+ PinotMetricUtils.removeMetric(_metricsRegistry, PinotMetricUtils.makePinotMetricName(_clazz, _metricPrefix + metricName));
}
protected abstract QP[] getQueryPhases();
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerGauge.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerGauge.java
index 86f8a3e..0f46e1a 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerGauge.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerGauge.java
@@ -33,24 +33,24 @@ public enum BrokerGauge implements AbstractMetrics.Gauge {
REQUEST_SIZE("requestSize", false),
RESIZE_TIME_MS("milliseconds", false);
- private final String brokerGaugeName;
- private final String unit;
- private final boolean global;
+ private final String _brokerGaugeName;
+ private final String _unit;
+ private final boolean _global;
BrokerGauge(String unit, boolean global) {
- this.unit = unit;
- this.global = global;
- this.brokerGaugeName = Utils.toCamelCase(name().toLowerCase());
+ _unit = unit;
+ _global = global;
+ _brokerGaugeName = Utils.toCamelCase(name().toLowerCase());
}
@Override
public String getGaugeName() {
- return brokerGaugeName;
+ return _brokerGaugeName;
}
@Override
public String getUnit() {
- return unit;
+ return _unit;
}
/**
@@ -60,6 +60,6 @@ public enum BrokerGauge implements AbstractMetrics.Gauge {
*/
@Override
public boolean isGlobal() {
- return global;
+ return _global;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerMeter.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerMeter.java
index a6411a7..183106d 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerMeter.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerMeter.java
@@ -103,24 +103,24 @@ public enum BrokerMeter implements AbstractMetrics.Meter {
PROACTIVE_CLUSTER_CHANGE_CHECK("proactiveClusterChangeCheck", true);
- private final String brokerMeterName;
- private final String unit;
- private final boolean global;
+ private final String _brokerMeterName;
+ private final String _unit;
+ private final boolean _global;
BrokerMeter(String unit, boolean global) {
- this.unit = unit;
- this.global = global;
- this.brokerMeterName = Utils.toCamelCase(name().toLowerCase());
+ _unit = unit;
+ _global = global;
+ _brokerMeterName = Utils.toCamelCase(name().toLowerCase());
}
@Override
public String getMeterName() {
- return brokerMeterName;
+ return _brokerMeterName;
}
@Override
public String getUnit() {
- return unit;
+ return _unit;
}
/**
@@ -130,6 +130,6 @@ public enum BrokerMeter implements AbstractMetrics.Meter {
*/
@Override
public boolean isGlobal() {
- return global;
+ return _global;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerMetrics.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerMetrics.java
index 850d7f3..b354765 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerMetrics.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerMetrics.java
@@ -41,8 +41,7 @@ public class BrokerMetrics extends AbstractMetrics<BrokerQueryPhase, BrokerMeter
this(metricsRegistry, DEFAULT_ENABLE_TABLE_LEVEL_METRICS, Collections.emptySet());
}
- public BrokerMetrics(PinotMetricsRegistry metricsRegistry, boolean isTableLevelMetricsEnabled,
- Collection<String> allowedTables) {
+ public BrokerMetrics(PinotMetricsRegistry metricsRegistry, boolean isTableLevelMetricsEnabled, Collection<String> allowedTables) {
this(DEFAULT_METRICS_NAME_PREFIX, metricsRegistry, isTableLevelMetricsEnabled, allowedTables);
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerQueryPhase.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerQueryPhase.java
index cc8cd58..9150f06 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerQueryPhase.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerQueryPhase.java
@@ -26,23 +26,16 @@ import org.apache.pinot.common.Utils;
*
*/
public enum BrokerQueryPhase implements AbstractMetrics.QueryPhase {
- REQUEST_COMPILATION,
- QUERY_EXECUTION,
- QUERY_ROUTING,
- SCATTER_GATHER,
- DESERIALIZATION,
- REDUCE,
- REQUEST_CONNECTION_WAIT,
- AUTHORIZATION;
+ REQUEST_COMPILATION, QUERY_EXECUTION, QUERY_ROUTING, SCATTER_GATHER, DESERIALIZATION, REDUCE, REQUEST_CONNECTION_WAIT, AUTHORIZATION;
- private final String queryPhaseName;
+ private final String _queryPhaseName;
BrokerQueryPhase() {
- queryPhaseName = Utils.toCamelCase(name().toLowerCase());
+ _queryPhaseName = Utils.toCamelCase(name().toLowerCase());
}
@Override
public String getQueryPhaseName() {
- return queryPhaseName;
+ return _queryPhaseName;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerTimer.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerTimer.java
index d8afab1..faa1043 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerTimer.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerTimer.java
@@ -26,30 +26,27 @@ import org.apache.pinot.common.Utils;
*
*/
public enum BrokerTimer implements AbstractMetrics.Timer {
- ROUTING_TABLE_UPDATE_TIME(true),
- CLUSTER_CHANGE_QUEUE_TIME(true),
- // metric tracking the freshness lag for consuming segments
+ ROUTING_TABLE_UPDATE_TIME(true), CLUSTER_CHANGE_QUEUE_TIME(true), // metric tracking the freshness lag for consuming segments
FRESHNESS_LAG_MS(false),
// The latency of sending the request from broker to server
NETTY_CONNECTION_SEND_REQUEST_LATENCY(false),
// aggregated query processing cost (thread cpu time in nanoseconds) from offline servers
- OFFLINE_THREAD_CPU_TIME_NS(false),
- // aggregated query processing cost (thread cpu time in nanoseconds) from realtime servers
+ OFFLINE_THREAD_CPU_TIME_NS(false), // aggregated query processing cost (thread cpu time in nanoseconds) from realtime servers
REALTIME_THREAD_CPU_TIME_NS(false);
- private final String timerName;
- private final boolean global;
+ private final String _timerName;
+ private final boolean _global;
BrokerTimer(boolean global) {
- this.global = global;
- this.timerName = Utils.toCamelCase(name().toLowerCase());
+ _global = global;
+ _timerName = Utils.toCamelCase(name().toLowerCase());
}
@Override
public String getTimerName() {
- return timerName;
+ return _timerName;
}
/**
@@ -59,6 +56,6 @@ public enum BrokerTimer implements AbstractMetrics.Timer {
*/
@Override
public boolean isGlobal() {
- return global;
+ return _global;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ControllerGauge.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ControllerGauge.java
index 31c6b8d..77b69ec 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ControllerGauge.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ControllerGauge.java
@@ -85,24 +85,24 @@ public enum ControllerGauge implements AbstractMetrics.Gauge {
// Number of online minion instances
ONLINE_MINION_INSTANCES("onlineMinionInstances", true);
- private final String gaugeName;
- private final String unit;
- private final boolean global;
+ private final String _gaugeName;
+ private final String _unit;
+ private final boolean _global;
ControllerGauge(String unit, boolean global) {
- this.unit = unit;
- this.global = global;
- this.gaugeName = Utils.toCamelCase(name().toLowerCase());
+ _unit = unit;
+ _global = global;
+ _gaugeName = Utils.toCamelCase(name().toLowerCase());
}
@Override
public String getGaugeName() {
- return gaugeName;
+ return _gaugeName;
}
@Override
public String getUnit() {
- return unit;
+ return _unit;
}
/**
@@ -112,6 +112,6 @@ public enum ControllerGauge implements AbstractMetrics.Gauge {
*/
@Override
public boolean isGlobal() {
- return global;
+ return _global;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ControllerMeter.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ControllerMeter.java
index 8c3012d..8d1c60f 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ControllerMeter.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ControllerMeter.java
@@ -51,24 +51,24 @@ public enum ControllerMeter implements AbstractMetrics.Meter {
NUMBER_SEGMENT_UPLOAD_TIMEOUT_EXCEEDED("SegmentUploadTimeouts", true),
CRON_SCHEDULER_JOB_TRIGGERED("cronSchedulerJobTriggered", false);
- private final String brokerMeterName;
- private final String unit;
- private final boolean global;
+ private final String _brokerMeterName;
+ private final String _unit;
+ private final boolean _global;
ControllerMeter(String unit, boolean global) {
- this.unit = unit;
- this.global = global;
- this.brokerMeterName = Utils.toCamelCase(name().toLowerCase());
+ _unit = unit;
+ _global = global;
+ _brokerMeterName = Utils.toCamelCase(name().toLowerCase());
}
@Override
public String getMeterName() {
- return brokerMeterName;
+ return _brokerMeterName;
}
@Override
public String getUnit() {
- return unit;
+ return _unit;
}
/**
@@ -78,6 +78,6 @@ public enum ControllerMeter implements AbstractMetrics.Meter {
*/
@Override
public boolean isGlobal() {
- return global;
+ return _global;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ControllerTimer.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ControllerTimer.java
index 40ad9d5..6627382 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ControllerTimer.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ControllerTimer.java
@@ -28,17 +28,17 @@ import org.apache.pinot.common.Utils;
public enum ControllerTimer implements AbstractMetrics.Timer {
CRON_SCHEDULER_JOB_EXECUTION_TIME_MS("cronSchedulerJobExecutionTimeMs", false);
- private final String timerName;
- private final boolean global;
+ private final String _timerName;
+ private final boolean _global;
ControllerTimer(String unit, boolean global) {
- this.global = global;
- this.timerName = Utils.toCamelCase(name().toLowerCase());
+ _global = global;
+ _timerName = Utils.toCamelCase(name().toLowerCase());
}
@Override
public String getTimerName() {
- return timerName;
+ return _timerName;
}
/**
@@ -48,6 +48,6 @@ public enum ControllerTimer implements AbstractMetrics.Timer {
*/
@Override
public boolean isGlobal() {
- return global;
+ return _global;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/MinionGauge.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/MinionGauge.java
index b183bf3..0b08ba1 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/MinionGauge.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/MinionGauge.java
@@ -22,8 +22,7 @@ import org.apache.pinot.common.Utils;
public enum MinionGauge implements AbstractMetrics.Gauge {
- NUMBER_OF_TASKS("tasks", true),
- ;
+ NUMBER_OF_TASKS("tasks", true);
private final String _gaugeName;
private final String _unit;
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/MinionQueryPhase.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/MinionQueryPhase.java
index d26ef4d..cd66b01 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/MinionQueryPhase.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/MinionQueryPhase.java
@@ -22,8 +22,7 @@ import org.apache.pinot.common.Utils;
public enum MinionQueryPhase implements AbstractMetrics.QueryPhase {
- TASK_EXECUTION,
- TASK_QUEUEING;
+ TASK_EXECUTION, TASK_QUEUEING;
private final String _queryPhaseName;
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/MinionTimer.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/MinionTimer.java
index 0191d71..ee7bb2b 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/MinionTimer.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/MinionTimer.java
@@ -22,7 +22,10 @@ import org.apache.pinot.common.Utils;
public enum MinionTimer implements AbstractMetrics.Timer {
+ // Remove below checkstyle comment filter when first enum is created.
+ // CHECKSTYLE:OFF: checkstyle:coding
;
+ // CHECKSTYLE:OFF: checkstyle:coding
private final String _timerName;
private final boolean _global;
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/PinotMetricUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/PinotMetricUtils.java
index 96024f5..3ef51cb 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/PinotMetricUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/PinotMetricUtils.java
@@ -43,15 +43,17 @@ import org.slf4j.LoggerFactory;
public class PinotMetricUtils {
+ private PinotMetricUtils() {
+ }
+
private static final Logger LOGGER = LoggerFactory.getLogger(PinotMetricUtils.class);
private static final String METRICS_PACKAGE_REGEX_PATTERN = ".*\\.plugin\\.metrics\\..*";
+ private static final Map<PinotMetricsRegistry, Boolean> METRICS_REGISTRY_MAP = new ConcurrentHashMap<>();
+ private static final Map<MetricsRegistryRegistrationListener, Boolean> METRICS_REGISTRY_REGISTRATION_LISTENERS_MAP =
+ new ConcurrentHashMap<>();
private static PinotMetricsFactory _pinotMetricsFactory = null;
- private static final Map<PinotMetricsRegistry, Boolean> metricsRegistryMap = new ConcurrentHashMap<>();
- private static final Map<MetricsRegistryRegistrationListener, Boolean> metricsRegistryRegistrationListenersMap =
- new ConcurrentHashMap<>();
-
public static void init(PinotConfiguration metricsConfiguration) {
// Initializes PinotMetricsFactory.
initializePinotMetricsFactory(metricsConfiguration);
@@ -106,19 +108,17 @@ public class PinotMetricUtils {
try {
Class<? extends MetricsRegistryRegistrationListener> clazz =
(Class<? extends MetricsRegistryRegistrationListener>) Class.forName(listenerClassName);
- Constructor<? extends MetricsRegistryRegistrationListener> defaultConstructor =
- clazz.getDeclaredConstructor();
+ Constructor<? extends MetricsRegistryRegistrationListener> defaultConstructor = clazz.getDeclaredConstructor();
MetricsRegistryRegistrationListener listener = defaultConstructor.newInstance();
LOGGER.info("Registering metricsRegistry to listener {}", listenerClassName);
addMetricsRegistryRegistrationListener(listener);
} catch (Exception e) {
- LOGGER
- .warn("Caught exception while initializing MetricsRegistryRegistrationListener " + listenerClassName, e);
+ LOGGER.warn("Caught exception while initializing MetricsRegistryRegistrationListener " + listenerClassName, e);
}
}
}
- LOGGER.info("Number of listeners got registered: {}", metricsRegistryRegistrationListenersMap.size());
+ LOGGER.info("Number of listeners got registered: {}", METRICS_REGISTRY_REGISTRATION_LISTENERS_MAP.size());
}
/**
@@ -130,10 +130,10 @@ public class PinotMetricUtils {
*/
private static void addMetricsRegistryRegistrationListener(MetricsRegistryRegistrationListener listener) {
synchronized (PinotMetricUtils.class) {
- metricsRegistryRegistrationListenersMap.put(listener, Boolean.TRUE);
+ METRICS_REGISTRY_REGISTRATION_LISTENERS_MAP.put(listener, Boolean.TRUE);
// Fire events to register all previously registered metrics registries
- Set<PinotMetricsRegistry> metricsRegistries = metricsRegistryMap.keySet();
+ Set<PinotMetricsRegistry> metricsRegistries = METRICS_REGISTRY_MAP.keySet();
LOGGER.info("Number of metrics registry: {}", metricsRegistries.size());
for (PinotMetricsRegistry metricsRegistry : metricsRegistries) {
listener.onMetricsRegistryRegistered(metricsRegistry);
@@ -148,11 +148,10 @@ public class PinotMetricUtils {
*/
private static void registerMetricsRegistry(PinotMetricsRegistry registry) {
synchronized (PinotMetricUtils.class) {
- metricsRegistryMap.put(registry, Boolean.TRUE);
+ METRICS_REGISTRY_MAP.put(registry, Boolean.TRUE);
// Fire event to all registered listeners
- Set<MetricsRegistryRegistrationListener> metricsRegistryRegistrationListeners =
- metricsRegistryRegistrationListenersMap.keySet();
+ Set<MetricsRegistryRegistrationListener> metricsRegistryRegistrationListeners = METRICS_REGISTRY_REGISTRATION_LISTENERS_MAP.keySet();
for (MetricsRegistryRegistrationListener metricsRegistryRegistrationListener : metricsRegistryRegistrationListeners) {
metricsRegistryRegistrationListener.onMetricsRegistryRegistered(registry);
}
@@ -169,7 +168,8 @@ public class PinotMetricUtils {
public static PinotMetricsRegistry getPinotMetricsRegistry() {
if (_pinotMetricsFactory == null) {
- // If init method didn't get called previously, just simply init with an empty hashmap. This is commonly used in tests.
+ // If init method didn't get called previously, just simply init with an empty hashmap. This is commonly used
+ // in tests.
init(new PinotConfiguration(Collections.emptyMap()));
}
return _pinotMetricsFactory.getPinotMetricsRegistry();
@@ -187,13 +187,11 @@ public class PinotMetricUtils {
return registry.newGauge(name, gauge);
}
- public static PinotTimer makePinotTimer(PinotMetricsRegistry registry, PinotMetricName name, TimeUnit durationUnit,
- TimeUnit rateUnit) {
+ public static PinotTimer makePinotTimer(PinotMetricsRegistry registry, PinotMetricName name, TimeUnit durationUnit, TimeUnit rateUnit) {
return registry.newTimer(name, durationUnit, rateUnit);
}
- public static PinotMeter makePinotMeter(PinotMetricsRegistry registry, PinotMetricName name, String eventType,
- TimeUnit unit) {
+ public static PinotMeter makePinotMeter(PinotMetricsRegistry registry, PinotMetricName name, String eventType, TimeUnit unit) {
return registry.newMeter(name, eventType, unit);
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerGauge.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerGauge.java
index 2b22f4a..d9b9c5d 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerGauge.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerGauge.java
@@ -45,24 +45,24 @@ public enum ServerGauge implements AbstractMetrics.Gauge {
// Upsert metrics
UPSERT_PRIMARY_KEYS_COUNT("upsertPrimaryKeysCount", false);
- private final String gaugeName;
- private final String unit;
- private final boolean global;
+ private final String _gaugeName;
+ private final String _unit;
+ private final boolean _global;
ServerGauge(String unit, boolean global) {
- this.unit = unit;
- this.global = global;
- this.gaugeName = Utils.toCamelCase(name().toLowerCase());
+ _unit = unit;
+ _global = global;
+ _gaugeName = Utils.toCamelCase(name().toLowerCase());
}
@Override
public String getGaugeName() {
- return gaugeName;
+ return _gaugeName;
}
@Override
public String getUnit() {
- return unit;
+ return _unit;
}
/**
@@ -72,6 +72,6 @@ public enum ServerGauge implements AbstractMetrics.Gauge {
*/
@Override
public boolean isGlobal() {
- return global;
+ return _global;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerMeter.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerMeter.java
index 0399b9d..bf4d507 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerMeter.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerMeter.java
@@ -70,24 +70,24 @@ public enum ServerMeter implements AbstractMetrics.Meter {
NETTY_CONNECTION_RESPONSES_SENT("nettyConnection", true),
NETTY_CONNECTION_BYTES_SENT("nettyConnection", true);
- private final String meterName;
- private final String unit;
- private final boolean global;
+ private final String _meterName;
+ private final String _unit;
+ private final boolean _global;
ServerMeter(String unit, boolean global) {
- this.unit = unit;
- this.global = global;
- this.meterName = Utils.toCamelCase(name().toLowerCase());
+ _unit = unit;
+ _global = global;
+ _meterName = Utils.toCamelCase(name().toLowerCase());
}
@Override
public String getMeterName() {
- return meterName;
+ return _meterName;
}
@Override
public String getUnit() {
- return unit;
+ return _unit;
}
/**
@@ -97,6 +97,6 @@ public enum ServerMeter implements AbstractMetrics.Meter {
*/
@Override
public boolean isGlobal() {
- return global;
+ return _global;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerMetrics.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerMetrics.java
index 2784c4f..ceb8fd6 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerMetrics.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerMetrics.java
@@ -36,8 +36,7 @@ public class ServerMetrics extends AbstractMetrics<ServerQueryPhase, ServerMeter
this(DEFAULT_METRICS_PREFIX, metricsRegistry, DEFAULT_ENABLE_TABLE_LEVEL_METRICS, Collections.emptySet());
}
- public ServerMetrics(PinotMetricsRegistry metricsRegistry, boolean isTableLevelMetricsEnabled,
- Collection<String> allowedTables) {
+ public ServerMetrics(PinotMetricsRegistry metricsRegistry, boolean isTableLevelMetricsEnabled, Collection<String> allowedTables) {
this(DEFAULT_METRICS_PREFIX, metricsRegistry, isTableLevelMetricsEnabled, allowedTables);
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerQueryPhase.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerQueryPhase.java
index 7a667eb..2953c4a 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerQueryPhase.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerQueryPhase.java
@@ -37,14 +37,14 @@ public enum ServerQueryPhase implements AbstractMetrics.QueryPhase {
// NOTE: update query.context.TimerContext toString() method if you
// time more phases of query execution
- private final String queryPhaseName;
+ private final String _queryPhaseName;
ServerQueryPhase() {
- queryPhaseName = Utils.toCamelCase(name().toLowerCase());
+ _queryPhaseName = Utils.toCamelCase(name().toLowerCase());
}
@Override
public String getQueryPhaseName() {
- return queryPhaseName;
+ return _queryPhaseName;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerTimer.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerTimer.java
index 947e598..c1e1615 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerTimer.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerTimer.java
@@ -35,17 +35,17 @@ public enum ServerTimer implements AbstractMetrics.Timer {
// Query cost (thread cpu time) for query processing on server
EXECUTION_THREAD_CPU_TIME_NS("nanoseconds", false);
- private final String timerName;
- private final boolean global;
+ private final String _timerName;
+ private final boolean _global;
ServerTimer(String unit, boolean global) {
- this.global = global;
- this.timerName = Utils.toCamelCase(name().toLowerCase());
+ _global = global;
+ _timerName = Utils.toCamelCase(name().toLowerCase());
}
@Override
public String getTimerName() {
- return timerName;
+ return _timerName;
}
/**
@@ -55,6 +55,6 @@ public enum ServerTimer implements AbstractMetrics.Timer {
*/
@Override
public boolean isGlobal() {
- return global;
+ return _global;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ValidationMetrics.java b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ValidationMetrics.java
index 440791d..43f401f 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/metrics/ValidationMetrics.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/metrics/ValidationMetrics.java
@@ -33,6 +33,8 @@ import org.apache.pinot.spi.metrics.PinotMetricsRegistry;
* Validation metrics utility class, which contains the glue code to publish metrics.
*/
public class ValidationMetrics {
+ private static final double MILLIS_PER_HOUR = TimeUnit.MILLISECONDS.convert(1, TimeUnit.HOURS);
+
private final PinotMetricsRegistry _metricsRegistry;
private final Map<String, Long> _gaugeValues = new HashMap<>();
private final Set<PinotMetricName> _metricNames = new HashSet<>();
@@ -41,15 +43,15 @@ public class ValidationMetrics {
* A simple gauge that returns whatever last value was stored in the _gaugeValues hash map.
*/
private class StoredValueGauge implements PinotGauge<Long> {
- private final String key;
+ private final String _key;
public StoredValueGauge(String key) {
- this.key = key;
+ _key = key;
}
@Override
public Long value() {
- return _gaugeValues.get(key);
+ return _gaugeValues.get(_key);
}
@Override
@@ -68,17 +70,15 @@ public class ValidationMetrics {
* _gaugeValues hash map.
*/
private class CurrentTimeMillisDeltaGaugeHours implements PinotGauge<Double> {
- private final String key;
-
- private final double MILLIS_PER_HOUR = TimeUnit.MILLISECONDS.convert(1, TimeUnit.HOURS);
+ private final String _key;
public CurrentTimeMillisDeltaGaugeHours(String key) {
- this.key = key;
+ _key = key;
}
@Override
public Double value() {
- Long gaugeValue = _gaugeValues.get(key);
+ Long gaugeValue = _gaugeValues.get(_key);
if (gaugeValue != null && gaugeValue != Long.MIN_VALUE) {
return (System.currentTimeMillis() - gaugeValue) / MILLIS_PER_HOUR;
@@ -149,8 +149,7 @@ public class ValidationMetrics {
*/
public void updateOfflineSegmentDelayGauge(final String resource, final long lastOfflineSegmentTime) {
final String fullGaugeNameHours = makeGaugeName(resource, "offlineSegmentDelayHours");
- makeGauge(fullGaugeNameHours, makeMetricName(fullGaugeNameHours), _currentTimeMillisDeltaGaugeHoursFactory,
- lastOfflineSegmentTime);
+ makeGauge(fullGaugeNameHours, makeMetricName(fullGaugeNameHours), _currentTimeMillisDeltaGaugeHoursFactory, lastOfflineSegmentTime);
}
/**
@@ -162,8 +161,7 @@ public class ValidationMetrics {
*/
public void updateLastPushTimeGauge(final String resource, final long lastPushTimeMillis) {
final String fullGaugeNameHours = makeGaugeName(resource, "lastPushTimeDelayHours");
- makeGauge(fullGaugeNameHours, makeMetricName(fullGaugeNameHours), _currentTimeMillisDeltaGaugeHoursFactory,
- lastPushTimeMillis);
+ makeGauge(fullGaugeNameHours, makeMetricName(fullGaugeNameHours), _currentTimeMillisDeltaGaugeHoursFactory, lastPushTimeMillis);
}
/**
@@ -208,8 +206,7 @@ public class ValidationMetrics {
return PinotMetricUtils.makePinotMetricName(ValidationMetrics.class, gaugeName);
}
- private void makeGauge(final String gaugeName, final PinotMetricName metricName, final GaugeFactory<?> gaugeFactory,
- final long value) {
+ private void makeGauge(final String gaugeName, final PinotMetricName metricName, final GaugeFactory<?> gaugeFactory, final long value) {
if (!_gaugeValues.containsKey(gaugeName)) {
_gaugeValues.put(gaugeName, value);
PinotMetricUtils.makeGauge(_metricsRegistry, metricName, gaugeFactory.buildGauge(gaugeName));
@@ -233,7 +230,7 @@ public class ValidationMetrics {
@VisibleForTesting
public long getValueOfGauge(final String fullGaugeName) {
- Long value = _gaugeValues.get(fullGaugeName);
+ Long value = _gaugeValues.get(fullGaugeName);
if (value == null) {
return 0;
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/minion/MergeRollupTaskMetadata.java b/pinot-common/src/main/java/org/apache/pinot/common/minion/MergeRollupTaskMetadata.java
index 47ea6d1..e46eca4 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/minion/MergeRollupTaskMetadata.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/minion/MergeRollupTaskMetadata.java
@@ -27,7 +27,8 @@ import org.apache.pinot.spi.utils.JsonUtils;
/**
* Metadata for the minion task of type <code>MergeRollupTask</code>.
- * The <code>watermarkMap</code> denotes the time (exclusive) upto which tasks have been executed for the bucket granularity.
+ * The <code>watermarkMap</code> denotes the time (exclusive) upto which tasks have been executed for the bucket
+ * granularity.
*
* This gets serialized and stored in zookeeper under the path MINION_TASK_METADATA/MergeRollupTask/tableNameWithType
*/
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/minion/MinionClient.java b/pinot-common/src/main/java/org/apache/pinot/common/minion/MinionClient.java
index 292328f..ba47139 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/minion/MinionClient.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/minion/MinionClient.java
@@ -67,14 +67,14 @@ public class MinionClient {
public Map<String, String> scheduleMinionTasks(@Nullable String taskType, @Nullable String tableNameWithType)
throws IOException {
- HttpPost httpPost = createHttpPostRequest(
- MinionRequestURLBuilder.baseUrl(getControllerUrl()).forTaskSchedule(taskType, tableNameWithType));
+ HttpPost httpPost =
+ createHttpPostRequest(MinionRequestURLBuilder.baseUrl(getControllerUrl()).forTaskSchedule(taskType, tableNameWithType));
HttpResponse response = HTTP_CLIENT.execute(httpPost);
int statusCode = response.getStatusLine().getStatusCode();
final String responseString = IOUtils.toString(response.getEntity().getContent());
if (statusCode >= 400) {
- throw new HttpException(String
- .format("Unable to schedule minion tasks. Error code %d, Error message: %s", statusCode, responseString));
+ throw new HttpException(
+ String.format("Unable to schedule minion tasks. Error code %d, Error message: %s", statusCode, responseString));
}
return JsonUtils.stringToObject(responseString, new TypeReference<Map<String, String>>() {
});
@@ -82,14 +82,13 @@ public class MinionClient {
public Map<String, String> getTasksStates(String taskType)
throws IOException {
- HttpGet httpGet =
- createHttpGetRequest(MinionRequestURLBuilder.baseUrl(getControllerUrl()).forTasksStates(taskType));
+ HttpGet httpGet = createHttpGetRequest(MinionRequestURLBuilder.baseUrl(getControllerUrl()).forTasksStates(taskType));
HttpResponse response = HTTP_CLIENT.execute(httpGet);
int statusCode = response.getStatusLine().getStatusCode();
final String responseString = IOUtils.toString(response.getEntity().getContent());
if (statusCode >= 400) {
- throw new HttpException(String
- .format("Unable to get tasks states map. Error code %d, Error message: %s", statusCode, responseString));
+ throw new HttpException(
+ String.format("Unable to get tasks states map. Error code %d, Error message: %s", statusCode, responseString));
}
return JsonUtils.stringToObject(responseString, new TypeReference<Map<String, String>>() {
});
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/minion/MinionTaskMetadataUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/minion/MinionTaskMetadataUtils.java
index 02a250e..10e0c0f 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/minion/MinionTaskMetadataUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/minion/MinionTaskMetadataUtils.java
@@ -56,43 +56,39 @@ public final class MinionTaskMetadataUtils {
* Will fail if expectedVersion does not match.
* Set expectedVersion -1 to override version check.
*/
- public static void persistMergeRollupTaskMetadata(HelixPropertyStore<ZNRecord> propertyStore,
- String taskType, MergeRollupTaskMetadata mergeRollupTaskMetadata,
- int expectedVersion) {
- String path = ZKMetadataProvider.constructPropertyStorePathForMinionTaskMetadata(taskType,
- mergeRollupTaskMetadata.getTableNameWithType());
- if (!propertyStore
- .set(path, mergeRollupTaskMetadata.toZNRecord(), expectedVersion, AccessOption.PERSISTENT)) {
- throw new ZkException(
- "Failed to persist minion MergeRollupTask metadata: " + mergeRollupTaskMetadata);
+ public static void persistMergeRollupTaskMetadata(HelixPropertyStore<ZNRecord> propertyStore, String taskType,
+ MergeRollupTaskMetadata mergeRollupTaskMetadata, int expectedVersion) {
+ String path =
+ ZKMetadataProvider.constructPropertyStorePathForMinionTaskMetadata(taskType, mergeRollupTaskMetadata.getTableNameWithType());
+ if (!propertyStore.set(path, mergeRollupTaskMetadata.toZNRecord(), expectedVersion, AccessOption.PERSISTENT)) {
+ throw new ZkException("Failed to persist minion MergeRollupTask metadata: " + mergeRollupTaskMetadata);
}
}
/**
- * Fetches the ZNRecord for RealtimeToOfflineSegmentsTask for given tableNameWithType from MINION_TASK_METADATA/RealtimeToOfflineSegmentsTask/tableNameWthType
+ * Fetches the ZNRecord for RealtimeToOfflineSegmentsTask for given tableNameWithType from
+ * MINION_TASK_METADATA/RealtimeToOfflineSegmentsTask/tableNameWthType
* and converts it to a {@link RealtimeToOfflineSegmentsTaskMetadata} object
*/
@Nullable
- public static RealtimeToOfflineSegmentsTaskMetadata getRealtimeToOfflineSegmentsTaskMetadata(
- HelixPropertyStore<ZNRecord> propertyStore, String taskType, String tableNameWithType) {
+ public static RealtimeToOfflineSegmentsTaskMetadata getRealtimeToOfflineSegmentsTaskMetadata(HelixPropertyStore<ZNRecord> propertyStore,
+ String taskType, String tableNameWithType) {
ZNRecord znRecord = fetchMinionTaskMetadataZNRecord(propertyStore, taskType, tableNameWithType);
return znRecord != null ? RealtimeToOfflineSegmentsTaskMetadata.fromZNRecord(znRecord) : null;
}
/**
- * Persists the provided {@link RealtimeToOfflineSegmentsTaskMetadata} to MINION_TASK_METADATA/RealtimeToOfflineSegmentsTask/tableNameWthType.
+ * Persists the provided {@link RealtimeToOfflineSegmentsTaskMetadata} to MINION_TASK_METADATA
+ * /RealtimeToOfflineSegmentsTask/tableNameWthType.
* Will fail if expectedVersion does not match.
* Set expectedVersion -1 to override version check.
*/
- public static void persistRealtimeToOfflineSegmentsTaskMetadata(HelixPropertyStore<ZNRecord> propertyStore,
- String taskType, RealtimeToOfflineSegmentsTaskMetadata realtimeToOfflineSegmentsTaskMetadata,
- int expectedVersion) {
- String path = ZKMetadataProvider.constructPropertyStorePathForMinionTaskMetadata(taskType,
- realtimeToOfflineSegmentsTaskMetadata.getTableNameWithType());
- if (!propertyStore
- .set(path, realtimeToOfflineSegmentsTaskMetadata.toZNRecord(), expectedVersion, AccessOption.PERSISTENT)) {
- throw new ZkException(
- "Failed to persist minion RealtimeToOfflineSegmentsTask metadata: " + realtimeToOfflineSegmentsTaskMetadata);
+ public static void persistRealtimeToOfflineSegmentsTaskMetadata(HelixPropertyStore<ZNRecord> propertyStore, String taskType,
+ RealtimeToOfflineSegmentsTaskMetadata realtimeToOfflineSegmentsTaskMetadata, int expectedVersion) {
+ String path = ZKMetadataProvider
+ .constructPropertyStorePathForMinionTaskMetadata(taskType, realtimeToOfflineSegmentsTaskMetadata.getTableNameWithType());
+ if (!propertyStore.set(path, realtimeToOfflineSegmentsTaskMetadata.toZNRecord(), expectedVersion, AccessOption.PERSISTENT)) {
+ throw new ZkException("Failed to persist minion RealtimeToOfflineSegmentsTask metadata: " + realtimeToOfflineSegmentsTaskMetadata);
}
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/minion/RealtimeToOfflineSegmentsTaskMetadata.java b/pinot-common/src/main/java/org/apache/pinot/common/minion/RealtimeToOfflineSegmentsTaskMetadata.java
index 2bd9c4c..5a3d70d 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/minion/RealtimeToOfflineSegmentsTaskMetadata.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/minion/RealtimeToOfflineSegmentsTaskMetadata.java
@@ -27,7 +27,8 @@ import org.apache.pinot.spi.utils.JsonUtils;
* Metadata for the minion task of type <code>RealtimeToOfflineSegmentsTask</code>.
* The <code>watermarkMs</code> denotes the time (exclusive) upto which tasks have been executed.
*
- * This gets serialized and stored in zookeeper under the path MINION_TASK_METADATA/RealtimeToOfflineSegmentsTask/tableNameWithType
+ * This gets serialized and stored in zookeeper under the path
+ * MINION_TASK_METADATA/RealtimeToOfflineSegmentsTask/tableNameWithType
*
* PinotTaskGenerator:
* The <code>watermarkMs</code>> is used by the <code>RealtimeToOfflineSegmentsTaskGenerator</code>,
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/protocols/SegmentCompletionProtocol.java b/pinot-common/src/main/java/org/apache/pinot/common/protocols/SegmentCompletionProtocol.java
index 3fa2c2c..4805105 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/protocols/SegmentCompletionProtocol.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/protocols/SegmentCompletionProtocol.java
@@ -52,6 +52,8 @@ import org.apache.pinot.spi.utils.JsonUtils;
* https://cwiki.apache.org/confluence/display/PINOT/Consuming+and+Indexing+rows+in+Realtime
*/
public class SegmentCompletionProtocol {
+ private SegmentCompletionProtocol() {
+ }
/**
* MAX_HOLD_TIME_MS is the maximum time (msecs) for which a server will be in HOLDING state, after which it will
@@ -59,12 +61,12 @@ public class SegmentCompletionProtocol {
*/
public static final long MAX_HOLD_TIME_MS = 3000;
/**
- * MAX_SEGMENT_COMMIT_TIME_MS is the longest time (msecs) a server will take to complete building a segment and committing
+ * MAX_SEGMENT_COMMIT_TIME_MS is the longest time (msecs) a server will take to complete building a segment and
+ * committing
* it (via a SegmentCommit message) after the server has been notified that it is the committer.
*/
private static final int DEFAULT_MAX_SEGMENT_COMMIT_TIME_SEC = 120;
- private static long MAX_SEGMENT_COMMIT_TIME_MS =
- TimeUnit.MILLISECONDS.convert(DEFAULT_MAX_SEGMENT_COMMIT_TIME_SEC, TimeUnit.SECONDS);
+ private static long _maxSegmentCommitTimeMs = TimeUnit.MILLISECONDS.convert(DEFAULT_MAX_SEGMENT_COMMIT_TIME_SEC, TimeUnit.SECONDS);
public enum ControllerResponseStatus {
/** Never sent by the controller, but locally used by server when sending a request fails */
@@ -106,7 +108,8 @@ public class SegmentCompletionProtocol {
public static final String STATUS_KEY = "status";
public static final String OFFSET_KEY = "offset";
- public static final String BUILD_TIME_KEY = "buildTimeSec"; // Sent by controller in COMMIT message
+ // Sent by controller in COMMIT message
+ public static final String BUILD_TIME_KEY = "buildTimeSec";
public static final String COMMIT_TYPE_KEY = "isSplitCommitType";
public static final String SEGMENT_LOCATION_KEY = "segmentLocation";
public static final String CONTROLLER_VIP_URL_KEY = "controllerVipUrl";
@@ -131,29 +134,30 @@ public class SegmentCompletionProtocol {
public static final String PARAM_REASON = "reason";
// Sent by servers to request additional time to build
public static final String PARAM_EXTRA_TIME_SEC = "extraTimeSec";
- public static final String PARAM_ROW_COUNT = "rowCount"; // Sent by servers to indicate the number of rows read so far
- public static final String PARAM_BUILD_TIME_MILLIS = "buildTimeMillis"; // Time taken to build segment
- public static final String PARAM_WAIT_TIME_MILLIS = "waitTimeMillis"; // Time taken to wait for build to start.
-
- public static final String REASON_ROW_LIMIT = "rowLimit"; // Stop reason sent by server as max num rows reached
- public static final String REASON_TIME_LIMIT = "timeLimit"; // Stop reason sent by server as max time reached
- public static final String REASON_END_OF_PARTITION_GROUP = "endOfPartitionGroup"; // Stop reason sent by server as end of partitionGroup reached
+ // Sent by servers to indicate the number of rows read so far
+ public static final String PARAM_ROW_COUNT = "rowCount";
+ // Time taken to build segment
+ public static final String PARAM_BUILD_TIME_MILLIS = "buildTimeMillis";
+ // Time taken to wait for build to start.
+ public static final String PARAM_WAIT_TIME_MILLIS = "waitTimeMillis";
+
+ // Stop reason sent by server as max num rows reached
+ public static final String REASON_ROW_LIMIT = "rowLimit";
+ // Stop reason sent by server as max time reached
+ public static final String REASON_TIME_LIMIT = "timeLimit";
+ // Stop reason sent by server as end of partitionGroup reached
+ public static final String REASON_END_OF_PARTITION_GROUP = "endOfPartitionGroup";
// Canned responses
- public static final Response RESP_NOT_LEADER =
- new Response(new Response.Params().withStatus(ControllerResponseStatus.NOT_LEADER));
- public static final Response RESP_FAILED =
- new Response(new Response.Params().withStatus(ControllerResponseStatus.FAILED));
- public static final Response RESP_DISCARD =
- new Response(new Response.Params().withStatus(ControllerResponseStatus.DISCARD));
+ public static final Response RESP_NOT_LEADER = new Response(new Response.Params().withStatus(ControllerResponseStatus.NOT_LEADER));
+ public static final Response RESP_FAILED = new Response(new Response.Params().withStatus(ControllerResponseStatus.FAILED));
+ public static final Response RESP_DISCARD = new Response(new Response.Params().withStatus(ControllerResponseStatus.DISCARD));
public static final Response RESP_COMMIT_SUCCESS =
new Response(new Response.Params().withStatus(ControllerResponseStatus.COMMIT_SUCCESS));
public static final Response RESP_COMMIT_CONTINUE =
new Response(new Response.Params().withStatus(ControllerResponseStatus.COMMIT_CONTINUE));
- public static final Response RESP_PROCESSED =
- new Response(new Response.Params().withStatus(ControllerResponseStatus.PROCESSED));
- public static final Response RESP_NOT_SENT =
- new Response(new Response.Params().withStatus(ControllerResponseStatus.NOT_SENT));
+ public static final Response RESP_PROCESSED = new Response(new Response.Params().withStatus(ControllerResponseStatus.PROCESSED));
+ public static final Response RESP_NOT_SENT = new Response(new Response.Params().withStatus(ControllerResponseStatus.NOT_SENT));
private static final long MEMORY_USED_BYTES_DEFAULT = -1L;
private static final int NUM_ROWS_DEFAULT = -1;
@@ -162,11 +166,11 @@ public class SegmentCompletionProtocol {
private static final long WAIT_TIME_MILLIS_DEFAULT = -1L;
public static long getMaxSegmentCommitTimeMs() {
- return MAX_SEGMENT_COMMIT_TIME_MS;
+ return _maxSegmentCommitTimeMs;
}
public static void setMaxSegmentCommitTimeMs(long commitTimeMs) {
- MAX_SEGMENT_COMMIT_TIME_MS = commitTimeMs;
+ _maxSegmentCommitTimeMs = commitTimeMs;
}
public static int getDefaultMaxSegmentCommitTimeSeconds() {
@@ -191,22 +195,22 @@ public class SegmentCompletionProtocol {
if (_params.getReason() != null) {
params.put(PARAM_REASON, _params.getReason());
}
- if ( _params.getBuildTimeMillis() > 0) {
+ if (_params.getBuildTimeMillis() > 0) {
params.put(PARAM_BUILD_TIME_MILLIS, String.valueOf(_params.getBuildTimeMillis()));
}
- if ( _params.getWaitTimeMillis() > 0) {
+ if (_params.getWaitTimeMillis() > 0) {
params.put(PARAM_WAIT_TIME_MILLIS, String.valueOf(_params.getWaitTimeMillis()));
}
- if ( _params.getExtraTimeSec() > 0) {
+ if (_params.getExtraTimeSec() > 0) {
params.put(PARAM_EXTRA_TIME_SEC, String.valueOf(_params.getExtraTimeSec()));
}
- if ( _params.getMemoryUsedBytes() > 0) {
+ if (_params.getMemoryUsedBytes() > 0) {
params.put(PARAM_MEMORY_USED_BYTES, String.valueOf(_params.getMemoryUsedBytes()));
}
- if ( _params.getSegmentSizeBytes() > 0) {
+ if (_params.getSegmentSizeBytes() > 0) {
params.put(PARAM_SEGMENT_SIZE_BYTES, String.valueOf(_params.getSegmentSizeBytes()));
}
- if ( _params.getNumRows() > 0) {
+ if (_params.getNumRows() > 0) {
params.put(PARAM_ROW_COUNT, String.valueOf(_params.getNumRows()));
}
if (_params.getSegmentLocation() != null) {
@@ -371,11 +375,10 @@ public class SegmentCompletionProtocol {
}
public String toString() {
- return "Offset: " + _offset + ",Segment name: " + _segmentName + ",Instance Id: " + _instanceId + ",Reason: "
- + _reason + ",NumRows: " + _numRows + ",BuildTimeMillis: " + _buildTimeMillis + ",WaitTimeMillis: "
- + _waitTimeMillis + ",ExtraTimeSec: " + _extraTimeSec + ",SegmentLocation: " + _segmentLocation
- + ",MemoryUsedBytes: " + _memoryUsedBytes + ",SegmentSizeBytes: " + _segmentSizeBytes
- + ",StreamPartitionMsgOffset: " + _streamPartitionMsgOffset;
+ return "Offset: " + _offset + ",Segment name: " + _segmentName + ",Instance Id: " + _instanceId + ",Reason: " + _reason
+ + ",NumRows: " + _numRows + ",BuildTimeMillis: " + _buildTimeMillis + ",WaitTimeMillis: " + _waitTimeMillis + ",ExtraTimeSec: "
+ + _extraTimeSec + ",SegmentLocation: " + _segmentLocation + ",MemoryUsedBytes: " + _memoryUsedBytes + ",SegmentSizeBytes: "
+ + _segmentSizeBytes + ",StreamPartitionMsgOffset: " + _streamPartitionMsgOffset;
}
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/response/broker/BrokerResponseNative.java b/pinot-common/src/main/java/org/apache/pinot/common/response/broker/BrokerResponseNative.java
index 6e50816..da1d80c 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/response/broker/BrokerResponseNative.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/response/broker/BrokerResponseNative.java
@@ -39,13 +39,14 @@ import org.apache.pinot.spi.utils.JsonUtils;
*
* Supports serialization via JSON.
*/
-@JsonPropertyOrder({"selectionResults", "aggregationResults", "resultTable", "exceptions", "numServersQueried", "numServersResponded", "numSegmentsQueried", "numSegmentsProcessed", "numSegmentsMatched", "numConsumingSegmentsQueried", "numDocsScanned", "numEntriesScannedInFilter", "numEntriesScannedPostFilter", "numGroupsLimitReached", "totalDocs", "timeUsedMs", "offlineThreadCpuTimeNs", "realtimeThreadCpuTimeNs", "segmentStatistics", "traceInfo"})
+@JsonPropertyOrder({"selectionResults", "aggregationResults", "resultTable", "exceptions", "numServersQueried", "numServersResponded",
+ "numSegmentsQueried", "numSegmentsProcessed", "numSegmentsMatched", "numConsumingSegmentsQueried", "numDocsScanned",
+ "numEntriesScannedInFilter", "numEntriesScannedPostFilter", "numGroupsLimitReached", "totalDocs", "timeUsedMs",
+ "offlineThreadCpuTimeNs", "realtimeThreadCpuTimeNs", "segmentStatistics", "traceInfo"})
public class BrokerResponseNative implements BrokerResponse {
public static final BrokerResponseNative EMPTY_RESULT = BrokerResponseNative.empty();
- public static final BrokerResponseNative NO_TABLE_RESULT =
- new BrokerResponseNative(QueryException.BROKER_RESOURCE_MISSING_ERROR);
- public static final BrokerResponseNative TABLE_DOES_NOT_EXIST =
- new BrokerResponseNative(QueryException.TABLE_DOES_NOT_EXIST_ERROR);
+ public static final BrokerResponseNative NO_TABLE_RESULT = new BrokerResponseNative(QueryException.BROKER_RESOURCE_MISSING_ERROR);
+ public static final BrokerResponseNative TABLE_DOES_NOT_EXIST = new BrokerResponseNative(QueryException.TABLE_DOES_NOT_EXIST_ERROR);
private int _numServersQueried = 0;
private int _numServersResponded = 0;
@@ -291,7 +292,9 @@ public class BrokerResponseNative implements BrokerResponse {
@JsonProperty("numRowsResultSet")
@Override
- public int getNumRowsResultSet() { return _numRowsResultSet; }
+ public int getNumRowsResultSet() {
+ return _numRowsResultSet;
+ }
@JsonProperty("offlineThreadCpuTimeNs")
@Override
@@ -301,7 +304,9 @@ public class BrokerResponseNative implements BrokerResponse {
@JsonProperty("numRowsResultSet")
@Override
- public void setNumRowsResultSet(int numRowsResultSet) { _numRowsResultSet = numRowsResultSet; }
+ public void setNumRowsResultSet(int numRowsResultSet) {
+ _numRowsResultSet = numRowsResultSet;
+ }
@JsonProperty("realtimeThreadCpuTimeNs")
@Override
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/response/broker/SelectionResults.java b/pinot-common/src/main/java/org/apache/pinot/common/response/broker/SelectionResults.java
index abffd5b..e848f17 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/response/broker/SelectionResults.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/response/broker/SelectionResults.java
@@ -31,8 +31,7 @@ public class SelectionResults {
private List<Serializable[]> _rows;
@JsonCreator
- public SelectionResults(@JsonProperty("columns") List<String> columns,
- @JsonProperty("results") List<Serializable[]> results) {
+ public SelectionResults(@JsonProperty("columns") List<String> columns, @JsonProperty("results") List<Serializable[]> results) {
_columns = columns;
_rows = results;
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/ResourceUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/ResourceUtils.java
index 88ce0a3..8a8e6be 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/ResourceUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/ResourceUtils.java
@@ -30,11 +30,11 @@ import org.slf4j.LoggerFactory;
* Util class for Pinot APIs.
*/
public class ResourceUtils {
- private static final Logger LOGGER = LoggerFactory.getLogger(ResourceUtils.class);
-
private ResourceUtils() {
}
+ private static final Logger LOGGER = LoggerFactory.getLogger(ResourceUtils.class);
+
public static String convertToJsonString(Object object) {
try {
return JsonUtils.objectToPrettyString(object);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentConsumerInfo.java b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentConsumerInfo.java
index 83e0433..78adab8 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentConsumerInfo.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentConsumerInfo.java
@@ -33,8 +33,7 @@ public class SegmentConsumerInfo {
private final long _lastConsumedTimestamp;
private final Map<String, String> _partitionToOffsetMap;
- public SegmentConsumerInfo(@JsonProperty("segmentName") String segmentName,
- @JsonProperty("consumerState") String consumerState,
+ public SegmentConsumerInfo(@JsonProperty("segmentName") String segmentName, @JsonProperty("consumerState") String consumerState,
@JsonProperty("lastConsumedTimestamp") long lastConsumedTimestamp,
@JsonProperty("partitionToOffsetMap") Map<String, String> partitionToOffsetMap) {
_segmentName = segmentName;
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentErrorInfo.java b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentErrorInfo.java
index 29e7257..34a6347 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentErrorInfo.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentErrorInfo.java
@@ -57,8 +57,8 @@ public class SegmentErrorInfo {
*
*/
@JsonCreator
- public SegmentErrorInfo(@JsonProperty("timestamp") String timestamp,
- @JsonProperty("errorMessage") String errorMessage, @JsonProperty("stackTrace") String stackTrace) {
+ public SegmentErrorInfo(@JsonProperty("timestamp") String timestamp, @JsonProperty("errorMessage") String errorMessage,
+ @JsonProperty("stackTrace") String stackTrace) {
_timestamp = timestamp;
_errorMessage = errorMessage;
_stackTrace = stackTrace;
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentServerDebugInfo.java b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentServerDebugInfo.java
index b6953d6..61a8efc 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentServerDebugInfo.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentServerDebugInfo.java
@@ -40,9 +40,8 @@ public class SegmentServerDebugInfo {
private final SegmentErrorInfo _errorInfo;
@JsonCreator
- public SegmentServerDebugInfo(@JsonProperty("segmentName") String segmentName,
- @JsonProperty("segmentSize") String segmentSize, @JsonProperty("consumerInfo") SegmentConsumerInfo consumerInfo,
- @JsonProperty("errorInfo") SegmentErrorInfo errorInfo) {
+ public SegmentServerDebugInfo(@JsonProperty("segmentName") String segmentName, @JsonProperty("segmentSize") String segmentSize,
+ @JsonProperty("consumerInfo") SegmentConsumerInfo consumerInfo, @JsonProperty("errorInfo") SegmentErrorInfo errorInfo) {
_segmentName = segmentName;
_segmentSize = segmentSize;
_consumerInfo = consumerInfo;
@@ -64,5 +63,4 @@ public class SegmentServerDebugInfo {
public SegmentErrorInfo getErrorInfo() {
return _errorInfo;
}
-
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentSizeInfo.java b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentSizeInfo.java
index 362c8a5..3972143 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentSizeInfo.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentSizeInfo.java
@@ -18,21 +18,28 @@
*/
package org.apache.pinot.common.restlet.resources;
+import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class SegmentSizeInfo {
- public String segmentName;
- public long diskSizeInBytes = -1;
+ private final String _segmentName;
+ private final long _diskSizeInBytes;
- public SegmentSizeInfo() {
+ @JsonCreator
+ public SegmentSizeInfo(@JsonProperty("segmentName") String segmentName, @JsonProperty("diskSizeInBytes") long sizeBytes) {
+ _segmentName = segmentName;
+ _diskSizeInBytes = sizeBytes;
+ }
+ public String getSegmentName() {
+ return _segmentName;
}
- public SegmentSizeInfo(String segmentName, long sizeBytes) {
- this.segmentName = segmentName;
- this.diskSizeInBytes = sizeBytes;
+ public long getDiskSizeInBytes() {
+ return _diskSizeInBytes;
}
@Override
@@ -46,16 +53,16 @@ public class SegmentSizeInfo {
SegmentSizeInfo that = (SegmentSizeInfo) o;
- if (diskSizeInBytes != that.diskSizeInBytes) {
+ if (_diskSizeInBytes != that._diskSizeInBytes) {
return false;
}
- return segmentName != null ? segmentName.equals(that.segmentName) : that.segmentName == null;
+ return _segmentName != null ? _segmentName.equals(that._segmentName) : that._segmentName == null;
}
@Override
public int hashCode() {
- int result = segmentName != null ? segmentName.hashCode() : 0;
- result = 31 * result + (int) (diskSizeInBytes ^ (diskSizeInBytes >>> 32));
+ int result = _segmentName != null ? _segmentName.hashCode() : 0;
+ result = 31 * result + (int) (_diskSizeInBytes ^ (_diskSizeInBytes >>> 32));
return result;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/StartReplaceSegmentsRequest.java b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/StartReplaceSegmentsRequest.java
index fdf3f56..7210294 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/StartReplaceSegmentsRequest.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/StartReplaceSegmentsRequest.java
@@ -33,8 +33,8 @@ import javax.annotation.Nullable;
* 2. segmentsTo : merged segments.
*/
public class StartReplaceSegmentsRequest {
- private List<String> _segmentsFrom;
- private List<String> _segmentsTo;
+ private final List<String> _segmentsFrom;
+ private final List<String> _segmentsTo;
public StartReplaceSegmentsRequest(@JsonProperty("segmentsFrom") @Nullable List<String> segmentsFrom,
@JsonProperty("segmentsTo") List<String> segmentsTo) {
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SystemResourceInfo.java b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SystemResourceInfo.java
index 1cdf20e..b188ad3 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SystemResourceInfo.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SystemResourceInfo.java
@@ -34,9 +34,9 @@ import java.util.Map;
public class SystemResourceInfo {
private static final int MEGA_BYTES = 1024 * 1024;
- private final String NUM_CORES_KEY = "numCores";
- private final String TOTAL_MEMORY_MB_KEY = "totalMemoryMB";
- private final String MAX_HEAP_SIZE_MB_KEY = "maxHeapSizeMB";
+ private static final String NUM_CORES_KEY = "numCores";
+ private static final String TOTAL_MEMORY_MB_KEY = "totalMemoryMB";
+ private static final String MAX_HEAP_SIZE_MB_KEY = "maxHeapSizeMB";
private final int _numCores;
private final long _totalMemoryMB;
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TableMetadataInfo.java b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TableMetadataInfo.java
index ecafce0..558e848 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TableMetadataInfo.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TableMetadataInfo.java
@@ -18,8 +18,9 @@
*/
package org.apache.pinot.common.restlet.resources;
+import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import java.util.HashMap;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;
@@ -34,10 +35,47 @@ import java.util.Map;
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class TableMetadataInfo {
- public String tableName = "";
- public long diskSizeInBytes = 0;
- public long numSegments = 0;
- public long numRows = 0;
- public Map<String, Double> columnLengthMap = new HashMap<>();
- public Map<String, Double> columnCardinalityMap = new HashMap<>();
+ private final String _tableName;
+ private final long _diskSizeInBytes;
+ private final long _numSegments;
+ private final long _numRows;
+ private final Map<String, Double> _columnLengthMap;
+ private final Map<String, Double> _columnCardinalityMap;
+
+ @JsonCreator
+ public TableMetadataInfo(@JsonProperty("tableName") String tableName, @JsonProperty("diskSizeInBytes") long sizeInBytes,
+ @JsonProperty("numSegments") long numSegments, @JsonProperty("numRows") long numRows,
+ @JsonProperty("columnLengthMap") Map<String, Double> columnLengthMap,
+ @JsonProperty("columnCardinalityMap") Map<String, Double> columnCardinalityMap) {
+ _tableName = tableName;
+ _diskSizeInBytes = sizeInBytes;
+ _numSegments = numSegments;
+ _numRows = numRows;
+ _columnLengthMap = columnLengthMap;
+ _columnCardinalityMap = columnCardinalityMap;
+ }
+
+ public String getTableName() {
+ return _tableName;
+ }
+
+ public long getDiskSizeInBytes() {
+ return _diskSizeInBytes;
+ }
+
+ public long getNumSegments() {
+ return _numSegments;
+ }
+
+ public long getNumRows() {
+ return _numRows;
+ }
+
+ public Map<String, Double> getColumnLengthMap() {
+ return _columnLengthMap;
+ }
+
+ public Map<String, Double> getColumnCardinalityMap() {
+ return _columnCardinalityMap;
+ }
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TableSegments.java b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TableSegments.java
index ccda527..adedc28 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TableSegments.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TableSegments.java
@@ -23,17 +23,13 @@ import java.util.List;
public class TableSegments {
- List<String> segments;
+ private final List<String> _segments;
public TableSegments(@JsonProperty("segments") List<String> segments) {
- this.segments = segments;
+ _segments = segments;
}
public List<String> getSegments() {
- return segments;
- }
-
- public void setSegments(List<String> segments) {
- this.segments = segments;
+ return _segments;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TableSizeInfo.java b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TableSizeInfo.java
index 548a78e..b6621d9 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TableSizeInfo.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TableSizeInfo.java
@@ -18,23 +18,35 @@
*/
package org.apache.pinot.common.restlet.resources;
+import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import java.util.ArrayList;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
public class TableSizeInfo {
- public String tableName;
- public long diskSizeInBytes = -1;
- public List<SegmentSizeInfo> segments = new ArrayList<>();
+ private final String _tableName;
+ private final long _diskSizeInBytes;
+ private final List<SegmentSizeInfo> _segments;
- public TableSizeInfo() {
+ @JsonCreator
+ public TableSizeInfo(@JsonProperty("tableName") String tableName, @JsonProperty("diskSizeInBytes") long sizeInBytes,
+ @JsonProperty("segments") List<SegmentSizeInfo> segments) {
+ _tableName = tableName;
+ _diskSizeInBytes = sizeInBytes;
+ _segments = segments;
+ }
+
+ public String getTableName() {
+ return _tableName;
+ }
+ public long getDiskSizeInBytes() {
+ return _diskSizeInBytes;
}
- public TableSizeInfo(String tableName, long sizeInBytes) {
- this.tableName = tableName;
- this.diskSizeInBytes = sizeInBytes;
+ public List<SegmentSizeInfo> getSegments() {
+ return _segments;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TablesList.java b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TablesList.java
index 3fb3ce3..fc32940 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TablesList.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/TablesList.java
@@ -23,7 +23,7 @@ import java.util.List;
public class TablesList {
- private List<String> _tables;
+ private final List<String> _tables;
public TablesList(@JsonProperty("tables") List<String> tables) {
_tables = tables;
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/segment/generation/SegmentGenerationUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/segment/generation/SegmentGenerationUtils.java
index 1b0c809..d45a876 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/segment/generation/SegmentGenerationUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/segment/generation/SegmentGenerationUtils.java
@@ -39,6 +39,8 @@ import org.apache.pinot.spi.utils.JsonUtils;
public class SegmentGenerationUtils {
+ private SegmentGenerationUtils() {
+ }
private static final String OFFLINE = "OFFLINE";
public static final String PINOT_PLUGINS_TAR_GZ = "pinot-plugins.tar.gz";
@@ -120,8 +122,7 @@ public class SegmentGenerationUtils {
try {
tableConfigJson = fetchUrl(tableConfigURI.toURL(), authToken);
} catch (IOException e) {
- throw new RuntimeException(
- "Failed to read from table config file data stream on Pinot fs - '" + tableConfigURI + "'", e);
+ throw new RuntimeException("Failed to read from table config file data stream on Pinot fs - '" + tableConfigURI + "'", e);
}
}
// Controller API returns a wrapper of table config.
@@ -154,8 +155,7 @@ public class SegmentGenerationUtils {
public static URI getRelativeOutputPath(URI baseInputDir, URI inputFile, URI outputDir) {
URI relativePath = baseInputDir.relativize(inputFile);
Preconditions.checkState(relativePath.getPath().length() > 0 && !relativePath.equals(inputFile),
- "Unable to extract out the relative path for input file '" + inputFile + "', based on base input path: "
- + baseInputDir);
+ "Unable to extract out the relative path for input file '" + inputFile + "', based on base input path: " + baseInputDir);
String outputDirStr = outputDir.toString();
outputDir = !outputDirStr.endsWith("/") ? URI.create(outputDirStr.concat("/")) : outputDir;
URI relativeOutputURI = outputDir.resolve(relativePath).resolve(".");
@@ -189,9 +189,8 @@ public class SegmentGenerationUtils {
throws URISyntaxException {
URI fileURI = URI.create(uriStr);
if (fileURI.getScheme() == null) {
- return new URI(fullUriForPathOnlyUriStr.getScheme(), fullUriForPathOnlyUriStr.getUserInfo(),
- fullUriForPathOnlyUriStr.getHost(), fullUriForPathOnlyUriStr.getPort(), fileURI.getPath(), fileURI.getQuery(),
- fileURI.getFragment());
+ return new URI(fullUriForPathOnlyUriStr.getScheme(), fullUriForPathOnlyUriStr.getUserInfo(), fullUriForPathOnlyUriStr.getHost(),
+ fullUriForPathOnlyUriStr.getPort(), fileURI.getPath(), fileURI.getQuery(), fileURI.getFragment());
}
return fileURI;
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/tier/TierSegmentSelector.java b/pinot-common/src/main/java/org/apache/pinot/common/tier/TierSegmentSelector.java
index a4c7769..565479c 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/tier/TierSegmentSelector.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/tier/TierSegmentSelector.java
@@ -35,5 +35,4 @@ public interface TierSegmentSelector {
* @return true if eligible
*/
boolean selectSegment(String tableNameWithType, String segmentName);
-
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/tier/TimeBasedTierSegmentSelector.java b/pinot-common/src/main/java/org/apache/pinot/common/tier/TimeBasedTierSegmentSelector.java
index 3f06761..f526b87 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/tier/TimeBasedTierSegmentSelector.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/tier/TimeBasedTierSegmentSelector.java
@@ -43,7 +43,8 @@ public class TimeBasedTierSegmentSelector implements TierSegmentSelector {
}
/**
- * Checks if a segment is eligible for the tier based on the segment age i.e. the end time of the segment from zk metadata
+ * Checks if a segment is eligible for the tier based on the segment age i.e. the end time of the segment from zk
+ * metadata
* @param tableNameWithType Name of the table
* @param segmentName Name of the segment
* @return true if eligible
@@ -53,14 +54,12 @@ public class TimeBasedTierSegmentSelector implements TierSegmentSelector {
SegmentZKMetadata segmentZKMetadata =
ZKMetadataProvider.getSegmentZKMetadata(_helixManager.getHelixPropertyStore(), tableNameWithType, segmentName);
Preconditions
- .checkNotNull(segmentZKMetadata, "Could not find zk metadata for segment: {} of table: {}", segmentName,
- tableNameWithType);
+ .checkNotNull(segmentZKMetadata, "Could not find zk metadata for segment: {} of table: {}", segmentName, tableNameWithType);
// get segment end time to decide if segment gets selected
long endTimeMs = segmentZKMetadata.getEndTimeMs();
Preconditions
- .checkState(endTimeMs > 0, "Invalid endTimeMs: %s for segment: %s of table: %s", endTimeMs, segmentName,
- tableNameWithType);
+ .checkState(endTimeMs > 0, "Invalid endTimeMs: %s for segment: %s of table: %s", endTimeMs, segmentName, tableNameWithType);
long now = System.currentTimeMillis();
return (now - endTimeMs) > _segmentAgeMillis;
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/ClientSSLContextGenerator.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/ClientSSLContextGenerator.java
index a5a7e0f..32a41bc 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/ClientSSLContextGenerator.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/ClientSSLContextGenerator.java
@@ -101,8 +101,7 @@ public class ClientSSLContextGenerator {
int i = 0;
while (is.available() > 0) {
X509Certificate cert = (X509Certificate) certificateFactory.generateCertificate(is);
- LOGGER.info("Read certificate serial number {} by issuer {} ", cert.getSerialNumber().toString(16),
- cert.getIssuerDN().toString());
+ LOGGER.info("Read certificate serial number {} by issuer {} ", cert.getSerialNumber().toString(16), cert.getIssuerDN().toString());
String serverKey = "https-server-" + i;
trustStore.setCertificateEntry(serverKey, cert);
@@ -130,7 +129,8 @@ public class ClientSSLContextGenerator {
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
- }};
+ }
+ };
return trustAllCerts;
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/DataSchema.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/DataSchema.java
index b871c0e..961bde6 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/DataSchema.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/DataSchema.java
@@ -46,8 +46,7 @@ public class DataSchema {
private ColumnDataType[] _storedColumnDataTypes;
@JsonCreator
- public DataSchema(@JsonProperty("columnNames") String[] columnNames,
- @JsonProperty("columnDataTypes") ColumnDataType[] columnDataTypes) {
+ public DataSchema(@JsonProperty("columnNames") String[] columnNames, @JsonProperty("columnDataTypes") ColumnDataType[] columnDataTypes) {
_columnNames = columnNames;
_columnDataTypes = columnDataTypes;
}
@@ -277,8 +276,7 @@ public class DataSchema {
}
public boolean isArray() {
- return this == INT_ARRAY || this == LONG_ARRAY || this == FLOAT_ARRAY || this == DOUBLE_ARRAY
- || this == STRING_ARRAY;
+ return this == INT_ARRAY || this == LONG_ARRAY || this == FLOAT_ARRAY || this == DOUBLE_ARRAY || this == STRING_ARRAY;
}
public boolean isNumberArray() {
@@ -291,8 +289,8 @@ public class DataSchema {
public boolean isCompatible(ColumnDataType anotherColumnDataType) {
// All numbers are compatible with each other
- return this == anotherColumnDataType || (this.isNumber() && anotherColumnDataType.isNumber()) || (
- this.isNumberArray() && anotherColumnDataType.isNumberArray());
+ return this == anotherColumnDataType || (this.isNumber() && anotherColumnDataType.isNumber()) || (this.isNumberArray()
+ && anotherColumnDataType.isNumberArray());
}
public DataType toDataType() {
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/DataTable.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/DataTable.java
index 0e62948..8e4abd8 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/DataTable.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/DataTable.java
@@ -101,7 +101,7 @@ public interface DataTable {
RESIZE_TIME_MS("resizeTimeMs", MetadataValueType.LONG),
THREAD_CPU_TIME_NS("threadCpuTimeNs", MetadataValueType.LONG);
- private static final Map<String, MetadataKey> _nameToEnumKeyMap = new HashMap<>();
+ private static final Map<String, MetadataKey> NAME_TO_ENUM_KEY_MAP = new HashMap<>();
private final String _name;
private final MetadataValueType _valueType;
@@ -121,7 +121,7 @@ public interface DataTable {
// getByName returns an enum key for a given name or null if the key does not exist.
public static MetadataKey getByName(String name) {
- return _nameToEnumKeyMap.getOrDefault(name, null);
+ return NAME_TO_ENUM_KEY_MAP.getOrDefault(name, null);
}
// getName returns the associated name(string) of the enum key.
@@ -136,7 +136,7 @@ public interface DataTable {
static {
for (MetadataKey key : MetadataKey.values()) {
- if (_nameToEnumKeyMap.put(key.getName(), key) != null) {
+ if (NAME_TO_ENUM_KEY_MAP.put(key.getName(), key) != null) {
throw new IllegalArgumentException("Duplicate name defined in the MetadataKey definition: " + key.getName());
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java
index e6b5914..b85144e 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java
@@ -181,8 +181,7 @@ public class FileUploadDownloadClient implements Closeable {
* This method calls the old segment endpoint. We will deprecate this behavior soon.
*/
@Deprecated
- public static URI getDeleteSegmentHttpUri(String host, int port, String rawTableName, String segmentName,
- String tableType)
+ public static URI getDeleteSegmentHttpUri(String host, int port, String rawTableName, String segmentName, String tableType)
throws URISyntaxException {
return new URI(StringUtil.join("/", StringUtils.chomp(HTTP + "://" + host + ":" + port, "/"), OLD_SEGMENT_PATH,
rawTableName + "/" + URIUtils.encode(segmentName) + "?" + TYPE_DELIMITER + tableType));
@@ -194,8 +193,7 @@ public class FileUploadDownloadClient implements Closeable {
* This method calls the old segment endpoint. We will deprecate this behavior soon.
*/
@Deprecated
- public static URI getRetrieveAllSegmentWithTableTypeHttpUri(String host, int port, String rawTableName,
- String tableType)
+ public static URI getRetrieveAllSegmentWithTableTypeHttpUri(String host, int port, String rawTableName, String tableType)
throws URISyntaxException {
return new URI(StringUtil.join("/", StringUtils.chomp(HTTP + "://" + host + ":" + port, "/"), OLD_SEGMENT_PATH,
rawTableName + "?" + TYPE_DELIMITER + tableType));
@@ -315,65 +313,60 @@ public class FileUploadDownloadClient implements Closeable {
OLD_SEGMENT_PATH + "/" + rawTableName + START_REPLACE_SEGMENTS_PATH, TYPE_DELIMITER + tableType);
}
- public static URI getEndReplaceSegmentsURI(URI controllerURI, String rawTableName, String tableType,
- String segmentLineageEntryId)
+ public static URI getEndReplaceSegmentsURI(URI controllerURI, String rawTableName, String tableType, String segmentLineageEntryId)
throws URISyntaxException {
return getURI(controllerURI.getScheme(), controllerURI.getHost(), controllerURI.getPort(),
OLD_SEGMENT_PATH + "/" + rawTableName + END_REPLACE_SEGMENTS_PATH,
TYPE_DELIMITER + tableType + SEGMENT_LINEAGE_ENTRY_ID_PARAMETER + segmentLineageEntryId);
}
-
- private static HttpUriRequest getUploadFileRequest(String method, URI uri, ContentBody contentBody,
- @Nullable List<Header> headers, @Nullable List<NameValuePair> parameters, int socketTimeoutMs) {
+ private static HttpUriRequest getUploadFileRequest(String method, URI uri, ContentBody contentBody, @Nullable List<Header> headers,
+ @Nullable List<NameValuePair> parameters, int socketTimeoutMs) {
// Build the Http entity
- HttpEntity entity = MultipartEntityBuilder.create().setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
- .addPart(contentBody.getFilename(), contentBody).build();
+ HttpEntity entity =
+ MultipartEntityBuilder.create().setMode(HttpMultipartMode.BROWSER_COMPATIBLE).addPart(contentBody.getFilename(), contentBody)
+ .build();
// Build the request
- RequestBuilder requestBuilder =
- RequestBuilder.create(method).setVersion(HttpVersion.HTTP_1_1).setUri(uri).setEntity(entity);
+ RequestBuilder requestBuilder = RequestBuilder.create(method).setVersion(HttpVersion.HTTP_1_1).setUri(uri).setEntity(entity);
addHeadersAndParameters(requestBuilder, headers, parameters);
setTimeout(requestBuilder, socketTimeoutMs);
return requestBuilder.build();
}
- private static HttpUriRequest getDeleteFileRequest(String method, URI uri, ContentBody contentBody,
- @Nullable List<Header> headers, @Nullable List<NameValuePair> parameters, int socketTimeoutMs) {
+ private static HttpUriRequest getDeleteFileRequest(String method, URI uri, ContentBody contentBody, @Nullable List<Header> headers,
+ @Nullable List<NameValuePair> parameters, int socketTimeoutMs) {
// Build the Http entity
- HttpEntity entity = MultipartEntityBuilder.create().setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
- .addPart(contentBody.getFilename(), contentBody).build();
+ HttpEntity entity =
+ MultipartEntityBuilder.create().setMode(HttpMultipartMode.BROWSER_COMPATIBLE).addPart(contentBody.getFilename(), contentBody)
+ .build();
// Build the request
- RequestBuilder requestBuilder =
- RequestBuilder.create(method).setVersion(HttpVersion.HTTP_1_1).setUri(uri).setEntity(entity);
+ RequestBuilder requestBuilder = RequestBuilder.create(method).setVersion(HttpVersion.HTTP_1_1).setUri(uri).setEntity(entity);
addHeadersAndParameters(requestBuilder, headers, parameters);
setTimeout(requestBuilder, socketTimeoutMs);
return requestBuilder.build();
}
- private static HttpUriRequest getAddSchemaRequest(URI uri, String schemaName, File schemaFile,
- @Nullable List<Header> headers, @Nullable List<NameValuePair> parameters) {
+ private static HttpUriRequest getAddSchemaRequest(URI uri, String schemaName, File schemaFile, @Nullable List<Header> headers,
+ @Nullable List<NameValuePair> parameters) {
return getUploadFileRequest(HttpPost.METHOD_NAME, uri, getContentBody(schemaName, schemaFile), headers, parameters,
DEFAULT_SOCKET_TIMEOUT_MS);
}
- private static HttpUriRequest getUploadSegmentRequest(URI uri, String segmentName, File segmentFile,
- @Nullable List<Header> headers, @Nullable List<NameValuePair> parameters, int socketTimeoutMs) {
- return getUploadFileRequest(HttpPost.METHOD_NAME, uri, getContentBody(segmentName, segmentFile), headers,
- parameters, socketTimeoutMs);
+ private static HttpUriRequest getUploadSegmentRequest(URI uri, String segmentName, File segmentFile, @Nullable List<Header> headers,
+ @Nullable List<NameValuePair> parameters, int socketTimeoutMs) {
+ return getUploadFileRequest(HttpPost.METHOD_NAME, uri, getContentBody(segmentName, segmentFile), headers, parameters, socketTimeoutMs);
}
private static HttpUriRequest getUploadSegmentRequest(URI uri, String segmentName, InputStream inputStream,
@Nullable List<Header> headers, @Nullable List<NameValuePair> parameters, int socketTimeoutMs) {
- return getUploadFileRequest(HttpPost.METHOD_NAME, uri, getContentBody(segmentName, inputStream), headers,
- parameters, socketTimeoutMs);
+ return getUploadFileRequest(HttpPost.METHOD_NAME, uri, getContentBody(segmentName, inputStream), headers, parameters, socketTimeoutMs);
}
private static HttpUriRequest getUploadSegmentMetadataRequest(URI uri, String segmentName, File segmentFile,
@Nullable List<Header> headers, @Nullable List<NameValuePair> parameters, int socketTimeoutMs) {
- return getUploadFileRequest(HttpPost.METHOD_NAME, uri, getContentBody(segmentName, segmentFile), headers,
- parameters, socketTimeoutMs);
+ return getUploadFileRequest(HttpPost.METHOD_NAME, uri, getContentBody(segmentName, segmentFile), headers, parameters, socketTimeoutMs);
}
private static HttpUriRequest getUploadSegmentMetadataFilesRequest(URI uri, Map<String, File> metadataFiles,
@@ -395,9 +388,9 @@ public class FileUploadDownloadClient implements Closeable {
private static HttpUriRequest getSendSegmentUriRequest(URI uri, String downloadUri, @Nullable List<Header> headers,
@Nullable List<NameValuePair> parameters, int socketTimeoutMs) {
- RequestBuilder requestBuilder = RequestBuilder.post(uri).setVersion(HttpVersion.HTTP_1_1)
- .setHeader(CustomHeaders.UPLOAD_TYPE, FileUploadType.URI.toString())
- .setHeader(CustomHeaders.DOWNLOAD_URI, downloadUri).setHeader(HttpHeaders.CONTENT_TYPE, JSON_CONTENT_TYPE);
+ RequestBuilder requestBuilder =
+ RequestBuilder.post(uri).setVersion(HttpVersion.HTTP_1_1).setHeader(CustomHeaders.UPLOAD_TYPE, FileUploadType.URI.toString())
+ .setHeader(CustomHeaders.DOWNLOAD_URI, downloadUri).setHeader(HttpHeaders.CONTENT_TYPE, JSON_CONTENT_TYPE);
addHeadersAndParameters(requestBuilder, headers, parameters);
setTimeout(requestBuilder, socketTimeoutMs);
return requestBuilder.build();
@@ -405,25 +398,25 @@ public class FileUploadDownloadClient implements Closeable {
private static HttpUriRequest getSendSegmentJsonRequest(URI uri, String jsonString, @Nullable List<Header> headers,
@Nullable List<NameValuePair> parameters, int socketTimeoutMs) {
- RequestBuilder requestBuilder = RequestBuilder.post(uri).setVersion(HttpVersion.HTTP_1_1)
- .setHeader(CustomHeaders.UPLOAD_TYPE, FileUploadType.JSON.toString())
- .setEntity(new StringEntity(jsonString, ContentType.APPLICATION_JSON));
+ RequestBuilder requestBuilder =
+ RequestBuilder.post(uri).setVersion(HttpVersion.HTTP_1_1).setHeader(CustomHeaders.UPLOAD_TYPE, FileUploadType.JSON.toString())
+ .setEntity(new StringEntity(jsonString, ContentType.APPLICATION_JSON));
addHeadersAndParameters(requestBuilder, headers, parameters);
setTimeout(requestBuilder, socketTimeoutMs);
return requestBuilder.build();
}
private static HttpUriRequest getStartReplaceSegmentsRequest(URI uri, String jsonRequestBody, int socketTimeoutMs) {
- RequestBuilder requestBuilder = RequestBuilder.post(uri).setVersion(HttpVersion.HTTP_1_1)
- .setHeader(HttpHeaders.CONTENT_TYPE, JSON_CONTENT_TYPE)
- .setEntity(new StringEntity(jsonRequestBody, ContentType.APPLICATION_JSON));
+ RequestBuilder requestBuilder =
+ RequestBuilder.post(uri).setVersion(HttpVersion.HTTP_1_1).setHeader(HttpHeaders.CONTENT_TYPE, JSON_CONTENT_TYPE)
+ .setEntity(new StringEntity(jsonRequestBody, ContentType.APPLICATION_JSON));
setTimeout(requestBuilder, socketTimeoutMs);
return requestBuilder.build();
}
private static HttpUriRequest getEndReplaceSegmentsRequest(URI uri, int socketTimeoutMs) {
- RequestBuilder requestBuilder = RequestBuilder.post(uri).setVersion(HttpVersion.HTTP_1_1)
- .setHeader(HttpHeaders.CONTENT_TYPE, JSON_CONTENT_TYPE);
+ RequestBuilder requestBuilder =
+ RequestBuilder.post(uri).setVersion(HttpVersion.HTTP_1_1).setHeader(HttpHeaders.CONTENT_TYPE, JSON_CONTENT_TYPE);
setTimeout(requestBuilder, socketTimeoutMs);
return requestBuilder.build();
}
@@ -488,9 +481,8 @@ public class FileUploadDownloadClient implements Closeable {
controllerVersion = response.getFirstHeader(CommonConstants.Controller.VERSION_HTTP_HEADER).getValue();
}
if (controllerHost != null) {
- LOGGER.info(String
- .format("Sending request: %s to controller: %s, version: %s", request.getURI(), controllerHost,
- controllerVersion));
+ LOGGER
+ .info(String.format("Sending request: %s to controller: %s, version: %s", request.getURI(), controllerHost, controllerVersion));
}
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode >= 300) {
@@ -514,11 +506,11 @@ public class FileUploadDownloadClient implements Closeable {
} catch (Exception e) {
reason = "Failed to get reason";
}
- String errorMessage = String.format("Got error status code: %d (%s) with reason: \"%s\" while sending request: %s",
- statusLine.getStatusCode(), statusLine.getReasonPhrase(), reason, request.getURI());
+ String errorMessage = String
+ .format("Got error status code: %d (%s) with reason: \"%s\" while sending request: %s", statusLine.getStatusCode(),
+ statusLine.getReasonPhrase(), reason, request.getURI());
if (controllerHost != null) {
- errorMessage =
- String.format("%s to controller: %s, version: %s", errorMessage, controllerHost, controllerVersion);
+ errorMessage = String.format("%s to controller: %s, version: %s", errorMessage, controllerHost, controllerVersion);
}
return errorMessage;
}
@@ -621,8 +613,7 @@ public class FileUploadDownloadClient implements Closeable {
public SimpleHttpResponse updateSchema(URI uri, String schemaName, File schemaFile)
throws IOException, HttpErrorStatusException {
return sendRequest(
- getUploadFileRequest(HttpPut.METHOD_NAME, uri, getContentBody(schemaName, schemaFile), null, null,
- DEFAULT_SOCKET_TIMEOUT_MS));
+ getUploadFileRequest(HttpPut.METHOD_NAME, uri, getContentBody(schemaName, schemaFile), null, null, DEFAULT_SOCKET_TIMEOUT_MS));
}
/**
@@ -640,9 +631,8 @@ public class FileUploadDownloadClient implements Closeable {
public SimpleHttpResponse updateSchema(URI uri, String schemaName, File schemaFile, @Nullable List<Header> headers,
@Nullable List<NameValuePair> parameters)
throws IOException, HttpErrorStatusException {
- return sendRequest(
- getUploadFileRequest(HttpPut.METHOD_NAME, uri, getContentBody(schemaName, schemaFile), headers, parameters,
- DEFAULT_SOCKET_TIMEOUT_MS));
+ return sendRequest(getUploadFileRequest(HttpPut.METHOD_NAME, uri, getContentBody(schemaName, schemaFile), headers, parameters,
+ DEFAULT_SOCKET_TIMEOUT_MS));
}
/**
@@ -658,11 +648,10 @@ public class FileUploadDownloadClient implements Closeable {
* @throws IOException
* @throws HttpErrorStatusException
*/
- public SimpleHttpResponse uploadSegmentMetadata(URI uri, String segmentName, File segmentMetadataFile,
- @Nullable List<Header> headers, @Nullable List<NameValuePair> parameters, int socketTimeoutMs)
+ public SimpleHttpResponse uploadSegmentMetadata(URI uri, String segmentName, File segmentMetadataFile, @Nullable List<Header> headers,
+ @Nullable List<NameValuePair> parameters, int socketTimeoutMs)
throws IOException, HttpErrorStatusException {
- return sendRequest(
- getUploadSegmentMetadataRequest(uri, segmentName, segmentMetadataFile, headers, parameters, socketTimeoutMs));
+ return sendRequest(getUploadSegmentMetadataRequest(uri, segmentName, segmentMetadataFile, headers, parameters, socketTimeoutMs));
}
/**
@@ -672,19 +661,16 @@ public class FileUploadDownloadClient implements Closeable {
*/
@Deprecated
// Upload a set of segment metadata files (e.g., meta.properties and creation.meta) to controllers.
- public SimpleHttpResponse uploadSegmentMetadataFiles(URI uri, Map<String, File> metadataFiles,
- int segmentUploadRequestTimeoutMs)
+ public SimpleHttpResponse uploadSegmentMetadataFiles(URI uri, Map<String, File> metadataFiles, int segmentUploadRequestTimeoutMs)
throws IOException, HttpErrorStatusException {
- return uploadSegmentMetadataFiles(uri, metadataFiles, Collections.emptyList(), Collections.emptyList(),
- segmentUploadRequestTimeoutMs);
+ return uploadSegmentMetadataFiles(uri, metadataFiles, Collections.emptyList(), Collections.emptyList(), segmentUploadRequestTimeoutMs);
}
// Upload a set of segment metadata files (e.g., meta.properties and creation.meta) to controllers.
- public SimpleHttpResponse uploadSegmentMetadataFiles(URI uri, Map<String, File> metadataFiles,
- @Nullable List<Header> headers, @Nullable List<NameValuePair> parameters, int segmentUploadRequestTimeoutMs)
+ public SimpleHttpResponse uploadSegmentMetadataFiles(URI uri, Map<String, File> metadataFiles, @Nullable List<Header> headers,
+ @Nullable List<NameValuePair> parameters, int segmentUploadRequestTimeoutMs)
throws IOException, HttpErrorStatusException {
- return sendRequest(
- getUploadSegmentMetadataFilesRequest(uri, metadataFiles, headers, parameters, segmentUploadRequestTimeoutMs));
+ return sendRequest(getUploadSegmentMetadataFilesRequest(uri, metadataFiles, headers, parameters, segmentUploadRequestTimeoutMs));
}
/**
@@ -747,8 +733,7 @@ public class FileUploadDownloadClient implements Closeable {
* @throws IOException
* @throws HttpErrorStatusException
*/
- public SimpleHttpResponse uploadSegment(URI uri, String segmentName, File segmentFile, String tableName,
- TableType tableType)
+ public SimpleHttpResponse uploadSegment(URI uri, String segmentName, File segmentFile, String tableName, TableType tableType)
throws IOException, HttpErrorStatusException {
// Add table name and type request parameters
NameValuePair tableNameValuePair = new BasicNameValuePair(QueryParameters.TABLE_NAME, tableName);
@@ -772,8 +757,8 @@ public class FileUploadDownloadClient implements Closeable {
* @throws IOException
* @throws HttpErrorStatusException
*/
- public SimpleHttpResponse uploadSegment(URI uri, String segmentName, InputStream inputStream,
- @Nullable List<Header> headers, @Nullable List<NameValuePair> parameters, int socketTimeoutMs)
+ public SimpleHttpResponse uploadSegment(URI uri, String segmentName, InputStream inputStream, @Nullable List<Header> headers,
+ @Nullable List<NameValuePair> parameters, int socketTimeoutMs)
throws IOException, HttpErrorStatusException {
return sendRequest(getUploadSegmentRequest(uri, segmentName, inputStream, headers, parameters, socketTimeoutMs));
}
@@ -900,7 +885,8 @@ public class FileUploadDownloadClient implements Closeable {
* @throws IOException
* @throws HttpErrorStatusException
*/
- public SimpleHttpResponse endReplaceSegments(URI uri) throws IOException, HttpErrorStatusException {
+ public SimpleHttpResponse endReplaceSegments(URI uri)
+ throws IOException, HttpErrorStatusException {
return sendRequest(getEndReplaceSegmentsRequest(uri, DEFAULT_SOCKET_TIMEOUT_MS));
}
@@ -992,8 +978,8 @@ public class FileUploadDownloadClient implements Closeable {
if (contentLength >= 0L) {
long fileLength = dest.length();
Preconditions.checkState(fileLength == contentLength, String
- .format("While downloading file with uri: %s, file length: %d does not match content length: %d", uri,
- fileLength, contentLength));
+ .format("While downloading file with uri: %s, file length: %d does not match content length: %d", uri, fileLength,
+ contentLength));
}
return statusCode;
@@ -1069,7 +1055,6 @@ public class FileUploadDownloadClient implements Closeable {
* @return param list
*/
public static List<NameValuePair> makeTableParam(String tableName) {
- return Collections
- .singletonList(new BasicNameValuePair(FileUploadDownloadClient.QueryParameters.TABLE_NAME, tableName));
+ return Collections.singletonList(new BasicNameValuePair(FileUploadDownloadClient.QueryParameters.TABLE_NAME, tableName));
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/HLCSegmentName.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/HLCSegmentName.java
index 6c1ba3d..59f444b 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/HLCSegmentName.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/HLCSegmentName.java
@@ -35,7 +35,8 @@ package org.apache.pinot.common.utils;
// groupId: tableName_REALTIME_1433316466991_0
// partitionRange: 0
// sequenceNumber: 1465314044238
-// see org.apache.pinot.controller.helix.core.PinotTableIdealStateBuilder#getGroupIdFromRealtimeDataTable for details on the groupId
+// see org.apache.pinot.controller.helix.core.PinotTableIdealStateBuilder#getGroupIdFromRealtimeDataTable for details
+// on the groupId
import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
@@ -56,7 +57,7 @@ public class HLCSegmentName extends SegmentName {
if (!isHighLevelConsumerSegmentName(segmentName)) {
throw new RuntimeException(segmentName + " is not a HighLevelConsumer segment name");
}
- String parts[] = segmentName.split(SEPARATOR);
+ String[] parts = segmentName.split(SEPARATOR);
if (parts.length == 5) {
_isOldStyleNaming = true;
} else if (parts.length == 3) {
@@ -99,8 +100,7 @@ public class HLCSegmentName extends SegmentName {
_segmentType = RealtimeSegmentType.HLC_SHORT;
} else {
throw new IllegalArgumentException(
- "Invalid group id (" + groupId + "), partition range (" + partitionRange + ") or sequence number ("
- + sequenceNumber + ")");
+ "Invalid group id (" + groupId + "), partition range (" + partitionRange + ") or sequence number (" + sequenceNumber + ")");
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/HashUtil.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/HashUtil.java
index 6571621..2156fa3 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/HashUtil.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/HashUtil.java
@@ -23,11 +23,13 @@ import java.nio.IntBuffer;
public class HashUtil {
+ private HashUtil() {
+ }
/** Tests show that even for smaller set sizes, setting the hash size to this min value
* improves performance at an insignificant increase of memory footprint.
*/
- public static int MIN_FASTUTIL_HASHSET_SIZE = 25;
+ public static final int MIN_FASTUTIL_HASHSET_SIZE = 25;
/**
* Returns the min size for the fast-util hash-set given the expected size of
@@ -70,16 +72,15 @@ public class HashUtil {
final long m = 0xc6a4a7935bd1e995L;
final int r = 47;
- long h = (seed & 0xffffffffl) ^ (length * m);
+ long h = (seed & 0xffffffffL) ^ (length * m);
int length8 = length / 8;
for (int i = 0; i < length8; i++) {
final int i8 = i * 8;
- long k =
- ((long) data[i8 + 0] & 0xff) + (((long) data[i8 + 1] & 0xff) << 8) + (((long) data[i8 + 2] & 0xff) << 16) + (
- ((long) data[i8 + 3] & 0xff) << 24) + (((long) data[i8 + 4] & 0xff) << 32) + (((long) data[i8 + 5] & 0xff)
- << 40) + (((long) data[i8 + 6] & 0xff) << 48) + (((long) data[i8 + 7] & 0xff) << 56);
+ long k = ((long) data[i8 + 0] & 0xff) + (((long) data[i8 + 1] & 0xff) << 8) + (((long) data[i8 + 2] & 0xff) << 16) + (
+ ((long) data[i8 + 3] & 0xff) << 24) + (((long) data[i8 + 4] & 0xff) << 32) + (((long) data[i8 + 5] & 0xff) << 40) + (
+ ((long) data[i8 + 6] & 0xff) << 48) + (((long) data[i8 + 7] & 0xff) << 56);
k *= m;
k ^= k >>> r;
@@ -89,6 +90,7 @@ public class HashUtil {
h *= m;
}
+ // CHECKSTYLE:OFF: checkstyle:coding
switch (length % 8) {
case 7:
h ^= (long) (data[(length & ~7) + 6] & 0xff) << 48;
@@ -106,6 +108,7 @@ public class HashUtil {
h ^= data[length & ~7] & 0xff;
h *= m;
}
+ // CHECKSTYLE:ON: checkstyle:coding
h ^= h >>> r;
h *= m;
@@ -118,6 +121,7 @@ public class HashUtil {
* @param data byte array to hash
* @return 32 bit hash of the given array
*/
+ @SuppressWarnings("checkstyle")
public static int murmur2(final byte[] data) {
int length = data.length;
int seed = 0x9747b28c;
@@ -132,9 +136,7 @@ public class HashUtil {
for (int i = 0; i < length4; i++) {
final int i4 = i * 4;
- int k =
- (data[i4 + 0] & 0xff) + ((data[i4 + 1] & 0xff) << 8) + ((data[i4 + 2] & 0xff) << 16) + ((data[i4 + 3] & 0xff)
- << 24);
+ int k = (data[i4 + 0] & 0xff) + ((data[i4 + 1] & 0xff) << 8) + ((data[i4 + 2] & 0xff) << 16) + ((data[i4 + 3] & 0xff) << 24);
k *= m;
k ^= k >>> r;
k *= m;
@@ -142,6 +144,7 @@ public class HashUtil {
h ^= k;
}
+ // CHECKSTYLE:OFF: checkstyle:coding
// Handle the last few bytes of the input array
switch (length % 4) {
case 3:
@@ -152,6 +155,7 @@ public class HashUtil {
h ^= data[length & ~3] & 0xff;
h *= m;
}
+ // CHECKSTYLE:ON: checkstyle:coding
h ^= h >>> 13;
h *= m;
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/LLCSegmentName.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/LLCSegmentName.java
index a66bb3c..86305fd 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/LLCSegmentName.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/LLCSegmentName.java
@@ -107,8 +107,7 @@ public class LLCSegmentName extends SegmentName implements Comparable {
public int compareTo(Object o) {
LLCSegmentName other = (LLCSegmentName) o;
if (!this.getTableName().equals(other.getTableName())) {
- throw new RuntimeException(
- "Cannot compare segment names " + this.getSegmentName() + " and " + other.getSegmentName());
+ throw new RuntimeException("Cannot compare segment names " + this.getSegmentName() + " and " + other.getSegmentName());
}
if (this.getPartitionGroupId() > other.getPartitionGroupId()) {
return 1;
@@ -122,8 +121,7 @@ public class LLCSegmentName extends SegmentName implements Comparable {
} else {
if (!this.getCreationTime().equals(other.getCreationTime())) {
// If sequence number is the same, time cannot be different.
- throw new RuntimeException(
- "Cannot compare segment names " + this.getSegmentName() + " and " + other.getSegmentName());
+ throw new RuntimeException("Cannot compare segment names " + this.getSegmentName() + " and " + other.getSegmentName());
}
return 0;
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/LLCUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/LLCUtils.java
index 3adbb90..ee71e29 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/LLCUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/LLCUtils.java
@@ -26,6 +26,9 @@ import java.util.TreeSet;
public class LLCUtils {
+ private LLCUtils() {
+ }
+
/**
* Compute the table of a sorted list of segments grouped by Kafka partition.
*
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/LikeToRegexpLikePatternConverterUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/LikeToRegexpLikePatternConverterUtils.java
index 6799742..50f3fdb 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/LikeToRegexpLikePatternConverterUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/LikeToRegexpLikePatternConverterUtils.java
@@ -22,6 +22,9 @@ package org.apache.pinot.common.utils;
* Utility for converting LIKE operator syntax to a regex
*/
public class LikeToRegexpLikePatternConverterUtils {
+ private LikeToRegexpLikePatternConverterUtils() {
+ }
+
/* Represents all metacharacters to be processed */
public static final String[] REGEXP_METACHARACTERS =
{"\\", "^", "$", ".", "{", "}", "[", "]", "(", ")", "*", "+", "?", "|", "<", ">", "-", "&", "/"};
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/NamedThreadFactory.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/NamedThreadFactory.java
index dc98a5d..aa52971 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/NamedThreadFactory.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/NamedThreadFactory.java
@@ -47,11 +47,12 @@ import java.util.concurrent.atomic.AtomicInteger;
* {@link Executors#defaultThreadFactory()}.
*/
public class NamedThreadFactory implements ThreadFactory {
- private static final AtomicInteger threadPoolNumber = new AtomicInteger(1);
- private final ThreadGroup group;
- private final AtomicInteger threadNumber = new AtomicInteger(1);
+ private static final AtomicInteger THREAD_POOL_NUMBER = new AtomicInteger(1);
private static final String NAME_PATTERN = "%s-%d-thread";
- private final String threadNamePrefix;
+
+ private final ThreadGroup _group;
+ private final AtomicInteger _threadNumber = new AtomicInteger(1);
+ private final String _threadNamePrefix;
/**
* Creates a new {@link NamedThreadFactory} instance
@@ -60,9 +61,8 @@ public class NamedThreadFactory implements ThreadFactory {
*/
public NamedThreadFactory(String threadNamePrefix) {
final SecurityManager s = System.getSecurityManager();
- group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
- this.threadNamePrefix =
- String.format(NAME_PATTERN, checkPrefix(threadNamePrefix), threadPoolNumber.getAndIncrement());
+ _group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
+ _threadNamePrefix = String.format(NAME_PATTERN, checkPrefix(threadNamePrefix), THREAD_POOL_NUMBER.getAndIncrement());
}
private static String checkPrefix(String prefix) {
@@ -75,8 +75,7 @@ public class NamedThreadFactory implements ThreadFactory {
* @see java.util.concurrent.ThreadFactory#newThread(java.lang.Runnable)
*/
public Thread newThread(Runnable r) {
- final Thread t =
- new Thread(group, r, String.format("%s-%d", this.threadNamePrefix, threadNumber.getAndIncrement()), 0);
+ final Thread t = new Thread(_group, r, String.format("%s-%d", _threadNamePrefix, _threadNumber.getAndIncrement()), 0);
t.setDaemon(false);
t.setPriority(Thread.NORM_PRIORITY);
return t;
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/PinotAppConfigs.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/PinotAppConfigs.java
index eecc11e..517828f 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/PinotAppConfigs.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/PinotAppConfigs.java
@@ -105,14 +105,15 @@ public class PinotAppConfigs {
// Not all platforms may implement this, and so we may not have access to some of the api's.
if (osMXBean instanceof com.sun.management.OperatingSystemMXBean) {
com.sun.management.OperatingSystemMXBean sunOsMXBean = (com.sun.management.OperatingSystemMXBean) osMXBean;
- systemConfig = new SystemConfig(osMXBean.getArch(), osMXBean.getName(), osMXBean.getVersion(),
- osMXBean.getAvailableProcessors(), FileUtils.byteCountToDisplaySize(sunOsMXBean.getTotalPhysicalMemorySize()),
+ systemConfig = new SystemConfig(osMXBean.getArch(), osMXBean.getName(), osMXBean.getVersion(), osMXBean.getAvailableProcessors(),
+ FileUtils.byteCountToDisplaySize(sunOsMXBean.getTotalPhysicalMemorySize()),
FileUtils.byteCountToDisplaySize(sunOsMXBean.getFreePhysicalMemorySize()),
FileUtils.byteCountToDisplaySize(sunOsMXBean.getTotalSwapSpaceSize()),
FileUtils.byteCountToDisplaySize(sunOsMXBean.getFreeSwapSpaceSize()));
} else {
- systemConfig = new SystemConfig(osMXBean.getArch(), osMXBean.getName(), osMXBean.getVersion(),
- osMXBean.getAvailableProcessors(), UNKNOWN_VALUE, UNKNOWN_VALUE, UNKNOWN_VALUE, UNKNOWN_VALUE);
+ systemConfig =
+ new SystemConfig(osMXBean.getArch(), osMXBean.getName(), osMXBean.getVersion(), osMXBean.getAvailableProcessors(), UNKNOWN_VALUE,
+ UNKNOWN_VALUE, UNKNOWN_VALUE, UNKNOWN_VALUE);
}
return systemConfig;
}
@@ -121,8 +122,8 @@ public class PinotAppConfigs {
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
List<GarbageCollectorMXBean> garbageCollectorMXBeans = ManagementFactory.getGarbageCollectorMXBeans();
String bootClassPath = runtimeMXBean.isBootClassPathSupported() ? runtimeMXBean.getBootClassPath() : null;
- return new JVMConfig(runtimeMXBean.getInputArguments(), runtimeMXBean.getLibraryPath(),
- bootClassPath, runtimeMXBean.getSystemProperties(), System.getenv(),
+ return new JVMConfig(runtimeMXBean.getInputArguments(), runtimeMXBean.getLibraryPath(), bootClassPath,
+ runtimeMXBean.getSystemProperties(), System.getenv(),
garbageCollectorMXBeans.stream().map(MemoryManagerMXBean::getName).collect(Collectors.toList()));
}
@@ -132,8 +133,7 @@ public class PinotAppConfigs {
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
return new RuntimeConfig(threadMXBean.getTotalStartedThreadCount(), threadMXBean.getThreadCount(),
- FileUtils.byteCountToDisplaySize(heapMemoryUsage.getMax()),
- FileUtils.byteCountToDisplaySize(heapMemoryUsage.getUsed()));
+ FileUtils.byteCountToDisplaySize(heapMemoryUsage.getMax()), FileUtils.byteCountToDisplaySize(heapMemoryUsage.getUsed()));
}
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -148,11 +148,10 @@ public class PinotAppConfigs {
private final String _freeSwapSpace;
@JsonCreator
- public SystemConfig(@JsonProperty("arch") String arch, @JsonProperty("name") String name,
- @JsonProperty("version") String version, @JsonProperty("availableProcessors") int availableProcessors,
- @JsonProperty("totalPhysicalMemory") String totalPhysicalMemory,
- @JsonProperty("freePhysicalMemory") String freePhysicalMemory,
- @JsonProperty("totalSwapSpace") String totalSwapSpace, @JsonProperty("freeSwapSpace") String freeSwapSpace) {
+ public SystemConfig(@JsonProperty("arch") String arch, @JsonProperty("name") String name, @JsonProperty("version") String version,
+ @JsonProperty("availableProcessors") int availableProcessors, @JsonProperty("totalPhysicalMemory") String totalPhysicalMemory,
+ @JsonProperty("freePhysicalMemory") String freePhysicalMemory, @JsonProperty("totalSwapSpace") String totalSwapSpace,
+ @JsonProperty("freeSwapSpace") String freeSwapSpace) {
_arch = arch;
_name = name;
_version = version;
@@ -204,17 +203,16 @@ public class PinotAppConfigs {
return false;
}
SystemConfig that = (SystemConfig) o;
- return _availableProcessors == that._availableProcessors && Objects.equals(_arch, that._arch) && Objects
- .equals(_name, that._name) && Objects.equals(_version, that._version) && Objects
- .equals(_totalPhysicalMemory, that._totalPhysicalMemory) && Objects
- .equals(_freePhysicalMemory, that._freePhysicalMemory) && Objects
- .equals(_totalSwapSpace, that._totalSwapSpace) && Objects.equals(_freeSwapSpace, that._freeSwapSpace);
+ return _availableProcessors == that._availableProcessors && Objects.equals(_arch, that._arch) && Objects.equals(_name, that._name)
+ && Objects.equals(_version, that._version) && Objects.equals(_totalPhysicalMemory, that._totalPhysicalMemory) && Objects
+ .equals(_freePhysicalMemory, that._freePhysicalMemory) && Objects.equals(_totalSwapSpace, that._totalSwapSpace) && Objects
+ .equals(_freeSwapSpace, that._freeSwapSpace);
}
@Override
public int hashCode() {
- return Objects.hash(_arch, _name, _version, _availableProcessors, _totalPhysicalMemory, _freePhysicalMemory,
- _totalSwapSpace, _freeSwapSpace);
+ return Objects
+ .hash(_arch, _name, _version, _availableProcessors, _totalPhysicalMemory, _freePhysicalMemory, _totalSwapSpace, _freeSwapSpace);
}
}
@@ -226,9 +224,8 @@ public class PinotAppConfigs {
private final String _currentHeapSize;
@JsonCreator
- public RuntimeConfig(@JsonProperty("numTotalThreads") long numTotalThreads,
- @JsonProperty("numCurrentThreads") int numCurrentThreads, @JsonProperty("maxHeapSize") String maxHeapSize,
- @JsonProperty("currentHeapSize") String currentHeapSize) {
+ public RuntimeConfig(@JsonProperty("numTotalThreads") long numTotalThreads, @JsonProperty("numCurrentThreads") int numCurrentThreads,
+ @JsonProperty("maxHeapSize") String maxHeapSize, @JsonProperty("currentHeapSize") String currentHeapSize) {
_numTotalThreads = numTotalThreads;
_numCurrentThreads = numCurrentThreads;
_maxHeapSize = maxHeapSize;
@@ -290,9 +287,8 @@ public class PinotAppConfigs {
}
JVMConfig jvmConfig = (JVMConfig) o;
return Objects.equals(_args, jvmConfig._args) && Objects.equals(_libraryPath, jvmConfig._libraryPath) && Objects
- .equals(_bootClassPath, jvmConfig._bootClassPath) && Objects.equals(_envVariables, jvmConfig._envVariables)
- && Objects.equals(_systemProperties, jvmConfig._systemProperties) && Objects
- .equals(_garbageCollectors, jvmConfig._garbageCollectors);
+ .equals(_bootClassPath, jvmConfig._bootClassPath) && Objects.equals(_envVariables, jvmConfig._envVariables) && Objects
+ .equals(_systemProperties, jvmConfig._systemProperties) && Objects.equals(_garbageCollectors, jvmConfig._garbageCollectors);
}
@Override
@@ -302,10 +298,8 @@ public class PinotAppConfigs {
@JsonCreator
public JVMConfig(@JsonProperty("args") List<String> args, @JsonProperty("libraryPath") String libraryPath,
- @JsonProperty("bootClassPath") String bootClassPath,
- @JsonProperty("systemProperties") Map<String, String> systemProperties,
- @JsonProperty("envVariables") Map<String, String> envVariables,
- @JsonProperty("garbageCollectors") List<String> garbageCollectors) {
+ @JsonProperty("bootClassPath") String bootClassPath, @JsonProperty("systemProperties") Map<String, String> systemProperties,
+ @JsonProperty("envVariables") Map<String, String> envVariables, @JsonProperty("garbageCollectors") List<String> garbageCollectors) {
_args = args;
_libraryPath = libraryPath;
_bootClassPath = bootClassPath;
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/PinotDataType.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/PinotDataType.java
index cb4b5fa..2f258c3 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/PinotDataType.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/PinotDataType.java
@@ -585,8 +585,7 @@ public enum PinotDataType {
try {
return Base64.getDecoder().decode(value.toString());
} catch (Exception e) {
- throw new RuntimeException("Unable to convert JSON base64 encoded string value to BYTES. Input value: " + value,
- e);
+ throw new RuntimeException("Unable to convert JSON base64 encoded string value to BYTES. Input value: " + value, e);
}
}
@@ -845,8 +844,7 @@ public enum PinotDataType {
try {
return JsonUtils.objectToString(value);
} catch (Exception e) {
- throw new RuntimeException(
- "Unable to convert " + value.getClass().getCanonicalName() + " to JSON. Input value: " + value, e);
+ throw new RuntimeException("Unable to convert " + value.getClass().getCanonicalName() + " to JSON. Input value: " + value, e);
}
}
}
@@ -1187,8 +1185,7 @@ public enum PinotDataType {
throw new IllegalStateException("There is no multi-value type for BYTES");
}
default:
- throw new UnsupportedOperationException(
- "Unsupported data type: " + dataType + " in field: " + fieldSpec.getName());
+ throw new UnsupportedOperationException("Unsupported data type: " + dataType + " in field: " + fieldSpec.getName());
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/PrimitiveArrayUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/PrimitiveArrayUtils.java
index a6a0343..c6bfa3c 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/PrimitiveArrayUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/PrimitiveArrayUtils.java
@@ -25,6 +25,9 @@ import org.apache.commons.lang3.ArrayUtils;
* Utility functions for primitive arrays.
*/
public class PrimitiveArrayUtils {
+ private PrimitiveArrayUtils() {
+ }
+
/**
* Turns the passed array into a primitive array, if necessary.
*
@@ -32,9 +35,8 @@ public class PrimitiveArrayUtils {
* @return A primitive array
*/
public static Object toPrimitive(Object array) {
- if (array instanceof int[] || array instanceof long[] || array instanceof short[] || array instanceof byte[]
- || array instanceof char[] || array instanceof float[] || array instanceof double[]
- || array instanceof boolean[]) {
+ if (array instanceof int[] || array instanceof long[] || array instanceof short[] || array instanceof byte[] || array instanceof char[]
+ || array instanceof float[] || array instanceof double[] || array instanceof boolean[]) {
return array;
} else if (array instanceof Integer[]) {
return ArrayUtils.toPrimitive((Integer[]) array);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/SchemaUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/SchemaUtils.java
index c7f3c99..10b8f8c 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/SchemaUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/SchemaUtils.java
@@ -134,8 +134,7 @@ public class SchemaUtils {
httpPost.releaseConnection();
}
} catch (Exception e) {
- LOGGER.error("Caught exception while posting the schema: {} to host: {}, port: {}", schema.getSchemaName(), host,
- port, e);
+ LOGGER.error("Caught exception while posting the schema: {} to host: {}, port: {}", schema.getSchemaName(), host, port, e);
return false;
}
}
@@ -180,17 +179,16 @@ public class SchemaUtils {
Preconditions.checkNotNull(schema1);
Preconditions.checkNotNull(schema2);
- return schema1.getSchemaName().equals(schema2.getSchemaName()) && schema1.getFieldSpecMap()
- .equals(schema2.getFieldSpecMap());
+ return schema1.getSchemaName().equals(schema2.getSchemaName()) && schema1.getFieldSpecMap().equals(schema2.getFieldSpecMap());
}
/**
* An example on how to use this utility class.
*/
public static void main(String[] args) {
- Schema schema = new Schema.SchemaBuilder().setSchemaName("testSchema")
- .addSingleValueDimension("dimension", FieldSpec.DataType.DOUBLE).addMetric("metric", FieldSpec.DataType.INT)
- .addTime(new TimeGranularitySpec(FieldSpec.DataType.INT, TimeUnit.DAYS, "time"), null).build();
+ Schema schema = new Schema.SchemaBuilder().setSchemaName("testSchema").addSingleValueDimension("dimension", FieldSpec.DataType.DOUBLE)
+ .addMetric("metric", FieldSpec.DataType.INT).addTime(new TimeGranularitySpec(FieldSpec.DataType.INT, TimeUnit.DAYS, "time"), null)
+ .build();
System.out.println(postSchema("localhost", 8100, schema));
Schema fetchedSchema = getSchema("localhost", 8100, "testSchema");
Preconditions.checkNotNull(fetchedSchema);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/SegmentUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/SegmentUtils.java
index cc63ab9..04f2985 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/SegmentUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/SegmentUtils.java
@@ -35,8 +35,8 @@ public class SegmentUtils {
// Returns the partition id of a realtime segment based segment name and segment metadata info retrieved via Helix.
// Important: The method is costly because it may read data from zookeeper. Do not use it in any query execution
// path.
- public static int getRealtimeSegmentPartitionId(String segmentName, String realtimeTableName,
- HelixManager helixManager, String partitionColumn) {
+ public static int getRealtimeSegmentPartitionId(String segmentName, String realtimeTableName, HelixManager helixManager,
+ String partitionColumn) {
// A fast path if the segmentName is a LLC segment name and we can get the partition id from the name directly.
if (LLCSegmentName.isLowLevelConsumerSegmentName(segmentName)) {
return new LLCSegmentName(segmentName).getPartitionGroupId();
@@ -45,22 +45,19 @@ public class SegmentUtils {
// enabled tables have partition ids in their segment metadata.
SegmentZKMetadata segmentZKMetadata =
ZKMetadataProvider.getSegmentZKMetadata(helixManager.getHelixPropertyStore(), realtimeTableName, segmentName);
- Preconditions
- .checkState(segmentZKMetadata != null, "Failed to find segment ZK metadata for segment: %s of table: %s",
- segmentName, realtimeTableName);
+ Preconditions.checkState(segmentZKMetadata != null, "Failed to find segment ZK metadata for segment: %s of table: %s", segmentName,
+ realtimeTableName);
SegmentPartitionMetadata segmentPartitionMetadata = segmentZKMetadata.getPartitionMetadata();
Preconditions.checkState(segmentPartitionMetadata != null,
- "Segment ZK metadata for segment: %s of table: %s does not contain partition metadata", segmentName,
- realtimeTableName);
- ColumnPartitionMetadata columnPartitionMetadata =
- segmentPartitionMetadata.getColumnPartitionMap().get(partitionColumn);
+ "Segment ZK metadata for segment: %s of table: %s does not contain partition metadata", segmentName, realtimeTableName);
+ ColumnPartitionMetadata columnPartitionMetadata = segmentPartitionMetadata.getColumnPartitionMap().get(partitionColumn);
Preconditions.checkState(columnPartitionMetadata != null,
- "Segment ZK metadata for segment: %s of table: %s does not contain partition metadata for column: %s. Check if the table is an upsert table.",
- segmentName, realtimeTableName, partitionColumn);
+ "Segment ZK metadata for segment: %s of table: %s does not contain partition metadata for column: %s. Check "
+ + "if the table is an upsert table.", segmentName, realtimeTableName, partitionColumn);
Set<Integer> partitions = columnPartitionMetadata.getPartitions();
Preconditions.checkState(partitions.size() == 1,
- "Segment ZK metadata for segment: %s of table: %s contains multiple partitions for column: %s with %s",
- segmentName, realtimeTableName, partitionColumn, partitions);
+ "Segment ZK metadata for segment: %s of table: %s contains multiple partitions for column: %s with %s", segmentName,
+ realtimeTableName, partitionColumn, partitions);
return partitions.iterator().next();
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/ServiceStatus.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/ServiceStatus.java
index cfbd4f0..5df3a6b 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/ServiceStatus.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/ServiceStatus.java
@@ -44,6 +44,9 @@ import org.slf4j.LoggerFactory;
*/
@SuppressWarnings("unused")
public class ServiceStatus {
+ private ServiceStatus() {
+ }
+
public static final String STATUS_DESCRIPTION_NONE = "None";
public static final String STATUS_DESCRIPTION_INIT = "Init";
public static final String STATUS_DESCRIPTION_STARTED = "Started";
@@ -51,25 +54,25 @@ public class ServiceStatus {
public static final String STATUS_DESCRIPTION_NO_HELIX_STATE = "Helix state does not exist";
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceStatus.class);
private static final int MAX_RESOURCE_NAMES_TO_LOG = 5;
- private static final Map<String, ServiceStatusCallback> serviceStatusCallbackMap = new ConcurrentHashMap<>();
- private static final ServiceStatusCallback serviceStatusCallback =
- new MapBasedMultipleCallbackServiceStatusCallback(serviceStatusCallbackMap);
+ private static final Map<String, ServiceStatusCallback> SERVICE_STATUS_CALLBACK_MAP = new ConcurrentHashMap<>();
+ private static final ServiceStatusCallback SERVICE_STATUS_CALLBACK =
+ new MapBasedMultipleCallbackServiceStatusCallback(SERVICE_STATUS_CALLBACK_MAP);
public static void setServiceStatusCallback(String name, ServiceStatusCallback serviceStatusCallback) {
- ServiceStatus.serviceStatusCallbackMap.put(name, serviceStatusCallback);
+ ServiceStatus.SERVICE_STATUS_CALLBACK_MAP.put(name, serviceStatusCallback);
}
public static void removeServiceStatusCallback(String name) {
- ServiceStatus.serviceStatusCallbackMap.remove(name);
+ ServiceStatus.SERVICE_STATUS_CALLBACK_MAP.remove(name);
}
public static Status getServiceStatus() {
- return getServiceStatus(serviceStatusCallback);
+ return getServiceStatus(SERVICE_STATUS_CALLBACK);
}
public static Status getServiceStatus(String name) {
- if (serviceStatusCallbackMap.containsKey(name)) {
- return getServiceStatus(serviceStatusCallbackMap.get(name));
+ if (SERVICE_STATUS_CALLBACK_MAP.containsKey(name)) {
+ return getServiceStatus(SERVICE_STATUS_CALLBACK_MAP.get(name));
} else {
return Status.NOT_STARTED;
}
@@ -85,12 +88,12 @@ public class ServiceStatus {
}
public static String getStatusDescription() {
- return getStatusDescription(serviceStatusCallback);
+ return getStatusDescription(SERVICE_STATUS_CALLBACK);
}
public static String getStatusDescription(String name) {
- if (serviceStatusCallbackMap.containsKey(name)) {
- return getStatusDescription(serviceStatusCallbackMap.get(name));
+ if (SERVICE_STATUS_CALLBACK_MAP.containsKey(name)) {
+ return getStatusDescription(SERVICE_STATUS_CALLBACK_MAP.get(name));
} else {
return STATUS_DESCRIPTION_NONE;
}
@@ -106,7 +109,7 @@ public class ServiceStatus {
public static Map<String, Map<String, String>> getServiceStatusMap() {
Map<String, Map<String, String>> results = new HashMap<>();
- serviceStatusCallbackMap.forEach((k, v) -> {
+ SERVICE_STATUS_CALLBACK_MAP.forEach((k, v) -> {
Map<String, String> result = new HashMap<>();
result.put("StatusDescription", v.getStatusDescription());
result.put("ServiceStatus", v.getServiceStatus().toString());
@@ -154,8 +157,8 @@ public class ServiceStatus {
public String getStatusDescription() {
StringBuilder statusDescription = new StringBuilder();
for (ServiceStatusCallback statusCallback : _statusCallbacks) {
- statusDescription.append(statusCallback.getClass().getSimpleName()).append(":")
- .append(statusCallback.getStatusDescription()).append(";");
+ statusDescription.append(statusCallback.getClass().getSimpleName()).append(":").append(statusCallback.getStatusDescription())
+ .append(";");
}
return statusDescription.toString();
}
@@ -192,8 +195,8 @@ public class ServiceStatus {
}
StringBuilder statusDescription = new StringBuilder();
for (ServiceStatusCallback statusCallback : _statusCallbacks.values()) {
- statusDescription.append(statusCallback.getClass().getSimpleName()).append(":")
- .append(statusCallback.getStatusDescription()).append(";");
+ statusDescription.append(statusCallback.getClass().getSimpleName()).append(":").append(statusCallback.getStatusDescription())
+ .append(";");
}
return statusDescription.toString();
}
@@ -216,14 +219,14 @@ public class ServiceStatus {
/**
* Realtime consumption catchup service which adds a static wait time for consuming segments to catchup
*/
- public RealtimeConsumptionCatchupServiceStatusCallback(HelixManager helixManager, String clusterName,
- String instanceName, long realtimeConsumptionCatchupWaitMs) {
+ public RealtimeConsumptionCatchupServiceStatusCallback(HelixManager helixManager, String clusterName, String instanceName,
+ long realtimeConsumptionCatchupWaitMs) {
- // A consuming segment will actually be ready to serve queries after (time of creation of partition consumer) + (configured max time to catchup)
+ // A consuming segment will actually be ready to serve queries after (time of creation of partition consumer) +
+ // (configured max time to catchup)
// We are approximating it to (time of server startup) + (configured max time to catch up)
_endWaitTime = System.currentTimeMillis() + realtimeConsumptionCatchupWaitMs;
- LOGGER.info("Monitoring realtime consumption catchup. Will allow {} ms before marking status GOOD",
- realtimeConsumptionCatchupWaitMs);
+ LOGGER.info("Monitoring realtime consumption catchup. Will allow {} ms before marking status GOOD", realtimeConsumptionCatchupWaitMs);
}
@Override
@@ -233,8 +236,7 @@ public class ServiceStatus {
}
long now = System.currentTimeMillis();
if (now < _endWaitTime) {
- _statusDescription =
- String.format("Waiting for consuming segments to catchup, timeRemaining=%dms", _endWaitTime - now);
+ _statusDescription = String.format("Waiting for consuming segments to catchup, timeRemaining=%dms", _endWaitTime - now);
return Status.STARTING;
}
_statusDescription = String.format("Consuming segments status GOOD since %dms", _endWaitTime);
@@ -276,8 +278,8 @@ public class ServiceStatus {
_numTotalResourcesToMonitor = _resourcesToMonitor.size();
_minResourcesStartCount = (int) Math.ceil(minResourcesStartPercent * _numTotalResourcesToMonitor / 100);
- LOGGER.info("Monitoring {} resources: {} for start up of instance {}", _numTotalResourcesToMonitor,
- getResourceListAsString(), _instanceName);
+ LOGGER.info("Monitoring {} resources: {} for start up of instance {}", _numTotalResourcesToMonitor, getResourceListAsString(),
+ _instanceName);
}
@Nullable
@@ -325,10 +327,9 @@ public class ServiceStatus {
// Resource is done starting up, remove it from the set
_resourceIterator.remove();
} else {
- _statusDescription = String
- .format("%s, waitingFor=%s, resource=%s, numResourcesLeft=%d, numTotalResources=%d, minStartCount=%d,",
- statusDescriptionPair._description, getMatchName(), resourceName, _resourcesToMonitor.size(),
- _numTotalResourcesToMonitor, _minResourcesStartCount);
+ _statusDescription = String.format("%s, waitingFor=%s, resource=%s, numResourcesLeft=%d, numTotalResources=%d, minStartCount=%d,",
+ statusDescriptionPair._description, getMatchName(), resourceName, _resourcesToMonitor.size(), _numTotalResourcesToMonitor,
+ _minResourcesStartCount);
return statusDescriptionPair._status;
}
@@ -366,9 +367,8 @@ public class ServiceStatus {
_statusDescription = STATUS_DESCRIPTION_NONE;
} else {
_statusDescription = String
- .format("waitingFor=%s, numResourcesLeft=%d, numTotalResources=%d, minStartCount=%d, resourceList=%s",
- getMatchName(), _resourcesToMonitor.size(), _numTotalResourcesToMonitor, _minResourcesStartCount,
- getResourceListAsString());
+ .format("waitingFor=%s, numResourcesLeft=%d, numTotalResources=%d, minStartCount=%d, resourceList=%s", getMatchName(),
+ _resourcesToMonitor.size(), _numTotalResourcesToMonitor, _minResourcesStartCount, getResourceListAsString());
LOGGER.info("Instance {} returning GOOD because {}", _instanceName, _statusDescription);
}
@@ -408,8 +408,8 @@ public class ServiceStatus {
} else {
HelixProperty.Stat stat = helixState.getStat();
String description = String
- .format("partition=%s, expected=%s, found=%s, creationTime=%d, modifiedTime=%d, version=%d",
- partitionName, idealStateStatus, currentStateStatus, stat != null ? stat.getCreationTime() : -1,
+ .format("partition=%s, expected=%s, found=%s, creationTime=%d, modifiedTime=%d, version=%d", partitionName,
+ idealStateStatus, currentStateStatus, stat != null ? stat.getCreationTime() : -1,
stat != null ? stat.getModifiedTime() : -1, stat != null ? stat.getVersion() : -1);
return new StatusDescriptionPair(Status.STARTING, description);
}
@@ -448,8 +448,8 @@ public class ServiceStatus {
public static class IdealStateAndCurrentStateMatchServiceStatusCallback extends IdealStateMatchServiceStatusCallback<CurrentState> {
private static final String MATCH_NAME = "CurrentStateMatch";
- public IdealStateAndCurrentStateMatchServiceStatusCallback(HelixManager helixManager, String clusterName,
- String instanceName, List<String> resourcesToMonitor, double minResourcesStartPercent) {
+ public IdealStateAndCurrentStateMatchServiceStatusCallback(HelixManager helixManager, String clusterName, String instanceName,
+ List<String> resourcesToMonitor, double minResourcesStartPercent) {
super(helixManager, clusterName, instanceName, resourcesToMonitor, minResourcesStartPercent);
}
@@ -489,8 +489,8 @@ public class ServiceStatus {
public static class IdealStateAndExternalViewMatchServiceStatusCallback extends IdealStateMatchServiceStatusCallback<ExternalView> {
private static final String MATCH_NAME = "ExternalViewMatch";
- public IdealStateAndExternalViewMatchServiceStatusCallback(HelixManager helixManager, String clusterName,
- String instanceName, List<String> resourcesToMonitor, double minResourcesStartPercent) {
+ public IdealStateAndExternalViewMatchServiceStatusCallback(HelixManager helixManager, String clusterName, String instanceName,
+ List<String> resourcesToMonitor, double minResourcesStartPercent) {
super(helixManager, clusterName, instanceName, resourcesToMonitor, minResourcesStartPercent);
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/StringUtil.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/StringUtil.java
index 51f7632..7a2cb6d 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/StringUtil.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/StringUtil.java
@@ -24,8 +24,11 @@ import org.apache.commons.lang.StringUtils;
// TODO: Use pinot-spi StringUtils instead
public class StringUtil {
+ private StringUtil() {
+ }
+
private static final char NULL_CHARACTER = '\0';
- private static final String charSet = "UTF-8";
+ private static final String CHAR_SET = "UTF-8";
/**
* Joins the given keys with the separator.
@@ -63,7 +66,7 @@ public class StringUtil {
public static byte[] encodeUtf8(String s) {
try {
- return s.getBytes(charSet);
+ return s.getBytes(CHAR_SET);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
@@ -75,7 +78,7 @@ public class StringUtil {
public static String decodeUtf8(byte[] bytes, int startIndex, int length) {
try {
- return new String(bytes, startIndex, length, charSet);
+ return new String(bytes, startIndex, length, CHAR_SET);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/TarGzCompressionUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/TarGzCompressionUtils.java
index b209044..da7d5e9 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/TarGzCompressionUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/TarGzCompressionUtils.java
@@ -56,8 +56,9 @@ public class TarGzCompressionUtils {
*/
public static void createTarGzFile(File inputFile, File outputFile)
throws IOException {
- Preconditions.checkArgument(outputFile.getName().endsWith(TAR_GZ_FILE_EXTENSION),
- "Output file: %s does not have '.tar.gz' file extension", outputFile);
+ Preconditions
+ .checkArgument(outputFile.getName().endsWith(TAR_GZ_FILE_EXTENSION), "Output file: %s does not have '.tar.gz' file extension",
+ outputFile);
try (OutputStream fileOut = Files.newOutputStream(outputFile.toPath());
BufferedOutputStream bufferedOut = new BufferedOutputStream(fileOut);
OutputStream gzipOut = new GzipCompressorOutputStream(bufferedOut);
@@ -113,8 +114,7 @@ public class TarGzCompressionUtils {
throws IOException {
String outputDirCanonicalPath = outputDir.getCanonicalPath();
List<File> untarredFiles = new ArrayList<>();
- try (InputStream bufferedIn = new BufferedInputStream(inputStream);
- InputStream gzipIn = new GzipCompressorInputStream(bufferedIn);
+ try (InputStream bufferedIn = new BufferedInputStream(inputStream); InputStream gzipIn = new GzipCompressorInputStream(bufferedIn);
ArchiveInputStream tarGzIn = new TarArchiveInputStream(gzipIn)) {
ArchiveEntry entry;
while ((entry = tarGzIn.getNextEntry()) != null) {
@@ -126,8 +126,8 @@ public class TarGzCompressionUtils {
}
if (entry.isDirectory()) {
if (!outputFile.getCanonicalPath().startsWith(outputDirCanonicalPath)) {
- throw new IOException(String
- .format("Trying to create directory: %s outside of the output directory: %s", outputFile, outputDir));
+ throw new IOException(
+ String.format("Trying to create directory: %s outside of the output directory: %s", outputFile, outputDir));
}
if (!outputFile.isDirectory() && !outputFile.mkdirs()) {
throw new IOException(String.format("Failed to create directory: %s", outputFile));
@@ -135,8 +135,8 @@ public class TarGzCompressionUtils {
} else {
File parentFile = outputFile.getParentFile();
if (!parentFile.getCanonicalPath().startsWith(outputDirCanonicalPath)) {
- throw new IOException(String
- .format("Trying to create directory: %s outside of the output directory: %s", parentFile, outputDir));
+ throw new IOException(
+ String.format("Trying to create directory: %s outside of the output directory: %s", parentFile, outputDir));
}
if (!parentFile.isDirectory() && !parentFile.mkdirs()) {
throw new IOException(String.format("Failed to create directory: %s", parentFile));
@@ -156,10 +156,8 @@ public class TarGzCompressionUtils {
*/
public static void untarOneFile(File inputFile, String fileName, File outputFile)
throws IOException {
- try (InputStream fileIn = Files.newInputStream(inputFile.toPath());
- InputStream bufferedIn = new BufferedInputStream(fileIn);
- InputStream gzipIn = new GzipCompressorInputStream(bufferedIn);
- ArchiveInputStream tarGzIn = new TarArchiveInputStream(gzipIn)) {
+ try (InputStream fileIn = Files.newInputStream(inputFile.toPath()); InputStream bufferedIn = new BufferedInputStream(fileIn);
+ InputStream gzipIn = new GzipCompressorInputStream(bufferedIn); ArchiveInputStream tarGzIn = new TarArchiveInputStream(gzipIn)) {
ArchiveEntry entry;
while ((entry = tarGzIn.getNextEntry()) != null) {
if (!entry.isDirectory()) {
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/ZkStarter.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/ZkStarter.java
index c5ae088..9515fc7 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/ZkStarter.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/ZkStarter.java
@@ -33,6 +33,9 @@ import org.slf4j.LoggerFactory;
public class ZkStarter {
+ private ZkStarter() {
+ }
+
private static final Logger LOGGER = LoggerFactory.getLogger(ZkStarter.class);
public static final int DEFAULT_ZK_TEST_PORT = 2191;
private static final int DEFAULT_ZK_CLIENT_RETRIES = 10;
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/config/TableConfigUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/config/TableConfigUtils.java
index dac88a9..96ec65d 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/config/TableConfigUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/config/TableConfigUtils.java
@@ -66,8 +66,7 @@ public class TableConfigUtils {
Preconditions.checkState(tableType != null, FIELD_MISSING_MESSAGE_TEMPLATE, TableConfig.TABLE_TYPE_KEY);
String validationConfigString = simpleFields.get(TableConfig.VALIDATION_CONFIG_KEY);
- Preconditions
- .checkState(validationConfigString != null, FIELD_MISSING_MESSAGE_TEMPLATE, TableConfig.VALIDATION_CONFIG_KEY);
+ Preconditions.checkState(validationConfigString != null, FIELD_MISSING_MESSAGE_TEMPLATE, TableConfig.VALIDATION_CONFIG_KEY);
SegmentsValidationAndRetentionConfig validationConfig =
JsonUtils.stringToObject(validationConfigString, SegmentsValidationAndRetentionConfig.class);
@@ -76,8 +75,7 @@ public class TableConfigUtils {
TenantConfig tenantConfig = JsonUtils.stringToObject(tenantConfigString, TenantConfig.class);
String indexingConfigString = simpleFields.get(TableConfig.INDEXING_CONFIG_KEY);
- Preconditions
- .checkState(indexingConfigString != null, FIELD_MISSING_MESSAGE_TEMPLATE, TableConfig.INDEXING_CONFIG_KEY);
+ Preconditions.checkState(indexingConfigString != null, FIELD_MISSING_MESSAGE_TEMPLATE, TableConfig.INDEXING_CONFIG_KEY);
IndexingConfig indexingConfig = JsonUtils.stringToObject(indexingConfigString, IndexingConfig.class);
String customConfigString = simpleFields.get(TableConfig.CUSTOM_CONFIG_KEY);
@@ -112,8 +110,8 @@ public class TableConfigUtils {
Map<InstancePartitionsType, InstanceAssignmentConfig> instanceAssignmentConfigMap = null;
String instanceAssignmentConfigMapString = simpleFields.get(TableConfig.INSTANCE_ASSIGNMENT_CONFIG_MAP_KEY);
if (instanceAssignmentConfigMapString != null) {
- instanceAssignmentConfigMap = JsonUtils.stringToObject(instanceAssignmentConfigMapString,
- new TypeReference<Map<InstancePartitionsType, InstanceAssignmentConfig>>() {
+ instanceAssignmentConfigMap = JsonUtils
+ .stringToObject(instanceAssignmentConfigMapString, new TypeReference<Map<InstancePartitionsType, InstanceAssignmentConfig>>() {
});
}
@@ -149,9 +147,9 @@ public class TableConfigUtils {
tunerConfig = JsonUtils.stringToObject(tunerConfigString, TunerConfig.class);
}
- return new TableConfig(tableName, tableType, validationConfig, tenantConfig, indexingConfig, customConfig,
- quotaConfig, taskConfig, routingConfig, queryConfig, instanceAssignmentConfigMap, fieldConfigList, upsertConfig,
- ingestionConfig, tierConfigList, isDimTable, tunerConfig);
+ return new TableConfig(tableName, tableType, validationConfig, tenantConfig, indexingConfig, customConfig, quotaConfig, taskConfig,
+ routingConfig, queryConfig, instanceAssignmentConfigMap, fieldConfigList, upsertConfig, ingestionConfig, tierConfigList, isDimTable,
+ tunerConfig);
}
public static ZNRecord toZNRecord(TableConfig tableConfig)
@@ -184,11 +182,9 @@ public class TableConfigUtils {
if (queryConfig != null) {
simpleFields.put(TableConfig.QUERY_CONFIG_KEY, queryConfig.toJsonString());
}
- Map<InstancePartitionsType, InstanceAssignmentConfig> instanceAssignmentConfigMap =
- tableConfig.getInstanceAssignmentConfigMap();
+ Map<InstancePartitionsType, InstanceAssignmentConfig> instanceAssignmentConfigMap = tableConfig.getInstanceAssignmentConfigMap();
if (instanceAssignmentConfigMap != null) {
- simpleFields
- .put(TableConfig.INSTANCE_ASSIGNMENT_CONFIG_MAP_KEY, JsonUtils.objectToString(instanceAssignmentConfigMap));
+ simpleFields.put(TableConfig.INSTANCE_ASSIGNMENT_CONFIG_MAP_KEY, JsonUtils.objectToString(instanceAssignmentConfigMap));
}
List<FieldConfig> fieldConfigList = tableConfig.getFieldConfigList();
if (fieldConfigList != null) {
@@ -229,8 +225,7 @@ public class TableConfigUtils {
public static void convertFromLegacyTableConfig(TableConfig tableConfig) {
// It is possible that indexing as well as ingestion configs exist, in which case we always honor ingestion config.
IngestionConfig ingestionConfig = tableConfig.getIngestionConfig();
- BatchIngestionConfig batchIngestionConfig =
- (ingestionConfig != null) ? ingestionConfig.getBatchIngestionConfig() : null;
+ BatchIngestionConfig batchIngestionConfig = (ingestionConfig != null) ? ingestionConfig.getBatchIngestionConfig() : null;
SegmentsValidationAndRetentionConfig validationConfig = tableConfig.getValidationConfig();
String segmentPushType = validationConfig.getSegmentPushType();
@@ -252,8 +247,7 @@ public class TableConfigUtils {
}
}
- StreamIngestionConfig streamIngestionConfig =
- (ingestionConfig != null) ? ingestionConfig.getStreamIngestionConfig() : null;
+ StreamIngestionConfig streamIngestionConfig = (ingestionConfig != null) ? ingestionConfig.getStreamIngestionConfig() : null;
IndexingConfig indexingConfig = tableConfig.getIndexingConfig();
if (streamIngestionConfig == null) {
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/config/TierConfigUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/config/TierConfigUtils.java
index 5983b11..1f03b02 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/config/TierConfigUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/config/TierConfigUtils.java
@@ -51,8 +51,7 @@ public final class TierConfigUtils {
/**
* Gets sorted list of tiers for given storage type from provided list of TierConfig
*/
- public static List<Tier> getSortedTiersForStorageType(List<TierConfig> tierConfigList, String storageType,
- HelixManager helixManager) {
+ public static List<Tier> getSortedTiersForStorageType(List<TierConfig> tierConfigList, String storageType, HelixManager helixManager) {
List<Tier> sortedTiers = new ArrayList<>();
for (TierConfig tierConfig : tierConfigList) {
if (storageType.equalsIgnoreCase(tierConfig.getStorageType())) {
@@ -66,17 +65,20 @@ public final class TierConfigUtils {
/**
* Comparator for sorting the {@link Tier}.
* As of now, we have only 1 type of {@link TierSegmentSelector} and 1 type of {@link TierStorage}.
- * Tier with an older age bucket in {@link TimeBasedTierSegmentSelector} should appear before a younger age bucket, in sort order
+ * Tier with an older age bucket in {@link TimeBasedTierSegmentSelector} should appear before a younger age bucket,
+ * in sort order
* TODO: As we add more types, this logic needs to be upgraded
*/
public static Comparator<Tier> getTierComparator() {
return (o1, o2) -> {
TierSegmentSelector s1 = o1.getSegmentSelector();
TierSegmentSelector s2 = o2.getSegmentSelector();
- Preconditions.checkState(TierFactory.TIME_SEGMENT_SELECTOR_TYPE.equalsIgnoreCase(s1.getType()),
- "Unsupported segmentSelectorType class %s", s1.getClass());
- Preconditions.checkState(TierFactory.TIME_SEGMENT_SELECTOR_TYPE.equalsIgnoreCase(s2.getType()),
- "Unsupported segmentSelectorType class %s", s2.getClass());
+ Preconditions
+ .checkState(TierFactory.TIME_SEGMENT_SELECTOR_TYPE.equalsIgnoreCase(s1.getType()), "Unsupported segmentSelectorType class %s",
+ s1.getClass());
+ Preconditions
+ .checkState(TierFactory.TIME_SEGMENT_SELECTOR_TYPE.equalsIgnoreCase(s2.getType()), "Unsupported segmentSelectorType class %s",
+ s2.getClass());
Long period1 = ((TimeBasedTierSegmentSelector) s1).getSegmentAgeMillis();
Long period2 = ((TimeBasedTierSegmentSelector) s2).getSegmentAgeMillis();
return period2.compareTo(period1);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/BaseSegmentFetcher.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/BaseSegmentFetcher.java
index bc1a975..b3db39a 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/BaseSegmentFetcher.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/BaseSegmentFetcher.java
@@ -55,9 +55,8 @@ public abstract class BaseSegmentFetcher implements SegmentFetcher {
_retryDelayScaleFactor = config.getProperty(RETRY_DELAY_SCALE_FACTOR_CONFIG_KEY, DEFAULT_RETRY_DELAY_SCALE_FACTOR);
_authToken = config.getProperty(AUTH_TOKEN);
doInit(config);
- _logger
- .info("Initialized with retryCount: {}, retryWaitMs: {}, retryDelayScaleFactor: {}", _retryCount, _retryWaitMs,
- _retryDelayScaleFactor);
+ _logger.info("Initialized with retryCount: {}, retryWaitMs: {}, retryDelayScaleFactor: {}", _retryCount, _retryWaitMs,
+ _retryDelayScaleFactor);
}
/**
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/HttpSegmentFetcher.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/HttpSegmentFetcher.java
index f854ec7..85832c0 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/HttpSegmentFetcher.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/HttpSegmentFetcher.java
@@ -40,21 +40,18 @@ public class HttpSegmentFetcher extends BaseSegmentFetcher {
RetryPolicies.exponentialBackoffRetryPolicy(_retryCount, _retryWaitMs, _retryDelayScaleFactor).attempt(() -> {
try {
int statusCode = _httpClient.downloadFile(uri, dest, _authToken);
- _logger
- .info("Downloaded segment from: {} to: {} of size: {}; Response status code: {}", uri, dest, dest.length(),
- statusCode);
+ _logger.info("Downloaded segment from: {} to: {} of size: {}; Response status code: {}", uri, dest, dest.length(), statusCode);
return true;
} catch (HttpErrorStatusException e) {
int statusCode = e.getStatusCode();
if (statusCode >= 500) {
// Temporary exception
- _logger.warn("Got temporary error status code: {} while downloading segment from: {} to: {}", statusCode, uri,
- dest, e);
+ _logger.warn("Got temporary error status code: {} while downloading segment from: {} to: {}", statusCode, uri, dest, e);
return false;
} else {
// Permanent exception
- _logger.error("Got permanent error status code: {} while downloading segment from: {} to: {}, won't retry",
- statusCode, uri, dest, e);
+ _logger.error("Got permanent error status code: {} while downloading segment from: {} to: {}, won't retry", statusCode, uri, dest,
+ e);
throw e;
}
} catch (Exception e) {
@@ -69,10 +66,8 @@ public class HttpSegmentFetcher extends BaseSegmentFetcher {
throws Exception {
try {
int statusCode = _httpClient.downloadFile(uri, dest, _authToken);
- _logger
- .info("Downloaded segment from: {} to: {} of size: {}; Response status code: {}", uri, dest, dest.length(),
- statusCode);
- } catch (Exception e) {
+ _logger.info("Downloaded segment from: {} to: {} of size: {}; Response status code: {}", uri, dest, dest.length(), statusCode);
+ } catch (Exception e) {
_logger.warn("Caught exception while downloading segment from: {} to: {}", uri, dest, e);
throw e;
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/HttpsSegmentFetcher.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/HttpsSegmentFetcher.java
index 8fec2e6..64dcb60 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/HttpsSegmentFetcher.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/HttpsSegmentFetcher.java
@@ -59,7 +59,7 @@ public class HttpsSegmentFetcher extends HttpSegmentFetcher {
PinotConfiguration sslConfig = config.subset(CommonConstants.PREFIX_OF_SSL_SUBSET);
_logger.info("Initializing with the following ssl config:");
Set<String> protectedConfigKeys = ClientSSLContextGenerator.getProtectedConfigKeys();
-
+
for (String configKey : sslConfig.getKeys()) {
if (protectedConfigKeys.contains(configKey)) {
_logger.info("{}: {}", configKey, "********");
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/SegmentFetcherFactory.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/SegmentFetcherFactory.java
index e6a51ed..c6d71e8 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/SegmentFetcherFactory.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/SegmentFetcherFactory.java
@@ -83,6 +83,7 @@ public class SegmentFetcherFactory {
break;
default:
segmentFetcher = new PinotFSSegmentFetcher();
+ break;
}
} else {
LOGGER.info("Creating segment fetcher for protocol: {} with class: {}", protocol, segmentFetcherClassName);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/grpc/GrpcQueryClient.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/grpc/GrpcQueryClient.java
index 68c03b8..8485ced 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/grpc/GrpcQueryClient.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/grpc/GrpcQueryClient.java
@@ -30,8 +30,7 @@ public class GrpcQueryClient {
public GrpcQueryClient(String host, int port) {
// Set max message size to 128MB
- Channel channel =
- ManagedChannelBuilder.forAddress(host, port).maxInboundMessageSize(128 * 1024 * 1024).usePlaintext().build();
+ Channel channel = ManagedChannelBuilder.forAddress(host, port).maxInboundMessageSize(128 * 1024 * 1024).usePlaintext().build();
_blockingStub = PinotQueryServerGrpc.newBlockingStub(channel);
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/grpc/GrpcRequestBuilder.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/grpc/GrpcRequestBuilder.java
index 51280be..8cb4a21 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/grpc/GrpcRequestBuilder.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/grpc/GrpcRequestBuilder.java
@@ -80,8 +80,7 @@ public class GrpcRequestBuilder {
}
public Server.ServerRequest build() {
- Preconditions.checkState(_payloadType != null && CollectionUtils.isNotEmpty(_segments),
- "Query and segmentsToQuery must be set");
+ Preconditions.checkState(_payloadType != null && CollectionUtils.isNotEmpty(_segments), "Query and segmentsToQuery must be set");
Map<String, String> metadata = new HashMap<>();
metadata.put(Request.MetadataKeys.REQUEST_ID, Integer.toString(_requestId));
@@ -99,8 +98,8 @@ public class GrpcRequestBuilder {
} catch (TException e) {
throw new RuntimeException("Caught exception while serializing broker request: " + _brokerRequest, e);
}
- return Server.ServerRequest.newBuilder().putAllMetadata(metadata).setPayload(ByteString.copyFrom(payLoad))
- .addAllSegments(_segments).build();
+ return Server.ServerRequest.newBuilder().putAllMetadata(metadata).setPayload(ByteString.copyFrom(payLoad)).addAllSegments(_segments)
+ .build();
}
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/HelixHelper.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/HelixHelper.java
index 94bef13..719c679 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/HelixHelper.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/HelixHelper.java
@@ -54,12 +54,14 @@ import org.slf4j.LoggerFactory;
public class HelixHelper {
+ private HelixHelper() {
+ }
+
private static final int NUM_PARTITIONS_THRESHOLD_TO_ENABLE_COMPRESSION = 1000;
private static final String ENABLE_COMPRESSIONS_KEY = "enableCompression";
private static final RetryPolicy DEFAULT_RETRY_POLICY = RetryPolicies.exponentialBackoffRetryPolicy(5, 1000L, 2.0f);
- private static final RetryPolicy DEFAULT_TABLE_IDEALSTATES_UPDATE_RETRY_POLICY =
- RetryPolicies.randomDelayRetryPolicy(20, 100L, 200L);
+ private static final RetryPolicy DEFAULT_TABLE_IDEALSTATES_UPDATE_RETRY_POLICY = RetryPolicies.randomDelayRetryPolicy(20, 100L, 200L);
private static final Logger LOGGER = LoggerFactory.getLogger(HelixHelper.class);
private static final ZNRecordSerializer ZN_RECORD_SERIALIZER = new ZNRecordSerializer();
@@ -69,8 +71,7 @@ public class HelixHelper {
public static final String BROKER_RESOURCE = CommonConstants.Helix.BROKER_RESOURCE_INSTANCE;
public static IdealState cloneIdealState(IdealState idealState) {
- return new IdealState(
- (ZNRecord) ZN_RECORD_SERIALIZER.deserialize(ZN_RECORD_SERIALIZER.serialize(idealState.getRecord())));
+ return new IdealState((ZNRecord) ZN_RECORD_SERIALIZER.deserialize(ZN_RECORD_SERIALIZER.serialize(idealState.getRecord())));
}
/**
@@ -80,7 +81,8 @@ public class HelixHelper {
* @param resourceName The resource for which to update the ideal state
* @param updater A function that returns an updated ideal state given an input ideal state
*/
- // TODO: since updater always update ideal state in place, it should return boolean indicating whether the ideal state get changed.
+ // TODO: since updater always update ideal state in place, it should return boolean indicating whether the ideal
+ // state get changed.
public static void updateIdealState(final HelixManager helixManager, final String resourceName,
final Function<IdealState, IdealState> updater, RetryPolicy policy, final boolean noChangeOk) {
try {
@@ -126,8 +128,7 @@ public class HelixHelper {
// Check version and set ideal state
try {
if (dataAccessor.getBaseDataAccessor()
- .set(idealStateKey.getPath(), updatedZNRecord, idealState.getRecord().getVersion(),
- AccessOption.PERSISTENT)) {
+ .set(idealStateKey.getPath(), updatedZNRecord, idealState.getRecord().getVersion(), AccessOption.PERSISTENT)) {
return true;
} else {
LOGGER.warn("Failed to update ideal state for resource: {}", resourceName);
@@ -137,8 +138,8 @@ public class HelixHelper {
LOGGER.warn("Version changed while updating ideal state for resource: {}", resourceName);
return false;
} catch (Exception e) {
- LOGGER.warn("Caught exception while updating ideal state for resource: {} (compressed={})", resourceName,
- enableCompression, e);
+ LOGGER
+ .warn("Caught exception while updating ideal state for resource: {} (compressed={})", resourceName, enableCompression, e);
return false;
}
} else {
@@ -170,8 +171,7 @@ public class HelixHelper {
}
}
- public static void updateIdealState(HelixManager helixManager, String resourceName,
- Function<IdealState, IdealState> updater) {
+ public static void updateIdealState(HelixManager helixManager, String resourceName, Function<IdealState, IdealState> updater) {
updateIdealState(helixManager, resourceName, updater, DEFAULT_TABLE_IDEALSTATES_UPDATE_RETRY_POLICY, false);
}
@@ -220,30 +220,26 @@ public class HelixHelper {
admin.enableInstance(clusterName, instanceName, enable);
}
- public static void setStateForInstanceList(List<String> instances, String clusterName, HelixAdmin admin,
- boolean enable) {
+ public static void setStateForInstanceList(List<String> instances, String clusterName, HelixAdmin admin, boolean enable) {
for (final String instance : instances) {
setInstanceState(instance, clusterName, admin, enable);
}
}
- public static void setStateForInstanceSet(Set<String> instances, String clusterName, HelixAdmin admin,
- boolean enable) {
+ public static void setStateForInstanceSet(Set<String> instances, String clusterName, HelixAdmin admin, boolean enable) {
for (final String instanceName : instances) {
setInstanceState(instanceName, clusterName, admin, enable);
}
}
- public static Map<String, String> getInstanceConfigsMapFor(String instanceName, String clusterName,
- HelixAdmin admin) {
+ public static Map<String, String> getInstanceConfigsMapFor(String instanceName, String clusterName, HelixAdmin admin) {
final HelixConfigScope scope = getInstanceScopefor(clusterName, instanceName);
final List<String> keys = admin.getConfigKeys(scope);
return admin.getConfig(scope, keys);
}
public static HelixConfigScope getInstanceScopefor(String clusterName, String instanceName) {
- return new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT, clusterName).forParticipant(instanceName)
- .build();
+ return new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT, clusterName).forParticipant(instanceName).build();
}
public static HelixConfigScope getResourceScopeFor(String clusterName, String resourceName) {
@@ -256,14 +252,12 @@ public class HelixHelper {
return admin.getConfig(scope, keys);
}
- public static void updateResourceConfigsFor(Map<String, String> newConfigs, String resourceName, String clusterName,
- HelixAdmin admin) {
+ public static void updateResourceConfigsFor(Map<String, String> newConfigs, String resourceName, String clusterName, HelixAdmin admin) {
final HelixConfigScope scope = getResourceScopeFor(clusterName, resourceName);
admin.setConfig(scope, newConfigs);
}
- public static void deleteResourcePropertyFromHelix(HelixAdmin admin, String clusterName, String resourceName,
- String configKey) {
+ public static void deleteResourcePropertyFromHelix(HelixAdmin admin, String clusterName, String resourceName, String configKey) {
final List<String> keys = new ArrayList<String>();
keys.add(configKey);
@@ -285,8 +279,7 @@ public class HelixHelper {
return HelixHelper.getResourceConfigsFor(clusterName, BROKER_RESOURCE, admin);
}
- public static void updateBrokerConfig(Map<String, String> brokerResourceConfig, HelixAdmin admin,
- String clusterName) {
+ public static void updateBrokerConfig(Map<String, String> brokerResourceConfig, HelixAdmin admin, String clusterName) {
HelixHelper.updateResourceConfigsFor(brokerResourceConfig, BROKER_RESOURCE, clusterName, admin);
}
@@ -315,8 +308,7 @@ public class HelixHelper {
// Removing partitions from ideal state
LOGGER.info("Trying to remove resource {} from idealstate", resourceTag);
- HelixHelper
- .updateIdealState(helixManager, CommonConstants.Helix.BROKER_RESOURCE_INSTANCE, updater, DEFAULT_RETRY_POLICY);
+ HelixHelper.updateIdealState(helixManager, CommonConstants.Helix.BROKER_RESOURCE_INSTANCE, updater, DEFAULT_RETRY_POLICY);
}
/**
@@ -366,8 +358,7 @@ public class HelixHelper {
* @param tableName Name of the table to which the new segment is to be added.
* @param segmentName Name of the new segment to be added
*/
- public static void removeSegmentFromIdealState(HelixManager helixManager, String tableName,
- final String segmentName) {
+ public static void removeSegmentFromIdealState(HelixManager helixManager, String tableName, final String segmentName) {
Function<IdealState, IdealState> updater = new Function<IdealState, IdealState>() {
@Override
public IdealState apply(IdealState idealState) {
@@ -386,8 +377,7 @@ public class HelixHelper {
updateIdealState(helixManager, tableName, updater, DEFAULT_RETRY_POLICY);
}
- public static void removeSegmentsFromIdealState(HelixManager helixManager, String tableName,
- final List<String> segments) {
+ public static void removeSegmentsFromIdealState(HelixManager helixManager, String tableName, final List<String> segments) {
Function<IdealState, IdealState> updater = new Function<IdealState, IdealState>() {
@Nullable
@Override
@@ -479,10 +469,8 @@ public class HelixHelper {
*/
public static Set<String> getServerInstancesForTenant(List<InstanceConfig> instanceConfigs, String tenant) {
Set<String> serverInstances = new HashSet<>();
- serverInstances
- .addAll(HelixHelper.getInstancesWithTag(instanceConfigs, TagNameUtils.getOfflineTagForTenant(tenant)));
- serverInstances
- .addAll(HelixHelper.getInstancesWithTag(instanceConfigs, TagNameUtils.getRealtimeTagForTenant(tenant)));
+ serverInstances.addAll(HelixHelper.getInstancesWithTag(instanceConfigs, TagNameUtils.getOfflineTagForTenant(tenant)));
+ serverInstances.addAll(HelixHelper.getInstancesWithTag(instanceConfigs, TagNameUtils.getRealtimeTagForTenant(tenant)));
return serverInstances;
}
@@ -495,8 +483,7 @@ public class HelixHelper {
return new HashSet<>(getInstancesWithTag(instanceConfigs, TagNameUtils.getBrokerTagForTenant(tenant)));
}
- public static Set<InstanceConfig> getBrokerInstanceConfigsForTenant(List<InstanceConfig> instanceConfigs,
- String tenant) {
+ public static Set<InstanceConfig> getBrokerInstanceConfigsForTenant(List<InstanceConfig> instanceConfigs, String tenant) {
return new HashSet<>(getInstancesConfigsWithTag(instanceConfigs, TagNameUtils.getBrokerTagForTenant(tenant)));
}
@@ -516,9 +503,9 @@ public class HelixHelper {
// NOTE: Use HelixDataAccessor.setProperty() instead of HelixAdmin.setInstanceConfig() because the latter explicitly
// forbids instance host/port modification
HelixDataAccessor helixDataAccessor = helixManager.getHelixDataAccessor();
- Preconditions.checkState(helixDataAccessor
- .setProperty(helixDataAccessor.keyBuilder().instanceConfig(instanceConfig.getId()), instanceConfig),
- "Failed to update instance config for instance: " + instanceConfig.getId());
+ Preconditions
+ .checkState(helixDataAccessor.setProperty(helixDataAccessor.keyBuilder().instanceConfig(instanceConfig.getId()), instanceConfig),
+ "Failed to update instance config for instance: " + instanceConfig.getId());
}
/**
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/LeadControllerUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/LeadControllerUtils.java
index 96c9788..075489c 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/LeadControllerUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/LeadControllerUtils.java
@@ -32,13 +32,17 @@ import org.slf4j.LoggerFactory;
public class LeadControllerUtils {
+ private LeadControllerUtils() {
+ }
+
private static final Logger LOGGER = LoggerFactory.getLogger(LeadControllerUtils.class);
/**
* Given a raw table name and number of partitions, returns the partition id in lead controller resource.
* Uses murmur2 function to get hashcode for table, ignores the most significant bit.
* Note: This method CANNOT be changed when lead controller resource is enabled.
- * Otherwise it will assign different controller for the same table, which will mess up the controller periodic tasks and realtime segment completion.
+ * Otherwise it will assign different controller for the same table, which will mess up the controller periodic
+ * tasks and realtime segment completion.
* @param rawTableName raw table name
* @return partition id in lead controller resource.
*/
@@ -48,7 +52,8 @@ public class LeadControllerUtils {
}
/**
- * Generates participant instance id, e.g. returns Controller_localhost_9000 given localhost as hostname and 9000 as port.
+ * Generates participant instance id, e.g. returns Controller_localhost_9000 given localhost as hostname and 9000
+ * as port.
*/
public static String generateParticipantInstanceId(String controllerHost, int controllerPort) {
return Helix.PREFIX_OF_CONTROLLER_INSTANCE + controllerHost + "_" + controllerPort;
@@ -74,8 +79,7 @@ public class LeadControllerUtils {
*/
public static boolean isLeadControllerResourceEnabled(HelixManager helixManager) {
ConfigAccessor configAccessor = helixManager.getConfigAccessor();
- ResourceConfig resourceConfig =
- configAccessor.getResourceConfig(helixManager.getClusterName(), Helix.LEAD_CONTROLLER_RESOURCE_NAME);
+ ResourceConfig resourceConfig = configAccessor.getResourceConfig(helixManager.getClusterName(), Helix.LEAD_CONTROLLER_RESOURCE_NAME);
String resourceEnabled = resourceConfig.getSimpleConfig(Helix.LEAD_CONTROLLER_RESOURCE_ENABLED_KEY);
return Boolean.parseBoolean(resourceEnabled);
}
@@ -96,8 +100,7 @@ public class LeadControllerUtils {
String helixLeaderInstanceId = liveInstance.getInstanceName();
String helixVersion = liveInstance.getHelixVersion();
long modifiedTime = liveInstance.getModifiedTime();
- LOGGER.info("Getting Helix leader: {}, Helix version: {}, mtime: {}", helixLeaderInstanceId, helixVersion,
- modifiedTime);
+ LOGGER.info("Getting Helix leader: {}, Helix version: {}, mtime: {}", helixLeaderInstanceId, helixVersion, modifiedTime);
return helixLeaderInstanceId;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/PinotHelixPropertyStoreZnRecordProvider.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/PinotHelixPropertyStoreZnRecordProvider.java
index 98466c2..60d3da4 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/PinotHelixPropertyStoreZnRecordProvider.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/PinotHelixPropertyStoreZnRecordProvider.java
@@ -25,18 +25,17 @@ import org.apache.helix.store.zk.ZkHelixPropertyStore;
public class PinotHelixPropertyStoreZnRecordProvider {
- private final ZkHelixPropertyStore<ZNRecord> propertyStore;
- private final String pathPrefix;
+ private final ZkHelixPropertyStore<ZNRecord> _propertyStore;
+ private final String _pathPrefix;
private PinotHelixPropertyStoreZnRecordProvider() {
- this.pathPrefix = null;
- this.propertyStore = null;
+ _pathPrefix = null;
+ _propertyStore = null;
}
- private PinotHelixPropertyStoreZnRecordProvider(ZkHelixPropertyStore<ZNRecord> propertyStore,
- String relativePathName) {
- this.propertyStore = propertyStore;
- this.pathPrefix = relativePathName;
+ private PinotHelixPropertyStoreZnRecordProvider(ZkHelixPropertyStore<ZNRecord> propertyStore, String relativePathName) {
+ _propertyStore = propertyStore;
+ _pathPrefix = relativePathName;
}
public static PinotHelixPropertyStoreZnRecordProvider forSchema(ZkHelixPropertyStore<ZNRecord> propertyStore) {
@@ -52,18 +51,18 @@ public class PinotHelixPropertyStoreZnRecordProvider {
}
public ZNRecord get(String name) {
- return propertyStore.get(pathPrefix + "/" + name, null, AccessOption.PERSISTENT);
+ return _propertyStore.get(_pathPrefix + "/" + name, null, AccessOption.PERSISTENT);
}
public void set(String name, ZNRecord record) {
- propertyStore.set(pathPrefix + "/" + name, record, AccessOption.PERSISTENT);
+ _propertyStore.set(_pathPrefix + "/" + name, record, AccessOption.PERSISTENT);
}
public boolean exist(String path) {
- return propertyStore.exists(pathPrefix + "/" + path, AccessOption.PERSISTENT);
+ return _propertyStore.exists(_pathPrefix + "/" + path, AccessOption.PERSISTENT);
}
public String getRelativePath() {
- return pathPrefix;
+ return _pathPrefix;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/request/FilterQueryTree.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/request/FilterQueryTree.java
index 7344e3b..dedb025 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/request/FilterQueryTree.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/request/FilterQueryTree.java
@@ -23,32 +23,32 @@ import org.apache.pinot.common.request.FilterOperator;
public class FilterQueryTree {
- private final String column;
- private final List<String> value;
- private final FilterOperator operator;
- private final List<FilterQueryTree> children;
+ private final String _column;
+ private final List<String> _value;
+ private final FilterOperator _operator;
+ private final List<FilterQueryTree> _children;
public FilterQueryTree(String column, List<String> value, FilterOperator operator, List<FilterQueryTree> children) {
- this.column = column;
- this.value = value;
- this.operator = operator;
- this.children = children;
+ _column = column;
+ _value = value;
+ _operator = operator;
+ _children = children;
}
public String getColumn() {
- return column;
+ return _column;
}
public List<String> getValue() {
- return value;
+ return _value;
}
public FilterOperator getOperator() {
- return operator;
+ return _operator;
}
public List<FilterQueryTree> getChildren() {
- return children;
+ return _children;
}
public String toString() {
@@ -61,14 +61,14 @@ public class FilterQueryTree {
for (int i = 0; i < indent; i++) {
stringBuffer.append(' ');
}
- if (operator == FilterOperator.OR || operator == FilterOperator.AND) {
- stringBuffer.append(operator);
- for (FilterQueryTree child : children) {
+ if (_operator == FilterOperator.OR || _operator == FilterOperator.AND) {
+ stringBuffer.append(_operator);
+ for (FilterQueryTree child : _children) {
stringBuffer.append('\n');
child.recursiveToStringIntoBuffer(indent + 1, stringBuffer);
}
} else {
- stringBuffer.append(column).append(' ').append(operator).append(' ').append(value);
+ stringBuffer.append(_column).append(' ').append(_operator).append(' ').append(_value);
}
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/request/RequestUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/request/RequestUtils.java
index bcb853a..92fa4f7 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/request/RequestUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/request/RequestUtils.java
@@ -180,8 +180,8 @@ public class RequestUtils {
return expression;
}
- private static FilterQuery traverseFilterQueryAndPopulateMap(FilterQueryTree tree,
- Map<Integer, FilterQuery> filterQueryMap, MutableInt currentId) {
+ private static FilterQuery traverseFilterQueryAndPopulateMap(FilterQueryTree tree, Map<Integer, FilterQuery> filterQueryMap,
+ MutableInt currentId) {
int currentNodeId = currentId.intValue();
currentId.increment();
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/webhdfs/WebHdfsV1Client.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/webhdfs/WebHdfsV1Client.java
index 2deaf20..b1320a6 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/webhdfs/WebHdfsV1Client.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/webhdfs/WebHdfsV1Client.java
@@ -39,8 +39,7 @@ public class WebHdfsV1Client {
private static final int DEFAULT_PERMISSION = 755;
//Web hdfs upload path template has 6 parameters: protocol/host/port/hdfs_path/overwrite/permission
- private static final String WEB_HDFS_UPLOAD_PATH_TEMPLATE =
- "%s://%s:%s/webhdfs/v1%s?op=CREATE&overwrite=%s&permission=%s";
+ private static final String WEB_HDFS_UPLOAD_PATH_TEMPLATE = "%s://%s:%s/webhdfs/v1%s?op=CREATE&overwrite=%s&permission=%s";
//Web hdfs download path template has 4 parameters: protocol/host/port/hdfs_path
private static final String WEB_HDFS_DOWNLOAD_PATH_TEMPLATE = "%s://%s:%s/webhdfs/v1%s?op=OPEN";
@@ -70,8 +69,7 @@ public class WebHdfsV1Client {
public synchronized boolean uploadSegment(String webHdfsPath, String localFilePath) {
// Step 1: Submit a HTTP PUT request without automatically following
// redirects and without sending the file data.
- String firstPutReqString =
- String.format(WEB_HDFS_UPLOAD_PATH_TEMPLATE, _protocol, _host, _port, webHdfsPath, _overwrite, _permission);
+ String firstPutReqString = String.format(WEB_HDFS_UPLOAD_PATH_TEMPLATE, _protocol, _host, _port, webHdfsPath, _overwrite, _permission);
HttpMethod firstPutReq = new PutMethod(firstPutReqString);
try {
LOGGER.info("Trying to send request: {}.", firstPutReqString);
@@ -83,8 +81,7 @@ public class WebHdfsV1Client {
return false;
}
} catch (Exception e) {
- LOGGER.error(
- String.format("Failed to execute the first request to upload segment to webhdfs: %s.", firstPutReqString), e);
+ LOGGER.error(String.format("Failed to execute the first request to upload segment to webhdfs: %s.", firstPutReqString), e);
return false;
} finally {
firstPutReq.releaseConnection();
@@ -107,9 +104,7 @@ public class WebHdfsV1Client {
}
return true;
} catch (IOException e) {
- LOGGER.error(String
- .format("Failed to execute the redirected request to upload segment to webhdfs: %s.", redirectedReqString),
- e);
+ LOGGER.error(String.format("Failed to execute the redirected request to upload segment to webhdfs: %s.", redirectedReqString), e);
return false;
} finally {
redirectedReq.releaseConnection();
diff --git a/pinot-common/src/main/java/org/apache/pinot/parsers/utils/BrokerRequestComparisonUtils.java b/pinot-common/src/main/java/org/apache/pinot/parsers/utils/BrokerRequestComparisonUtils.java
index c08cb66..163851d 100644
--- a/pinot-common/src/main/java/org/apache/pinot/parsers/utils/BrokerRequestComparisonUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/parsers/utils/BrokerRequestComparisonUtils.java
@@ -31,6 +31,8 @@ import org.slf4j.LoggerFactory;
public class BrokerRequestComparisonUtils {
+ private BrokerRequestComparisonUtils() {
+ }
private static final Logger LOGGER = LoggerFactory.getLogger(BrokerRequestComparisonUtils.class);
@@ -52,21 +54,20 @@ public class BrokerRequestComparisonUtils {
if (br1.getFilterQuery() != null) {
if (!validateFilterQuery(br1.getFilterQuery(), br2.getFilterQuery())) {
- sb.append("br1.getFilterQuery() = ").append(br1.getFilterQuery()).append("\n")
- .append("br2.getFilterQuery() = ").append(br2.getFilterQuery());
+ sb.append("br1.getFilterQuery() = ").append(br1.getFilterQuery()).append("\n").append("br2.getFilterQuery() = ")
+ .append(br2.getFilterQuery());
LOGGER.error("Filter did not match after conversion.{}", sb);
return false;
}
if (!validateFilterSubQueryMap(br1.getFilterSubQueryMap(), br2.getFilterSubQueryMap())) {
- sb.append("br1.getFilterSubQueryMap() = ").append(br1.getFilterSubQueryMap()).append("\n")
- .append("br2.getFilterSubQueryMap() = ").append(br2.getFilterSubQueryMap());
+ sb.append("br1.getFilterSubQueryMap() = ").append(br1.getFilterSubQueryMap()).append("\n").append("br2.getFilterSubQueryMap() = ")
+ .append(br2.getFilterSubQueryMap());
LOGGER.error("FilterSubQueryMap did not match after conversion. {}", sb);
return false;
}
} else if (br2.getFilterQuery() != null) {
- LOGGER.error("Filter did not match, br1.getFilterQuery() = null, br2.getFilterQuery() = {}",
- br2.getFilterQuery());
+ LOGGER.error("Filter did not match, br1.getFilterQuery() = null, br2.getFilterQuery() = {}", br2.getFilterQuery());
return false;
}
if (br1.getSelections() != null) {
@@ -77,14 +78,12 @@ public class BrokerRequestComparisonUtils {
return false;
}
} else if (br2.getSelections() != null) {
- LOGGER.error("Selection did not match, br1.getSelections() = null, br2.getSelections() = {}",
- br2.getSelections());
+ LOGGER.error("Selection did not match, br1.getSelections() = null, br2.getSelections() = {}", br2.getSelections());
return false;
}
if (br1.getGroupBy() != null) {
if (!validateGroupBy(br1.getGroupBy(), br2.getGroupBy())) {
- sb.append("br1.getGroupBy() = ").append(br1.getGroupBy()).append("\n").append("br2.getGroupBy() = ")
- .append(br2.getGroupBy());
+ sb.append("br1.getGroupBy() = ").append(br1.getGroupBy()).append("\n").append("br2.getGroupBy() = ").append(br2.getGroupBy());
LOGGER.error("Group By did not match conversion:{}", sb);
return false;
}
@@ -94,8 +93,7 @@ public class BrokerRequestComparisonUtils {
}
if (br1.getAggregationsInfo() != null) {
if (!validateAggregations(br1.getAggregationsInfo(), br2.getAggregationsInfo())) {
- sb.append("br1.getGroupBy() = ").append(br1.getGroupBy()).append("\n").append("br2.getGroupBy() = ")
- .append(br2.getGroupBy());
+ sb.append("br1.getGroupBy() = ").append(br1.getGroupBy()).append("\n").append("br2.getGroupBy() = ").append(br2.getGroupBy());
LOGGER.error("Group By did not match conversion:{}", sb);
return false;
}
@@ -107,8 +105,7 @@ public class BrokerRequestComparisonUtils {
if (!ignoreOrderBy) {
if (br1.getOrderBy() != null) {
if (!validateOrderBys(br1.getOrderBy(), br2.getOrderBy())) {
- sb.append("br1.getOrderBy() = ").append(br1.getOrderBy()).append("\n").append("br2.getOrderBy() = ")
- .append(br2.getOrderBy());
+ sb.append("br1.getOrderBy() = ").append(br1.getOrderBy()).append("\n").append("br2.getOrderBy() = ").append(br2.getOrderBy());
LOGGER.error("Order By did not match conversion:{}", sb);
return false;
}
@@ -135,8 +132,7 @@ public class BrokerRequestComparisonUtils {
}
for (int i = 0; i < orderBy1.size(); i++) {
if (!validateOrderBy(orderBy1.get(i), orderBy2.get(i))) {
- LOGGER.error("Failed to validate OrderBys at idx {} doesn't match.\n\t{}\n\t{}", i, orderBy1.get(i),
- orderBy2.get(i));
+ LOGGER.error("Failed to validate OrderBys at idx {} doesn't match.\n\t{}\n\t{}", i, orderBy1.get(i), orderBy2.get(i));
return false;
}
}
@@ -145,13 +141,12 @@ public class BrokerRequestComparisonUtils {
private static boolean validateOrderBy(SelectionSort orderBy1, SelectionSort orderBy2) {
if (orderBy1.isIsAsc() != orderBy2.isIsAsc()) {
- LOGGER.error("Failed to validate OrderBy at field: `isAsc` {} doesn't match.\n\t{}\n\t{}", orderBy1.isIsAsc(),
- orderBy2.isIsAsc());
+ LOGGER.error("Failed to validate OrderBy at field: `isAsc` {} doesn't match.\n\t{}\n\t{}", orderBy1.isIsAsc(), orderBy2.isIsAsc());
return false;
}
if (!orderBy1.getColumn().equalsIgnoreCase(orderBy2.getColumn())) {
- LOGGER.error("Failed to validate OrderBy at field: `column` {} doesn't match.\n\t{}\n\t{}", orderBy1.getColumn(),
- orderBy2.getColumn());
+ LOGGER
+ .error("Failed to validate OrderBy at field: `column` {} doesn't match.\n\t{}\n\t{}", orderBy1.getColumn(), orderBy2.getColumn());
return false;
}
return true;
@@ -182,13 +177,13 @@ public class BrokerRequestComparisonUtils {
}
for (int i = 0; i < agg1.getExpressionsSize(); i++) {
if (!agg1.getExpressions().get(i).equals(agg2.getExpressions().get(i))) {
- LOGGER.error("Failed to validate AggregationInfo: Expressions mis-match.\n\t{}\n\t{}",
- agg1.getExpressions().get(i), agg1.getExpressions().get(i));
+ LOGGER.error("Failed to validate AggregationInfo: Expressions mis-match.\n\t{}\n\t{}", agg1.getExpressions().get(i),
+ agg1.getExpressions().get(i));
return false;
}
}
return true;
-}
+ }
private static boolean validateGroupBy(GroupBy groupBy1, GroupBy groupBy2) {
if (groupBy1.getTopN() != groupBy2.getTopN()) {
@@ -223,17 +218,12 @@ public class BrokerRequestComparisonUtils {
}
if (s1.getSelectionSortSequence() != null) {
for (int i = 0; i < s1.getSelectionSortSequence().size(); i++) {
- if (!s1.getSelectionSortSequence().get(i).getColumn()
- .equals(s2.getSelectionSortSequence().get(i).getColumn())) {
- LOGGER
- .error("Failed to validate Selections: SelectionSortSequence Column at idx {} doesn't match.\n\t{}\n\t{}",
- i, s1, s2);
+ if (!s1.getSelectionSortSequence().get(i).getColumn().equals(s2.getSelectionSortSequence().get(i).getColumn())) {
+ LOGGER.error("Failed to validate Selections: SelectionSortSequence Column at idx {} doesn't match.\n\t{}\n\t{}", i, s1, s2);
return false;
}
if (s1.getSelectionSortSequence().get(i).isIsAsc() != s2.getSelectionSortSequence().get(i).isIsAsc()) {
- LOGGER
- .error("Failed to validate Selections: SelectionSortSequence isAsc at idx {} doesn't match.\n\t{}\n\t{}",
- i, s1, s2);
+ LOGGER.error("Failed to validate Selections: SelectionSortSequence isAsc at idx {} doesn't match.\n\t{}\n\t{}", i, s1, s2);
return false;
}
}
@@ -277,8 +267,7 @@ public class BrokerRequestComparisonUtils {
final String s1 = fq1.getValue().get(i);
final String s2 = fq2.getValue().get(i);
if (!s1.equals(s2)) {
- LOGGER.error("Failed to validate FilterQuery: value at idx {} doesn't match.\n\t{}\n\t{}\n\t{}\n\t{}", i, fq1,
- fq2, s1, s2);
+ LOGGER.error("Failed to validate FilterQuery: value at idx {} doesn't match.\n\t{}\n\t{}\n\t{}\n\t{}", i, fq1, fq2, s1, s2);
return false;
}
}
@@ -290,8 +279,7 @@ public class BrokerRequestComparisonUtils {
}
for (int i = 0; i < fq1.getNestedFilterQueryIds().size(); i++) {
if (fq1.getNestedFilterQueryIds().get(i) != fq2.getNestedFilterQueryIds().get(i)) {
- LOGGER.error("Failed to validate FilterQuery: nestedFilterQueryIds at idx {} doesn't match.\n\t{}\n\t{}", i,
- fq1, fq2);
+ LOGGER.error("Failed to validate FilterQuery: nestedFilterQueryIds at idx {} doesn't match.\n\t{}\n\t{}", i, fq1, fq2);
return false;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/PinotQuery2BrokerRequestConverter.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/PinotQuery2BrokerRequestConverter.java
index 944abf4..86e13c0 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/PinotQuery2BrokerRequestConverter.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/PinotQuery2BrokerRequestConverter.java
@@ -120,12 +120,14 @@ public class PinotQuery2BrokerRequestConverter {
private void convertSelectList(PinotQuery pinotQuery, BrokerRequest brokerRequest) {
Selection selection = null;
List<AggregationInfo> aggregationInfoList = null;
- for (Expression expression : pinotQuery.getSelectList()) {
- ExpressionType type = expression.getType();
- if (type == ExpressionType.FUNCTION && expression.getFunctionCall().getOperator()
- .equalsIgnoreCase(SqlKind.AS.toString())) {
- expression = expression.getFunctionCall().getOperands().get(0);
+ for (Expression selectExpression : pinotQuery.getSelectList()) {
+ ExpressionType type = selectExpression.getType();
+ Expression expression;
+ if (type == ExpressionType.FUNCTION && selectExpression.getFunctionCall().getOperator().equalsIgnoreCase(SqlKind.AS.toString())) {
+ expression = selectExpression.getFunctionCall().getOperands().get(0);
type = expression.getType();
+ } else {
+ expression = selectExpression;
}
switch (type) {
case LITERAL:
@@ -156,6 +158,8 @@ public class PinotQuery2BrokerRequestConverter {
selection.addToSelectionColumns(ParserUtils.standardizeExpression(expression, false));
}
break;
+ default:
+ throw new IllegalArgumentException("Unrecognized expression type - " + type);
}
}
@@ -246,7 +250,8 @@ public class PinotQuery2BrokerRequestConverter {
filterQuery.setId(id);
filterSubQueryMap.putToFilterQueryMap(id, filterQuery);
List<Integer> childFilterIds = new ArrayList<>();
- switch (filterExpression.getType()) {
+ final ExpressionType filterExpressionType = filterExpression.getType();
+ switch (filterExpressionType) {
case LITERAL:
case IDENTIFIER:
break;
@@ -285,6 +290,8 @@ public class PinotQuery2BrokerRequestConverter {
throw new UnsupportedOperationException("Filter UDF not supported");
}
break;
+ default:
+ throw new IllegalArgumentException("Unrecognized filter expression type - " + filterExpressionType);
}
filterQuery.setNestedFilterQueryIds(childFilterIds);
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/Pql2CompilationException.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/Pql2CompilationException.java
index 98b2976..fb6b163 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/Pql2CompilationException.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/Pql2CompilationException.java
@@ -29,8 +29,7 @@ public class Pql2CompilationException extends RuntimeException {
super(message);
}
- public Pql2CompilationException(String msg, Object offendingSymbol, int line, int charPositionInLine,
- RecognitionException e) {
+ public Pql2CompilationException(String msg, Object offendingSymbol, int line, int charPositionInLine, RecognitionException e) {
super(line + ":" + charPositionInLine + ": '" + offendingSymbol + "' " + msg, e);
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/Pql2Compiler.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/Pql2Compiler.java
index ba94a2f..ae1860b 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/Pql2Compiler.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/Pql2Compiler.java
@@ -18,6 +18,7 @@
*/
package org.apache.pinot.pql.parsers;
+import com.google.common.annotations.VisibleForTesting;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
@@ -53,18 +54,30 @@ public class Pql2Compiler implements QueryCompiler {
private static final Logger LOGGER = LoggerFactory.getLogger(Pql2Compiler.class);
- public static boolean ENABLE_PINOT_QUERY =
- Boolean.valueOf(System.getProperty("pinot.query.converter.enabled", "false"));
- public static boolean VALIDATE_CONVERTER =
- Boolean.valueOf(System.getProperty("pinot.query.converter.validate", "false"));
- public static boolean FAIL_ON_CONVERSION_ERROR =
- Boolean.valueOf(System.getProperty("pinot.query.converter.fail_on_error", "false"));
+ private static boolean _enablePinotQuery = Boolean.valueOf(System.getProperty("pinot.query.converter.enabled", "false"));
+ private static boolean _validateConverter = Boolean.valueOf(System.getProperty("pinot.query.converter.validate", "false"));
+ private static boolean _failOnConversionError = Boolean.valueOf(System.getProperty("pinot.query.converter.fail_on_error", "false"));
+
+ @VisibleForTesting
+ public static void setEnablePinotQuery(boolean enablePinotQuery) {
+ _enablePinotQuery = enablePinotQuery;
+ }
+
+ @VisibleForTesting
+ public static void setValidateConverter(boolean validateConverter) {
+ _validateConverter = validateConverter;
+ }
+
+ @VisibleForTesting
+ public static void setFailOnConversionError(boolean failOnConversionError) {
+ _failOnConversionError = failOnConversionError;
+ }
private static class ErrorListener extends BaseErrorListener {
@Override
- public void syntaxError(@Nonnull Recognizer<?, ?> recognizer, @Nullable Object offendingSymbol, int line,
- int charPositionInLine, @Nonnull String msg, @Nullable RecognitionException e) {
+ public void syntaxError(@Nonnull Recognizer<?, ?> recognizer, @Nullable Object offendingSymbol, int line, int charPositionInLine,
+ @Nonnull String msg, @Nullable RecognitionException e) {
throw new Pql2CompilationException(msg, offendingSymbol, line, charPositionInLine, e);
}
}
@@ -103,19 +116,18 @@ public class Pql2Compiler implements QueryCompiler {
AstNode rootNode = listener.getRootNode();
BrokerRequest brokerRequest = new BrokerRequest();
rootNode.updateBrokerRequest(brokerRequest);
- if (ENABLE_PINOT_QUERY) {
+ if (_enablePinotQuery) {
try {
PinotQuery pinotQuery = new PinotQuery();
rootNode.updatePinotQuery(pinotQuery);
- if (VALIDATE_CONVERTER) {
+ if (_validateConverter) {
PinotQuery2BrokerRequestConverter converter = new PinotQuery2BrokerRequestConverter();
BrokerRequest tempBrokerRequest = converter.convert(pinotQuery);
boolean result = BrokerRequestComparisonUtils.validate(brokerRequest, tempBrokerRequest);
if (!result) {
LOGGER.error("Pinot query to broker request conversion failed. PQL:{}", expression);
- if (FAIL_ON_CONVERSION_ERROR) {
- throw new Pql2CompilationException(
- "Pinot query to broker request conversion failed. PQL:" + expression);
+ if (_failOnConversionError) {
+ throw new Pql2CompilationException("Pinot query to broker request conversion failed. PQL:" + expression);
}
}
}
@@ -123,7 +135,7 @@ public class Pql2Compiler implements QueryCompiler {
} catch (Exception e) {
//non fatal for now.
LOGGER.error("Non fatal: Failed to populate pinot query and broker request. PQL:{}", expression, e);
- if (FAIL_ON_CONVERSION_ERROR) {
+ if (_failOnConversionError) {
throw e;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BetweenPredicateAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BetweenPredicateAstNode.java
index 0e793a8..967c89c 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BetweenPredicateAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BetweenPredicateAstNode.java
@@ -61,12 +61,11 @@ public class BetweenPredicateAstNode extends PredicateAstNode {
LiteralAstNode left = (LiteralAstNode) getChildren().get(0);
LiteralAstNode right = (LiteralAstNode) getChildren().get(1);
return new FilterQueryTree(_identifier, Collections.singletonList(
- Range.LOWER_INCLUSIVE + left.getValueAsString() + Range.DELIMITER + right.getValueAsString()
- + Range.UPPER_INCLUSIVE), FilterOperator.RANGE, null);
+ Range.LOWER_INCLUSIVE + left.getValueAsString() + Range.DELIMITER + right.getValueAsString() + Range.UPPER_INCLUSIVE),
+ FilterOperator.RANGE, null);
} catch (ClassCastException e) {
throw new Pql2CompilationException(
- "BETWEEN clause was expecting two literal AST nodes, got " + getChildren().get(0) + " and " + getChildren()
- .get(1));
+ "BETWEEN clause was expecting two literal AST nodes, got " + getChildren().get(0) + " and " + getChildren().get(1));
}
} else {
throw new Pql2CompilationException("BETWEEN clause does not have two children nodes");
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/ComparisonPredicateAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/ComparisonPredicateAstNode.java
index a6bce42..f3e715b 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/ComparisonPredicateAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/ComparisonPredicateAstNode.java
@@ -77,7 +77,7 @@ public class ComparisonPredicateAstNode extends PredicateAstNode {
/**
* This function creates a standard unified shaped string for the value and operand side of the comparison
*
- * @returns A String containing the range representation of the predicate
+ * @return A String containing the range representation of the predicate
*/
private String createRangeStringForComparison() {
String comparison = null;
@@ -123,15 +123,13 @@ public class ComparisonPredicateAstNode extends PredicateAstNode {
if ("=".equals(_operand)) {
if (_identifier != null && _literal != null) {
- return new FilterQueryTree(_identifier, Collections.singletonList(_literal.getValueAsString()),
- FilterOperator.EQUALITY, null);
+ return new FilterQueryTree(_identifier, Collections.singletonList(_literal.getValueAsString()), FilterOperator.EQUALITY, null);
} else {
throw new Pql2CompilationException("Comparison is not between a column and a constant");
}
} else if ("<>".equals(_operand) || "!=".equals(_operand)) {
if (_identifier != null && _literal != null) {
- return new FilterQueryTree(_identifier, Collections.singletonList(_literal.getValueAsString()),
- FilterOperator.NOT, null);
+ return new FilterQueryTree(_identifier, Collections.singletonList(_literal.getValueAsString()), FilterOperator.NOT, null);
} else {
throw new Pql2CompilationException("Comparison is not between a column and a constant");
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FilterKind.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FilterKind.java
index ff49eb3..5b75b8f 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FilterKind.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FilterKind.java
@@ -44,7 +44,7 @@ public enum FilterKind {
* @return True if the enum is of Range type, false otherwise.
*/
public boolean isRange() {
- return this == GREATER_THAN || this == GREATER_THAN_OR_EQUAL || this == LESS_THAN || this == LESS_THAN_OR_EQUAL
- || this == BETWEEN || this == RANGE;
+ return this == GREATER_THAN || this == GREATER_THAN_OR_EQUAL || this == LESS_THAN || this == LESS_THAN_OR_EQUAL || this == BETWEEN
+ || this == RANGE;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FloatingPointLiteralAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FloatingPointLiteralAstNode.java
index 2e18965..bb5e4d1 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FloatingPointLiteralAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FloatingPointLiteralAstNode.java
@@ -22,23 +22,23 @@ package org.apache.pinot.pql.parsers.pql2.ast;
* Floating point literal AST node.
*/
public class FloatingPointLiteralAstNode extends LiteralAstNode {
- private double value;
+ private double _value;
public FloatingPointLiteralAstNode(double value) {
- this.value = value;
+ _value = value;
}
public double getValue() {
- return value;
+ return _value;
}
@Override
public String toString() {
- return "FloatingPointLiteralAstNode{" + "value=" + value + '}';
+ return "FloatingPointLiteralAstNode{" + "value=" + _value + '}';
}
@Override
public String getValueAsString() {
- return Double.toString(value);
+ return Double.toString(_value);
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FunctionCallAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FunctionCallAstNode.java
index 598424a..6aec9fa 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FunctionCallAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FunctionCallAstNode.java
@@ -56,9 +56,8 @@ public class FunctionCallAstNode extends BaseAstNode {
FunctionCallAstNode functionCallAstNode = (FunctionCallAstNode) obj;
if (_name.equals(functionCallAstNode.getName()) && _expression.equals(functionCallAstNode.getExpression())) {
return true;
- } else {
- return false;
}
+ return false;
}
public int hashCode() {
@@ -96,7 +95,8 @@ public class FunctionCallAstNode extends BaseAstNode {
if (_name.equalsIgnoreCase(AggregationFunctionType.DISTINCT.getName()) && children.size() == 1 && children
.get(0) instanceof StarExpressionAstNode) {
throw new Pql2CompilationException(
- "Syntax error: Pinot currently does not support DISTINCT with *. Please specify each column name as argument to DISTINCT function");
+ "Syntax error: Pinot currently does not support DISTINCT with *. Please specify each column name as "
+ + "argument to DISTINCT function");
}
// Need to de-dup the args for Distinct.
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OrderByAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OrderByAstNode.java
index efeb8c5..3571e42 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OrderByAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OrderByAstNode.java
@@ -42,8 +42,7 @@ public class OrderByAstNode extends BaseAstNode {
for (AstNode astNode : getChildren()) {
if (astNode instanceof OrderByExpressionAstNode) {
OrderByExpressionAstNode orderByExpressionAstNode = (OrderByExpressionAstNode) astNode;
- TransformExpressionTree orderByExpression =
- TransformExpressionTree.compileToExpressionTree(orderByExpressionAstNode.getColumn());
+ TransformExpressionTree orderByExpression = TransformExpressionTree.compileToExpressionTree(orderByExpressionAstNode.getColumn());
// Deduplicate the order-by expressions
if (orderByExpressions.add(orderByExpression)) {
@@ -52,7 +51,8 @@ public class OrderByAstNode extends BaseAstNode {
selectionSort.setIsAsc(orderByExpressionAstNode.getOrdering().equalsIgnoreCase(ASCENDING_ORDER));
brokerRequest.addToOrderBy(selectionSort);
- // TODO: Change selection to directly use Order-by. Won't be required if move to PinotQuery happens before that.
+ // TODO: Change selection to directly use Order-by. Won't be required if move to PinotQuery happens before
+ // that.
if (brokerRequest.getSelections() != null) {
brokerRequest.getSelections().addToSelectionSortSequence(selectionSort);
}
@@ -69,17 +69,14 @@ public class OrderByAstNode extends BaseAstNode {
for (AstNode astNode : getChildren()) {
if (astNode instanceof OrderByExpressionAstNode) {
OrderByExpressionAstNode orderByExpressionAstNode = (OrderByExpressionAstNode) astNode;
- TransformExpressionTree orderByExpression =
- TransformExpressionTree.compileToExpressionTree(orderByExpressionAstNode.getColumn());
+ TransformExpressionTree orderByExpression = TransformExpressionTree.compileToExpressionTree(orderByExpressionAstNode.getColumn());
// Deduplicate the order-by expressions
if (orderByExpressions.add(orderByExpression)) {
- String ordering = ASCENDING_ORDER.equalsIgnoreCase(orderByExpressionAstNode.getOrdering()) ? ASCENDING_ORDER
- : DESCENDING_ORDER;
+ String ordering = ASCENDING_ORDER.equalsIgnoreCase(orderByExpressionAstNode.getOrdering()) ? ASCENDING_ORDER : DESCENDING_ORDER;
Expression orderByFunctionExpression = RequestUtils.getFunctionExpression(ordering);
// TODO: Support order-by transform expressions, which should be converted to another FUNCTION expression
- orderByFunctionExpression.getFunctionCall()
- .addToOperands(RequestUtils.createIdentifierExpression(orderByExpression.toString()));
+ orderByFunctionExpression.getFunctionCall().addToOperands(RequestUtils.createIdentifierExpression(orderByExpression.toString()));
pinotQuery.addToOrderByList(orderByFunctionExpression);
}
} else {
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateListAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateListAstNode.java
index 7697070..6789730 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateListAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateListAstNode.java
@@ -31,8 +31,7 @@ import org.apache.pinot.common.utils.request.RequestUtils;
*/
public class PredicateListAstNode extends PredicateAstNode {
- public void buildQueryTreePredicates(List<FilterQueryTree> filterQueryOrPredicates,
- List<FilterQueryTree> filterQueryAndPredicates) {
+ public void buildQueryTreePredicates(List<FilterQueryTree> filterQueryOrPredicates, List<FilterQueryTree> filterQueryAndPredicates) {
int childrenCount = getChildren().size();
for (int i = 0; i < childrenCount; i += 2) {
PredicateAstNode predicate = (PredicateAstNode) getChildren().get(i);
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/SelectAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/SelectAstNode.java
index e5151f4..6edbe78 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/SelectAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/SelectAstNode.java
@@ -98,8 +98,8 @@ public class SelectAstNode extends BaseAstNode {
@Override
public String toString() {
- return "SelectAstNode{" + "_tableName='" + _tableName + '\'' + ", _resourceName='" + _resourceName + '\''
- + ", _recordLimit=" + _recordLimit + ", _offset=" + _offset + '}';
+ return "SelectAstNode{" + "_tableName='" + _tableName + '\'' + ", _resourceName='" + _resourceName + '\'' + ", _recordLimit="
+ + _recordLimit + ", _offset=" + _offset + '}';
}
@Override
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/TableNameAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/TableNameAstNode.java
index 82af195..330a73c 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/TableNameAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/TableNameAstNode.java
@@ -26,8 +26,7 @@ public class TableNameAstNode extends BaseAstNode {
private String _resourceName;
public TableNameAstNode(String tableName) {
- if ((tableName.startsWith("'") && tableName.endsWith("'")) || (tableName.startsWith("\"") && tableName
- .endsWith("\""))) {
+ if ((tableName.startsWith("'") && tableName.endsWith("'")) || (tableName.startsWith("\"") && tableName.endsWith("\""))) {
tableName = tableName.substring(1, tableName.length() - 1);
}
int firstDotIndex = tableName.indexOf('.');
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/TextMatchPredicateAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/TextMatchPredicateAstNode.java
index 3e47b05..b9f6f46 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/TextMatchPredicateAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/TextMatchPredicateAstNode.java
@@ -52,8 +52,7 @@ public class TextMatchPredicateAstNode extends PredicateAstNode {
}
List<? extends AstNode> children = getChildren();
- Preconditions.checkState(children != null && children.size() == 1,
- "TEXT_MATCH predicate should have exactly one query string");
+ Preconditions.checkState(children != null && children.size() == 1, "TEXT_MATCH predicate should have exactly one query string");
AstNode child = children.get(0);
Preconditions.checkState(child instanceof StringLiteralAstNode);
String expr = ((StringLiteralAstNode) child).getValueAsString();
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/TopAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/TopAstNode.java
index 4efe455..fa2f37c 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/TopAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/TopAstNode.java
@@ -26,7 +26,7 @@ import org.apache.pinot.common.exception.QueryException;
*/
public class TopAstNode extends BaseAstNode {
private int _count;
- public static int DEFAULT_TOP_N = 50;
+ public static final int DEFAULT_TOP_N = 50;
public TopAstNode(int count) {
if (count < 0) {
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/utils/Pair.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/utils/Pair.java
index 143fb1a..5674eb8 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/utils/Pair.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/utils/Pair.java
@@ -22,28 +22,28 @@ import java.io.Serializable;
public class Pair<FIRST extends Serializable, SECOND extends Serializable> implements Serializable {
- private FIRST first;
- private SECOND second;
+ private FIRST _first;
+ private SECOND _second;
public FIRST getFirst() {
- return first;
+ return _first;
}
public void setFirst(FIRST first) {
- this.first = first;
+ _first = first;
}
public SECOND getSecond() {
- return second;
+ return _second;
}
public void setSecond(SECOND second) {
- this.second = second;
+ _second = second;
}
public Pair(FIRST first, SECOND second) {
super();
- this.first = first;
- this.second = second;
+ _first = first;
+ _second = second;
}
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java b/pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
index d6158d8..c8ef59e 100644
--- a/pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
+++ b/pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
@@ -68,6 +68,8 @@ import org.slf4j.LoggerFactory;
public class CalciteSqlParser {
+ private CalciteSqlParser() {
+ }
private static final Logger LOGGER = LoggerFactory.getLogger(CalciteSqlParser.class);
@@ -81,8 +83,8 @@ public class CalciteSqlParser {
// BABEL is a very liberal conformance value that allows anything supported by any dialect
private static final SqlParser.Config PARSER_CONFIG =
- SqlParser.configBuilder().setLex(PINOT_LEX).setConformance(SqlConformanceEnum.BABEL)
- .setParserFactory(SqlBabelParserImpl.FACTORY).build();
+ SqlParser.configBuilder().setLex(PINOT_LEX).setConformance(SqlConformanceEnum.BABEL).setParserFactory(SqlBabelParserImpl.FACTORY)
+ .build();
// To Keep the backward compatibility with 'OPTION' Functionality in PQL, which is used to
// provide more hints for query processing.
@@ -94,8 +96,7 @@ public class CalciteSqlParser {
// `OPTION (<k1> = <v1>, <k2> = <v2>, <k3> = <v3>)`
// or
// `OPTION (<k1> = <v1>) OPTION (<k2> = <v2>) OPTION (<k3> = <v3>)`
- private static final Pattern OPTIONS_REGEX_PATTEN =
- Pattern.compile("option\\s*\\(([^\\)]+)\\)", Pattern.CASE_INSENSITIVE);
+ private static final Pattern OPTIONS_REGEX_PATTEN = Pattern.compile("option\\s*\\(([^\\)]+)\\)", Pattern.CASE_INSENSITIVE);
public static PinotQuery compileToPinotQuery(String sql)
throws SqlCompilationException {
@@ -150,8 +151,7 @@ public class CalciteSqlParser {
}
if (selectExpr.getIdentifier() != null) {
if (aliasKeys.contains(selectExpr.getIdentifier().getName().toLowerCase())) {
- throw new SqlCompilationException(
- "Alias " + selectExpr.getIdentifier().getName() + " cannot be referred in SELECT Clause");
+ throw new SqlCompilationException("Alias " + selectExpr.getIdentifier().getName() + " cannot be referred in SELECT Clause");
}
}
}
@@ -161,19 +161,19 @@ public class CalciteSqlParser {
if (pinotQuery.getGroupByList() == null) {
return;
}
- // Sanity check group by query: All non-aggregate expression in selection list should be also included in group by list.
+ // Sanity check group by query: All non-aggregate expression in selection list should be also included in group
+ // by list.
Set<Expression> groupByExprs = new HashSet<>(pinotQuery.getGroupByList());
for (Expression selectExpression : pinotQuery.getSelectList()) {
if (!isAggregateExpression(selectExpression) && expressionOutsideGroupByList(selectExpression, groupByExprs)) {
- throw new SqlCompilationException(
- "'" + RequestUtils.prettyPrint(selectExpression) + "' should appear in GROUP BY clause.");
+ throw new SqlCompilationException("'" + RequestUtils.prettyPrint(selectExpression) + "' should appear in GROUP BY clause.");
}
}
// Sanity check on group by clause shouldn't contain aggregate expression.
for (Expression groupByExpression : pinotQuery.getGroupByList()) {
if (isAggregateExpression(groupByExpression)) {
- throw new SqlCompilationException("Aggregate expression '" + RequestUtils.prettyPrint(groupByExpression)
- + "' is not allowed in GROUP BY clause.");
+ throw new SqlCompilationException(
+ "Aggregate expression '" + RequestUtils.prettyPrint(groupByExpression) + "' is not allowed in GROUP BY clause.");
}
}
}
@@ -268,8 +268,7 @@ public class CalciteSqlParser {
identifiers.add(expression.getIdentifier().getName());
} else if (expression.getFunctionCall() != null) {
if (excludeAs && expression.getFunctionCall().getOperator().equalsIgnoreCase("AS")) {
- identifiers
- .addAll(extractIdentifiers(Arrays.asList(expression.getFunctionCall().getOperands().get(0)), true));
+ identifiers.addAll(extractIdentifiers(Arrays.asList(expression.getFunctionCall().getOperands().get(0)), true));
continue;
} else {
identifiers.addAll(extractIdentifiers(expression.getFunctionCall().getOperands(), excludeAs));
@@ -451,8 +450,7 @@ public class CalciteSqlParser {
}
return expression;
} else {
- throw new SqlCompilationException(
- String.format("Expected Ordinal value to be between 1 and %d.", selectList.size()));
+ throw new SqlCompilationException(String.format("Expected Ordinal value to be between 1 and %d.", selectList.size()));
}
}
@@ -508,6 +506,8 @@ public class CalciteSqlParser {
}
}
return;
+ default:
+ break;
}
for (Expression operand : functionCall.getOperands()) {
tryToRewriteArrayFunction(operand);
@@ -563,7 +563,7 @@ public class CalciteSqlParser {
} else {
selectIdentifiers.removeAll(groupByIdentifiers);
throw new SqlCompilationException(String.format(
- "For non-aggregation group by query, all the identifiers in select clause should be in groupBys. Found identifier: %s",
+ "For non-aggregation group by query, all the identifiers in select clause should be in groupBys. Found " + "identifier: %s",
Arrays.toString(selectIdentifiers.toArray(new String[0]))));
}
}
@@ -639,17 +639,16 @@ public class CalciteSqlParser {
operands.set(1, RequestUtils.getLiteralExpression(0));
break;
}
-
break;
default:
int numOperands = operands.size();
for (int i = 1; i < numOperands; i++) {
if (!operands.get(i).isSetLiteral()) {
throw new SqlCompilationException(String
- .format("For %s predicate, the operands except for the first one must be literal, got: %s",
- filterKind, expression));
+ .format("For %s predicate, the operands except for the first one must be literal, got: %s", filterKind, expression));
}
}
+ break;
}
}
return expression;
@@ -809,16 +808,14 @@ public class CalciteSqlParser {
Expression functionExpression = RequestUtils.getFunctionExpression(functionName);
for (SqlNode node : selectList) {
Expression columnExpression = toExpression(node);
- if (columnExpression.getType() == ExpressionType.IDENTIFIER && columnExpression.getIdentifier().getName()
- .equals("*")) {
+ if (columnExpression.getType() == ExpressionType.IDENTIFIER && columnExpression.getIdentifier().getName().equals("*")) {
throw new SqlCompilationException(
- "Syntax error: Pinot currently does not support DISTINCT with *. Please specify each column name after DISTINCT keyword");
+ "Syntax error: Pinot currently does not support DISTINCT with *. Please specify each column name after " + "DISTINCT keyword");
} else if (columnExpression.getType() == ExpressionType.FUNCTION) {
Function functionCall = columnExpression.getFunctionCall();
String function = functionCall.getOperator();
if (FunctionDefinitionRegistry.isAggFunc(function)) {
- throw new SqlCompilationException(
- "Syntax error: Use of DISTINCT with aggregation functions is not supported");
+ throw new SqlCompilationException("Syntax error: Use of DISTINCT with aggregation functions is not supported");
}
}
functionExpression.getFunctionCall().addToOperands(columnExpression);
@@ -879,23 +876,20 @@ public class CalciteSqlParser {
for (SqlNode whenSqlNode : whenOperands.getList()) {
Expression whenExpression = toExpression(whenSqlNode);
if (isAggregateExpression(whenExpression)) {
- throw new SqlCompilationException(
- "Aggregation functions inside WHEN Clause is not supported - " + whenSqlNode);
+ throw new SqlCompilationException("Aggregation functions inside WHEN Clause is not supported - " + whenSqlNode);
}
caseFuncExpr.getFunctionCall().addToOperands(whenExpression);
}
for (SqlNode thenSqlNode : thenOperands.getList()) {
Expression thenExpression = toExpression(thenSqlNode);
if (isAggregateExpression(thenExpression)) {
- throw new SqlCompilationException(
- "Aggregation functions inside THEN Clause is not supported - " + thenSqlNode);
+ throw new SqlCompilationException("Aggregation functions inside THEN Clause is not supported - " + thenSqlNode);
}
caseFuncExpr.getFunctionCall().addToOperands(thenExpression);
}
Expression elseExpression = toExpression(elseOperand);
if (isAggregateExpression(elseExpression)) {
- throw new SqlCompilationException(
- "Aggregation functions inside ELSE Clause is not supported - " + elseExpression);
+ throw new SqlCompilationException("Aggregation functions inside ELSE Clause is not supported - " + elseExpression);
}
caseFuncExpr.getFunctionCall().addToOperands(elseExpression);
return caseFuncExpr;
@@ -939,6 +933,7 @@ public class CalciteSqlParser {
break;
default:
functionName = functionKind.name();
+ break;
}
// When there is no argument, set an empty list as the operands
SqlNode[] childNodes = functionNode.getOperands();
@@ -1016,6 +1011,8 @@ public class CalciteSqlParser {
case "jsonextractkey":
validateJsonExtractKeyFunction(operands);
break;
+ default:
+ break;
}
}
@@ -1024,13 +1021,13 @@ public class CalciteSqlParser {
// Check that there are exactly 3 or 4 arguments
if (numOperands != 3 && numOperands != 4) {
- throw new SqlCompilationException(
- "Expect 3 or 4 arguments for transform function: jsonExtractScalar(jsonFieldName, 'jsonPath', 'resultsType', ['defaultValue'])");
+ throw new SqlCompilationException("Expect 3 or 4 arguments for transform function: jsonExtractScalar(jsonFieldName, 'jsonPath', "
+ + "'resultsType', ['defaultValue'])");
}
- if (!operands.get(1).isSetLiteral() || !operands.get(2).isSetLiteral() || (numOperands == 4 && !operands.get(3)
- .isSetLiteral())) {
+ if (!operands.get(1).isSetLiteral() || !operands.get(2).isSetLiteral() || (numOperands == 4 && !operands.get(3).isSetLiteral())) {
throw new SqlCompilationException(
- "Expect the 2nd/3rd/4th argument of transform function: jsonExtractScalar(jsonFieldName, 'jsonPath', 'resultsType', ['defaultValue']) to be a single-quoted literal value.");
+ "Expect the 2nd/3rd/4th argument of transform function: jsonExtractScalar(jsonFieldName, 'jsonPath',"
+ + " 'resultsType', ['defaultValue']) to be a single-quoted literal value.");
}
}
@@ -1041,8 +1038,8 @@ public class CalciteSqlParser {
"Expect 2 arguments are required for transform function: jsonExtractKey(jsonFieldName, 'jsonPath')");
}
if (!operands.get(1).isSetLiteral()) {
- throw new SqlCompilationException(
- "Expect the 2nd argument for transform function: jsonExtractKey(jsonFieldName, 'jsonPath') to be a single-quoted literal value.");
+ throw new SqlCompilationException("Expect the 2nd argument for transform function: jsonExtractKey(jsonFieldName, 'jsonPath') to be a "
+ + "single-quoted literal value.");
}
}
@@ -1112,8 +1109,7 @@ public class CalciteSqlParser {
return RequestUtils.getLiteralExpression(result);
} catch (Exception e) {
throw new SqlCompilationException(
- "Caught exception while invoking method: " + functionInfo.getMethod() + " with arguments: " + Arrays
- .toString(arguments), e);
+ "Caught exception while invoking method: " + functionInfo.getMethod() + " with arguments: " + Arrays.toString(arguments), e);
}
}
}
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/data/DateTimeFormatSpecTest.java b/pinot-common/src/test/java/org/apache/pinot/common/data/DateTimeFormatSpecTest.java
index 46c9f99..2b50378 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/data/DateTimeFormatSpecTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/data/DateTimeFormatSpecTest.java
@@ -53,20 +53,22 @@ public class DateTimeFormatSpecTest {
entries.add(new Object[]{"1:MILLISECONDS:EPOCH", "1498892400000", 1498892400000L});
entries.add(new Object[]{"1:HOURS:EPOCH", "0", 0L});
entries.add(new Object[]{"5:MINUTES:EPOCH", "4996308", 1498892400000L});
- entries.add(new Object[]{"1:MILLISECONDS:TIMESTAMP", "2017-07-01 00:00:00", Timestamp
- .valueOf("2017-07-01 00:00:00").getTime()});
+ entries.add(new Object[]{"1:MILLISECONDS:TIMESTAMP", "2017-07-01 00:00:00", Timestamp.valueOf("2017-07-01 00:00:00").getTime()
+ });
entries.add(new Object[]{"1:MILLISECONDS:TIMESTAMP", "1498892400000", 1498892400000L});
- entries.add(new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd", "20170701", DateTimeFormat.forPattern("yyyyMMdd")
- .withZoneUTC().parseMillis("20170701")});
- entries.add(new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd tz(America/Chicago)", "20170701", DateTimeFormat
- .forPattern("yyyyMMdd").withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("America/Chicago"))).parseMillis(
- "20170701")});
entries.add(
- new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH", "20170701 00", DateTimeFormat.forPattern("yyyyMMdd HH")
- .withZoneUTC().parseMillis("20170701 00")});
- entries.add(new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH tz(GMT+0600)", "20170701 00", DateTimeFormat
- .forPattern("yyyyMMdd HH").withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("GMT+0600"))).parseMillis(
- "20170701 00")});
+ new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd", "20170701", DateTimeFormat.forPattern("yyyyMMdd").withZoneUTC().parseMillis(
+ "20170701")
+ });
+ entries.add(new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd tz(America/Chicago)", "20170701", DateTimeFormat.forPattern("yyyyMMdd")
+ .withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("America/Chicago"))).parseMillis("20170701")
+ });
+ entries.add(new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH", "20170701 00", DateTimeFormat.forPattern("yyyyMMdd HH")
+ .withZoneUTC().parseMillis("20170701 00")
+ });
+ entries.add(new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH tz(GMT+0600)", "20170701 00", DateTimeFormat.forPattern("yyyyMMdd HH")
+ .withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("GMT+0600"))).parseMillis("20170701 00")
+ });
entries.add(new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH Z", "20170701 00 -07:00", 1498892400000L});
entries.add(new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:M/d/yyyy h:mm:ss a", "8/7/2017 12:45:50 AM", 1502066750000L});
return entries.toArray(new Object[entries.size()][]);
@@ -86,36 +88,45 @@ public class DateTimeFormatSpecTest {
entries.add(new Object[]{"1:MILLISECONDS:EPOCH", 1498892400000L, "1498892400000"});
entries.add(new Object[]{"1:HOURS:EPOCH", 0L, "0"});
entries.add(new Object[]{"5:MINUTES:EPOCH", 1498892400000L, "4996308"});
- entries.add(new Object[]{"1:MILLISECONDS:TIMESTAMP", Timestamp
- .valueOf("2017-07-01 00:00:00").getTime(), "2017-07-01 00:00:00.0"});
- entries.add(new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd", 1498892400000L, DateTimeFormat.forPattern("yyyyMMdd")
- .withZoneUTC().print(1498892400000L)});
- entries.add(new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd tz(America/New_York)", 1498892400000L, DateTimeFormat
- .forPattern("yyyyMMdd").withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("America/New_York"))).print(
- 1498892400000L)});
+ entries.add(new Object[]{"1:MILLISECONDS:TIMESTAMP", Timestamp.valueOf("2017-07-01 00:00:00").getTime(), "2017-07-01 00:00:00.0"
+ });
entries.add(
- new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH", 1498892400000L, DateTimeFormat.forPattern("yyyyMMdd HH")
- .withZoneUTC().print(1498892400000L)});
- entries.add(new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH tz(IST)", 1498892400000L, DateTimeFormat
- .forPattern("yyyyMMdd HH").withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("IST"))).print(
- 1498892400000L)});
- entries.add(new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH Z", 1498892400000L, DateTimeFormat
- .forPattern("yyyyMMdd HH Z").withZoneUTC().print(1498892400000L)});
- entries.add(new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH Z tz(GMT+0500)", 1498892400000L, DateTimeFormat
- .forPattern("yyyyMMdd HH Z").withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("GMT+0500"))).print(
- 1498892400000L)});
- entries.add(new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:M/d/yyyy h:mm:ss a", 1498892400000L, DateTimeFormat
- .forPattern("M/d/yyyy h:mm:ss a").withZoneUTC().withLocale(Locale.ENGLISH).print(1498892400000L)});
- entries.add(new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:M/d/yyyy h a", 1502066750000L, DateTimeFormat
- .forPattern("M/d/yyyy h a").withZoneUTC().withLocale(Locale.ENGLISH).print(1502066750000L)});
+ new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd", 1498892400000L, DateTimeFormat.forPattern("yyyyMMdd").withZoneUTC().print(
+ 1498892400000L)
+ });
+ entries.add(
+ new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd tz(America/New_York)", 1498892400000L, DateTimeFormat.forPattern("yyyyMMdd")
+ .withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("America/New_York"))).print(1498892400000L)
+ });
+ entries.add(
+ new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH", 1498892400000L, DateTimeFormat.forPattern("yyyyMMdd HH").withZoneUTC().print(
+ 1498892400000L)
+ });
+ entries.add(new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH tz(IST)", 1498892400000L, DateTimeFormat.forPattern("yyyyMMdd HH")
+ .withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("IST"))).print(1498892400000L)
+ });
+ entries.add(new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH Z", 1498892400000L, DateTimeFormat.forPattern("yyyyMMdd HH Z")
+ .withZoneUTC().print(1498892400000L)
+ });
+ entries.add(
+ new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH Z tz(GMT+0500)", 1498892400000L, DateTimeFormat.forPattern("yyyyMMdd HH Z")
+ .withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("GMT+0500"))).print(1498892400000L)
+ });
+ entries.add(
+ new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:M/d/yyyy h:mm:ss a", 1498892400000L, DateTimeFormat.forPattern("M/d/yyyy h:mm:ss a")
+ .withZoneUTC().withLocale(Locale.ENGLISH).print(1498892400000L)
+ });
+ entries.add(
+ new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:M/d/yyyy h a", 1502066750000L, DateTimeFormat.forPattern("M/d/yyyy h a").withZoneUTC()
+ .withLocale(Locale.ENGLISH).print(1502066750000L)
+ });
return entries.toArray(new Object[entries.size()][]);
}
// Test fetching components of a format form a given format
@Test(dataProvider = "testGetFromFormatDataProvider")
public void testGetFromFormat(String format, int columnSizeFromFormatExpected, TimeUnit columnUnitFromFormatExpected,
- TimeFormat timeFormatFromFormatExpected, String sdfPatternFromFormatExpected,
- DateTimeZone dateTimeZoneFromFormatExpected) {
+ TimeFormat timeFormatFromFormatExpected, String sdfPatternFromFormatExpected, DateTimeZone dateTimeZoneFromFormatExpected) {
DateTimeFormatSpec dateTimeFormatSpec = new DateTimeFormatSpec(format);
@@ -145,39 +156,49 @@ public class DateTimeFormatSpecTest {
List<Object[]> entries = new ArrayList<>();
- entries.add(
- new Object[]{"1:HOURS:EPOCH", 1, TimeUnit.HOURS, DateTimeFieldSpec.TimeFormat.EPOCH, null, DateTimeZone.UTC});
+ entries.add(new Object[]{"1:HOURS:EPOCH", 1, TimeUnit.HOURS, DateTimeFieldSpec.TimeFormat.EPOCH, null, DateTimeZone.UTC});
- entries.add(
- new Object[]{"5:MINUTES:EPOCH", 5, TimeUnit.MINUTES, DateTimeFieldSpec.TimeFormat.EPOCH, null, DateTimeZone.UTC});
+ entries.add(new Object[]{"5:MINUTES:EPOCH", 5, TimeUnit.MINUTES, DateTimeFieldSpec.TimeFormat.EPOCH, null, DateTimeZone.UTC});
entries.add(
- new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd", 1, TimeUnit.DAYS, DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT, "yyyyMMdd", DateTimeZone.UTC});
+ new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd", 1, TimeUnit.DAYS, DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT, "yyyyMMdd",
+ DateTimeZone.UTC});
entries.add(
- new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd tz(IST)", 1, TimeUnit.DAYS, DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT, "yyyyMMdd", DateTimeZone.forTimeZone(
- TimeZone.getTimeZone("IST"))});
+ new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd tz(IST)", 1, TimeUnit.DAYS, DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT,
+ "yyyyMMdd", DateTimeZone.forTimeZone(
+ TimeZone.getTimeZone("IST"))
+ });
entries.add(
- new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd tz(IST)", 1, TimeUnit.DAYS, DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT, "yyyyMMdd", DateTimeZone.forTimeZone(
- TimeZone.getTimeZone("IST"))});
+ new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd tz(IST)", 1, TimeUnit.DAYS,
+ DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT, "yyyyMMdd", DateTimeZone.forTimeZone(
+ TimeZone.getTimeZone("IST"))
+ });
entries.add(
- new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd tz ( IST ) ", 1, TimeUnit.DAYS, DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT, "yyyyMMdd", DateTimeZone.forTimeZone(
- TimeZone.getTimeZone("IST"))});
+ new Object[]{"1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd tz ( IST ) ", 1, TimeUnit.DAYS,
+ DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT, "yyyyMMdd", DateTimeZone.forTimeZone(
+ TimeZone.getTimeZone("IST"))
+ });
entries.add(
- new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH", 1, TimeUnit.HOURS, DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT, "yyyyMMdd HH", DateTimeZone.UTC});
+ new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH", 1, TimeUnit.HOURS, DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT,
+ "yyyyMMdd HH", DateTimeZone.UTC});
entries.add(
- new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH tz(dummy)", 1, TimeUnit.HOURS, DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT, "yyyyMMdd HH", DateTimeZone.UTC});
+ new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd HH tz(dummy)", 1, TimeUnit.HOURS,
+ DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT, "yyyyMMdd HH", DateTimeZone.UTC});
entries.add(
- new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:M/d/yyyy h:mm:ss a", 1, TimeUnit.HOURS, DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT, "M/d/yyyy h:mm:ss a", DateTimeZone.UTC});
+ new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:M/d/yyyy h:mm:ss a", 1, TimeUnit.HOURS, DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT,
+ "M/d/yyyy h:mm:ss a", DateTimeZone.UTC});
entries.add(
- new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:M/d/yyyy h:mm:ss a tz(Asia/Tokyo)", 1, TimeUnit.HOURS, DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT, "M/d/yyyy h:mm:ss a", DateTimeZone.forTimeZone(
- TimeZone.getTimeZone("Asia/Tokyo"))});
+ new Object[]{"1:HOURS:SIMPLE_DATE_FORMAT:M/d/yyyy h:mm:ss a tz(Asia/Tokyo)", 1, TimeUnit.HOURS,
+ DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT, "M/d/yyyy h:mm:ss a", DateTimeZone.forTimeZone(
+ TimeZone.getTimeZone("Asia/Tokyo"))
+ });
return entries.toArray(new Object[entries.size()][]);
}
@@ -215,15 +236,16 @@ public class DateTimeFormatSpecTest {
entries.add(new Object[]{1, TimeUnit.HOURS, null, null, null, null});
entries.add(new Object[]{1, TimeUnit.HOURS, "DUMMY", "yyyyMMdd", null, null});
entries.add(new Object[]{1, TimeUnit.HOURS, "SIMPLE_DATE_FORMAT", "yyyyMMdd", null, new DateTimeFormatSpec(
- "1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd")});
- entries.add(
- new Object[]{1, TimeUnit.HOURS, "SIMPLE_DATE_FORMAT", "yyyyMMdd tz(America/Los_Angeles)", null, new DateTimeFormatSpec(
- "1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd tz(America/Los_Angeles)")});
+ "1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd")
+ });
+ entries.add(new Object[]{1, TimeUnit.HOURS, "SIMPLE_DATE_FORMAT", "yyyyMMdd tz(America/Los_Angeles)", null, new DateTimeFormatSpec(
+ "1:HOURS:SIMPLE_DATE_FORMAT:yyyyMMdd tz(America/Los_Angeles)")
+ });
entries.add(new Object[]{1, TimeUnit.HOURS, "SIMPLE_DATE_FORMAT", null, null, null});
entries.add(new Object[]{-1, TimeUnit.HOURS, "SIMPLE_DATE_FORMAT", "yyyyMMDD", null, null});
- entries.add(
- new Object[]{1, TimeUnit.HOURS, "SIMPLE_DATE_FORMAT", "M/d/yyyy h:mm:ss a", null, new DateTimeFormatSpec(
- "1:HOURS:SIMPLE_DATE_FORMAT:M/d/yyyy h:mm:ss a")});
+ entries.add(new Object[]{1, TimeUnit.HOURS, "SIMPLE_DATE_FORMAT", "M/d/yyyy h:mm:ss a", null, new DateTimeFormatSpec(
+ "1:HOURS:SIMPLE_DATE_FORMAT:M/d/yyyy h:mm:ss a")
+ });
return entries.toArray(new Object[entries.size()][]);
}
}
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/data/FieldSpecTest.java b/pinot-common/src/test/java/org/apache/pinot/common/data/FieldSpecTest.java
index a020ebc..151605c 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/data/FieldSpecTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/data/FieldSpecTest.java
@@ -184,13 +184,11 @@ public class FieldSpecTest {
String incomingName = "incoming";
TimeUnit incomingTimeUnit = TimeUnit.HOURS;
int incomingTimeUnitSize = 1;
- TimeGranularitySpec incomingTimeGranularitySpec =
- new TimeGranularitySpec(LONG, incomingTimeUnitSize, incomingTimeUnit, incomingName);
+ TimeGranularitySpec incomingTimeGranularitySpec = new TimeGranularitySpec(LONG, incomingTimeUnitSize, incomingTimeUnit, incomingName);
String outgoingName = "outgoing";
TimeUnit outgoingTimeUnit = TimeUnit.DAYS;
int outgoingTimeUnitSize = 1;
- TimeGranularitySpec outgoingTimeGranularitySpec =
- new TimeGranularitySpec(INT, outgoingTimeUnitSize, outgoingTimeUnit, outgoingName);
+ TimeGranularitySpec outgoingTimeGranularitySpec = new TimeGranularitySpec(INT, outgoingTimeUnitSize, outgoingTimeUnit, outgoingName);
TimeFieldSpec timeFieldSpec1 = new TimeFieldSpec(incomingTimeGranularitySpec);
TimeFieldSpec timeFieldSpec2 = new TimeFieldSpec(incomingTimeGranularitySpec, outgoingTimeGranularitySpec);
Assert.assertNotEquals(timeFieldSpec1, timeFieldSpec2);
@@ -216,8 +214,7 @@ public class FieldSpecTest {
Assert.assertEquals(dateTimeFieldSpec1, dateTimeFieldSpec3);
DateTimeFieldSpec dateTimeFieldSpec4 = new DateTimeFieldSpec(name, LONG, format, granularity, 100000000L, null);
- DateTimeFieldSpec dateTimeFieldSpec5 =
- new DateTimeFieldSpec(name, INT, format, granularity, null, "toEpochHours(millis)");
+ DateTimeFieldSpec dateTimeFieldSpec5 = new DateTimeFieldSpec(name, INT, format, granularity, null, "toEpochHours(millis)");
Assert.assertNotEquals(dateTimeFieldSpec5, dateTimeFieldSpec4);
DateTimeFieldSpec dateTimeFieldSpec6 = new DateTimeFieldSpec(name, LONG, format, granularity, 100000000L, null);
@@ -225,8 +222,8 @@ public class FieldSpecTest {
}
@Test(dataProvider = "testFormatDataProvider")
- public void testDateTimeFormat(String name, FieldSpec.DataType dataType, String format, String granularity,
- boolean exceptionExpected, DateTimeFieldSpec dateTimeFieldExpected) {
+ public void testDateTimeFormat(String name, FieldSpec.DataType dataType, String format, String granularity, boolean exceptionExpected,
+ DateTimeFieldSpec dateTimeFieldExpected) {
DateTimeFieldSpec dateTimeFieldActual = null;
boolean exceptionActual = false;
@@ -255,11 +252,12 @@ public class FieldSpecTest {
entries.add(new Object[]{name, dataType, "0:HOURS:EPOCH", granularity, true, null});
entries.add(new Object[]{name, dataType, "-1:HOURS:EPOCH", granularity, true, null});
entries.add(new Object[]{name, dataType, "0.1:HOURS:EPOCH", granularity, true, null});
- entries.add(new Object[]{name, dataType, "1:HOURS:EPOCH", granularity, false, new DateTimeFieldSpec(name, dataType,
- "1:HOURS:EPOCH", granularity)});
- entries.add(
- new Object[]{name, dataType, "1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd", granularity, false, new DateTimeFieldSpec(
- name, dataType, "1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd", granularity)});
+ entries.add(new Object[]{name, dataType, "1:HOURS:EPOCH", granularity, false, new DateTimeFieldSpec(name, dataType, "1:HOURS:EPOCH",
+ granularity)
+ });
+ entries.add(new Object[]{name, dataType, "1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd", granularity, false, new DateTimeFieldSpec(name, dataType,
+ "1:DAYS:SIMPLE_DATE_FORMAT:yyyyMMdd", granularity)
+ });
return entries.toArray(new Object[entries.size()][]);
}
@@ -272,16 +270,14 @@ public class FieldSpecTest {
throws Exception {
// Metric field with default null value.
String[] metricFields = {"\"name\":\"metric\"", "\"dataType\":\"INT\"", "\"defaultNullValue\":-1"};
- MetricFieldSpec metricFieldSpec1 =
- JsonUtils.stringToObject(getRandomOrderJsonString(metricFields), MetricFieldSpec.class);
+ MetricFieldSpec metricFieldSpec1 = JsonUtils.stringToObject(getRandomOrderJsonString(metricFields), MetricFieldSpec.class);
MetricFieldSpec metricFieldSpec2 = new MetricFieldSpec("metric", INT, -1);
Assert.assertEquals(metricFieldSpec1, metricFieldSpec2, ERROR_MESSAGE);
Assert.assertEquals(metricFieldSpec1.getDefaultNullValue(), -1, ERROR_MESSAGE);
// Single-value boolean type dimension field with default null value.
String[] dimensionFields = {"\"name\":\"dimension\"", "\"dataType\":\"BOOLEAN\"", "\"defaultNullValue\":false"};
- DimensionFieldSpec dimensionFieldSpec1 =
- JsonUtils.stringToObject(getRandomOrderJsonString(dimensionFields), DimensionFieldSpec.class);
+ DimensionFieldSpec dimensionFieldSpec1 = JsonUtils.stringToObject(getRandomOrderJsonString(dimensionFields), DimensionFieldSpec.class);
DimensionFieldSpec dimensionFieldSpec2 = new DimensionFieldSpec("dimension", BOOLEAN, true, false);
Assert.assertEquals(dimensionFieldSpec1, dimensionFieldSpec2, ERROR_MESSAGE);
Assert.assertEquals(dimensionFieldSpec1.getDefaultNullValue(), 0, ERROR_MESSAGE);
@@ -295,10 +291,10 @@ public class FieldSpecTest {
Assert.assertEquals(dimensionFieldSpec1.getDefaultNullValue(), "default", ERROR_MESSAGE);
// Date time field with default null value.
- String[] dateTimeFields =
- {"\"name\":\"Date\"", "\"dataType\":\"LONG\"", "\"format\":\"1:MILLISECONDS:EPOCH\"", "\"granularity\":\"5:MINUTES\"", "\"dateTimeType\":\"PRIMARY\""};
- DateTimeFieldSpec dateTimeFieldSpec1 =
- JsonUtils.stringToObject(getRandomOrderJsonString(dateTimeFields), DateTimeFieldSpec.class);
+ String[] dateTimeFields = {"\"name\":\"Date\"", "\"dataType\":\"LONG\"", "\"format\":\"1:MILLISECONDS:EPOCH\"",
+ "\"granularity\":\"5" + ":MINUTES\"", "\"dateTimeType\":\"PRIMARY\""
+ };
+ DateTimeFieldSpec dateTimeFieldSpec1 = JsonUtils.stringToObject(getRandomOrderJsonString(dateTimeFields), DateTimeFieldSpec.class);
DateTimeFieldSpec dateTimeFieldSpec2 = new DateTimeFieldSpec("Date", LONG, "1:MILLISECONDS:EPOCH", "5:MINUTES");
Assert.assertEquals(dateTimeFieldSpec1, dateTimeFieldSpec2, ERROR_MESSAGE);
}
@@ -314,7 +310,8 @@ public class FieldSpecTest {
// Single-value boolean type dimension field with default null value.
String[] dimensionFields =
- {"\"name\":\"dimension\"", "\"dataType\":\"BOOLEAN\"", "\"defaultNullValue\":false", "\"transformFunction\":\"trim(foo)\""};
+ {"\"name\":\"dimension\"", "\"dataType\":\"BOOLEAN\"", "\"defaultNullValue\":false", "\"transformFunction" + "\":\"trim(foo)\""
+ };
first = JsonUtils.stringToObject(getRandomOrderJsonString(dimensionFields), DimensionFieldSpec.class);
second = JsonUtils.stringToObject(first.toJsonObject().toString(), DimensionFieldSpec.class);
Assert.assertEquals(first, second, ERROR_MESSAGE);
@@ -327,15 +324,18 @@ public class FieldSpecTest {
Assert.assertEquals(first, second, ERROR_MESSAGE);
// Time field with default value.
- String[] timeFields =
- {"\"incomingGranularitySpec\":{\"timeUnitSize\":1, \"timeType\":\"MILLISECONDS\",\"dataType\":\"LONG\",\"name\":\"incomingTime\"}", "\"outgoingGranularitySpec\":{\"timeType\":\"SECONDS\",\"dataType\":\"INT\",\"name\":\"outgoingTime\"}", "\"defaultNullValue\":-1", "\"transformFunction\":\"toEpochDays(millis)\""};
+ String[] timeFields = {"\"incomingGranularitySpec\":{\"timeUnitSize\":1, \"timeType\":\"MILLISECONDS\",\"dataType\":\"LONG\","
+ + "\"name\":\"incomingTime\"}", "\"outgoingGranularitySpec\":{\"timeType\":\"SECONDS\",\"dataType\":\"INT\","
+ + "\"name\":\"outgoingTime\"}", "\"defaultNullValue\":-1", "\"transformFunction\":\"toEpochDays" + "(millis)\""
+ };
first = JsonUtils.stringToObject(getRandomOrderJsonString(timeFields), TimeFieldSpec.class);
second = JsonUtils.stringToObject(first.toJsonObject().toString(), TimeFieldSpec.class);
Assert.assertEquals(first, second, ERROR_MESSAGE);
// DateTime field
- String[] dateTimeFields =
- {"\"name\":\"Date\"", "\"dataType\":\"LONG\"", "\"format\":\"1:MILLISECONDS:EPOCH\"", "\"granularity\":\"5:MINUTES\"", "\"transformFunction\":\"fromEpochDays(daysSinceEpoch)\""};
+ String[] dateTimeFields = {"\"name\":\"Date\"", "\"dataType\":\"LONG\"", "\"format\":\"1:MILLISECONDS:EPOCH\"",
+ "\"granularity\":\"5" + ":MINUTES\"", "\"transformFunction\":\"fromEpochDays(daysSinceEpoch)\""
+ };
first = JsonUtils.stringToObject(getRandomOrderJsonString(dateTimeFields), DateTimeFieldSpec.class);
second = JsonUtils.stringToObject(first.toJsonObject().toString(), DateTimeFieldSpec.class);
Assert.assertEquals(first, second, ERROR_MESSAGE);
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/data/SchemaTest.java b/pinot-common/src/test/java/org/apache/pinot/common/data/SchemaTest.java
index 47b536f..3d204c8 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/data/SchemaTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/data/SchemaTest.java
@@ -196,8 +196,7 @@ public class SchemaTest {
@Test
public void testFetchFieldSpecForTime() {
Schema schema = new Schema.SchemaBuilder().addSingleValueDimension("svDimension", FieldSpec.DataType.INT)
- .addMetric("metric", FieldSpec.DataType.INT)
- .addTime(new TimeGranularitySpec(FieldSpec.DataType.LONG, TimeUnit.DAYS, "time"), null)
+ .addMetric("metric", FieldSpec.DataType.INT).addTime(new TimeGranularitySpec(FieldSpec.DataType.LONG, TimeUnit.DAYS, "time"), null)
.addDateTime("dateTime", FieldSpec.DataType.LONG, "1:HOURS:EPOCH", "1:HOURS").build();
// Test method which fetches the DateTimeFieldSpec given the timeColumnName
@@ -239,8 +238,7 @@ public class SchemaTest {
TimeGranularitySpec outgoingTimeGranularitySpec =
new TimeGranularitySpec(outgoingDataType, outgoingTimeUnitSize, outgoingTimeUnit, outgoingName);
- Schema schema11 =
- new Schema.SchemaBuilder().setSchemaName("testSchema").addTime(incomingTimeGranularitySpec, null).build();
+ Schema schema11 = new Schema.SchemaBuilder().setSchemaName("testSchema").addTime(incomingTimeGranularitySpec, null).build();
Schema schema12 = new Schema.SchemaBuilder().setSchemaName("testSchema").build();
schema12.addField(new TimeFieldSpec(incomingTimeGranularitySpec, outgoingTimeGranularitySpec));
Assert.assertNotNull(schema11.getTimeFieldSpec());
@@ -248,8 +246,8 @@ public class SchemaTest {
Assert.assertNotEquals(schema12, schema11);
- schema11 = new Schema.SchemaBuilder().setSchemaName("testSchema")
- .addTime(incomingTimeGranularitySpec, outgoingTimeGranularitySpec).build();
+ schema11 =
+ new Schema.SchemaBuilder().setSchemaName("testSchema").addTime(incomingTimeGranularitySpec, outgoingTimeGranularitySpec).build();
Assert.assertEquals(schema11, schema12);
}
@@ -283,13 +281,11 @@ public class SchemaTest {
public void testSimpleDateFormat()
throws Exception {
TimeGranularitySpec incomingTimeGranularitySpec =
- new TimeGranularitySpec(FieldSpec.DataType.STRING, 1, TimeUnit.DAYS,
- TimeFormat.SIMPLE_DATE_FORMAT + ":yyyyMMdd", "Date");
+ new TimeGranularitySpec(FieldSpec.DataType.STRING, 1, TimeUnit.DAYS, TimeFormat.SIMPLE_DATE_FORMAT + ":yyyyMMdd", "Date");
TimeGranularitySpec outgoingTimeGranularitySpec =
- new TimeGranularitySpec(FieldSpec.DataType.STRING, 1, TimeUnit.DAYS,
- TimeFormat.SIMPLE_DATE_FORMAT + ":yyyyMMdd", "Date");
- Schema schema = new Schema.SchemaBuilder().setSchemaName("testSchema")
- .addTime(incomingTimeGranularitySpec, outgoingTimeGranularitySpec).build();
+ new TimeGranularitySpec(FieldSpec.DataType.STRING, 1, TimeUnit.DAYS, TimeFormat.SIMPLE_DATE_FORMAT + ":yyyyMMdd", "Date");
+ Schema schema =
+ new Schema.SchemaBuilder().setSchemaName("testSchema").addTime(incomingTimeGranularitySpec, outgoingTimeGranularitySpec).build();
String jsonSchema = schema.toSingleLineJsonString();
Schema schemaFromJson = Schema.fromString(jsonSchema);
Assert.assertEquals(schemaFromJson, schema);
@@ -325,8 +321,8 @@ public class SchemaTest {
Schema oldSchema = new Schema.SchemaBuilder().addSingleValueDimension("svDimension", FieldSpec.DataType.INT)
.addSingleValueDimension("svDimensionWithDefault", FieldSpec.DataType.INT, 10)
.addMultiValueDimension("mvDimension", FieldSpec.DataType.STRING)
- .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default")
- .addMetric("metric", FieldSpec.DataType.INT).addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
+ .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default").addMetric("metric", FieldSpec.DataType.INT)
+ .addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
.addTime(new TimeGranularitySpec(FieldSpec.DataType.LONG, TimeUnit.DAYS, "time"), null)
.addDateTime("dateTime", FieldSpec.DataType.LONG, "1:HOURS:EPOCH", "1:HOURS").build();
@@ -336,8 +332,8 @@ public class SchemaTest {
Schema schema1 = new Schema.SchemaBuilder().addSingleValueDimension("svDimension", FieldSpec.DataType.INT)
// Remove column svDimensionWithDefault
.addMultiValueDimension("mvDimension", FieldSpec.DataType.STRING)
- .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default")
- .addMetric("metric", FieldSpec.DataType.INT).addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
+ .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default").addMetric("metric", FieldSpec.DataType.INT)
+ .addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
.addTime(new TimeGranularitySpec(FieldSpec.DataType.LONG, TimeUnit.DAYS, "time"), null)
.addDateTime("dateTime", FieldSpec.DataType.LONG, "1:HOURS:EPOCH", "1:HOURS").build();
Assert.assertFalse(schema1.isBackwardCompatibleWith(oldSchema));
@@ -346,8 +342,8 @@ public class SchemaTest {
Schema schema2 = new Schema.SchemaBuilder().addSingleValueDimension("svDimension", FieldSpec.DataType.INT)
.addSingleValueDimension("svDimensionWithDefault", FieldSpec.DataType.LONG, 10) // INT -> LONG
.addMultiValueDimension("mvDimension", FieldSpec.DataType.STRING)
- .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default")
- .addMetric("metric", FieldSpec.DataType.INT).addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
+ .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default").addMetric("metric", FieldSpec.DataType.INT)
+ .addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
.addTime(new TimeGranularitySpec(FieldSpec.DataType.LONG, TimeUnit.DAYS, "time"), null)
.addDateTime("dateTime", FieldSpec.DataType.LONG, "1:HOURS:EPOCH", "1:HOURS").build();
Assert.assertFalse(schema2.isBackwardCompatibleWith(oldSchema));
@@ -356,8 +352,8 @@ public class SchemaTest {
Schema schema3 = new Schema.SchemaBuilder().addSingleValueDimension("svDimension", FieldSpec.DataType.INT)
.addSingleValueDimension("svDimensionWithDefault", FieldSpec.DataType.INT, 10)
.addMultiValueDimension("mvDimension", FieldSpec.DataType.STRING)
- .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default")
- .addMetric("metric", FieldSpec.DataType.INT).addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
+ .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default").addMetric("metric", FieldSpec.DataType.INT)
+ .addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
.addTime(new TimeGranularitySpec(FieldSpec.DataType.LONG, TimeUnit.HOURS, "time"), null)
.addDateTime("dateTime", FieldSpec.DataType.LONG, "1:HOURS:EPOCH", "1:HOURS").build();
Assert.assertFalse(schema3.isBackwardCompatibleWith(oldSchema));
@@ -366,8 +362,8 @@ public class SchemaTest {
Schema schema4 = new Schema.SchemaBuilder().addSingleValueDimension("svDimension", FieldSpec.DataType.INT)
.addSingleValueDimension("svDimensionWithDefault", FieldSpec.DataType.INT, 10)
.addMultiValueDimension("mvDimension", FieldSpec.DataType.STRING)
- .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default")
- .addMetric("metric", FieldSpec.DataType.INT).addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
+ .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default").addMetric("metric", FieldSpec.DataType.INT)
+ .addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
.addTime(new TimeGranularitySpec(FieldSpec.DataType.LONG, TimeUnit.DAYS, "time"), null)
.addDateTime("dateTime", FieldSpec.DataType.LONG, "2:HOURS:EPOCH", "1:HOURS").build(); // timeUnit 1 -> 2
Assert.assertFalse(schema4.isBackwardCompatibleWith(oldSchema));
@@ -376,8 +372,8 @@ public class SchemaTest {
Schema schema5 = new Schema.SchemaBuilder().addSingleValueDimension("svDimension", FieldSpec.DataType.INT)
.addSingleValueDimension("svDimensionWithDefault", FieldSpec.DataType.INT, 100) // default value 10 -> 100
.addMultiValueDimension("mvDimension", FieldSpec.DataType.STRING)
- .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default")
- .addMetric("metric", FieldSpec.DataType.INT).addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
+ .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default").addMetric("metric", FieldSpec.DataType.INT)
+ .addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
.addTime(new TimeGranularitySpec(FieldSpec.DataType.LONG, TimeUnit.DAYS, "time"), null)
.addDateTime("dateTime", FieldSpec.DataType.LONG, "1:HOURS:EPOCH", "1:HOURS").build();
Assert.assertFalse(schema5.isBackwardCompatibleWith(oldSchema));
@@ -387,8 +383,8 @@ public class SchemaTest {
.addSingleValueDimension("svDimensionWithDefault", FieldSpec.DataType.INT, 10)
.addSingleValueDimension("svDimensionWithDefault1", FieldSpec.DataType.INT, 10)
.addMultiValueDimension("mvDimension", FieldSpec.DataType.STRING)
- .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default")
- .addMetric("metric", FieldSpec.DataType.INT).addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
+ .addMultiValueDimension("mvDimensionWithDefault", FieldSpec.DataType.STRING, "default").addMetric("metric", FieldSpec.DataType.INT)
+ .addMetric("metricWithDefault", FieldSpec.DataType.INT, 5)
.addTime(new TimeGranularitySpec(FieldSpec.DataType.LONG, TimeUnit.DAYS, "time"), null)
.addDateTime("dateTime", FieldSpec.DataType.LONG, "1:HOURS:EPOCH", "1:HOURS").build();
Assert.assertTrue(schema6.isBackwardCompatibleWith(oldSchema));
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/function/AggregationFunctionTypeTest.java b/pinot-common/src/test/java/org/apache/pinot/common/function/AggregationFunctionTypeTest.java
index a47d276..70a25b5 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/function/AggregationFunctionTypeTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/function/AggregationFunctionTypeTest.java
@@ -32,38 +32,29 @@ public class AggregationFunctionTypeTest {
Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("MaX"), AggregationFunctionType.MAX);
Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("SuM"), AggregationFunctionType.SUM);
Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("AvG"), AggregationFunctionType.AVG);
- Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("MiNmAxRaNgE"),
- AggregationFunctionType.MINMAXRANGE);
- Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("DiStInCtCoUnT"),
- AggregationFunctionType.DISTINCTCOUNT);
- Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("DiStInCtCoUnThLl"),
- AggregationFunctionType.DISTINCTCOUNTHLL);
+ Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("MiNmAxRaNgE"), AggregationFunctionType.MINMAXRANGE);
+ Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("DiStInCtCoUnT"), AggregationFunctionType.DISTINCTCOUNT);
+ Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("DiStInCtCoUnThLl"), AggregationFunctionType.DISTINCTCOUNTHLL);
Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("DiStInCtCoUnTrAwHlL"),
AggregationFunctionType.DISTINCTCOUNTRAWHLL);
Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("FaStHlL"), AggregationFunctionType.FASTHLL);
- Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("PeRcEnTiLe5"),
- AggregationFunctionType.PERCENTILE);
- Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("PeRcEnTiLeEsT50"),
- AggregationFunctionType.PERCENTILEEST);
- Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("PeRcEnTiLeTdIgEsT99"),
- AggregationFunctionType.PERCENTILETDIGEST);
+ Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("PeRcEnTiLe5"), AggregationFunctionType.PERCENTILE);
+ Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("PeRcEnTiLeEsT50"), AggregationFunctionType.PERCENTILEEST);
+ Assert
+ .assertEquals(AggregationFunctionType.getAggregationFunctionType("PeRcEnTiLeTdIgEsT99"), AggregationFunctionType.PERCENTILETDIGEST);
Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("CoUnTMv"), AggregationFunctionType.COUNTMV);
Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("MiNmV"), AggregationFunctionType.MINMV);
Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("MaXmV"), AggregationFunctionType.MAXMV);
Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("SuMmV"), AggregationFunctionType.SUMMV);
Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("AvGmV"), AggregationFunctionType.AVGMV);
- Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("MiNmAxRaNgEmV"),
- AggregationFunctionType.MINMAXRANGEMV);
- Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("DiStInCtCoUnTmV"),
- AggregationFunctionType.DISTINCTCOUNTMV);
- Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("DiStInCtCoUnThLlMv"),
- AggregationFunctionType.DISTINCTCOUNTHLLMV);
+ Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("MiNmAxRaNgEmV"), AggregationFunctionType.MINMAXRANGEMV);
+ Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("DiStInCtCoUnTmV"), AggregationFunctionType.DISTINCTCOUNTMV);
+ Assert
+ .assertEquals(AggregationFunctionType.getAggregationFunctionType("DiStInCtCoUnThLlMv"), AggregationFunctionType.DISTINCTCOUNTHLLMV);
Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("DiStInCtCoUnTrAwHlLmV"),
AggregationFunctionType.DISTINCTCOUNTRAWHLLMV);
- Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("PeRcEnTiLe10Mv"),
- AggregationFunctionType.PERCENTILEMV);
- Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("PeRcEnTiLeEsT90mV"),
- AggregationFunctionType.PERCENTILEESTMV);
+ Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("PeRcEnTiLe10Mv"), AggregationFunctionType.PERCENTILEMV);
+ Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("PeRcEnTiLeEsT90mV"), AggregationFunctionType.PERCENTILEESTMV);
Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("PeRcEnTiLeTdIgEsT95mV"),
AggregationFunctionType.PERCENTILETDIGESTMV);
}
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/function/JsonFunctionsTest.java b/pinot-common/src/test/java/org/apache/pinot/common/function/JsonFunctionsTest.java
index 47f56d5..a47529d 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/function/JsonFunctionsTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/function/JsonFunctionsTest.java
@@ -38,6 +38,9 @@ public class JsonFunctionsTest {
@Test
public void testJsonFunction()
throws JsonProcessingException {
+
+ // CHECKSTYLE:OFF
+ // @formatter:off
String jsonString = "{" +
" \"id\": \"7044885078\"," +
" \"type\": \"CreateEvent\"," +
@@ -64,6 +67,8 @@ public class JsonFunctionsTest {
" \"public\": true," +
" \"created_at\": \"2018-01-01T11:12:53Z\"" +
"}";
+ // @formatter:on
+ // CHECKSTYLE:ON
assertEquals(JsonFunctions.jsonPathString(jsonString, "$.actor.id"), "33500718");
assertEquals(JsonFunctions.jsonPathLong(jsonString, "$.actor.id"), 33500718L);
assertEquals(JsonFunctions.jsonPathDouble(jsonString, "$.actor.id"), 33500718.0);
@@ -75,6 +80,8 @@ public class JsonFunctionsTest {
@Test
public void testJsonFunctionExtractingArray()
throws JsonProcessingException {
+ // CHECKSTYLE:OFF
+ // @formatter:off
String jsonString = "{\n" +
" \"name\": \"Pete\",\n" +
" \"age\": 24,\n" +
@@ -91,6 +98,8 @@ public class JsonFunctionsTest {
" }\n" +
" ]\n" +
"}";
+ // @formatter:on
+ // CHECKSTYLE:ON
assertEquals(JsonFunctions.jsonPathArray(jsonString, "$.subjects[*].name"), new String[]{"maths", "english"});
assertEquals(JsonFunctions.jsonPathArray(jsonString, "$.subjects[*].grade"), new String[]{"A", "B"});
assertEquals(JsonFunctions.jsonPathArray(jsonString, "$.subjects[*].homework_grades"),
@@ -113,6 +122,8 @@ public class JsonFunctionsTest {
assertEquals(JsonFunctions.jsonPathArrayDefaultEmpty(jsonString, "$.subjects[*].homework_grades"), new Object[]{});
// jsonPathArrayDefaultEmpty should work fine with existing fields.
+ // CHECKSTYLE:OFF
+ // @formatter:off
jsonString = "{\n" +
" \"name\": \"Pete\",\n" +
" \"age\": 24,\n" +
@@ -129,6 +140,8 @@ public class JsonFunctionsTest {
" }\n" +
" ]\n" +
"}";
+ // @formatter:on
+ // CHECKSTYLE:ON
assertEquals(JsonFunctions.jsonPathArrayDefaultEmpty(jsonString, "$.subjects[*].name"), new String[]{"maths", "english"});
assertEquals(JsonFunctions.jsonPathArrayDefaultEmpty(jsonString, "$.subjects[*].grade"), new String[]{"A", "B"});
assertEquals(JsonFunctions.jsonPathArrayDefaultEmpty(jsonString, "$.subjects[*].homework_grades"),
@@ -143,14 +156,13 @@ public class JsonFunctionsTest {
// Object[] doesn't work with default JsonPath, where "$.commits[*].sha" would return empty,
// and "$.commits[1].sha" led to exception `Filter: [1]['sha'] can only be applied to arrays`.
// Those failure could be reproduced by using the default JacksonJsonProvider for JsonPath.
- Map<String, Object> rawData = ImmutableMap.of("commits",
- ImmutableList.of(ImmutableMap.of("sha", 123, "name", "k"), ImmutableMap.of("sha", 456, "name", "j")));
+ Map<String, Object> rawData =
+ ImmutableMap.of("commits", ImmutableList.of(ImmutableMap.of("sha", 123, "name", "k"), ImmutableMap.of("sha", 456, "name", "j")));
assertEquals(JsonFunctions.jsonPathArray(rawData, "$.commits[*].sha"), new Integer[]{123, 456});
assertEquals(JsonFunctions.jsonPathArray(rawData, "$.commits[1].sha"), new Integer[]{456});
// ArrayAwareJacksonJsonProvider should fix this issue.
- rawData = ImmutableMap.of("commits",
- new Object[]{ImmutableMap.of("sha", 123, "name", "k"), ImmutableMap.of("sha", 456, "name", "j")});
+ rawData = ImmutableMap.of("commits", new Object[]{ImmutableMap.of("sha", 123, "name", "k"), ImmutableMap.of("sha", 456, "name", "j")});
assertEquals(JsonFunctions.jsonPathArray(rawData, "$.commits[*].sha"), new Integer[]{123, 456});
assertEquals(JsonFunctions.jsonPathArray(rawData, "$.commits[1].sha"), new Integer[]{456});
}
@@ -166,8 +178,7 @@ public class JsonFunctionsTest {
// ArrayAwareJacksonJsonProvider can work with Array directly, thus no need to serialize
// Object[] any more.
- Object[] rawDataInAry =
- new Object[]{ImmutableMap.of("sha", 123, "name", "kk"), ImmutableMap.of("sha", 456, "name", "jj")};
+ Object[] rawDataInAry = new Object[]{ImmutableMap.of("sha", 123, "name", "kk"), ImmutableMap.of("sha", 456, "name", "jj")};
assertEquals(JsonFunctions.jsonPathArray(rawDataInAry, "$.[*].sha"), new Integer[]{123, 456});
assertEquals(JsonFunctions.jsonPathArray(rawDataInAry, "$.[1].sha"), new Integer[]{456});
}
@@ -175,21 +186,25 @@ public class JsonFunctionsTest {
@Test
public void testJsonFunctionOnJsonArray()
throws JsonProcessingException {
+ // CHECKSTYLE:OFF
+ // @formatter:off
String jsonArrayString =
"[\n" +
- " {\n" +
- " \"name\": \"maths\",\n" +
- " \"grade\": \"A\",\n" +
- " \"homework_grades\": [80, 85, 90, 95, 100],\n" +
- " \"score\": 90\n" +
- " },\n" +
- " {\n" +
- " \"name\": \"english\",\n" +
- " \"grade\": \"B\",\n" +
- " \"homework_grades\": [60, 65, 70, 85, 90],\n" +
- " \"score\": 50\n" +
- " }\n" +
- "]";
+ " {\n" +
+ " \"name\": \"maths\",\n" +
+ " \"grade\": \"A\",\n" +
+ " \"homework_grades\": [80, 85, 90, 95, 100],\n" +
+ " \"score\": 90\n" +
+ " },\n" +
+ " {\n" +
+ " \"name\": \"english\",\n" +
+ " \"grade\": \"B\",\n" +
+ " \"homework_grades\": [60, 65, 70, 85, 90],\n" +
+ " \"score\": 50\n" +
+ " }\n" +
+ "]";
+ // @formatter:on
+ // CHECKSTYLE:ON
assertEquals(JsonFunctions.jsonPathArray(jsonArrayString, "$.[*].name"), new String[]{"maths", "english"});
assertEquals(JsonFunctions.jsonPathArray(jsonArrayString, "$.[*].grade"), new String[]{"A", "B"});
assertEquals(JsonFunctions.jsonPathArray(jsonArrayString, "$.[*].homework_grades"),
@@ -201,10 +216,8 @@ public class JsonFunctionsTest {
public void testJsonFunctionOnList()
throws JsonProcessingException {
List<Map<String, Object>> rawData = new ArrayList<Map<String, Object>>();
- rawData.add(ImmutableMap.of("name", "maths", "grade", "A", "score", 90,
- "homework_grades", Arrays.asList(80, 85, 90, 95, 100)));
- rawData.add(ImmutableMap.of("name", "english", "grade", "B", "score", 50,
- "homework_grades", Arrays.asList(60, 65, 70, 85, 90)));
+ rawData.add(ImmutableMap.of("name", "maths", "grade", "A", "score", 90, "homework_grades", Arrays.asList(80, 85, 90, 95, 100)));
+ rawData.add(ImmutableMap.of("name", "english", "grade", "B", "score", 50, "homework_grades", Arrays.asList(60, 65, 70, 85, 90)));
assertEquals(JsonFunctions.jsonPathArray(rawData, "$.[*].name"), new String[]{"maths", "english"});
assertEquals(JsonFunctions.jsonPathArray(rawData, "$.[*].grade"), new String[]{"A", "B"});
assertEquals(JsonFunctions.jsonPathArray(rawData, "$.[*].homework_grades"),
@@ -215,11 +228,9 @@ public class JsonFunctionsTest {
@Test
public void testJsonFunctionOnObjectArray()
throws JsonProcessingException {
- Object[] rawData = new Object[] {
- ImmutableMap.of("name", "maths", "grade", "A", "score", 90,
- "homework_grades", Arrays.asList(80, 85, 90, 95, 100)),
- ImmutableMap.of("name", "english", "grade", "B", "score", 50,
- "homework_grades", Arrays.asList(60, 65, 70, 85, 90))
+ Object[] rawData = new Object[]{ImmutableMap.of("name", "maths", "grade", "A", "score", 90, "homework_grades",
+ Arrays.asList(80, 85, 90, 95, 100)), ImmutableMap.of("name", "english", "grade", "B", "score", 50, "homework_grades",
+ Arrays.asList(60, 65, 70, 85, 90))
};
assertEquals(JsonFunctions.jsonPathArray(rawData, "$.[*].name"), new String[]{"maths", "english"});
assertEquals(JsonFunctions.jsonPathArray(rawData, "$.[*].grade"), new String[]{"A", "B"});
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/http/MultiGetRequestTest.java b/pinot-common/src/test/java/org/apache/pinot/common/http/MultiGetRequestTest.java
index 6e45ec6..d43a8b2 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/http/MultiGetRequestTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/http/MultiGetRequestTest.java
@@ -44,29 +44,28 @@ import org.testng.annotations.Test;
public class MultiGetRequestTest {
private static final Logger LOGGER = LoggerFactory.getLogger(MultiGetRequest.class);
+ private static final String SUCCESS_MSG = "success";
+ private static final String ERROR_MSG = "error";
+ private static final String TIMEOUT_MSG = "Timeout";
+ private static final int SUCCESS_CODE = 200;
+ private static final int ERROR_CODE = 500;
+ private static final String URI_PATH = "/foo";
+ private static final int TIMEOUT_MS = 5000;
- List<HttpServer> servers = new ArrayList<>();
- final int portStart = 14000;
- final String SUCCESS_MSG = "success";
- final String ERROR_MSG = "error";
- final String TIMEOUT_MSG = "Timeout";
- final int SUCCESS_CODE = 200;
- final int ERROR_CODE = 500;
- final String URI_PATH = "/foo";
- final int TIMEOUT_MS = 5000;
+ private final List<HttpServer> _servers = new ArrayList<>();
+ private final int _portStart = 14000;
@BeforeTest
public void setUpTest()
throws IOException {
-
- startServer(portStart, createHandler(SUCCESS_CODE, SUCCESS_MSG, 0));
- startServer(portStart + 1, createHandler(ERROR_CODE, ERROR_MSG, 0));
- startServer(portStart + 2, createHandler(SUCCESS_CODE, TIMEOUT_MSG, TIMEOUT_MS));
+ startServer(_portStart, createHandler(SUCCESS_CODE, SUCCESS_MSG, 0));
+ startServer(_portStart + 1, createHandler(ERROR_CODE, ERROR_MSG, 0));
+ startServer(_portStart + 2, createHandler(SUCCESS_CODE, TIMEOUT_MSG, TIMEOUT_MS));
}
@AfterTest
public void tearDownTest() {
- for (HttpServer server : servers) {
+ for (HttpServer server : _servers) {
server.stop(0);
}
}
@@ -101,19 +100,17 @@ public class MultiGetRequestTest {
server.start();
}
}).start();
- servers.add(server);
+ _servers.add(server);
return server;
}
@Test
public void testMultiGet() {
- MultiGetRequest mget =
- new MultiGetRequest(Executors.newCachedThreadPool(), new MultiThreadedHttpConnectionManager());
- List<String> urls = Arrays.asList("http://localhost:" + String.valueOf(portStart) + URI_PATH,
- "http://localhost:" + String.valueOf(portStart + 1) + URI_PATH,
- "http://localhost:" + String.valueOf(portStart + 2) + URI_PATH,
+ MultiGetRequest mget = new MultiGetRequest(Executors.newCachedThreadPool(), new MultiThreadedHttpConnectionManager());
+ List<String> urls = Arrays.asList("http://localhost:" + String.valueOf(_portStart) + URI_PATH,
+ "http://localhost:" + String.valueOf(_portStart + 1) + URI_PATH, "http://localhost:" + String.valueOf(_portStart + 2) + URI_PATH,
// 2nd request to the same server
- "http://localhost:" + String.valueOf(portStart) + URI_PATH);
+ "http://localhost:" + String.valueOf(_portStart) + URI_PATH);
// timeout value needs to be less than 5000ms set above for
// third server
final int requestTimeoutMs = 1000;
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/lineage/SegmentLineageTest.java b/pinot-common/src/test/java/org/apache/pinot/common/lineage/SegmentLineageTest.java
index f890d16..37a3d99 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/lineage/SegmentLineageTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/lineage/SegmentLineageTest.java
@@ -33,8 +33,7 @@ public class SegmentLineageTest {
SegmentLineage segmentLineage = new SegmentLineage("test_OFFLINE");
String id = SegmentLineageUtils.generateLineageEntryId();
segmentLineage.addLineageEntry(id,
- new LineageEntry(Arrays.asList("s1", "s2", "s3"), Arrays.asList("s4", "s5"), LineageEntryState.COMPLETED,
- 11111L));
+ new LineageEntry(Arrays.asList("s1", "s2", "s3"), Arrays.asList("s4", "s5"), LineageEntryState.COMPLETED, 11111L));
LineageEntry lineageEntry = segmentLineage.getLineageEntry(id);
Assert.assertEquals(lineageEntry.getSegmentsFrom(), Arrays.asList("s1", "s2", "s3"));
Assert.assertEquals(lineageEntry.getSegmentsTo(), Arrays.asList("s4", "s5"));
@@ -43,8 +42,7 @@ public class SegmentLineageTest {
String id2 = SegmentLineageUtils.generateLineageEntryId();
segmentLineage.addLineageEntry(id2,
- new LineageEntry(Arrays.asList("s6", "s6", "s8"), Arrays.asList("s9", "s10"), LineageEntryState.COMPLETED,
- 22222L));
+ new LineageEntry(Arrays.asList("s6", "s6", "s8"), Arrays.asList("s9", "s10"), LineageEntryState.COMPLETED, 22222L));
LineageEntry lineageEntry2 = segmentLineage.getLineageEntry(id2);
Assert.assertEquals(lineageEntry2.getSegmentsFrom(), Arrays.asList("s6", "s6", "s8"));
Assert.assertEquals(lineageEntry2.getSegmentsTo(), Arrays.asList("s9", "s10"));
@@ -52,8 +50,8 @@ public class SegmentLineageTest {
Assert.assertEquals(lineageEntry2.getTimestamp(), 22222L);
String id3 = SegmentLineageUtils.generateLineageEntryId();
- segmentLineage.addLineageEntry(id3,
- new LineageEntry(Arrays.asList("s5", "s9"), Arrays.asList("s11"), LineageEntryState.IN_PROGRESS, 33333L));
+ segmentLineage
+ .addLineageEntry(id3, new LineageEntry(Arrays.asList("s5", "s9"), Arrays.asList("s11"), LineageEntryState.IN_PROGRESS, 33333L));
LineageEntry lineageEntry3 = segmentLineage.getLineageEntry(id3);
Assert.assertEquals(lineageEntry3.getSegmentsFrom(), Arrays.asList("s5", "s9"));
Assert.assertEquals(lineageEntry3.getSegmentsTo(), Arrays.asList("s11"));
@@ -61,8 +59,7 @@ public class SegmentLineageTest {
Assert.assertEquals(lineageEntry3.getTimestamp(), 33333L);
String id4 = SegmentLineageUtils.generateLineageEntryId();
- segmentLineage.addLineageEntry(id4,
- new LineageEntry(new ArrayList<>(), Arrays.asList("s12"), LineageEntryState.IN_PROGRESS, 44444L));
+ segmentLineage.addLineageEntry(id4, new LineageEntry(new ArrayList<>(), Arrays.asList("s12"), LineageEntryState.IN_PROGRESS, 44444L));
LineageEntry lineageEntry4 = segmentLineage.getLineageEntry(id4);
Assert.assertEquals(lineageEntry4.getSegmentsFrom(), new ArrayList<>());
Assert.assertEquals(lineageEntry4.getSegmentsTo(), Arrays.asList("s12"));
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/metadata/MetadataEqualsHashCodeTest.java b/pinot-common/src/test/java/org/apache/pinot/common/metadata/MetadataEqualsHashCodeTest.java
index c7dfcca..2ed98ff 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/metadata/MetadataEqualsHashCodeTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/metadata/MetadataEqualsHashCodeTest.java
@@ -37,17 +37,15 @@ public class MetadataEqualsHashCodeTest {
@Test
public void testEqualsAndHashCode() {
- EqualsVerifier.forClass(InstanceZKMetadata.class).suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS)
+ EqualsVerifier.forClass(InstanceZKMetadata.class).suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS).usingGetClass().verify();
+ EqualsVerifier.forClass(Schema.class).suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS).usingGetClass().verify();
+ EqualsVerifier.forClass(DimensionFieldSpec.class).suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS, Warning.TRANSIENT_FIELDS)
+ .usingGetClass().verify();
+ EqualsVerifier.forClass(MetricFieldSpec.class).suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS, Warning.TRANSIENT_FIELDS)
+ .usingGetClass().verify();
+ EqualsVerifier.forClass(TimeFieldSpec.class).suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS, Warning.TRANSIENT_FIELDS)
+ .usingGetClass().verify();
+ EqualsVerifier.forClass(DateTimeFieldSpec.class).suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS, Warning.TRANSIENT_FIELDS)
.usingGetClass().verify();
- EqualsVerifier.forClass(Schema.class).suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS).usingGetClass()
- .verify();
- EqualsVerifier.forClass(DimensionFieldSpec.class)
- .suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS, Warning.TRANSIENT_FIELDS).usingGetClass().verify();
- EqualsVerifier.forClass(MetricFieldSpec.class)
- .suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS, Warning.TRANSIENT_FIELDS).usingGetClass().verify();
- EqualsVerifier.forClass(TimeFieldSpec.class)
- .suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS, Warning.TRANSIENT_FIELDS).usingGetClass().verify();
- EqualsVerifier.forClass(DateTimeFieldSpec.class)
- .suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS, Warning.TRANSIENT_FIELDS).usingGetClass().verify();
}
}
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/metadata/MetadataUtils.java b/pinot-common/src/test/java/org/apache/pinot/common/metadata/MetadataUtils.java
index 35f1499..759899d 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/metadata/MetadataUtils.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/metadata/MetadataUtils.java
@@ -25,6 +25,9 @@ import org.apache.helix.ZNRecord;
public class MetadataUtils {
+ private MetadataUtils() {
+ }
+
public static boolean comparisonZNRecords(ZNRecord record1, ZNRecord record2) {
// Compare Id;
if (!record1.getId().equals(record2.getId())) {
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/metadata/RealtimeToOfflineSegmentsTaskMetadataTest.java b/pinot-common/src/test/java/org/apache/pinot/common/metadata/RealtimeToOfflineSegmentsTaskMetadataTest.java
index e5a4db2..bf8ce98 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/metadata/RealtimeToOfflineSegmentsTaskMetadataTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/metadata/RealtimeToOfflineSegmentsTaskMetadataTest.java
@@ -22,7 +22,7 @@ import org.apache.helix.ZNRecord;
import org.apache.pinot.common.minion.RealtimeToOfflineSegmentsTaskMetadata;
import org.testng.annotations.Test;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
/**
@@ -32,8 +32,7 @@ public class RealtimeToOfflineSegmentsTaskMetadataTest {
@Test
public void testToFromZNRecord() {
- RealtimeToOfflineSegmentsTaskMetadata metadata =
- new RealtimeToOfflineSegmentsTaskMetadata("testTable_REALTIME", 1000);
+ RealtimeToOfflineSegmentsTaskMetadata metadata = new RealtimeToOfflineSegmentsTaskMetadata("testTable_REALTIME", 1000);
ZNRecord znRecord = metadata.toZNRecord();
assertEquals(znRecord.getId(), "testTable_REALTIME");
assertEquals(znRecord.getSimpleField("watermarkMs"), "1000");
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/metadata/SegmentZKMetadataTest.java b/pinot-common/src/test/java/org/apache/pinot/common/metadata/SegmentZKMetadataTest.java
index e40dfcb..2322ccd 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/metadata/SegmentZKMetadataTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/metadata/SegmentZKMetadataTest.java
@@ -53,15 +53,17 @@ public class SegmentZKMetadataTest {
Assert.assertTrue(MetadataUtils.comparisonZNRecords(doneZnRecord, doneSegmentMetadata.toZNRecord()));
assertEquals(inProgressSegmentMetadata, new SegmentZKMetadata(inProgressZnRecord));
+ assertEquals(inProgressSegmentMetadata.hashCode(), new SegmentZKMetadata(inProgressZnRecord).hashCode());
assertEquals(doneSegmentMetadata, new SegmentZKMetadata(doneZnRecord));
+ assertEquals(doneSegmentMetadata.hashCode(), new SegmentZKMetadata(doneZnRecord).hashCode());
- Assert.assertTrue(
- MetadataUtils.comparisonZNRecords(inProgressZnRecord, new SegmentZKMetadata(inProgressZnRecord).toZNRecord()));
- Assert
- .assertTrue(MetadataUtils.comparisonZNRecords(doneZnRecord, new SegmentZKMetadata(doneZnRecord).toZNRecord()));
+ Assert.assertTrue(MetadataUtils.comparisonZNRecords(inProgressZnRecord, new SegmentZKMetadata(inProgressZnRecord).toZNRecord()));
+ Assert.assertTrue(MetadataUtils.comparisonZNRecords(doneZnRecord, new SegmentZKMetadata(doneZnRecord).toZNRecord()));
assertEquals(inProgressSegmentMetadata, new SegmentZKMetadata(inProgressSegmentMetadata.toZNRecord()));
+ assertEquals(inProgressSegmentMetadata.hashCode(), new SegmentZKMetadata(inProgressSegmentMetadata.toZNRecord()).hashCode());
assertEquals(doneSegmentMetadata, new SegmentZKMetadata(doneSegmentMetadata.toZNRecord()));
+ assertEquals(doneSegmentMetadata.hashCode(), new SegmentZKMetadata(doneSegmentMetadata.toZNRecord()).hashCode());
}
@Test
@@ -70,31 +72,32 @@ public class SegmentZKMetadataTest {
SegmentZKMetadata offlineSegmentMetadata = getTestOfflineSegmentZKMetadata();
Assert.assertTrue(MetadataUtils.comparisonZNRecords(offlineZNRecord, offlineSegmentMetadata.toZNRecord()));
assertEquals(offlineSegmentMetadata, new SegmentZKMetadata(offlineZNRecord));
- Assert.assertTrue(
- MetadataUtils.comparisonZNRecords(offlineZNRecord, new SegmentZKMetadata(offlineZNRecord).toZNRecord()));
+ assertEquals(offlineSegmentMetadata.hashCode(), new SegmentZKMetadata(offlineZNRecord).hashCode());
+ Assert.assertTrue(MetadataUtils.comparisonZNRecords(offlineZNRecord, new SegmentZKMetadata(offlineZNRecord).toZNRecord()));
assertEquals(offlineSegmentMetadata, new SegmentZKMetadata(offlineSegmentMetadata.toZNRecord()));
+ assertEquals(offlineSegmentMetadata.hashCode(), new SegmentZKMetadata(offlineSegmentMetadata.toZNRecord()).hashCode());
}
@Test
public void segmentPartitionMetadataTest()
throws IOException {
// Test for partition metadata serialization/de-serialization.
- String legacyMetadataString = "{\"columnPartitionMap\":{"
- + "\"column1\":{\"functionName\":\"func1\",\"numPartitions\":8,\"partitionRanges\":\"[5 5],[7 7]\"},"
- + "\"column2\":{\"functionName\":\"func2\",\"numPartitions\":12,\"partitionRanges\":\"[9 11]\"}}}";
- String metadataString = "{\"columnPartitionMap\":{"
- + "\"column1\":{\"functionName\":\"func1\",\"numPartitions\":8,\"partitions\":[5,7]},"
- + "\"column2\":{\"functionName\":\"func2\",\"numPartitions\":12,\"partitions\":[9,10,11]}}}";
+ String legacyMetadataString =
+ "{\"columnPartitionMap\":{" + "\"column1\":{\"functionName\":\"func1\",\"numPartitions\":8,\"partitionRanges\":\"[5 5],[7 7]\"},"
+ + "\"column2\":{\"functionName\":\"func2\",\"numPartitions\":12,\"partitionRanges\":\"[9 11]\"}}}";
+ String metadataString =
+ "{\"columnPartitionMap\":{" + "\"column1\":{\"functionName\":\"func1\",\"numPartitions\":8,\"partitions\":[5,7]},"
+ + "\"column2\":{\"functionName\":\"func2\",\"numPartitions\":12,\"partitions\":[9,10,11]}}}";
Map<String, ColumnPartitionMetadata> columnPartitionMetadataMap = new HashMap<>();
- columnPartitionMetadataMap
- .put("column1", new ColumnPartitionMetadata("func1", 8, new HashSet<>(Arrays.asList(5, 7))));
- columnPartitionMetadataMap
- .put("column2", new ColumnPartitionMetadata("func2", 12, new HashSet<>(Arrays.asList(9, 10, 11))));
+ columnPartitionMetadataMap.put("column1", new ColumnPartitionMetadata("func1", 8, new HashSet<>(Arrays.asList(5, 7))));
+ columnPartitionMetadataMap.put("column2", new ColumnPartitionMetadata("func2", 12, new HashSet<>(Arrays.asList(9, 10, 11))));
SegmentPartitionMetadata expectedPartitionMetadata = new SegmentPartitionMetadata(columnPartitionMetadataMap);
assertEquals(SegmentPartitionMetadata.fromJsonString(legacyMetadataString), expectedPartitionMetadata);
assertEquals(SegmentPartitionMetadata.fromJsonString(metadataString), expectedPartitionMetadata);
+ assertEquals(SegmentPartitionMetadata.fromJsonString(legacyMetadataString).hashCode(), expectedPartitionMetadata.hashCode());
+ assertEquals(SegmentPartitionMetadata.fromJsonString(metadataString).hashCode(), expectedPartitionMetadata.hashCode());
// Test partition metadata in OfflineSegmentZkMetadata
ZNRecord znRecord = getTestOfflineSegmentZNRecord();
@@ -103,6 +106,8 @@ public class SegmentZKMetadataTest {
SegmentPartitionMetadata actualPartitionMetadata = actualSegmentZKMetadata.getPartitionMetadata();
assertEquals(actualPartitionMetadata, expectedPartitionMetadata);
assertEquals(actualSegmentZKMetadata, new SegmentZKMetadata(actualSegmentZKMetadata.toZNRecord()));
+ assertEquals(actualPartitionMetadata.hashCode(), expectedPartitionMetadata.hashCode());
+ assertEquals(actualSegmentZKMetadata.hashCode(), new SegmentZKMetadata(actualSegmentZKMetadata.toZNRecord()).hashCode());
// Test partition metadata in RealtimeSegmentZkMetadata
znRecord = getTestDoneRealtimeSegmentZNRecord();
@@ -111,6 +116,8 @@ public class SegmentZKMetadataTest {
actualPartitionMetadata = actualSegmentZKMetadata.getPartitionMetadata();
assertEquals(actualPartitionMetadata, expectedPartitionMetadata);
assertEquals(actualSegmentZKMetadata, new SegmentZKMetadata(actualSegmentZKMetadata.toZNRecord()));
+ assertEquals(actualPartitionMetadata.hashCode(), expectedPartitionMetadata.hashCode());
+ assertEquals(actualSegmentZKMetadata.hashCode(), new SegmentZKMetadata(actualSegmentZKMetadata.toZNRecord()).hashCode());
}
private ZNRecord getTestDoneRealtimeSegmentZNRecord() {
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/metadata/segment/ColumnPartitionMetadataTest.java b/pinot-common/src/test/java/org/apache/pinot/common/metadata/segment/ColumnPartitionMetadataTest.java
index 887770d..34fc41a 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/metadata/segment/ColumnPartitionMetadataTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/metadata/segment/ColumnPartitionMetadataTest.java
@@ -41,8 +41,7 @@ public class ColumnPartitionMetadataTest {
public void testSerDe()
throws Exception {
ColumnPartitionMetadata expected = new ColumnPartitionMetadata(FUNCTION_NAME, NUM_PARTITIONS, PARTITIONS);
- ColumnPartitionMetadata actual =
- JsonUtils.stringToObject(JsonUtils.objectToString(expected), ColumnPartitionMetadata.class);
+ ColumnPartitionMetadata actual = JsonUtils.stringToObject(JsonUtils.objectToString(expected), ColumnPartitionMetadata.class);
assertEquals(actual, expected);
}
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/metrics/PinotMetricUtilsTest.java b/pinot-common/src/test/java/org/apache/pinot/common/metrics/PinotMetricUtilsTest.java
index 2f18d79..fcd3cdd 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/metrics/PinotMetricUtilsTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/metrics/PinotMetricUtilsTest.java
@@ -45,27 +45,27 @@ public class PinotMetricUtilsTest {
Assert.assertEquals(pinotMetricsRegistry.getClass().getSimpleName(), "YammerMetricsRegistry");
}
- public static boolean listenerOneOkay;
- public static boolean listenerTwoOkay;
+ public static boolean _listenerOneOkay;
+ public static boolean _listenerTwoOkay;
public static class ListenerOne implements MetricsRegistryRegistrationListener {
@Override
public void onMetricsRegistryRegistered(PinotMetricsRegistry metricsRegistry) {
- listenerOneOkay = true;
+ _listenerOneOkay = true;
}
}
public static class ListenerTwo implements MetricsRegistryRegistrationListener {
@Override
public void onMetricsRegistryRegistered(PinotMetricsRegistry metricsRegistry) {
- listenerTwoOkay = true;
+ _listenerTwoOkay = true;
}
}
@Test
public void testPinotMetricsRegistration() {
- listenerOneOkay = false;
- listenerTwoOkay = false;
+ _listenerOneOkay = false;
+ _listenerTwoOkay = false;
Map<String, Object> properties = new HashMap<>();
properties.put("pinot.broker.metrics.metricsRegistryRegistrationListeners",
@@ -75,20 +75,21 @@ public class PinotMetricUtilsTest {
PinotConfiguration configuration = new PinotConfiguration(properties);
PinotMetricUtils.init(configuration.subset("pinot.broker.metrics"));
PinotMetricsRegistry registry = PinotMetricUtils.getPinotMetricsRegistry();
- PinotMetricUtils.makePinotTimer(registry, PinotMetricUtils.makePinotMetricName(PinotMetricUtilsTest.class, "dummy"),
- TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS);
+ PinotMetricUtils
+ .makePinotTimer(registry, PinotMetricUtils.makePinotMetricName(PinotMetricUtilsTest.class, "dummy"), TimeUnit.MILLISECONDS,
+ TimeUnit.MILLISECONDS);
// Check that the two listeners fired
- Assert.assertTrue(listenerOneOkay);
- Assert.assertTrue(listenerTwoOkay);
+ Assert.assertTrue(_listenerOneOkay);
+ Assert.assertTrue(_listenerTwoOkay);
}
@Test
public void testMetricValue() {
PinotMetricsRegistry registry = PinotMetricUtils.getPinotMetricsRegistry();
PinotMeter pinotMeter = PinotMetricUtils
- .makePinotMeter(registry, PinotMetricUtils.makePinotMetricName(PinotMetricUtilsTest.class, "testMeter"),
- "dummyEventType", TimeUnit.MILLISECONDS);
+ .makePinotMeter(registry, PinotMetricUtils.makePinotMetricName(PinotMetricUtilsTest.class, "testMeter"), "dummyEventType",
+ TimeUnit.MILLISECONDS);
pinotMeter.mark();
Assert.assertEquals(pinotMeter.count(), 1L);
@@ -98,10 +99,8 @@ public class PinotMetricUtilsTest {
@Test
public void testPinotMetricName() {
- PinotMetricName testMetricName1 =
- PinotMetricUtils.makePinotMetricName(PinotMetricUtilsTest.class, "testMetricName");
- PinotMetricName testMetricName2 =
- PinotMetricUtils.makePinotMetricName(PinotMetricUtilsTest.class, "testMetricName");
+ PinotMetricName testMetricName1 = PinotMetricUtils.makePinotMetricName(PinotMetricUtilsTest.class, "testMetricName");
+ PinotMetricName testMetricName2 = PinotMetricUtils.makePinotMetricName(PinotMetricUtilsTest.class, "testMetricName");
Assert.assertNotNull(testMetricName1);
Assert.assertNotNull(testMetricName2);
Assert.assertEquals(testMetricName1, testMetricName2);
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/minion/MinionClientTest.java b/pinot-common/src/test/java/org/apache/pinot/common/minion/MinionClientTest.java
index eddb888..2c62722 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/minion/MinionClientTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/minion/MinionClientTest.java
@@ -60,8 +60,7 @@ public class MinionClientTest {
public void testTaskSchedule()
throws IOException {
HttpServer httpServer = startServer(14202, "/tasks/schedule",
- createHandler(200, "{\"SegmentGenerationAndPushTask\":\"Task_SegmentGenerationAndPushTask_1607470525615\"}",
- 0));
+ createHandler(200, "{\"SegmentGenerationAndPushTask\":\"Task_SegmentGenerationAndPushTask_1607470525615\"}", 0));
MinionClient minionClient = new MinionClient("localhost", "14202");
Assert.assertEquals(minionClient.scheduleMinionTasks(null, null).get("SegmentGenerationAndPushTask"),
"Task_SegmentGenerationAndPushTask_1607470525615");
@@ -74,16 +73,16 @@ public class MinionClientTest {
HttpServer httpServer = startServer(14203, "/tasks/SegmentGenerationAndPushTask/taskstates",
createHandler(200, "{\"Task_SegmentGenerationAndPushTask_1607470525615\":\"IN_PROGRESS\"}", 0));
MinionClient minionClient = new MinionClient("http", "localhost", "14203");
- Assert.assertEquals(minionClient.getTasksStates("SegmentGenerationAndPushTask")
- .get("Task_SegmentGenerationAndPushTask_1607470525615"), "IN_PROGRESS");
+ Assert.assertEquals(minionClient.getTasksStates("SegmentGenerationAndPushTask").get("Task_SegmentGenerationAndPushTask_1607470525615"),
+ "IN_PROGRESS");
httpServer.stop(0);
}
@Test
public void testTaskState()
throws IOException {
- HttpServer httpServer = startServer(14204, "/tasks/task/Task_SegmentGenerationAndPushTask_1607470525615/state",
- createHandler(200, "\"COMPLETED\"", 0));
+ HttpServer httpServer =
+ startServer(14204, "/tasks/task/Task_SegmentGenerationAndPushTask_1607470525615/state", createHandler(200, "\"COMPLETED\"", 0));
MinionClient minionClient = new MinionClient("http://localhost:14204");
Assert.assertEquals(minionClient.getTaskState("Task_SegmentGenerationAndPushTask_1607470525615"), "\"COMPLETED\"");
httpServer.stop(0);
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/protocols/SegmentCompletionProtocolTest.java b/pinot-common/src/test/java/org/apache/pinot/common/protocols/SegmentCompletionProtocolTest.java
index 2f5edb8..d72c105 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/protocols/SegmentCompletionProtocolTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/protocols/SegmentCompletionProtocolTest.java
@@ -35,8 +35,7 @@ public class SegmentCompletionProtocolTest {
// test default params
SegmentCompletionProtocol.Request.Params params = new SegmentCompletionProtocol.Request.Params();
- SegmentCompletionProtocol.ExtendBuildTimeRequest extendBuildTimeRequest =
- new SegmentCompletionProtocol.ExtendBuildTimeRequest(params);
+ SegmentCompletionProtocol.ExtendBuildTimeRequest extendBuildTimeRequest = new SegmentCompletionProtocol.ExtendBuildTimeRequest(params);
URI uri = new URI(extendBuildTimeRequest.getUrl("localhost:8080", "http"));
Assert.assertEquals(uri.getScheme(), "http");
Assert.assertEquals(uri.getHost(), "localhost");
@@ -58,15 +57,12 @@ public class SegmentCompletionProtocolTest {
Assert.assertNull(paramsMap.get(SegmentCompletionProtocol.PARAM_STREAM_PARTITION_MSG_OFFSET));
// test that params set only if valid values
- params = new SegmentCompletionProtocol.Request.Params().withSegmentName("foo__0__0__12345Z")
- .withInstanceId("Server_localhost_8099").withReason(null).withBuildTimeMillis(-100).withWaitTimeMillis(0)
- .withExtraTimeSec(-1).withMemoryUsedBytes(0).withSegmentSizeBytes(-12345).withNumRows(0)
- .withSegmentLocation(null).withStreamPartitionMsgOffset(null);
- SegmentCompletionProtocol.SegmentConsumedRequest segmentConsumedRequest =
- new SegmentCompletionProtocol.SegmentConsumedRequest(params);
+ params = new SegmentCompletionProtocol.Request.Params().withSegmentName("foo__0__0__12345Z").withInstanceId("Server_localhost_8099")
+ .withReason(null).withBuildTimeMillis(-100).withWaitTimeMillis(0).withExtraTimeSec(-1).withMemoryUsedBytes(0)
+ .withSegmentSizeBytes(-12345).withNumRows(0).withSegmentLocation(null).withStreamPartitionMsgOffset(null);
+ SegmentCompletionProtocol.SegmentConsumedRequest segmentConsumedRequest = new SegmentCompletionProtocol.SegmentConsumedRequest(params);
uri = new URI(segmentConsumedRequest.getUrl("localhost:8080", "http"));
- paramsMap =
- Arrays.stream(uri.getQuery().split("&")).collect(Collectors.toMap(e -> e.split("=")[0], e -> e.split("=")[1]));
+ paramsMap = Arrays.stream(uri.getQuery().split("&")).collect(Collectors.toMap(e -> e.split("=")[0], e -> e.split("=")[1]));
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_SEGMENT_NAME), "foo__0__0__12345Z");
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_OFFSET), "-1");
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_INSTANCE_ID), "Server_localhost_8099");
@@ -80,15 +76,12 @@ public class SegmentCompletionProtocolTest {
Assert.assertNull(paramsMap.get(SegmentCompletionProtocol.PARAM_SEGMENT_LOCATION));
Assert.assertNull(paramsMap.get(SegmentCompletionProtocol.PARAM_STREAM_PARTITION_MSG_OFFSET));
- params = new SegmentCompletionProtocol.Request.Params().withSegmentName("foo__0__0__12345Z")
- .withInstanceId("Server_localhost_8099").withReason("ROW_LIMIT").withBuildTimeMillis(1000)
- .withWaitTimeMillis(2000).withExtraTimeSec(3000).withMemoryUsedBytes(4000).withSegmentSizeBytes(5000)
- .withNumRows(6000).withSegmentLocation("/tmp/segment").withStreamPartitionMsgOffset("7000");
- SegmentCompletionProtocol.SegmentCommitRequest segmentCommitRequest =
- new SegmentCompletionProtocol.SegmentCommitRequest(params);
+ params = new SegmentCompletionProtocol.Request.Params().withSegmentName("foo__0__0__12345Z").withInstanceId("Server_localhost_8099")
+ .withReason("ROW_LIMIT").withBuildTimeMillis(1000).withWaitTimeMillis(2000).withExtraTimeSec(3000).withMemoryUsedBytes(4000)
+ .withSegmentSizeBytes(5000).withNumRows(6000).withSegmentLocation("/tmp/segment").withStreamPartitionMsgOffset("7000");
+ SegmentCompletionProtocol.SegmentCommitRequest segmentCommitRequest = new SegmentCompletionProtocol.SegmentCommitRequest(params);
uri = new URI(segmentCommitRequest.getUrl("localhost:8080", "http"));
- paramsMap =
- Arrays.stream(uri.getQuery().split("&")).collect(Collectors.toMap(e -> e.split("=")[0], e -> e.split("=")[1]));
+ paramsMap = Arrays.stream(uri.getQuery().split("&")).collect(Collectors.toMap(e -> e.split("=")[0], e -> e.split("=")[1]));
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_SEGMENT_NAME), "foo__0__0__12345Z");
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_OFFSET), "-1");
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_INSTANCE_ID), "Server_localhost_8099");
@@ -103,32 +96,25 @@ public class SegmentCompletionProtocolTest {
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_STREAM_PARTITION_MSG_OFFSET), "7000");
// test param encoding
- params = new SegmentCompletionProtocol.Request.Params().withSegmentName("foo%%__0__0__12345Z")
- .withInstanceId("Server_localhost_8099").withReason("{\"type\":\"ROW_LIMIT\", \"value\":1000}")
- .withBuildTimeMillis(1000).withWaitTimeMillis(2000).withExtraTimeSec(3000).withMemoryUsedBytes(4000)
- .withSegmentSizeBytes(5000).withNumRows(6000).withSegmentLocation("s3://my.bucket/segment")
- .withStreamPartitionMsgOffset(
- "{\"shardId-000000000001\":\"49615238429973311938200772279310862572716999467690098706\"}");
+ params = new SegmentCompletionProtocol.Request.Params().withSegmentName("foo%%__0__0__12345Z").withInstanceId("Server_localhost_8099")
+ .withReason("{\"type\":\"ROW_LIMIT\", \"value\":1000}").withBuildTimeMillis(1000).withWaitTimeMillis(2000).withExtraTimeSec(3000)
+ .withMemoryUsedBytes(4000).withSegmentSizeBytes(5000).withNumRows(6000).withSegmentLocation("s3://my.bucket/segment")
+ .withStreamPartitionMsgOffset("{\"shardId-000000000001\":\"49615238429973311938200772279310862572716999467690098706\"}");
SegmentCompletionProtocol.SegmentCommitStartRequest segmentCommitStartRequest =
new SegmentCompletionProtocol.SegmentCommitStartRequest(params);
String url = segmentCommitStartRequest.getUrl("localhost:8080", "http");
- paramsMap = Arrays.stream(url.split("\\?")[1].split("&"))
- .collect(Collectors.toMap(e -> e.split("=")[0], e -> e.split("=")[1]));
- Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_SEGMENT_NAME),
- URIUtils.encode("foo%%__0__0__12345Z"));
+ paramsMap = Arrays.stream(url.split("\\?")[1].split("&")).collect(Collectors.toMap(e -> e.split("=")[0], e -> e.split("=")[1]));
+ Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_SEGMENT_NAME), URIUtils.encode("foo%%__0__0__12345Z"));
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_OFFSET), "-1");
- Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_INSTANCE_ID),
- URIUtils.encode("Server_localhost_8099"));
- Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_REASON),
- URIUtils.encode("{\"type\":\"ROW_LIMIT\", \"value\":1000}"));
+ Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_INSTANCE_ID), URIUtils.encode("Server_localhost_8099"));
+ Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_REASON), URIUtils.encode("{\"type\":\"ROW_LIMIT\", \"value\":1000}"));
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_BUILD_TIME_MILLIS), "1000");
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_WAIT_TIME_MILLIS), "2000");
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_EXTRA_TIME_SEC), "3000");
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_MEMORY_USED_BYTES), "4000");
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_SEGMENT_SIZE_BYTES), "5000");
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_ROW_COUNT), "6000");
- Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_SEGMENT_LOCATION),
- URIUtils.encode("s3://my.bucket/segment"));
+ Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_SEGMENT_LOCATION), URIUtils.encode("s3://my.bucket/segment"));
Assert.assertEquals(paramsMap.get(SegmentCompletionProtocol.PARAM_STREAM_PARTITION_MSG_OFFSET),
URIUtils.encode("{\"shardId-000000000001\":\"49615238429973311938200772279310862572716999467690098706\"}"));
}
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/request/transform/TransformExpressionTreeTest.java b/pinot-common/src/test/java/org/apache/pinot/common/request/transform/TransformExpressionTreeTest.java
index f1d7511..00514e9 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/request/transform/TransformExpressionTreeTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/request/transform/TransformExpressionTreeTest.java
@@ -118,7 +118,7 @@ public class TransformExpressionTreeTest {
}
private static boolean equalsWithStandardExpressionTree(TransformExpressionTree expressionTree) {
- return expressionTree.hashCode() == STANDARD_EXPRESSION_TREE.hashCode() && expressionTree
- .equals(STANDARD_EXPRESSION_TREE) && expressionTree.toString().equals(STANDARD_EXPRESSION);
+ return expressionTree.hashCode() == STANDARD_EXPRESSION_TREE.hashCode() && expressionTree.equals(STANDARD_EXPRESSION_TREE)
+ && expressionTree.toString().equals(STANDARD_EXPRESSION);
}
}
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/segment/generation/SegmentGenerationUtilsTest.java b/pinot-common/src/test/java/org/apache/pinot/common/segment/generation/SegmentGenerationUtilsTest.java
index 841ad91..ce9b5ff 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/segment/generation/SegmentGenerationUtilsTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/segment/generation/SegmentGenerationUtilsTest.java
@@ -31,15 +31,12 @@ public class SegmentGenerationUtilsTest {
@Test
public void testExtractFileNameFromURI() {
- Assert.assertEquals(SegmentGenerationUtils.getFileName(URI.create("file:/var/data/myTable/2020/04/06/input.data")),
- "input.data");
- Assert.assertEquals(SegmentGenerationUtils.getFileName(URI.create("/var/data/myTable/2020/04/06/input.data")),
- "input.data");
- Assert.assertEquals(SegmentGenerationUtils
- .getFileName(URI.create("dbfs:/mnt/mydb/mytable/pt_year=2020/pt_month=4/pt_date=2020-04-01/input.data")),
- "input.data");
- Assert.assertEquals(SegmentGenerationUtils.getFileName(URI.create("hdfs://var/data/myTable/2020/04/06/input.data")),
+ Assert.assertEquals(SegmentGenerationUtils.getFileName(URI.create("file:/var/data/myTable/2020/04/06/input.data")), "input.data");
+ Assert.assertEquals(SegmentGenerationUtils.getFileName(URI.create("/var/data/myTable/2020/04/06/input.data")), "input.data");
+ Assert.assertEquals(
+ SegmentGenerationUtils.getFileName(URI.create("dbfs:/mnt/mydb/mytable/pt_year=2020/pt_month=4/pt_date=2020-04-01/input.data")),
"input.data");
+ Assert.assertEquals(SegmentGenerationUtils.getFileName(URI.create("hdfs://var/data/myTable/2020/04/06/input.data")), "input.data");
}
// Confirm output path generation works with URIs that have authority/userInfo.
@@ -50,8 +47,8 @@ public class SegmentGenerationUtilsTest {
URI inputFileURI = new URI("hdfs://namenode1:9999/path/to/subdir/file");
URI outputDirURI = new URI("hdfs://namenode2/output/dir/");
URI segmentTarFileName = new URI("file.tar.gz");
- URI outputSegmentTarURI = SegmentGenerationUtils.getRelativeOutputPath(inputDirURI, inputFileURI, outputDirURI)
- .resolve(segmentTarFileName);
+ URI outputSegmentTarURI =
+ SegmentGenerationUtils.getRelativeOutputPath(inputDirURI, inputFileURI, outputDirURI).resolve(segmentTarFileName);
Assert.assertEquals(outputSegmentTarURI.toString(), "hdfs://namenode2/output/dir/subdir/file.tar.gz");
}
@@ -70,10 +67,9 @@ public class SegmentGenerationUtilsTest {
Assert.assertTrue(e instanceof URISyntaxException);
}
URI outputSegmentTarURI = SegmentGenerationUtils.getRelativeOutputPath(inputDirURI, inputFileURI, outputDirURI)
- .resolve(new URI(
- URLEncoder.encode("table_OFFLINE_2021-02-01_09:39:00.000_2021-02-01_11:59:00.000_2.tar.gz", "UTF-8")));
+ .resolve(new URI(URLEncoder.encode("table_OFFLINE_2021-02-01_09:39:00.000_2021-02-01_11:59:00.000_2.tar.gz", "UTF-8")));
Assert.assertEquals(outputSegmentTarURI.toString(),
- "hdfs://namenode2/output/dir/subdir/table_OFFLINE_2021-02-01_09%3A39%3A00.000_2021-02-01_11%3A59%3A00.000_2.tar.gz");
+ "hdfs://namenode2/output/dir/subdir/table_OFFLINE_2021-02-01_09%3A39%3A00.000_2021-02-01_11%3A59%3A00.000_2" + ".tar.gz");
}
// Don't lose authority portion of inputDirURI when creating output files
@@ -83,13 +79,10 @@ public class SegmentGenerationUtilsTest {
public void testGetFileURI()
throws Exception {
// Raw path without scheme
- Assert.assertEquals(SegmentGenerationUtils.getFileURI("/path/to/file", new URI("file:/path/to")).toString(),
- "file:/path/to/file");
- Assert
- .assertEquals(SegmentGenerationUtils.getFileURI("/path/to/file", new URI("hdfs://namenode/path/to")).toString(),
- "hdfs://namenode/path/to/file");
- Assert.assertEquals(SegmentGenerationUtils.getFileURI("/path/to/file", new URI("hdfs:///path/to")).toString(),
- "hdfs:/path/to/file");
+ Assert.assertEquals(SegmentGenerationUtils.getFileURI("/path/to/file", new URI("file:/path/to")).toString(), "file:/path/to/file");
+ Assert.assertEquals(SegmentGenerationUtils.getFileURI("/path/to/file", new URI("hdfs://namenode/path/to")).toString(),
+ "hdfs://namenode/path/to/file");
+ Assert.assertEquals(SegmentGenerationUtils.getFileURI("/path/to/file", new URI("hdfs:///path/to")).toString(), "hdfs:/path/to/file");
// Typical local file URI
validateFileURI(new URI("file:/path/to/"));
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/tier/TierConfigUtilsTest.java b/pinot-common/src/test/java/org/apache/pinot/common/tier/TierConfigUtilsTest.java
index 0b9f0a9..6117bc1 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/tier/TierConfigUtilsTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/tier/TierConfigUtilsTest.java
@@ -43,14 +43,12 @@ public class TierConfigUtilsTest {
tableConfig = new TableConfigBuilder(TableType.OFFLINE).setTableName("myTable").setTierConfigList(null).build();
Assert.assertFalse(TierConfigUtils.shouldRelocateToTiers(tableConfig));
- tableConfig =
- new TableConfigBuilder(TableType.OFFLINE).setTableName("myTable").setTierConfigList(Collections.emptyList())
- .build();
+ tableConfig = new TableConfigBuilder(TableType.OFFLINE).setTableName("myTable").setTierConfigList(Collections.emptyList()).build();
Assert.assertFalse(TierConfigUtils.shouldRelocateToTiers(tableConfig));
- tableConfig = new TableConfigBuilder(TableType.OFFLINE).setTableName("myTable").setTierConfigList(Lists
- .newArrayList(new TierConfig("myTier", TierFactory.TIME_SEGMENT_SELECTOR_TYPE, "10d",
- TierFactory.PINOT_SERVER_STORAGE_TYPE, "tag_OFFLINE"))).build();
+ tableConfig = new TableConfigBuilder(TableType.OFFLINE).setTableName("myTable").setTierConfigList(Lists.newArrayList(
+ new TierConfig("myTier", TierFactory.TIME_SEGMENT_SELECTOR_TYPE, "10d", TierFactory.PINOT_SERVER_STORAGE_TYPE, "tag_OFFLINE")))
+ .build();
Assert.assertTrue(TierConfigUtils.shouldRelocateToTiers(tableConfig));
tableConfig = new TableConfigBuilder(TableType.REALTIME).setTableName("myTable").build();
@@ -59,14 +57,12 @@ public class TierConfigUtilsTest {
tableConfig = new TableConfigBuilder(TableType.REALTIME).setTableName("myTable").setTierConfigList(null).build();
Assert.assertFalse(TierConfigUtils.shouldRelocateToTiers(tableConfig));
- tableConfig =
- new TableConfigBuilder(TableType.REALTIME).setTableName("myTable").setTierConfigList(Collections.emptyList())
- .build();
+ tableConfig = new TableConfigBuilder(TableType.REALTIME).setTableName("myTable").setTierConfigList(Collections.emptyList()).build();
Assert.assertFalse(TierConfigUtils.shouldRelocateToTiers(tableConfig));
- tableConfig = new TableConfigBuilder(TableType.REALTIME).setTableName("myTable").setTierConfigList(Lists
- .newArrayList(new TierConfig("myTier", TierFactory.TIME_SEGMENT_SELECTOR_TYPE, "10d",
- TierFactory.PINOT_SERVER_STORAGE_TYPE, "tag_OFFLINE"))).build();
+ tableConfig = new TableConfigBuilder(TableType.REALTIME).setTableName("myTable").setTierConfigList(Lists.newArrayList(
+ new TierConfig("myTier", TierFactory.TIME_SEGMENT_SELECTOR_TYPE, "10d", TierFactory.PINOT_SERVER_STORAGE_TYPE, "tag_OFFLINE")))
+ .build();
Assert.assertTrue(TierConfigUtils.shouldRelocateToTiers(tableConfig));
}
@@ -76,14 +72,12 @@ public class TierConfigUtilsTest {
@Test
public void testGetTier() {
TierConfig tierConfig =
- new TierConfig("tier1", TierFactory.TIME_SEGMENT_SELECTOR_TYPE, "30d", TierFactory.PINOT_SERVER_STORAGE_TYPE,
- "tier1_tag_OFFLINE");
+ new TierConfig("tier1", TierFactory.TIME_SEGMENT_SELECTOR_TYPE, "30d", TierFactory.PINOT_SERVER_STORAGE_TYPE, "tier1_tag_OFFLINE");
Tier tier = TierFactory.getTier(tierConfig, null);
Assert.assertEquals(tier.getName(), "tier1");
Assert.assertTrue(tier.getSegmentSelector() instanceof TimeBasedTierSegmentSelector);
Assert.assertEquals(tier.getSegmentSelector().getType(), TierFactory.TIME_SEGMENT_SELECTOR_TYPE);
- Assert.assertEquals(((TimeBasedTierSegmentSelector) tier.getSegmentSelector()).getSegmentAgeMillis(),
- 30 * 24 * 60 * 60 * 1000L);
+ Assert.assertEquals(((TimeBasedTierSegmentSelector) tier.getSegmentSelector()).getSegmentAgeMillis(), 30 * 24 * 60 * 60 * 1000L);
Assert.assertTrue(tier.getStorage() instanceof PinotServerTierStorage);
Assert.assertEquals(tier.getStorage().getType(), TierFactory.PINOT_SERVER_STORAGE_TYPE);
Assert.assertEquals(((PinotServerTierStorage) tier.getStorage()).getTag(), "tier1_tag_OFFLINE");
@@ -112,16 +106,11 @@ public class TierConfigUtilsTest {
public void testTierComparator() {
Comparator<Tier> tierComparator = TierConfigUtils.getTierComparator();
- Tier tier1 =
- new Tier("tier1", new TimeBasedTierSegmentSelector(null, "30d"), new PinotServerTierStorage("tag_OFFLINE"));
- Tier tier2 =
- new Tier("tier2", new TimeBasedTierSegmentSelector(null, "1000d"), new PinotServerTierStorage("tag_OFFLINE"));
- Tier tier3 =
- new Tier("tier3", new TimeBasedTierSegmentSelector(null, "24h"), new PinotServerTierStorage("tag_OFFLINE"));
- Tier tier4 =
- new Tier("tier4", new TimeBasedTierSegmentSelector(null, "10m"), new PinotServerTierStorage("tag_OFFLINE"));
- Tier tier5 =
- new Tier("tier5", new TimeBasedTierSegmentSelector(null, "1d"), new PinotServerTierStorage("tag_OFFLINE"));
+ Tier tier1 = new Tier("tier1", new TimeBasedTierSegmentSelector(null, "30d"), new PinotServerTierStorage("tag_OFFLINE"));
+ Tier tier2 = new Tier("tier2", new TimeBasedTierSegmentSelector(null, "1000d"), new PinotServerTierStorage("tag_OFFLINE"));
+ Tier tier3 = new Tier("tier3", new TimeBasedTierSegmentSelector(null, "24h"), new PinotServerTierStorage("tag_OFFLINE"));
+ Tier tier4 = new Tier("tier4", new TimeBasedTierSegmentSelector(null, "10m"), new PinotServerTierStorage("tag_OFFLINE"));
+ Tier tier5 = new Tier("tier5", new TimeBasedTierSegmentSelector(null, "1d"), new PinotServerTierStorage("tag_OFFLINE"));
Assert.assertEquals(tierComparator.compare(tier1, tier2), 1);
Assert.assertEquals(tierComparator.compare(tier1, tier3), -1);
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/tier/TierSegmentSelectorTest.java b/pinot-common/src/test/java/org/apache/pinot/common/tier/TierSegmentSelectorTest.java
index 0052ab9..f1b1517 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/tier/TierSegmentSelectorTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/tier/TierSegmentSelectorTest.java
@@ -53,9 +53,8 @@ public class TierSegmentSelectorTest {
ZNRecord segmentZKMetadataZNRecord = offlineSegmentZKMetadata.toZNRecord();
ZkHelixPropertyStore<ZNRecord> propertyStore = mock(ZkHelixPropertyStore.class);
- when(propertyStore
- .get(eq(ZKMetadataProvider.constructPropertyStorePathForSegment(tableNameWithType, segmentName)), any(),
- anyInt())).thenReturn(segmentZKMetadataZNRecord);
+ when(propertyStore.get(eq(ZKMetadataProvider.constructPropertyStorePathForSegment(tableNameWithType, segmentName)), any(), anyInt()))
+ .thenReturn(segmentZKMetadataZNRecord);
HelixManager helixManager = mock(HelixManager.class);
when(helixManager.getHelixPropertyStore()).thenReturn(propertyStore);
@@ -90,9 +89,8 @@ public class TierSegmentSelectorTest {
realtimeSegmentZKMetadata.setNumReplicas(1);
segmentZKMetadataZNRecord = realtimeSegmentZKMetadata.toZNRecord();
- when(propertyStore
- .get(eq(ZKMetadataProvider.constructPropertyStorePathForSegment(tableNameWithType, segmentName)), any(),
- anyInt())).thenReturn(segmentZKMetadataZNRecord);
+ when(propertyStore.get(eq(ZKMetadataProvider.constructPropertyStorePathForSegment(tableNameWithType, segmentName)), any(), anyInt()))
+ .thenReturn(segmentZKMetadataZNRecord);
helixManager = mock(HelixManager.class);
when(helixManager.getHelixPropertyStore()).thenReturn(propertyStore);
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/DataSchemaTest.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/DataSchemaTest.java
index 838566a..407b2e0 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/utils/DataSchemaTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/DataSchemaTest.java
@@ -84,7 +84,8 @@ public class DataSchemaTest {
public void testToString() {
DataSchema dataSchema = new DataSchema(COLUMN_NAMES, COLUMN_DATA_TYPES);
Assert.assertEquals(dataSchema.toString(),
- "[int(INT),long(LONG),float(FLOAT),double(DOUBLE),string(STRING),object(OBJECT),int_array(INT_ARRAY),long_array(LONG_ARRAY),float_array(FLOAT_ARRAY),double_array(DOUBLE_ARRAY),string_array(STRING_ARRAY)]");
+ "[int(INT),long(LONG),float(FLOAT),double(DOUBLE),string(STRING),object(OBJECT),int_array(INT_ARRAY),"
+ + "long_array(LONG_ARRAY),float_array(FLOAT_ARRAY),double_array(DOUBLE_ARRAY),string_array(STRING_ARRAY)]");
}
@Test
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/EqualityUtilsTest.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/EqualityUtilsTest.java
index f35b60e..6eacfe2 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/utils/EqualityUtilsTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/EqualityUtilsTest.java
@@ -18,7 +18,13 @@
*/
package org.apache.pinot.common.utils;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.apache.pinot.spi.utils.EqualityUtils;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -141,7 +147,6 @@ public class EqualityUtilsTest {
Assert.assertFalse(EqualityUtils.isEqual(map1, map2), "Failed at loc " + loc);
}
});
-
}
@Test
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/FileUploadDownloadClientTest.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/FileUploadDownloadClientTest.java
index ac896fd..0e24e09 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/utils/FileUploadDownloadClientTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/FileUploadDownloadClientTest.java
@@ -50,18 +50,18 @@ public class FileUploadDownloadClientTest {
private static final int TEST_PORT = new Random().nextInt(10000) + 10000;
private static final String TEST_URI = "http://testhost/segments/testSegment";
private static final String TEST_CRYPTER = "testCrypter";
- private static HttpServer TEST_SERVER;
+ private HttpServer _testServer;
@BeforeClass
public void setUp()
throws Exception {
- TEST_SERVER = HttpServer.create(new InetSocketAddress(TEST_PORT), 0);
- TEST_SERVER.createContext("/v2/segments", new testSegmentUploadHandler());
- TEST_SERVER.setExecutor(null); // creates a default executor
- TEST_SERVER.start();
+ _testServer = HttpServer.create(new InetSocketAddress(TEST_PORT), 0);
+ _testServer.createContext("/v2/segments", new TestSegmentUploadHandler());
+ _testServer.setExecutor(null); // creates a default executor
+ _testServer.start();
}
- private static class testSegmentUploadHandler implements HttpHandler {
+ private static class TestSegmentUploadHandler implements HttpHandler {
@Override
public void handle(HttpExchange httpExchange)
@@ -74,8 +74,8 @@ public class FileUploadDownloadClientTest {
if (uploadType == FileUploadType.JSON) {
InputStream bodyStream = httpExchange.getRequestBody();
- downloadUri = JsonUtils.stringToJsonNode(IOUtils.toString(bodyStream, "UTF-8"))
- .get(CommonConstants.Segment.Offline.DOWNLOAD_URL).asText();
+ downloadUri =
+ JsonUtils.stringToJsonNode(IOUtils.toString(bodyStream, "UTF-8")).get(CommonConstants.Segment.Offline.DOWNLOAD_URL).asText();
} else if (uploadType == FileUploadType.URI) {
downloadUri = requestHeaders.getFirst(FileUploadDownloadClient.CustomHeaders.DOWNLOAD_URI);
String crypter = requestHeaders.getFirst(FileUploadDownloadClient.CustomHeaders.CRYPTER);
@@ -106,8 +106,8 @@ public class FileUploadDownloadClientTest {
List<NameValuePair> params = null;
SimpleHttpResponse response = fileUploadDownloadClient
- .sendSegmentUri(FileUploadDownloadClient.getUploadSegmentHttpURI(TEST_HOST, TEST_PORT), TEST_URI, headers,
- params, FileUploadDownloadClient.DEFAULT_SOCKET_TIMEOUT_MS);
+ .sendSegmentUri(FileUploadDownloadClient.getUploadSegmentHttpURI(TEST_HOST, TEST_PORT), TEST_URI, headers, params,
+ FileUploadDownloadClient.DEFAULT_SOCKET_TIMEOUT_MS);
Assert.assertEquals(response.getStatusCode(), HttpStatus.SC_OK);
Assert.assertEquals(response.getResponse(), "OK");
}
@@ -120,8 +120,8 @@ public class FileUploadDownloadClientTest {
segmentJson.put(CommonConstants.Segment.Offline.DOWNLOAD_URL, TEST_URI);
String jsonString = segmentJson.toString();
try (FileUploadDownloadClient fileUploadDownloadClient = new FileUploadDownloadClient()) {
- SimpleHttpResponse response = fileUploadDownloadClient
- .sendSegmentJson(FileUploadDownloadClient.getUploadSegmentHttpURI(TEST_HOST, TEST_PORT), jsonString);
+ SimpleHttpResponse response =
+ fileUploadDownloadClient.sendSegmentJson(FileUploadDownloadClient.getUploadSegmentHttpURI(TEST_HOST, TEST_PORT), jsonString);
Assert.assertEquals(response.getStatusCode(), HttpStatus.SC_OK);
Assert.assertEquals(response.getResponse(), "OK");
}
@@ -129,6 +129,6 @@ public class FileUploadDownloadClientTest {
@AfterClass
public void shutDown() {
- TEST_SERVER.stop(0);
+ _testServer.stop(0);
}
}
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/PinotDataTypeTest.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/PinotDataTypeTest.java
index e1e3e39..160d567 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/utils/PinotDataTypeTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/PinotDataTypeTest.java
@@ -33,32 +33,35 @@ import static org.testng.Assert.fail;
public class PinotDataTypeTest {
private static final PinotDataType[] SOURCE_TYPES =
- {BYTE, CHARACTER, SHORT, INTEGER, LONG, FLOAT, DOUBLE, STRING, JSON, BYTE_ARRAY, CHARACTER_ARRAY, SHORT_ARRAY, INTEGER_ARRAY, LONG_ARRAY, FLOAT_ARRAY, DOUBLE_ARRAY, STRING_ARRAY};
+ {BYTE, CHARACTER, SHORT, INTEGER, LONG, FLOAT, DOUBLE, STRING, JSON, BYTE_ARRAY, CHARACTER_ARRAY, SHORT_ARRAY, INTEGER_ARRAY,
+ LONG_ARRAY, FLOAT_ARRAY, DOUBLE_ARRAY, STRING_ARRAY};
private static final Object[] SOURCE_VALUES =
- {(byte) 123, (char) 123, (short) 123, 123, 123L, 123f, 123d, " 123", "123 ", new Object[]{(byte) 123}, new Object[]{(char) 123}, new Object[]{(short) 123}, new Object[]{123}, new Object[]{123L}, new Object[]{123f}, new Object[]{123d}, new Object[]{" 123"}};
- private static final PinotDataType[] DEST_TYPES =
- {INTEGER, LONG, FLOAT, DOUBLE, INTEGER_ARRAY, LONG_ARRAY, FLOAT_ARRAY, DOUBLE_ARRAY};
+ {(byte) 123, (char) 123, (short) 123, 123, 123L, 123f, 123d, " 123", "123 ", new Object[]{(byte) 123}, new Object[]{(char) 123},
+ new Object[]{(short) 123}, new Object[]{123}, new Object[]{123L}, new Object[]{123f}, new Object[]{123d}, new Object[]{" 123"}};
+ private static final PinotDataType[] DEST_TYPES = {INTEGER, LONG, FLOAT, DOUBLE, INTEGER_ARRAY, LONG_ARRAY, FLOAT_ARRAY, DOUBLE_ARRAY};
private static final Object[] EXPECTED_DEST_VALUES =
{123, 123L, 123f, 123d, new Object[]{123}, new Object[]{123L}, new Object[]{123f}, new Object[]{123d}};
private static final String[] EXPECTED_STRING_VALUES =
- {Byte.toString((byte) 123), Character.toString((char) 123), Short.toString((short) 123), Integer.toString(
- 123), Long.toString(123L), Float.toString(123f), Double.toString(123d), " 123", "123 ", Byte.toString(
- (byte) 123), Character.toString((char) 123), Short.toString((short) 123), Integer.toString(
- 123), Long.toString(123L), Float.toString(123f), Double.toString(123d), " 123"};
+ {Byte.toString((byte) 123), Character.toString((char) 123), Short.toString((short) 123), Integer.toString(123), Long.toString(
+ 123L), Float.toString(123f), Double.toString(123d), " 123", "123 ", Byte.toString((byte) 123), Character.toString(
+ (char) 123), Short.toString((short) 123), Integer.toString(123), Long.toString(123L), Float.toString(123f), Double.toString(
+ 123d), " 123"
+ };
// Test cases where array for MV column contains values of mixing types.
- private static final PinotDataType[] SOURCE_ARRAY_TYPES =
- {SHORT_ARRAY, INTEGER_ARRAY, LONG_ARRAY, FLOAT_ARRAY, DOUBLE_ARRAY};
+ private static final PinotDataType[] SOURCE_ARRAY_TYPES = {SHORT_ARRAY, INTEGER_ARRAY, LONG_ARRAY, FLOAT_ARRAY, DOUBLE_ARRAY};
private static final Object[] SOURCE_ARRAY_VALUES = new Object[]{(short) 123, 4, 5L, 6f, 7d, "8"};
private static final PinotDataType[] DEST_ARRAY_TYPES = {INTEGER_ARRAY, LONG_ARRAY, FLOAT_ARRAY, DOUBLE_ARRAY};
private static final Object[] EXPECTED_DEST_ARRAY_VALUES =
- {new Object[]{123, 4, 5, 6, 7, 8}, new Object[]{123L, 4L, 5L, 6L, 7L, 8L}, new Object[]{123f, 4f, 5f, 6f, 7f, 8f}, new Object[]{123d, 4d, 5d, 6d, 7d, 8d}};
+ {new Object[]{123, 4, 5, 6, 7, 8}, new Object[]{123L, 4L, 5L, 6L, 7L, 8L}, new Object[]{123f, 4f, 5f, 6f, 7f, 8f},
+ new Object[]{123d, 4d, 5d, 6d, 7d, 8d}};
private static final PinotDataType[] DEST_PRIMITIVE_ARRAY_TYPES =
{PRIMITIVE_INT_ARRAY, PRIMITIVE_LONG_ARRAY, PRIMITIVE_FLOAT_ARRAY, PRIMITIVE_DOUBLE_ARRAY};
private static final Object[] EXPECTED_DEST_PRIMITIVE_ARRAY_VALUES =
- {new int[]{123, 4, 5, 6, 7, 8}, new long[]{123L, 4L, 5L, 6L, 7L, 8L}, new float[]{123f, 4f, 5f, 6f, 7f, 8f}, new double[]{123d, 4d, 5d, 6d, 7d, 8d}};
+ {new int[]{123, 4, 5, 6, 7, 8}, new long[]{123L, 4L, 5L, 6L, 7L, 8L}, new float[]{123f, 4f, 5f, 6f, 7f, 8f}, new double[]{123d, 4d,
+ 5d, 6d, 7d, 8d}};
@Test
public void testNumberConversion() {
@@ -161,10 +164,10 @@ public class PinotDataTypeTest {
assertEquals(JSON.convert(true, BOOLEAN), "true");
assertEquals(JSON.convert(new byte[]{0, 1}, BYTES), "\"AAE=\""); // Base64 encoding.
assertEquals(JSON.convert(
- "{\"bytes\":\"AAE=\",\"map\":{\"key1\":\"value\",\"key2\":null,\"array\":[-5.4,4,\"2\"]},\"timestamp\":1620324238610}",
+ "{\"bytes\":\"AAE=\",\"map\":{\"key1\":\"value\",\"key2\":null,\"array\":[-5.4,4,\"2\"]}," + "\"timestamp\":1620324238610}",
STRING),
- "{\"bytes\":\"AAE=\",\"map\":{\"key1\":\"value\",\"key2\":null,\"array\":[-5.4,4,\"2\"]},\"timestamp\":1620324238610}");
- assertEquals(JSON.convert(new Timestamp(1620324238610l), TIMESTAMP), "1620324238610");
+ "{\"bytes\":\"AAE=\",\"map\":{\"key1\":\"value\",\"key2\":null,\"array\":[-5.4,4,\"2\"]}," + "\"timestamp\":1620324238610}");
+ assertEquals(JSON.convert(new Timestamp(1620324238610L), TIMESTAMP), "1620324238610");
}
@Test
@@ -177,7 +180,7 @@ public class PinotDataTypeTest {
assertEquals(OBJECT.toTimestamp(new NumberObject("123")).getTime(), 123L);
assertEquals(OBJECT.toString(new NumberObject("123")), "123");
assertEquals(OBJECT.toJson(getGenericTestObject()),
- "{\"bytes\":\"AAE=\",\"map\":{\"key1\":\"value\",\"key2\":null,\"array\":[-5.4,4,\"2\"]},\"timestamp\":1620324238610}");
+ "{\"bytes\":\"AAE=\",\"map\":{\"key1\":\"value\",\"key2\":null,\"array\":[-5.4,4,\"2\"]}," + "\"timestamp\":1620324238610}");
assertEquals(OBJECT_ARRAY.getSingleValueType(), OBJECT);
// Non-zero value is treated as true.
assertTrue(OBJECT.toBoolean(1.1d));
@@ -236,7 +239,7 @@ public class PinotDataTypeTest {
Map<String, Object> map2 = new HashMap<>();
map2.put("map", map1);
map2.put("bytes", new byte[]{0, 1});
- map2.put("timestamp", new Timestamp(1620324238610l));
+ map2.put("timestamp", new Timestamp(1620324238610L));
return map2;
}
@@ -272,8 +275,7 @@ public class PinotDataTypeTest {
assertInvalidConversion("xyz", STRING, JSON, RuntimeException.class);
}
- private void assertInvalidConversion(Object value, PinotDataType sourceType, PinotDataType destType,
- Class expectedExceptionType) {
+ private void assertInvalidConversion(Object value, PinotDataType sourceType, PinotDataType destType, Class expectedExceptionType) {
try {
destType.convert(value, sourceType);
} catch (Exception e) {
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/SegmentNameBuilderTest.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/SegmentNameBuilderTest.java
index 2bf24cb..bf7b63e 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/utils/SegmentNameBuilderTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/SegmentNameBuilderTest.java
@@ -82,16 +82,12 @@ public class SegmentNameBuilderTest {
assertEquals(shortNameSegment.getSegmentType(), SegmentName.RealtimeSegmentType.HLC_SHORT);
assertEquals(SegmentName.getSegmentType(llcSegment.getSegmentName()), SegmentName.RealtimeSegmentType.LLC);
- assertEquals(SegmentName.getSegmentType(longNameSegment.getSegmentName()),
- SegmentName.RealtimeSegmentType.HLC_LONG);
- assertEquals(SegmentName.getSegmentType(shortNameSegment.getSegmentName()),
- SegmentName.RealtimeSegmentType.HLC_SHORT);
+ assertEquals(SegmentName.getSegmentType(longNameSegment.getSegmentName()), SegmentName.RealtimeSegmentType.HLC_LONG);
+ assertEquals(SegmentName.getSegmentType(shortNameSegment.getSegmentName()), SegmentName.RealtimeSegmentType.HLC_SHORT);
// Invalid segment names
- assertEquals(SegmentName.getSegmentType(longNameSegment.getSegmentName() + "__"),
- SegmentName.RealtimeSegmentType.UNSUPPORTED);
- assertEquals(SegmentName.getSegmentType("a__abc__1__3__4__54__g__gg___h"),
- SegmentName.RealtimeSegmentType.UNSUPPORTED);
+ assertEquals(SegmentName.getSegmentType(longNameSegment.getSegmentName() + "__"), SegmentName.RealtimeSegmentType.UNSUPPORTED);
+ assertEquals(SegmentName.getSegmentType("a__abc__1__3__4__54__g__gg___h"), SegmentName.RealtimeSegmentType.UNSUPPORTED);
}
@Test
@@ -117,7 +113,7 @@ public class SegmentNameBuilderTest {
}
@Test
- public void LLCSegNameTest() {
+ public void testLLCSegName() {
final String tableName = "myTable";
final int partitionGroupId = 4;
final int sequenceNumber = 27;
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/ServiceStatusTest.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/ServiceStatusTest.java
index eb657cb..4f03980 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/utils/ServiceStatusTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/ServiceStatusTest.java
@@ -79,14 +79,13 @@ public class ServiceStatusTest {
public static final String TABLE_NAME = "myTable_OFFLINE";
public static final String INSTANCE_NAME = "Server_1.2.3.4_1234";
- private static final String CHARS_IN_RANDOM_TABLE_NAME =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- private static Random random;
+ private static final String CHARS_IN_RANDOM_TABLE_NAME = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ private static Random _random;
@BeforeClass
public void setUp() {
long seed = System.currentTimeMillis();
- random = new Random(seed);
+ _random = new Random(seed);
// Printing to sysout so that we can re-generate failure cases.
System.out.println(ServiceStatusTest.class.getSimpleName() + ":Using random number seed " + seed);
}
@@ -119,8 +118,7 @@ public class ServiceStatusTest {
// Good + starting + bad = starting (check for left-to-right evaluation)
ServiceStatus.MultipleCallbackServiceStatusCallback goodStartingAndBad =
- new ServiceStatus.MultipleCallbackServiceStatusCallback(
- ImmutableList.of(ALWAYS_GOOD, ALWAYS_STARTING, ALWAYS_BAD));
+ new ServiceStatus.MultipleCallbackServiceStatusCallback(ImmutableList.of(ALWAYS_GOOD, ALWAYS_STARTING, ALWAYS_BAD));
assertEquals(goodStartingAndBad.getServiceStatus(), ServiceStatus.Status.STARTING);
}
@@ -202,15 +200,14 @@ public class ServiceStatusTest {
}
private TestIdealStateAndExternalViewMatchServiceStatusCallback buildTestISEVCallback() {
- return new TestIdealStateAndExternalViewMatchServiceStatusCallback("potato", INSTANCE_NAME,
- Collections.singletonList(TABLE_NAME));
+ return new TestIdealStateAndExternalViewMatchServiceStatusCallback("potato", INSTANCE_NAME, Collections.singletonList(TABLE_NAME));
}
private String generateRandomString(int len) {
final int numChars = CHARS_IN_RANDOM_TABLE_NAME.length();
StringBuilder builder = new StringBuilder();
for (int i = 0; i < len; i++) {
- builder.append(CHARS_IN_RANDOM_TABLE_NAME.charAt(random.nextInt(numChars)));
+ builder.append(CHARS_IN_RANDOM_TABLE_NAME.charAt(_random.nextInt(numChars)));
}
return builder.toString();
}
@@ -229,10 +226,10 @@ public class ServiceStatusTest {
private void testMultipleResourcesAndPercent(double percentReady) {
final long now = System.currentTimeMillis();
- random = new Random(now);
+ _random = new Random(now);
final String clusterName = "noSuchCluster";
final List<String> tables = new ArrayList<>();
- final int tableCount = 2500 + random.nextInt(100);
+ final int tableCount = 2500 + _random.nextInt(100);
int readyTables = 0;
Map<String, IdealState> idealStates = new HashMap<>();
Map<String, ExternalView> externalViews = new HashMap<>();
@@ -242,7 +239,7 @@ public class ServiceStatusTest {
tables.add(tableName);
final String segmentName = "segment1";
String evState;
- if (random.nextDouble() * 100 < percentReady) {
+ if (_random.nextDouble() * 100 < percentReady) {
evState = "ONLINE";
readyTables++;
} else {
@@ -265,8 +262,7 @@ public class ServiceStatusTest {
// Call getServiceStatus() enough number of times so that we are only left with the tables
// that are not ready yet. We need to call getServiceStatus() at most tableCount times.
for (double minReadyPercent = lowestReadyPercent; minReadyPercent <= 100; minReadyPercent += 0.1) {
- TestMultiResourceISAndEVMatchCB callback =
- new TestMultiResourceISAndEVMatchCB(clusterName, INSTANCE_NAME, tables, minReadyPercent);
+ TestMultiResourceISAndEVMatchCB callback = new TestMultiResourceISAndEVMatchCB(clusterName, INSTANCE_NAME, tables, minReadyPercent);
callback.setIdealStates(idealStates);
callback.setExternalViews(externalViews);
@@ -279,17 +275,18 @@ public class ServiceStatusTest {
status = callback.getServiceStatus();
}
- ServiceStatus.Status expected =
- minReadyPercent > actualReadyPercent ? ServiceStatus.Status.STARTING : ServiceStatus.Status.GOOD;
- String errorMsg = "Mismatch at " + minReadyPercent + "%, tableCount=" + tableCount + ", percentTablesReady="
- + actualReadyPercent + ":" + callback.getStatusDescription();
+ ServiceStatus.Status expected = minReadyPercent > actualReadyPercent ? ServiceStatus.Status.STARTING : ServiceStatus.Status.GOOD;
+ String errorMsg =
+ "Mismatch at " + minReadyPercent + "%, tableCount=" + tableCount + ", percentTablesReady=" + actualReadyPercent + ":" + callback
+ .getStatusDescription();
Assert.assertEquals(status, expected, errorMsg);
// The status should never change going forward from here.
for (int i = nBadTables + 1; i < tableCount; i++) {
ServiceStatus.Status laterStatus = callback.getServiceStatus();
- String msg = "Mismatch at " + minReadyPercent + "%, tableCount=" + tableCount + ", percentTablesReady="
- + actualReadyPercent + ", i=" + i + ":" + callback.getStatusDescription();
+ String msg =
+ "Mismatch at " + minReadyPercent + "%, tableCount=" + tableCount + ", percentTablesReady=" + actualReadyPercent + ", i=" + i
+ + ":" + callback.getStatusDescription();
Assert.assertEquals(laterStatus, status, msg);
}
}
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/URIUtilsTest.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/URIUtilsTest.java
index 403793a..d4cc432 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/utils/URIUtilsTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/URIUtilsTest.java
@@ -36,11 +36,9 @@ public class URIUtilsTest {
public void testGetUri() {
assertEquals(URIUtils.getUri("http://foo/bar").toString(), "http://foo/bar");
assertEquals(URIUtils.getUri("http://foo/bar", "table").toString(), "http://foo/bar/table");
- assertEquals(URIUtils.getUri("http://foo/bar", "table", "segment+%25").toString(),
- "http://foo/bar/table/segment+%25");
+ assertEquals(URIUtils.getUri("http://foo/bar", "table", "segment+%25").toString(), "http://foo/bar/table/segment+%25");
assertEquals(URIUtils.getUri("/foo/bar", "table", "segment+%25").toString(), "file:/foo/bar/table/segment+%25");
- assertEquals(URIUtils.getUri("file:/foo/bar", "table", "segment+%25").toString(),
- "file:/foo/bar/table/segment+%25");
+ assertEquals(URIUtils.getUri("file:/foo/bar", "table", "segment+%25").toString(), "file:/foo/bar/table/segment+%25");
}
@Test
@@ -54,10 +52,8 @@ public class URIUtilsTest {
@Test
public void testConstructDownloadUrl() {
- assertEquals(URIUtils.constructDownloadUrl("http://foo/bar", "table", "segment"),
- "http://foo/bar/segments/table/segment");
- assertEquals(URIUtils.constructDownloadUrl("http://foo/bar", "table", "segment %"),
- "http://foo/bar/segments/table/segment+%25");
+ assertEquals(URIUtils.constructDownloadUrl("http://foo/bar", "table", "segment"), "http://foo/bar/segments/table/segment");
+ assertEquals(URIUtils.constructDownloadUrl("http://foo/bar", "table", "segment %"), "http://foo/bar/segments/table/segment+%25");
}
@Test
@@ -86,8 +82,8 @@ public class URIUtilsTest {
params.put("stringParam", "aString");
params.put("stringParamNeedsEncoding", "{\"format\":\"JSON\",\"timeout\":1000}");
uri = URIUtils.buildURI("http", "foo", "bar", params);
- Assert.assertEquals(uri.toString(), "http://foo/bar?stringParam=aString&stringParamNeedsEncoding=" + URIUtils
- .encode("{\"format\":\"JSON\",\"timeout\":1000}"));
+ Assert.assertEquals(uri.toString(),
+ "http://foo/bar?stringParam=aString&stringParamNeedsEncoding=" + URIUtils.encode("{\"format\":\"JSON\",\"timeout\":1000}"));
// test that path gets encoded
uri = URIUtils.buildURI("http", "foo", "bar%moo{}", Collections.emptyMap());
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/config/InstanceUtilsTest.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/config/InstanceUtilsTest.java
index 09cc182..8301e36 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/utils/config/InstanceUtilsTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/config/InstanceUtilsTest.java
@@ -104,8 +104,7 @@ public class InstanceUtilsTest {
@Test
public void testUpdateHelixInstanceConfig() {
Instance instance =
- new Instance("localhost", 1234, InstanceType.SERVER, Collections.singletonList("DefaultTenant_OFFLINE"), null,
- 0, 123, false);
+ new Instance("localhost", 1234, InstanceType.SERVER, Collections.singletonList("DefaultTenant_OFFLINE"), null, 0, 123, false);
InstanceConfig instanceConfig = InstanceUtils.toHelixInstanceConfig(instance);
// Put some custom fields, which should not be updated
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/config/TableConfigSerDeTest.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/config/TableConfigSerDeTest.java
index ee919c2..ca2a2db 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/utils/config/TableConfigSerDeTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/config/TableConfigSerDeTest.java
@@ -108,8 +108,7 @@ public class TableConfigSerDeTest {
}
{
// With tenant config
- TableConfig tableConfig =
- tableConfigBuilder.setServerTenant("aServerTenant").setBrokerTenant("aBrokerTenant").build();
+ TableConfig tableConfig = tableConfigBuilder.setServerTenant("aServerTenant").setBrokerTenant("aBrokerTenant").build();
checkTenantConfigWithoutTagOverride(tableConfig);
@@ -172,8 +171,7 @@ public class TableConfigSerDeTest {
}
{
// With routing config
- RoutingConfig routingConfig =
- new RoutingConfig("builder", Arrays.asList("pruner0", "pruner1", "pruner2"), "selector");
+ RoutingConfig routingConfig = new RoutingConfig("builder", Arrays.asList("pruner0", "pruner1", "pruner2"), "selector");
TableConfig tableConfig = tableConfigBuilder.setRoutingConfig(routingConfig).build();
checkRoutingConfig(tableConfig);
@@ -209,8 +207,8 @@ public class TableConfigSerDeTest {
new InstanceAssignmentConfig(new InstanceTagPoolConfig("tenant_OFFLINE", true, 3, null),
new InstanceConstraintConfig(Arrays.asList("constraint1", "constraint2")),
new InstanceReplicaGroupPartitionConfig(true, 0, 3, 5, 0, 0));
- TableConfig tableConfig = tableConfigBuilder.setInstanceAssignmentConfigMap(
- Collections.singletonMap(InstancePartitionsType.OFFLINE, instanceAssignmentConfig)).build();
+ TableConfig tableConfig = tableConfigBuilder
+ .setInstanceAssignmentConfigMap(Collections.singletonMap(InstancePartitionsType.OFFLINE, instanceAssignmentConfig)).build();
checkInstanceAssignmentConfig(tableConfig);
@@ -228,9 +226,9 @@ public class TableConfigSerDeTest {
Map<String, String> properties = new HashMap<>();
properties.put("foo", "bar");
properties.put("foobar", "potato");
- List<FieldConfig> fieldConfigList = Arrays.asList(
- new FieldConfig("column1", FieldConfig.EncodingType.DICTIONARY, FieldConfig.IndexType.INVERTED, null,
- properties), new FieldConfig("column2", null, null, null, null));
+ List<FieldConfig> fieldConfigList = Arrays
+ .asList(new FieldConfig("column1", FieldConfig.EncodingType.DICTIONARY, FieldConfig.IndexType.INVERTED, null, properties),
+ new FieldConfig("column2", null, null, null, null));
TableConfig tableConfig = tableConfigBuilder.setFieldConfigList(fieldConfigList).build();
checkFieldConfig(tableConfig);
@@ -246,8 +244,7 @@ public class TableConfigSerDeTest {
}
{
// with upsert config
- UpsertConfig upsertConfig =
- new UpsertConfig(UpsertConfig.Mode.FULL, null, "comparison", UpsertConfig.HashFunction.NONE);
+ UpsertConfig upsertConfig = new UpsertConfig(UpsertConfig.Mode.FULL, null, "comparison", UpsertConfig.HashFunction.NONE);
TableConfig tableConfig = tableConfigBuilder.setUpsertConfig(upsertConfig).build();
@@ -258,10 +255,8 @@ public class TableConfigSerDeTest {
{
// with SegmentsValidationAndRetentionConfig
TableConfig tableConfig = tableConfigBuilder.setPeerSegmentDownloadScheme(CommonConstants.HTTP_PROTOCOL).build();
- checkSegmentsValidationAndRetentionConfig(
- JsonUtils.stringToObject(tableConfig.toJsonString(), TableConfig.class));
- checkSegmentsValidationAndRetentionConfig(
- TableConfigUtils.fromZNRecord(TableConfigUtils.toZNRecord(tableConfig)));
+ checkSegmentsValidationAndRetentionConfig(JsonUtils.stringToObject(tableConfig.toJsonString(), TableConfig.class));
+ checkSegmentsValidationAndRetentionConfig(TableConfigUtils.fromZNRecord(TableConfigUtils.toZNRecord(tableConfig)));
}
{
// With ingestion config
@@ -277,8 +272,8 @@ public class TableConfigSerDeTest {
batchConfigMaps.add(batchConfigMap);
List<String> fieldsToUnnest = Arrays.asList("c1, c2");
IngestionConfig ingestionConfig =
- new IngestionConfig(new BatchIngestionConfig(batchConfigMaps, "APPEND", "HOURLY"),
- new StreamIngestionConfig(streamConfigMaps), new FilterConfig("filterFunc(foo)"), transformConfigs,
+ new IngestionConfig(new BatchIngestionConfig(batchConfigMaps, "APPEND", "HOURLY"), new StreamIngestionConfig(streamConfigMaps),
+ new FilterConfig("filterFunc(foo)"), transformConfigs,
new ComplexTypeConfig(fieldsToUnnest, ".", ComplexTypeConfig.CollectionNotUnnestedToJson.NON_PRIMITIVE));
TableConfig tableConfig = tableConfigBuilder.setIngestionConfig(ingestionConfig).build();
@@ -487,8 +482,7 @@ public class TableConfigSerDeTest {
}
private void checkInstanceAssignmentConfig(TableConfig tableConfig) {
- Map<InstancePartitionsType, InstanceAssignmentConfig> instanceAssignmentConfigMap =
- tableConfig.getInstanceAssignmentConfigMap();
+ Map<InstancePartitionsType, InstanceAssignmentConfig> instanceAssignmentConfigMap = tableConfig.getInstanceAssignmentConfigMap();
assertNotNull(instanceAssignmentConfigMap);
assertEquals(instanceAssignmentConfigMap.size(), 1);
assertTrue(instanceAssignmentConfigMap.containsKey(InstancePartitionsType.OFFLINE));
@@ -504,8 +498,7 @@ public class TableConfigSerDeTest {
assertNotNull(constraintConfig);
assertEquals(constraintConfig.getConstraints(), Arrays.asList("constraint1", "constraint2"));
- InstanceReplicaGroupPartitionConfig replicaGroupPartitionConfig =
- instanceAssignmentConfig.getReplicaGroupPartitionConfig();
+ InstanceReplicaGroupPartitionConfig replicaGroupPartitionConfig = instanceAssignmentConfig.getReplicaGroupPartitionConfig();
assertTrue(replicaGroupPartitionConfig.isReplicaGroupBased());
assertEquals(replicaGroupPartitionConfig.getNumInstances(), 0);
assertEquals(replicaGroupPartitionConfig.getNumReplicaGroups(), 3);
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/config/TableConfigUtilsTest.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/config/TableConfigUtilsTest.java
index 0a769a5..0205935 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/utils/config/TableConfigUtilsTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/config/TableConfigUtilsTest.java
@@ -58,9 +58,9 @@ public class TableConfigUtilsTest {
String expectedPushType = "APPEND";
Map<String, String> expectedStreamConfigsMap = getTestStreamConfigs();
- TableConfig tableConfig = new TableConfigBuilder(TableType.REALTIME).setTableName(TABLE_NAME)
- .setSegmentPushFrequency(expectedPushFrequency).setSegmentPushType(expectedPushType)
- .setStreamConfigs(expectedStreamConfigsMap).build();
+ TableConfig tableConfig =
+ new TableConfigBuilder(TableType.REALTIME).setTableName(TABLE_NAME).setSegmentPushFrequency(expectedPushFrequency)
+ .setSegmentPushType(expectedPushType).setStreamConfigs(expectedStreamConfigsMap).build();
// Before conversion, the ingestion config should be null.
Assert.assertNull(tableConfig.getIngestionConfig());
@@ -73,8 +73,7 @@ public class TableConfigUtilsTest {
Assert.assertEquals(batchIngestionConfig.getSegmentIngestionFrequency(), expectedPushFrequency);
Assert.assertEquals(batchIngestionConfig.getSegmentIngestionType(), expectedPushType);
- Map<String, String> actualStreamConfigsMap =
- tableConfig.getIngestionConfig().getStreamIngestionConfig().getStreamConfigMaps().get(0);
+ Map<String, String> actualStreamConfigsMap = tableConfig.getIngestionConfig().getStreamIngestionConfig().getStreamConfigMaps().get(0);
Assert.assertEquals(actualStreamConfigsMap, expectedStreamConfigsMap);
// Assert that the deprecated fields are cleared.
@@ -99,18 +98,13 @@ public class TableConfigUtilsTest {
// All mandatory properties set
Map<String, String> streamConfigMap = new HashMap<>();
streamConfigMap.put(StreamConfigProperties.STREAM_TYPE, "streamType");
+ streamConfigMap.put(StreamConfigProperties.constructStreamProperty(streamType, StreamConfigProperties.STREAM_TOPIC_NAME), topic);
streamConfigMap
- .put(StreamConfigProperties.constructStreamProperty(streamType, StreamConfigProperties.STREAM_TOPIC_NAME),
- topic);
- streamConfigMap
- .put(StreamConfigProperties.constructStreamProperty(streamType, StreamConfigProperties.STREAM_CONSUMER_TYPES),
- consumerType);
- streamConfigMap.put(StreamConfigProperties
- .constructStreamProperty(streamType, StreamConfigProperties.STREAM_CONSUMER_FACTORY_CLASS),
+ .put(StreamConfigProperties.constructStreamProperty(streamType, StreamConfigProperties.STREAM_CONSUMER_TYPES), consumerType);
+ streamConfigMap.put(StreamConfigProperties.constructStreamProperty(streamType, StreamConfigProperties.STREAM_CONSUMER_FACTORY_CLASS),
consumerFactoryClass);
streamConfigMap
- .put(StreamConfigProperties.constructStreamProperty(streamType, StreamConfigProperties.STREAM_DECODER_CLASS),
- decoderClass);
+ .put(StreamConfigProperties.constructStreamProperty(streamType, StreamConfigProperties.STREAM_DECODER_CLASS), decoderClass);
return streamConfigMap;
}
@@ -140,8 +134,7 @@ public class TableConfigUtilsTest {
}
@Override
- public StreamLevelConsumer createStreamLevelConsumer(String clientId, String tableName, Set<String> fieldsToRead,
- String groupId) {
+ public StreamLevelConsumer createStreamLevelConsumer(String clientId, String tableName, Set<String> fieldsToRead, String groupId) {
return null;
}
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/config/TagNameUtilsTest.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/config/TagNameUtilsTest.java
index 341d66a..e46601a 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/utils/config/TagNameUtilsTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/config/TagNameUtilsTest.java
@@ -50,16 +50,15 @@ public class TagNameUtilsTest {
inputs.add(new Object[]{tenantConfig, "aServerTenant_OFFLINE", "aServerTenant_REALTIME", "overriddenTag_OFFLINE"});
// defined both overrides
- tenantConfig = new TenantConfig(null, "aServerTenant",
- new TagOverrideConfig("overriddenTag_REALTIME", "overriddenTag_OFFLINE"));
+ tenantConfig = new TenantConfig(null, "aServerTenant", new TagOverrideConfig("overriddenTag_REALTIME", "overriddenTag_OFFLINE"));
inputs.add(new Object[]{tenantConfig, "aServerTenant_OFFLINE", "overriddenTag_REALTIME", "overriddenTag_OFFLINE"});
return inputs.toArray(new Object[inputs.size()][]);
}
@Test(dataProvider = "tagOverrideConfigTestDataProvider")
- public void testTagOverrideConfig(TenantConfig tenantConfig, String expectedOfflineServerTag,
- String expectedConsumingServerTag, String expectedCompletedServerTag) {
+ public void testTagOverrideConfig(TenantConfig tenantConfig, String expectedOfflineServerTag, String expectedConsumingServerTag,
+ String expectedCompletedServerTag) {
assertEquals(TagNameUtils.extractOfflineServerTag(tenantConfig), expectedOfflineServerTag);
assertEquals(TagNameUtils.extractConsumingServerTag(tenantConfig), expectedConsumingServerTag);
assertEquals(TagNameUtils.extractCompletedServerTag(tenantConfig), expectedCompletedServerTag);
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/fetcher/SegmentFetcherFactoryTest.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/fetcher/SegmentFetcherFactoryTest.java
index 54679a3..b7ddf17 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/utils/fetcher/SegmentFetcherFactoryTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/fetcher/SegmentFetcherFactoryTest.java
@@ -54,8 +54,7 @@ public class SegmentFetcherFactoryTest {
properties.put("foo", "bar");
properties.put("protocols", Arrays.asList(HTTP_PROTOCOL, HTTPS_PROTOCOL, TEST_PROTOCOL, "foo"));
properties.put("http.foo", "bar");
- properties.put(TEST_PROTOCOL + SegmentFetcherFactory.SEGMENT_FETCHER_CLASS_KEY_SUFFIX,
- FakeSegmentFetcher.class.getName());
+ properties.put(TEST_PROTOCOL + SegmentFetcherFactory.SEGMENT_FETCHER_CLASS_KEY_SUFFIX, FakeSegmentFetcher.class.getName());
SegmentFetcherFactory.init(new PinotConfiguration(properties));
assertEquals(SegmentFetcherFactory.getSegmentFetcher(HTTP_PROTOCOL).getClass(), HttpSegmentFetcher.class);
diff --git a/pinot-common/src/test/java/org/apache/pinot/pql/parsers/Pql2CompilerTest.java b/pinot-common/src/test/java/org/apache/pinot/pql/parsers/Pql2CompilerTest.java
index 401e283..447ea5e 100644
--- a/pinot-common/src/test/java/org/apache/pinot/pql/parsers/Pql2CompilerTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/pql/parsers/Pql2CompilerTest.java
@@ -52,48 +52,47 @@ public class Pql2CompilerTest {
@BeforeClass
public void setUp() {
- Pql2Compiler.ENABLE_PINOT_QUERY = true;
- Pql2Compiler.VALIDATE_CONVERTER = true;
- Pql2Compiler.FAIL_ON_CONVERSION_ERROR = true;
+ Pql2Compiler.setEnablePinotQuery(true);
+ Pql2Compiler.setValidateConverter(true);
+ Pql2Compiler.setFailOnConversionError(true);
}
@AfterClass
public void tearDown() {
- Pql2Compiler.ENABLE_PINOT_QUERY = false;
- Pql2Compiler.VALIDATE_CONVERTER = false;
- Pql2Compiler.FAIL_ON_CONVERSION_ERROR = false;
+ Pql2Compiler.setEnablePinotQuery(false);
+ Pql2Compiler.setValidateConverter(false);
+ Pql2Compiler.setFailOnConversionError(false);
}
@Test
public void testQuotedStrings() {
- BrokerRequest brokerRequest =
- COMPILER.compileToBrokerRequest("select * from vegetables where origin = 'Martha''s Vineyard'");
+ BrokerRequest brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where origin = 'Martha''s Vineyard'");
Assert.assertEquals(brokerRequest.getFilterQuery().getValue().get(0), "Martha's Vineyard");
// Test PinotQuery
Assert.assertEquals(
- brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral()
- .getStringValue(), "Martha's Vineyard");
+ brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getStringValue(),
+ "Martha's Vineyard");
brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where origin = 'Martha\"\"s Vineyard'");
Assert.assertEquals(brokerRequest.getFilterQuery().getValue().get(0), "Martha\"\"s Vineyard");
// Test PinotQuery
Assert.assertEquals(
- brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral()
- .getStringValue(), "Martha\"\"s Vineyard");
+ brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getStringValue(),
+ "Martha\"\"s Vineyard");
brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where origin = \"Martha\"\"s Vineyard\"");
Assert.assertEquals(brokerRequest.getFilterQuery().getValue().get(0), "Martha\"s Vineyard");
// Test PinotQuery
Assert.assertEquals(
- brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral()
- .getStringValue(), "Martha\"s Vineyard");
+ brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getStringValue(),
+ "Martha\"s Vineyard");
brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where origin = \"Martha''s Vineyard\"");
Assert.assertEquals(brokerRequest.getFilterQuery().getValue().get(0), "Martha''s Vineyard");
// Test PinotQuery
Assert.assertEquals(
- brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral()
- .getStringValue(), "Martha''s Vineyard");
+ brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getStringValue(),
+ "Martha''s Vineyard");
}
@Test
@@ -221,8 +220,8 @@ public class Pql2CompilerTest {
Assert.assertEquals(brokerRequest.getPinotQuery().getGroupByList().get(0).getIdentifier().getName(), "group_city");
Assert.assertEquals(brokerRequest.getOrderBy().get(0).getColumn(), "sum(rsvp_count)");
Assert.assertEquals(
- brokerRequest.getPinotQuery().getOrderByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
- .getName(), "sum(rsvp_count)");
+ brokerRequest.getPinotQuery().getOrderByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
+ "sum(rsvp_count)");
}
@Test
@@ -246,8 +245,7 @@ public class Pql2CompilerTest {
} catch (Pql2CompilationException e) {
// Expected
Assert.assertTrue(e.getMessage().startsWith("1:30: "),
- "Compilation exception should contain line and character for error message. Error message is " + e
- .getMessage());
+ "Compilation exception should contain line and character for error message. Error message is " + e.getMessage());
return;
}
@@ -256,23 +254,20 @@ public class Pql2CompilerTest {
@Test
public void testCStyleInequalityOperator() {
- BrokerRequest brokerRequest =
- COMPILER.compileToBrokerRequest("select * from vegetables where name != 'Brussels sprouts'");
+ BrokerRequest brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where name != 'Brussels sprouts'");
Assert.assertEquals(brokerRequest.getFilterQuery().getOperator(), FilterOperator.NOT);
}
@Test
public void testQueryOptions() {
- BrokerRequest brokerRequest =
- COMPILER.compileToBrokerRequest("select * from vegetables where name != 'Brussels sprouts'");
+ BrokerRequest brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where name != 'Brussels sprouts'");
Assert.assertEquals(brokerRequest.getQueryOptionsSize(), 0);
Assert.assertNull(brokerRequest.getQueryOptions());
// Test PinotQuery
Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptionsSize(), 0);
Assert.assertNull(brokerRequest.getPinotQuery().getQueryOptions());
- brokerRequest = COMPILER
- .compileToBrokerRequest("select * from vegetables where name != 'Brussels sprouts' OPTION (delicious=yes)");
+ brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where name != 'Brussels sprouts' OPTION (delicious=yes)");
Assert.assertEquals(brokerRequest.getQueryOptionsSize(), 1);
Assert.assertTrue(brokerRequest.getQueryOptions().containsKey("delicious"));
Assert.assertEquals(brokerRequest.getQueryOptions().get("delicious"), "yes");
@@ -281,8 +276,8 @@ public class Pql2CompilerTest {
Assert.assertTrue(brokerRequest.getPinotQuery().getQueryOptions().containsKey("delicious"));
Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptions().get("delicious"), "yes");
- brokerRequest = COMPILER.compileToBrokerRequest(
- "select * from vegetables where name != 'Brussels sprouts' OPTION (delicious=yes, foo=1234, bar='potato')");
+ brokerRequest = COMPILER
+ .compileToBrokerRequest("select * from vegetables where name != 'Brussels sprouts' OPTION (delicious=yes, foo=1234, bar='potato')");
Assert.assertEquals(brokerRequest.getQueryOptionsSize(), 3);
Assert.assertTrue(brokerRequest.getQueryOptions().containsKey("delicious"));
Assert.assertEquals(brokerRequest.getQueryOptions().get("delicious"), "yes");
@@ -296,7 +291,7 @@ public class Pql2CompilerTest {
Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptions().get("bar"), "potato");
brokerRequest = COMPILER.compileToBrokerRequest(
- "select * from vegetables where name != 'Brussels sprouts' OPTION (delicious=yes) option(foo=1234) option(bar='potato')");
+ "select * from vegetables where name != 'Brussels sprouts' OPTION (delicious=yes) option(foo=1234) option" + "(bar='potato')");
Assert.assertEquals(brokerRequest.getQueryOptionsSize(), 3);
Assert.assertTrue(brokerRequest.getQueryOptions().containsKey("delicious"));
Assert.assertEquals(brokerRequest.getQueryOptions().get("delicious"), "yes");
@@ -316,19 +311,17 @@ public class Pql2CompilerTest {
Assert.assertEquals(expTree.getExpressionType(), TransformExpressionTree.ExpressionType.IDENTIFIER);
Assert.assertEquals(expTree.getValue(), "a.b.c");
- BrokerRequest brokerRequest = COMPILER.compileToBrokerRequest(
- "select avg(`attributes.age`) as `avg_age` from `person` group by `attributes.address_city`");
+ BrokerRequest brokerRequest =
+ COMPILER.compileToBrokerRequest("select avg(`attributes.age`) as `avg_age` from `person` group by `attributes.address_city`");
Assert.assertEquals(brokerRequest.getAggregationsInfo().get(0).getExpressions().get(0), "attributes.age");
- Assert.assertEquals(brokerRequest.getGroupBy().getExpressions(),
- Collections.singletonList("attributes.address_city"));
+ Assert.assertEquals(brokerRequest.getGroupBy().getExpressions(), Collections.singletonList("attributes.address_city"));
// Test PinotQuery
- Assert.assertEquals(
- brokerRequest.getPinotQuery().getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
- .getName(), "attributes.age");
- Assert.assertEquals(brokerRequest.getPinotQuery().getGroupByList().get(0).getIdentifier().getName(),
- "attributes.address_city");
+ Assert
+ .assertEquals(brokerRequest.getPinotQuery().getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
+ "attributes.age");
+ Assert.assertEquals(brokerRequest.getPinotQuery().getGroupByList().get(0).getIdentifier().getName(), "attributes.address_city");
}
@Test
@@ -337,8 +330,7 @@ public class Pql2CompilerTest {
assertCompilationFails("SELECT 'foo' FROM table");
// Allow string literal column in aggregation and group-by query
- BrokerRequest brokerRequest =
- COMPILER.compileToBrokerRequest("SELECT SUM('foo'), MAX(\"bar\") FROM table GROUP BY 'foo', \"bar\"");
+ BrokerRequest brokerRequest = COMPILER.compileToBrokerRequest("SELECT SUM('foo'), MAX(\"bar\") FROM table GROUP BY 'foo', \"bar\"");
List<AggregationInfo> aggregationInfos = brokerRequest.getAggregationsInfo();
Assert.assertEquals(aggregationInfos.size(), 2);
Assert.assertEquals(aggregationInfos.get(0).getExpressions().get(0), "foo");
@@ -351,18 +343,15 @@ public class Pql2CompilerTest {
// Test PinotQuery
List<Expression> selectFunctionList = brokerRequest.getPinotQuery().getSelectList();
Assert.assertEquals(selectFunctionList.size(), 2);
- Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getLiteral().getStringValue(),
- "foo");
- Assert.assertEquals(selectFunctionList.get(1).getFunctionCall().getOperands().get(0).getLiteral().getStringValue(),
- "bar");
+ Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getLiteral().getStringValue(), "foo");
+ Assert.assertEquals(selectFunctionList.get(1).getFunctionCall().getOperands().get(0).getLiteral().getStringValue(), "bar");
List<Expression> groupbyList = brokerRequest.getPinotQuery().getGroupByList();
Assert.assertEquals(groupbyList.size(), 2);
Assert.assertEquals(groupbyList.get(0).getLiteral().getStringValue(), "foo");
Assert.assertEquals(groupbyList.get(1).getLiteral().getStringValue(), "bar");
// For UDF, string literal won't be treated as column but as LITERAL
- brokerRequest =
- COMPILER.compileToBrokerRequest("SELECT SUM(ADD(foo, 'bar')) FROM table GROUP BY SUB(\"foo\", bar)");
+ brokerRequest = COMPILER.compileToBrokerRequest("SELECT SUM(ADD(foo, 'bar')) FROM table GROUP BY SUB(\"foo\", bar)");
aggregationInfos = brokerRequest.getAggregationsInfo();
Assert.assertEquals(aggregationInfos.size(), 1);
Assert.assertEquals(aggregationInfos.get(0).getExpressions().get(0), "add(foo,'bar')");
@@ -376,17 +365,13 @@ public class Pql2CompilerTest {
Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperator(), "SUM");
Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().size(), 1);
- Assert
- .assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "ADD");
- Assert.assertEquals(
- selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().size(), 2);
- Assert.assertEquals(
- selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "foo");
+ Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "ADD");
+ Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().size(), 2);
Assert.assertEquals(
- selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getLiteral().getStringValue(), "bar");
+ selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
+ "foo");
+ Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getLiteral()
+ .getStringValue(), "bar");
groupbyList = brokerRequest.getPinotQuery().getGroupByList();
Assert.assertEquals(groupbyList.size(), 1);
Assert.assertEquals(groupbyList.get(0).getFunctionCall().getOperator(), "SUB");
@@ -401,17 +386,16 @@ public class Pql2CompilerTest {
COMPILER.compileToBrokerRequest("Select * from T where a IN (1,2,2,3,4)");
COMPILER.compileToBrokerRequest("SELECT MIN(div(DaysSinceEpoch,2)) FROM mytable");
- COMPILER.compileToBrokerRequest(
- "SELECT SUM(DepDelayMinutes), SUM(ArrDel15), SUM(DepDelay), SUM(DepDel15) FROM myStarTable WHERE Carrier IN ('UA', 'WN', 'FL', 'F9') AND Carrier NOT IN ('EV', 'AS', 'FL') AND DayofMonth > 5 AND DayofMonth <= 17 AND Diverted > 0 AND OriginCityName > 'Detroit, MI' GROUP BY CRSDepTime");
+ COMPILER.compileToBrokerRequest("SELECT SUM(DepDelayMinutes), SUM(ArrDel15), SUM(DepDelay), SUM(DepDel15) FROM myStarTable"
+ + " WHERE Carrier IN ('UA', 'WN', 'FL', 'F9') AND Carrier NOT IN ('EV', 'AS', 'FL') AND"
+ + " DayofMonth > 5 AND DayofMonth <= 17 AND Diverted > 0 AND OriginCityName > 'Detroit, MI'" + " GROUP BY CRSDepTime");
COMPILER.compileToBrokerRequest("Select * from T where a > 1 and a < 10");
COMPILER.compileToBrokerRequest("Select * from T where a between 1 and 10");
- BrokerRequest brokerRequest =
- COMPILER.compileToBrokerRequest("select * from vegetables where name != 'Brussels sprouts'");
- Assert.assertEquals(brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperator(),
- FilterKind.NOT_EQUALS.name());
- final BufferedReader br = new BufferedReader(
- new InputStreamReader(Pql2CompilerTest.class.getClassLoader().getResourceAsStream("pql_queries.list")));
+ BrokerRequest brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where name != 'Brussels sprouts'");
+ Assert.assertEquals(brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperator(), FilterKind.NOT_EQUALS.name());
+ final BufferedReader br =
+ new BufferedReader(new InputStreamReader(Pql2CompilerTest.class.getClassLoader().getResourceAsStream("pql_queries.list")));
String pql;
int seqId = 0;
while ((pql = br.readLine()) != null) {
@@ -434,26 +418,22 @@ public class Pql2CompilerTest {
testOrderBy("select * from table order by d2, d3 desc", Arrays.asList("d2", "d3"), Arrays.asList(true, false));
- testOrderBy("select * from table order by d2 asc, d2 desc", Collections.singletonList("d2"),
- Collections.singletonList(true));
+ testOrderBy("select * from table order by d2 asc, d2 desc", Collections.singletonList("d2"), Collections.singletonList(true));
- testOrderBy("select * from table order by d2, d2 desc", Collections.singletonList("d2"),
- Collections.singletonList(true));
+ testOrderBy("select * from table order by d2, d2 desc", Collections.singletonList("d2"), Collections.singletonList(true));
testOrderBy("select * from table order by d2, add(d3, 1) desc, add(d3, 1)", Arrays.asList("d2", "add(d3,'1')"),
Arrays.asList(true, false));
- testOrderBy("select sum(m1) from table group by d2, d3 order by d2 desc, d3", Arrays.asList("d2", "d3"),
- Arrays.asList(false, true));
+ testOrderBy("select sum(m1) from table group by d2, d3 order by d2 desc, d3", Arrays.asList("d2", "d3"), Arrays.asList(false, true));
testOrderBy("select sum(m1) from table group by d2, d3 order by sum(m1), d3 desc", Arrays.asList("sum(m1)", "d3"),
Arrays.asList(true, false));
- testOrderBy("select sum(m1), sum(m2) from table group by d1 order by sum(m1) desc, sum(m2) asc",
- Arrays.asList("sum(m1)", "sum(m2)"), Arrays.asList(false, true));
+ testOrderBy("select sum(m1), sum(m2) from table group by d1 order by sum(m1) desc, sum(m2) asc", Arrays.asList("sum(m1)", "sum(m2)"),
+ Arrays.asList(false, true));
- testOrderBy(
- "select sum(m1), max(foo(bar(x, y), z)) from table group by d1 order by sum(m1) desc, max(foo(bar(x, y), z))",
+ testOrderBy("select sum(m1), max(foo(bar(x, y), z)) from table group by d1 order by sum(m1) desc, max(foo(bar(x, y), z))",
Arrays.asList("sum(m1)", "max(foo(bar(x,y),z))"), Arrays.asList(false, true));
testOrderBy("select sum(m1) from table group by foo(bar(x, y), z) order by sum(m1) desc, foo(bar(x, y), z) asc",
diff --git a/pinot-common/src/test/java/org/apache/pinot/request/BrokerRequestSerializationTest.java b/pinot-common/src/test/java/org/apache/pinot/request/BrokerRequestSerializationTest.java
index a251626..b90ebe6 100644
--- a/pinot-common/src/test/java/org/apache/pinot/request/BrokerRequestSerializationTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/request/BrokerRequestSerializationTest.java
@@ -43,6 +43,8 @@ import org.testng.annotations.Test;
public class BrokerRequestSerializationTest {
+ private BrokerRequestSerializationTest() {
+ }
@Test
public static void testSerialization()
@@ -168,14 +170,12 @@ public class BrokerRequestSerializationTest {
Expression filterExpr1 = RequestUtils.getFunctionExpression(FilterOperator.EQUALITY.name());
filterExpr1.getFunctionCall().addToOperands(RequestUtils.createIdentifierExpression("dummy1"));
- filterExpr1.getFunctionCall()
- .addToOperands(RequestUtils.createLiteralExpression(new StringLiteralAstNode("dummy1")));
+ filterExpr1.getFunctionCall().addToOperands(RequestUtils.createLiteralExpression(new StringLiteralAstNode("dummy1")));
filter.getFunctionCall().addToOperands(filterExpr1);
Expression filterExpr2 = RequestUtils.getFunctionExpression(FilterOperator.EQUALITY.name());
filterExpr2.getFunctionCall().addToOperands(RequestUtils.createIdentifierExpression("dummy2"));
- filterExpr2.getFunctionCall()
- .addToOperands(RequestUtils.createLiteralExpression(new StringLiteralAstNode("dummy2")));
+ filterExpr2.getFunctionCall().addToOperands(RequestUtils.createLiteralExpression(new StringLiteralAstNode("dummy2")));
filter.getFunctionCall().addToOperands(filterExpr2);
pinotQuery.setFilterExpression(filter);
diff --git a/pinot-common/src/test/java/org/apache/pinot/request/BrokerResponseNativeTest.java b/pinot-common/src/test/java/org/apache/pinot/request/BrokerResponseNativeTest.java
index 1b4946f..5548b1d 100644
--- a/pinot-common/src/test/java/org/apache/pinot/request/BrokerResponseNativeTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/request/BrokerResponseNativeTest.java
@@ -46,10 +46,9 @@ public class BrokerResponseNativeTest {
BrokerResponseNative expected = BrokerResponseNative.NO_TABLE_RESULT;
String brokerString = expected.toJsonString();
BrokerResponseNative actual = BrokerResponseNative.fromJsonString(brokerString);
- Assert.assertEquals(actual.getProcessingExceptions().get(0).getErrorCode(),
- QueryException.BROKER_RESOURCE_MISSING_ERROR.getErrorCode());
- Assert.assertEquals(actual.getProcessingExceptions().get(0).getMessage(),
- QueryException.BROKER_RESOURCE_MISSING_ERROR.getMessage());
+ Assert
+ .assertEquals(actual.getProcessingExceptions().get(0).getErrorCode(), QueryException.BROKER_RESOURCE_MISSING_ERROR.getErrorCode());
+ Assert.assertEquals(actual.getProcessingExceptions().get(0).getMessage(), QueryException.BROKER_RESOURCE_MISSING_ERROR.getMessage());
}
@Test
diff --git a/pinot-common/src/test/java/org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java b/pinot-common/src/test/java/org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java
index c7dc63b..205e4b4 100644
--- a/pinot-common/src/test/java/org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java
@@ -48,16 +48,15 @@ import org.testng.annotations.Test;
* Some tests for the SQL compiler.
*/
public class CalciteSqlCompilerTest {
- private static final PinotQuery2BrokerRequestConverter BROKER_REQUEST_CONVERTER =
- new PinotQuery2BrokerRequestConverter();
+ private static final PinotQuery2BrokerRequestConverter BROKER_REQUEST_CONVERTER = new PinotQuery2BrokerRequestConverter();
private static final long ONE_HOUR_IN_MS = TimeUnit.HOURS.toMillis(1);
@Test
public void testCaseWhenStatements() {
PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(
"SELECT OrderID, Quantity,\n" + "CASE\n" + " WHEN Quantity > 30 THEN 'The quantity is greater than 30'\n"
- + " WHEN Quantity = 30 THEN 'The quantity is 30'\n" + " ELSE 'The quantity is under 30'\n"
- + "END AS QuantityText\n" + "FROM OrderDetails");
+ + " WHEN Quantity = 30 THEN 'The quantity is 30'\n" + " ELSE 'The quantity is under 30'\n" + "END AS QuantityText\n"
+ + "FROM OrderDetails");
Assert.assertEquals(pinotQuery.getSelectList().get(0).getIdentifier().getName(), "OrderID");
Assert.assertEquals(pinotQuery.getSelectList().get(1).getIdentifier().getName(), "Quantity");
Function asFunc = pinotQuery.getSelectList().get(2).getFunctionCall();
@@ -110,40 +109,35 @@ public class CalciteSqlCompilerTest {
public void testInvalidCaseWhenStatements() {
// Not support Aggregation functions in case statements.
try {
- CalciteSqlParser.compileToPinotQuery("SELECT OrderID, Quantity,\n" + "CASE\n"
- + " WHEN sum(Quantity) > 30 THEN 'The quantity is greater than 30'\n"
- + " WHEN sum(Quantity) = 30 THEN 'The quantity is 30'\n" + " ELSE 'The quantity is under 30'\n"
- + "END AS QuantityText\n" + "FROM OrderDetails");
+ CalciteSqlParser.compileToPinotQuery(
+ "SELECT OrderID, Quantity,\n" + "CASE\n" + " WHEN sum(Quantity) > 30 THEN 'The quantity is greater than 30'\n"
+ + " WHEN sum(Quantity) = 30 THEN 'The quantity is 30'\n" + " ELSE 'The quantity is under 30'\n"
+ + "END AS QuantityText\n" + "FROM OrderDetails");
} catch (SqlCompilationException e) {
- Assert.assertEquals(e.getMessage(),
- "Aggregation functions inside WHEN Clause is not supported - SUM(`Quantity`) > 30");
+ Assert.assertEquals(e.getMessage(), "Aggregation functions inside WHEN Clause is not supported - SUM(`Quantity`) > 30");
throw e;
}
}
@Test
public void testQuotedStrings() {
- PinotQuery pinotQuery =
- CalciteSqlParser.compileToPinotQuery("select * from vegetables where origin = 'Martha''s Vineyard'");
- Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getStringValue(),
+ PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where origin = 'Martha''s Vineyard'");
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getStringValue(),
"Martha's Vineyard");
pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where origin = 'Martha\"\"s Vineyard'");
- Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getStringValue(),
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getStringValue(),
"Martha\"\"s Vineyard");
- pinotQuery =
- CalciteSqlParser.compileToPinotQuery("select * from vegetables where origin = \"Martha\"\"s Vineyard\"");
+ pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where origin = \"Martha\"\"s Vineyard\"");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getIdentifier().getName(), "Martha\"s Vineyard");
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier()
+ .getName(), "Martha\"s Vineyard");
pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where origin = \"Martha''s Vineyard\"");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getIdentifier().getName(), "Martha''s Vineyard");
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier()
+ .getName(), "Martha''s Vineyard");
}
@Test
@@ -195,133 +189,105 @@ public class CalciteSqlCompilerTest {
Function func = pinotQuery.getFilterExpression().getFunctionCall();
Assert.assertEquals(func.getOperator(), SqlKind.GREATER_THAN.name());
Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperator(), "MINUS");
- Assert
- .assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "a");
- Assert
- .assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "b");
+ Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "a");
+ Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "b");
Assert.assertEquals(func.getOperands().get(1).getLiteral().getLongValue(), 0L);
pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where 0 < a-b");
func = pinotQuery.getFilterExpression().getFunctionCall();
Assert.assertEquals(func.getOperator(), SqlKind.GREATER_THAN.name());
Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperator(), "MINUS");
- Assert
- .assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "a");
- Assert
- .assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "b");
+ Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "a");
+ Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "b");
Assert.assertEquals(func.getOperands().get(1).getLiteral().getLongValue(), 0L);
pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where b < 100 + c");
func = pinotQuery.getFilterExpression().getFunctionCall();
Assert.assertEquals(func.getOperator(), SqlKind.LESS_THAN.name());
Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperator(), "MINUS");
- Assert
- .assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "b");
- Assert
- .assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperator(),
- "PLUS");
+ Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "b");
+ Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperator(), "PLUS");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0)
- .getLiteral().getLongValue(), 100L);
+ func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0).getLiteral().getLongValue(),
+ 100L);
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(1)
- .getIdentifier().getName(), "c");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(1).getIdentifier().getName(),
+ "c");
Assert.assertEquals(func.getOperands().get(1).getLiteral().getLongValue(), 0L);
pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where b -(100+c)< 0");
func = pinotQuery.getFilterExpression().getFunctionCall();
Assert.assertEquals(func.getOperator(), SqlKind.LESS_THAN.name());
Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperator(), "MINUS");
- Assert
- .assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "b");
- Assert
- .assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperator(),
- "PLUS");
+ Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "b");
+ Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperator(), "PLUS");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0)
- .getLiteral().getLongValue(), 100L);
+ func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0).getLiteral().getLongValue(),
+ 100L);
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(1)
- .getIdentifier().getName(), "c");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(1).getIdentifier().getName(),
+ "c");
Assert.assertEquals(func.getOperands().get(1).getLiteral().getLongValue(), 0L);
- pinotQuery =
- CalciteSqlParser.compileToPinotQuery("select * from vegetables where foo1(bar1(a-b)) <= foo2(bar2(c+d))");
+ pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where foo1(bar1(a-b)) <= foo2(bar2(c+d))");
func = pinotQuery.getFilterExpression().getFunctionCall();
Assert.assertEquals(func.getOperator(), SqlKind.LESS_THAN_OR_EQUAL.name());
Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperator(), "MINUS");
- Assert
- .assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "FOO1");
- Assert
- .assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperator(),
- "FOO2");
+ Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "FOO1");
+ Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperator(), "FOO2");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperator(), "BAR1");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperator(), "BAR1");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperator(), "BAR2");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperator(), "BAR2");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "MINUS");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getFunctionCall().getOperator(), "MINUS");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "PLUS");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getFunctionCall().getOperator(), "PLUS");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
- "a");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "a");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(),
- "b");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "b");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
- "c");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "c");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(),
- "d");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "d");
Assert.assertEquals(func.getOperands().get(1).getLiteral().getLongValue(), 0L);
- pinotQuery =
- CalciteSqlParser.compileToPinotQuery("select * from vegetables where foo1(bar1(a-b)) - foo2(bar2(c+d)) <= 0");
+ pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where foo1(bar1(a-b)) - foo2(bar2(c+d)) <= 0");
func = pinotQuery.getFilterExpression().getFunctionCall();
Assert.assertEquals(func.getOperator(), SqlKind.LESS_THAN_OR_EQUAL.name());
Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperator(), "MINUS");
- Assert
- .assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "FOO1");
- Assert
- .assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperator(),
- "FOO2");
+ Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "FOO1");
+ Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperator(), "FOO2");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperator(), "BAR1");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperator(), "BAR1");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperator(), "BAR2");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperator(), "BAR2");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "MINUS");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getFunctionCall().getOperator(), "MINUS");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "PLUS");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getFunctionCall().getOperator(), "PLUS");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
- "a");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "a");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(),
- "b");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "b");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
- "c");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "c");
Assert.assertEquals(
- func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(),
- "d");
+ func.getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "d");
Assert.assertEquals(func.getOperands().get(1).getLiteral().getLongValue(), 0L);
pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where c >= 10");
@@ -362,8 +328,7 @@ public class CalciteSqlCompilerTest {
@Test
public void testBrokerConverter() {
- PinotQuery pinotQuery =
- CalciteSqlParser.compileToPinotQuery("select * from vegetables where g IN (12, 13, 15.2, 17)");
+ PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where g IN (12, 13, 15.2, 17)");
Function func = pinotQuery.getFilterExpression().getFunctionCall();
Assert.assertEquals(func.getOperator(), SqlKind.IN.name());
Assert.assertEquals(func.getOperands().get(0).getIdentifier().getName(), "g");
@@ -411,8 +376,8 @@ public class CalciteSqlCompilerTest {
@Test
public void testSelectAs() {
- PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(
- "select sum(A) as sum_A, count(B) as count_B from vegetables where g IN (12, 13, 15.2, 17)");
+ PinotQuery pinotQuery =
+ CalciteSqlParser.compileToPinotQuery("select sum(A) as sum_A, count(B) as count_B from vegetables where g IN (12, 13, 15.2, 17)");
Function func = pinotQuery.getFilterExpression().getFunctionCall();
Assert.assertEquals(func.getOperator(), SqlKind.IN.name());
Assert.assertEquals(func.getOperands().get(0).getIdentifier().getName(), "g");
@@ -456,8 +421,7 @@ public class CalciteSqlCompilerTest {
public void testLimitOffsets() {
PinotQuery pinotQuery;
try {
- pinotQuery =
- CalciteSqlParser.compileToPinotQuery("select a, b, c from meetupRsvp order by a, b, c limit 100 offset 200");
+ pinotQuery = CalciteSqlParser.compileToPinotQuery("select a, b, c from meetupRsvp order by a, b, c limit 100 offset 200");
} catch (SqlCompilationException e) {
throw e;
}
@@ -468,8 +432,7 @@ public class CalciteSqlCompilerTest {
Assert.assertEquals(200, pinotQuery.getOffset());
try {
- pinotQuery =
- CalciteSqlParser.compileToPinotQuery("select a, b, c from meetupRsvp order by a, b, c limit 200,100");
+ pinotQuery = CalciteSqlParser.compileToPinotQuery("select a, b, c from meetupRsvp order by a, b, c limit 200,100");
} catch (SqlCompilationException e) {
throw e;
}
@@ -486,7 +449,7 @@ public class CalciteSqlCompilerTest {
PinotQuery pinotQuery;
try {
pinotQuery = CalciteSqlParser.compileToPinotQuery(
- "select sum(rsvp_count), count(*), group_city from meetupRsvp group by group_city order by sum(rsvp_count) limit 10");
+ "select sum(rsvp_count), count(*), group_city from meetupRsvp group by group_city order by sum(rsvp_count) " + "limit 10");
} catch (SqlCompilationException e) {
throw e;
}
@@ -495,14 +458,12 @@ public class CalciteSqlCompilerTest {
Assert.assertTrue(pinotQuery.isSetLimit());
Assert.assertTrue(pinotQuery.isSetOrderByList());
Assert.assertEquals(pinotQuery.getOrderByList().get(0).getType(), ExpressionType.FUNCTION);
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "SUM");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "SUM");
Assert.assertEquals(10, pinotQuery.getLimit());
try {
- pinotQuery = CalciteSqlParser.compileToPinotQuery(
- "select sum(rsvp_count), count(*) from meetupRsvp group by group_city order by sum(rsvp_count) limit 10");
+ pinotQuery = CalciteSqlParser
+ .compileToPinotQuery("select sum(rsvp_count), count(*) from meetupRsvp group by group_city order by sum(rsvp_count) limit 10");
} catch (SqlCompilationException e) {
throw e;
}
@@ -511,14 +472,13 @@ public class CalciteSqlCompilerTest {
Assert.assertTrue(pinotQuery.isSetLimit());
Assert.assertTrue(pinotQuery.isSetOrderByList());
Assert.assertEquals(pinotQuery.getOrderByList().get(0).getType(), ExpressionType.FUNCTION);
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "SUM");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "SUM");
Assert.assertEquals(10, pinotQuery.getLimit());
try {
pinotQuery = CalciteSqlParser.compileToPinotQuery(
- "select group_city, sum(rsvp_count), count(*) from meetupRsvp group by group_city order by sum(rsvp_count), count(*) limit 10");
+ "select group_city, sum(rsvp_count), count(*) from meetupRsvp group by group_city order by sum(rsvp_count),"
+ + " count(*) limit 10");
} catch (SqlCompilationException e) {
throw e;
}
@@ -527,26 +487,21 @@ public class CalciteSqlCompilerTest {
Assert.assertTrue(pinotQuery.isSetLimit());
Assert.assertTrue(pinotQuery.isSetOrderByList());
Assert.assertEquals(pinotQuery.getOrderByList().get(0).getType(), ExpressionType.FUNCTION);
+ Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "SUM");
Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "SUM");
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "rsvp_count");
+ pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "rsvp_count");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "COUNT");
Assert.assertEquals(
- pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "COUNT");
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "*");
+ pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "*");
Assert.assertEquals(10, pinotQuery.getLimit());
// nested functions in group by
try {
- pinotQuery = CalciteSqlParser.compileToPinotQuery(
- "select concat(upper(playerName), lower(teamID), '-') playerTeam, "
- + "upper(league) leagueUpper, count(playerName) cnt from baseballStats group by playerTeam, lower(teamID), leagueUpper "
- + "having cnt > 1 order by cnt desc limit 10");
+ pinotQuery = CalciteSqlParser.compileToPinotQuery("select concat(upper(playerName), lower(teamID), '-') playerTeam, "
+ + "upper(league) leagueUpper, count(playerName) cnt from baseballStats group by playerTeam, lower" + "(teamID), leagueUpper "
+ + "having cnt > 1 order by cnt desc limit 10");
} catch (SqlCompilationException e) {
throw e;
}
@@ -555,9 +510,7 @@ public class CalciteSqlCompilerTest {
Assert.assertTrue(pinotQuery.isSetLimit());
Assert.assertTrue(pinotQuery.isSetOrderByList());
Assert.assertEquals(pinotQuery.getOrderByList().get(0).getType(), ExpressionType.FUNCTION);
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "COUNT");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "COUNT");
Assert.assertEquals(10, pinotQuery.getLimit());
}
@@ -610,8 +563,7 @@ public class CalciteSqlCompilerTest {
} catch (SqlCompilationException e) {
// Expected
Assert.assertTrue(e.getCause().getMessage().contains("at line 1, column 31."),
- "Compilation exception should contain line and character for error message. Error message is " + e
- .getMessage());
+ "Compilation exception should contain line and character for error message. Error message is " + e.getMessage());
return;
}
@@ -620,8 +572,7 @@ public class CalciteSqlCompilerTest {
@Test
public void testCStyleInequalityOperator() {
- PinotQuery pinotQuery =
- CalciteSqlParser.compileToPinotQuery("select * from vegetables where name <> 'Brussels sprouts'");
+ PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where name <> 'Brussels sprouts'");
Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperator(), "NOT_EQUALS");
pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where name != 'Brussels sprouts'");
@@ -630,19 +581,17 @@ public class CalciteSqlCompilerTest {
@Test
public void testQueryOptions() {
- PinotQuery pinotQuery =
- CalciteSqlParser.compileToPinotQuery("select * from vegetables where name <> 'Brussels sprouts'");
+ PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where name <> 'Brussels sprouts'");
Assert.assertEquals(pinotQuery.getQueryOptionsSize(), 0);
Assert.assertNull(pinotQuery.getQueryOptions());
- pinotQuery = CalciteSqlParser
- .compileToPinotQuery("select * from vegetables where name <> 'Brussels sprouts' OPTION (delicious=yes)");
+ pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from vegetables where name <> 'Brussels sprouts' OPTION (delicious=yes)");
Assert.assertEquals(pinotQuery.getQueryOptionsSize(), 1);
Assert.assertTrue(pinotQuery.getQueryOptions().containsKey("delicious"));
Assert.assertEquals(pinotQuery.getQueryOptions().get("delicious"), "yes");
- pinotQuery = CalciteSqlParser.compileToPinotQuery(
- "select * from vegetables where name <> 'Brussels sprouts' OPTION (delicious=yes, foo=1234, bar='potato')");
+ pinotQuery = CalciteSqlParser
+ .compileToPinotQuery("select * from vegetables where name <> 'Brussels sprouts' OPTION (delicious=yes, foo=1234, bar='potato')");
Assert.assertEquals(pinotQuery.getQueryOptionsSize(), 3);
Assert.assertTrue(pinotQuery.getQueryOptions().containsKey("delicious"));
Assert.assertEquals(pinotQuery.getQueryOptions().get("delicious"), "yes");
@@ -650,7 +599,7 @@ public class CalciteSqlCompilerTest {
Assert.assertEquals(pinotQuery.getQueryOptions().get("bar"), "'potato'");
pinotQuery = CalciteSqlParser.compileToPinotQuery(
- "select * from vegetables where name <> 'Brussels sprouts' OPTION (delicious=yes) option(foo=1234) option(bar='potato')");
+ "select * from vegetables where name <> 'Brussels sprouts' OPTION (delicious=yes) option(foo=1234) option" + "(bar='potato')");
Assert.assertEquals(pinotQuery.getQueryOptionsSize(), 3);
Assert.assertTrue(pinotQuery.getQueryOptions().containsKey("delicious"));
Assert.assertEquals(pinotQuery.getQueryOptions().get("delicious"), "yes");
@@ -660,11 +609,11 @@ public class CalciteSqlCompilerTest {
@Test
public void testIdentifierQuoteCharacter() {
- PinotQuery pinotQuery = CalciteSqlParser
- .compileToPinotQuery("select avg(attributes.age) as avg_age from person group by attributes.address_city");
+ PinotQuery pinotQuery =
+ CalciteSqlParser.compileToPinotQuery("select avg(attributes.age) as avg_age from person group by attributes.address_city");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "attributes.age");
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "attributes.age");
Assert.assertEquals(pinotQuery.getGroupByList().get(0).getIdentifier().getName(), "attributes.address_city");
}
@@ -674,37 +623,29 @@ public class CalciteSqlCompilerTest {
assertCompilationFails("SELECT 'foo' FROM table");
// Allow string literal column in aggregation and group-by query
- PinotQuery pinotQuery =
- CalciteSqlParser.compileToPinotQuery("SELECT SUM('foo'), MAX(bar) FROM myTable GROUP BY 'foo', bar");
+ PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery("SELECT SUM('foo'), MAX(bar) FROM myTable GROUP BY 'foo', bar");
List<Expression> selectFunctionList = pinotQuery.getSelectList();
Assert.assertEquals(selectFunctionList.size(), 2);
- Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getLiteral().getStringValue(),
- "foo");
- Assert.assertEquals(selectFunctionList.get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
- "bar");
+ Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getLiteral().getStringValue(), "foo");
+ Assert.assertEquals(selectFunctionList.get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
List<Expression> groupbyList = pinotQuery.getGroupByList();
Assert.assertEquals(groupbyList.size(), 2);
Assert.assertEquals(groupbyList.get(0).getLiteral().getStringValue(), "foo");
Assert.assertEquals(groupbyList.get(1).getIdentifier().getName(), "bar");
// For UDF, string literal won't be treated as column but as LITERAL
- pinotQuery = CalciteSqlParser
- .compileToPinotQuery("SELECT SUM(ADD(foo, 'bar')) FROM myTable GROUP BY sub(foo, bar), SUB(BAR, FOO)");
+ pinotQuery = CalciteSqlParser.compileToPinotQuery("SELECT SUM(ADD(foo, 'bar')) FROM myTable GROUP BY sub(foo, bar), SUB(BAR, FOO)");
selectFunctionList = pinotQuery.getSelectList();
Assert.assertEquals(selectFunctionList.size(), 1);
Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperator(), "SUM");
Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().size(), 1);
- Assert
- .assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "ADD");
- Assert.assertEquals(
- selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().size(), 2);
- Assert.assertEquals(
- selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "foo");
+ Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "ADD");
+ Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().size(), 2);
Assert.assertEquals(
- selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getLiteral().getStringValue(), "bar");
+ selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
+ "foo");
+ Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getLiteral()
+ .getStringValue(), "bar");
groupbyList = pinotQuery.getGroupByList();
Assert.assertEquals(groupbyList.size(), 2);
Assert.assertEquals(groupbyList.get(0).getFunctionCall().getOperator(), "SUB");
@@ -720,82 +661,66 @@ public class CalciteSqlCompilerTest {
@Test
public void testFilterUdf() {
- PinotQuery pinotQuery =
- CalciteSqlParser.compileToPinotQuery("select count(*) from baseballStats where DIV(numberOfGames,10) = 100");
+ PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery("select count(*) from baseballStats where DIV(numberOfGames,10) = 100");
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "COUNT");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "*");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "*");
Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperator(), "EQUALS");
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "DIV");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "DIV");
- Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "numberOfGames");
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "numberOfGames");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getLiteral().getLongValue(), 10);
- Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 100);
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getLiteral()
+ .getLongValue(), 10);
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 100);
- pinotQuery = CalciteSqlParser.compileToPinotQuery(
- "SELECT count(*) FROM mytable WHERE timeConvert(DaysSinceEpoch,'DAYS','SECONDS') = 1394323200");
+ pinotQuery = CalciteSqlParser
+ .compileToPinotQuery("SELECT count(*) FROM mytable WHERE timeConvert(DaysSinceEpoch,'DAYS','SECONDS') = 1394323200");
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "COUNT");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "*");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "*");
Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperator(), "EQUALS");
- Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
"TIMECONVERT");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "DaysSinceEpoch");
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "DaysSinceEpoch");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getLiteral().getStringValue(), "DAYS");
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getLiteral()
+ .getStringValue(), "DAYS");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(2)
- .getLiteral().getStringValue(), "SECONDS");
- Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getLongValue(),
- 1394323200);
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(2).getLiteral()
+ .getStringValue(), "SECONDS");
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 1394323200);
}
@Test
public void testSelectionTransformFunction() {
- PinotQuery pinotQuery = CalciteSqlParser
- .compileToPinotQuery(" select mapKey(mapField,k1) from baseballStats where mapKey(mapField,k1) = 'v1'");
+ PinotQuery pinotQuery =
+ CalciteSqlParser.compileToPinotQuery(" select mapKey(mapField,k1) from baseballStats where mapKey(mapField,k1) = 'v1'");
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "MAPKEY");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "mapField");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "k1");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "mapField");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "k1");
Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperator(), "EQUALS");
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "MAPKEY");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "MAPKEY");
- Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "mapField");
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "mapField");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getIdentifier().getName(), "k1");
- Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getStringValue(), "v1");
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier()
+ .getName(), "k1");
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getStringValue(), "v1");
}
@Test
public void testTimeTransformFunction() {
- PinotQuery pinotQuery =
- CalciteSqlParser.compileToPinotQuery(" select hour(ts), d1, sum(m1) from baseballStats group by hour(ts), d1");
+ PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(" select hour(ts), d1, sum(m1) from baseballStats group by hour(ts), d1");
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "HOUR");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "ts");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "ts");
Assert.assertEquals(pinotQuery.getSelectList().get(1).getIdentifier().getName(), "d1");
Assert.assertEquals(pinotQuery.getSelectList().get(2).getFunctionCall().getOperator(), "SUM");
Assert.assertEquals(pinotQuery.getGroupByList().get(0).getFunctionCall().getOperator(), "HOUR");
- Assert.assertEquals(
- pinotQuery.getGroupByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "ts");
+ Assert.assertEquals(pinotQuery.getGroupByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "ts");
Assert.assertEquals(pinotQuery.getGroupByList().get(1).getIdentifier().getName(), "d1");
}
@@ -930,8 +855,7 @@ public class CalciteSqlCompilerTest {
Assert.fail("Query should have failed compilation");
} catch (Exception e) {
Assert.assertTrue(e instanceof SqlCompilationException);
- Assert.assertTrue(
- e.getMessage().contains("Syntax error: Use of DISTINCT with aggregation functions is not supported"));
+ Assert.assertTrue(e.getMessage().contains("Syntax error: Use of DISTINCT with aggregation functions is not supported"));
}
// same reason as above
@@ -941,8 +865,7 @@ public class CalciteSqlCompilerTest {
Assert.fail("Query should have failed compilation");
} catch (Exception e) {
Assert.assertTrue(e instanceof SqlCompilationException);
- Assert.assertTrue(
- e.getMessage().contains("Syntax error: Use of DISTINCT with aggregation functions is not supported"));
+ Assert.assertTrue(e.getMessage().contains("Syntax error: Use of DISTINCT with aggregation functions is not supported"));
}
// Pinot currently does not support DISTINCT * syntax
@@ -953,7 +876,7 @@ public class CalciteSqlCompilerTest {
} catch (Exception e) {
Assert.assertTrue(e instanceof SqlCompilationException);
Assert.assertTrue(e.getMessage().contains(
- "Syntax error: Pinot currently does not support DISTINCT with *. Please specify each column name after DISTINCT keyword"));
+ "Syntax error: Pinot currently does not support DISTINCT with *. Please specify each column name after " + "DISTINCT keyword"));
}
// Pinot currently does not support DISTINCT * syntax
@@ -964,7 +887,7 @@ public class CalciteSqlCompilerTest {
} catch (Exception e) {
Assert.assertTrue(e instanceof SqlCompilationException);
Assert.assertTrue(e.getMessage().contains(
- "Syntax error: Pinot currently does not support DISTINCT with *. Please specify each column name after DISTINCT keyword"));
+ "Syntax error: Pinot currently does not support DISTINCT with *. Please specify each column name after " + "DISTINCT keyword"));
}
// Pinot currently does not support GROUP BY with DISTINCT
@@ -1059,8 +982,7 @@ public class CalciteSqlCompilerTest {
Assert.assertEquals(aggregationInfos.size(), 1);
aggregationInfo = aggregationInfos.get(0);
Assert.assertEquals(aggregationInfo.getAggregationType(), AggregationFunctionType.DISTINCT.getName());
- Assert.assertEquals(aggregationInfo.getExpressions(),
- Arrays.asList("add(div(col1,col2),mul(col3,col4))", "sub(col3,col4)"));
+ Assert.assertEquals(aggregationInfo.getExpressions(), Arrays.asList("add(div(col1,col2),mul(col3,col4))", "sub(col3,col4)"));
// multi-column distinct with multiple transform columns and additional identifiers
sql = "SELECT DISTINCT add(div(col1, col2), mul(col3, col4)), sub(col3, col4), col5, col6 FROM foo";
@@ -1127,16 +1049,16 @@ public class CalciteSqlCompilerTest {
@Test
public void testQueryValidation() {
// Valid: Selection fields are part of group by identifiers.
- String sql =
- "select group_country, sum(rsvp_count), count(*) from meetupRsvp group by group_city, group_country ORDER BY sum(rsvp_count), count(*) limit 50";
+ String sql = "select group_country, sum(rsvp_count), count(*) from meetupRsvp group by group_city, group_country ORDER BY "
+ + "sum(rsvp_count), count(*) limit 50";
PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(sql);
Assert.assertEquals(pinotQuery.getGroupByListSize(), 2);
Assert.assertEquals(pinotQuery.getSelectListSize(), 3);
// Invalid: Selection field 'group_city' is not part of group by identifiers.
try {
- sql =
- "select group_city, group_country, sum(rsvp_count), count(*) from meetupRsvp group by group_country ORDER BY sum(rsvp_count), count(*) limit 50";
+ sql = "select group_city, group_country, sum(rsvp_count), count(*) from meetupRsvp group by group_country ORDER "
+ + "BY sum(rsvp_count), count(*) limit 50";
CalciteSqlParser.compileToPinotQuery(sql);
Assert.fail("Query should have failed compilation");
} catch (Exception e) {
@@ -1145,16 +1067,16 @@ public class CalciteSqlCompilerTest {
}
// Valid groupBy non-aggregate function should pass.
- sql =
- "select dateConvert(secondsSinceEpoch), sum(rsvp_count), count(*) from meetupRsvp group by dateConvert(secondsSinceEpoch) limit 50";
+ sql = "select dateConvert(secondsSinceEpoch), sum(rsvp_count), count(*) from meetupRsvp group by dateConvert"
+ + "(secondsSinceEpoch) limit 50";
pinotQuery = CalciteSqlParser.compileToPinotQuery(sql);
Assert.assertEquals(pinotQuery.getGroupByListSize(), 1);
Assert.assertEquals(pinotQuery.getSelectListSize(), 3);
// Invalid: secondsSinceEpoch should be in groupBy clause.
try {
- sql =
- "select secondsSinceEpoch, dateConvert(secondsSinceEpoch), sum(rsvp_count), count(*) from meetupRsvp group by dateConvert(secondsSinceEpoch) limit 50";
+ sql = "select secondsSinceEpoch, dateConvert(secondsSinceEpoch), sum(rsvp_count), count(*) from meetupRsvp"
+ + " group by dateConvert(secondsSinceEpoch) limit 50";
CalciteSqlParser.compileToPinotQuery(sql);
Assert.fail("Query should have failed compilation");
} catch (Exception e) {
@@ -1164,8 +1086,7 @@ public class CalciteSqlCompilerTest {
// Invalid groupBy clause shouldn't contain aggregate expression, like sum(rsvp_count), count(*).
try {
- sql =
- "select sum(rsvp_count), count(*) from meetupRsvp group by group_country, sum(rsvp_count), count(*) limit 50";
+ sql = "select sum(rsvp_count), count(*) from meetupRsvp group by group_country, sum(rsvp_count), count(*) limit " + "50";
CalciteSqlParser.compileToPinotQuery(sql);
Assert.fail("Query should have failed compilation");
} catch (Exception e) {
@@ -1179,72 +1100,59 @@ public class CalciteSqlCompilerTest {
String sql;
PinotQuery pinotQuery;
// Valid alias in query.
- sql =
- "select secondsSinceEpoch, sum(rsvp_count) as sum_rsvp_count, count(*) as cnt from meetupRsvp group by secondsSinceEpoch order by cnt, sum_rsvp_count DESC limit 50";
+ sql = "select secondsSinceEpoch, sum(rsvp_count) as sum_rsvp_count, count(*) as cnt from meetupRsvp"
+ + " group by secondsSinceEpoch order by cnt, sum_rsvp_count DESC limit 50";
pinotQuery = CalciteSqlParser.compileToPinotQuery(sql);
Assert.assertEquals(pinotQuery.getSelectListSize(), 3);
Assert.assertEquals(pinotQuery.getGroupByListSize(), 1);
Assert.assertEquals(pinotQuery.getOrderByListSize(), 2);
Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperator(), "ASC");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "COUNT");
Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "COUNT");
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "*");
+ pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "*");
Assert.assertEquals(pinotQuery.getOrderByList().get(1).getFunctionCall().getOperator(), "DESC");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "SUM");
Assert.assertEquals(
- pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "SUM");
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "rsvp_count");
+ pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "rsvp_count");
// Valid mixed alias expressions in query.
- sql =
- "select secondsSinceEpoch, sum(rsvp_count), count(*) as cnt from meetupRsvp group by secondsSinceEpoch order by cnt, sum(rsvp_count) DESC limit 50";
+ sql = "select secondsSinceEpoch, sum(rsvp_count), count(*) as cnt from meetupRsvp group by secondsSinceEpoch"
+ + " order by cnt, sum(rsvp_count) DESC limit 50";
pinotQuery = CalciteSqlParser.compileToPinotQuery(sql);
Assert.assertEquals(pinotQuery.getSelectListSize(), 3);
Assert.assertEquals(pinotQuery.getGroupByListSize(), 1);
Assert.assertEquals(pinotQuery.getOrderByListSize(), 2);
Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperator(), "ASC");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "COUNT");
Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "COUNT");
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "*");
+ pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "*");
Assert.assertEquals(pinotQuery.getOrderByList().get(1).getFunctionCall().getOperator(), "DESC");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "SUM");
Assert.assertEquals(
- pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "SUM");
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "rsvp_count");
+ pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "rsvp_count");
- sql =
- "select secondsSinceEpoch/86400 AS daysSinceEpoch, sum(rsvp_count) as sum_rsvp_count, count(*) as cnt from meetupRsvp where daysSinceEpoch = 18523 group by daysSinceEpoch order by cnt, sum_rsvp_count DESC limit 50";
+ sql = "select secondsSinceEpoch/86400 AS daysSinceEpoch, sum(rsvp_count) as sum_rsvp_count, count(*) as cnt"
+ + " from meetupRsvp where daysSinceEpoch = 18523 group by daysSinceEpoch order by cnt, sum_rsvp_count DESC" + " limit 50";
pinotQuery = CalciteSqlParser.compileToPinotQuery(sql);
Assert.assertEquals(pinotQuery.getSelectListSize(), 3);
Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperator(), "EQUALS");
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "DIVIDE");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "DIVIDE");
- Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "secondsSinceEpoch");
- Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getLiteral().getLongValue(), 86400);
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "secondsSinceEpoch");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 18523);
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getLiteral()
+ .getLongValue(), 86400);
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 18523);
Assert.assertEquals(pinotQuery.getGroupByListSize(), 1);
Assert.assertEquals(pinotQuery.getGroupByList().get(0).getFunctionCall().getOperator(), "DIVIDE");
- Assert.assertEquals(
- pinotQuery.getGroupByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
+ Assert.assertEquals(pinotQuery.getGroupByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
"secondsSinceEpoch");
- Assert.assertEquals(
- pinotQuery.getGroupByList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 86400);
+ Assert.assertEquals(pinotQuery.getGroupByList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 86400);
Assert.assertEquals(pinotQuery.getOrderByListSize(), 2);
// Invalid groupBy clause shouldn't contain aggregate expression, like sum(rsvp_count), count(*).
@@ -1266,22 +1174,16 @@ public class CalciteSqlCompilerTest {
pinotQuery = CalciteSqlParser.compileToPinotQuery(sql);
Assert.assertEquals(pinotQuery.getSelectListSize(), 3);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), SqlKind.AS.toString());
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "C1");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "ALIAS_C1");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "C1");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "ALIAS_C1");
Assert.assertEquals(pinotQuery.getSelectList().get(1).getFunctionCall().getOperator(), SqlKind.AS.toString());
- Assert.assertEquals(
- pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "C2");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "ALIAS_C2");
+ Assert.assertEquals(pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "C2");
+ Assert.assertEquals(pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "ALIAS_C2");
Assert.assertEquals(pinotQuery.getSelectList().get(2).getFunctionCall().getOperator(), "ADD");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "C1");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "C2");
+ Assert.assertEquals(pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "C1");
+ Assert.assertEquals(pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "C2");
// Invalid groupBy clause shouldn't contain aggregate expression, like sum(rsvp_count), count(*).
try {
@@ -1310,49 +1212,38 @@ public class CalciteSqlCompilerTest {
PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery("select a,b+2,c*5,(d+5)*2 from myTable");
Assert.assertEquals(pinotQuery.getSelectListSize(), 4);
Assert.assertEquals(pinotQuery.getSelectList().get(1).getFunctionCall().getOperator(), "PLUS");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "b");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 2);
+ Assert.assertEquals(pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "b");
+ Assert.assertEquals(pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 2);
Assert.assertEquals(pinotQuery.getSelectList().get(2).getFunctionCall().getOperator(), "TIMES");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "c");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 5);
+ Assert.assertEquals(pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "c");
+ Assert.assertEquals(pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 5);
Assert.assertEquals(pinotQuery.getSelectList().get(3).getFunctionCall().getOperator(), "TIMES");
+ Assert.assertEquals(pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "PLUS");
Assert.assertEquals(
- pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "PLUS");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "d");
+ pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "d");
Assert.assertEquals(
- pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getLiteral().getLongValue(), 5);
- Assert.assertEquals(
- pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 2);
+ pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getLiteral()
+ .getLongValue(), 5);
+ Assert.assertEquals(pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 2);
pinotQuery = CalciteSqlParser.compileToPinotQuery("select a % 200 + b * 5 from myTable");
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "PLUS");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "MOD");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "MOD");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "a");
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "a");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getLiteral().getLongValue(), 200);
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getLiteral()
+ .getLongValue(), 200);
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperator(), "TIMES");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperator(),
- "TIMES");
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "b");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "b");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(1)
- .getLiteral().getLongValue(), 5);
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(1).getLiteral()
+ .getLongValue(), 5);
}
/**
@@ -1364,59 +1255,42 @@ public class CalciteSqlCompilerTest {
// min, max, avg, sum, value, count, groups
PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(
- "select max(value) as max, min(value) as min, sum(value) as sum, count(*) as count, avg(value) as avg from myTable where groups = 'foo'");
+ "select max(value) as max, min(value) as min, sum(value) as sum, count(*) as count, avg(value) as avg from "
+ + "myTable where groups = 'foo'");
Assert.assertEquals(pinotQuery.getSelectListSize(), 5);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "AS");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "MAX");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "MAX");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "value");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "max");
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "value");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "max");
Assert.assertEquals(pinotQuery.getSelectList().get(1).getFunctionCall().getOperator(), "AS");
+ Assert.assertEquals(pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "MIN");
Assert.assertEquals(
- pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "MIN");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "value");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "min");
+ pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "value");
+ Assert.assertEquals(pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "min");
Assert.assertEquals(pinotQuery.getSelectList().get(2).getFunctionCall().getOperator(), "AS");
+ Assert.assertEquals(pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "SUM");
Assert.assertEquals(
- pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "SUM");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "value");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "sum");
+ pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "value");
+ Assert.assertEquals(pinotQuery.getSelectList().get(2).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "sum");
Assert.assertEquals(pinotQuery.getSelectList().get(3).getFunctionCall().getOperator(), "AS");
+ Assert.assertEquals(pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "COUNT");
Assert.assertEquals(
- pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "COUNT");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "*");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "count");
+ pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "*");
+ Assert.assertEquals(pinotQuery.getSelectList().get(3).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "count");
Assert.assertEquals(pinotQuery.getSelectList().get(4).getFunctionCall().getOperator(), "AS");
+ Assert.assertEquals(pinotQuery.getSelectList().get(4).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "AVG");
Assert.assertEquals(
- pinotQuery.getSelectList().get(4).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "AVG");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(4).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "value");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(4).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "avg");
+ pinotQuery.getSelectList().get(4).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "value");
+ Assert.assertEquals(pinotQuery.getSelectList().get(4).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "avg");
Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperator(), "EQUALS");
- Assert
- .assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getIdentifier().getName(),
- "groups");
- Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getStringValue(), "foo");
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getIdentifier().getName(), "groups");
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getStringValue(), "foo");
// language, module, return, position, system
pinotQuery = CalciteSqlParser.compileToPinotQuery(
@@ -1424,18 +1298,16 @@ public class CalciteSqlCompilerTest {
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperator(), "AND");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "position");
- Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getIdentifier().getName(), "language");
- Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getFunctionCall().getOperands().get(0).getIdentifier().getName(), "return");
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "position");
Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "module");
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getIdentifier().getName(), "language");
Assert.assertEquals(
- pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "system");
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall()
+ .getOperands().get(0).getIdentifier().getName(), "return");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "module");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "system");
// table - need to escape
try {
@@ -1493,18 +1365,18 @@ public class CalciteSqlCompilerTest {
// escaping the above works
pinotQuery = CalciteSqlParser.compileToPinotQuery(
- "select sum(foo) from \"table\" where \"Date\" = 2019 and (\"timestamp\" < 100 or \"time\" > 200) group by \"group\"");
+ "select sum(foo) from \"table\" where \"Date\" = 2019 and (\"timestamp\" < 100 or \"time\" > 200) group by " + "\"group\"");
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals(pinotQuery.getDataSource().getTableName(), "table");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "Date");
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "Date");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperands().get(0).getIdentifier().getName(), "timestamp");
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperands().get(0).getIdentifier().getName(), "timestamp");
Assert.assertEquals(
- pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(1)
- .getFunctionCall().getOperands().get(0).getIdentifier().getName(), "time");
+ pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getFunctionCall().getOperands().get(1).getFunctionCall()
+ .getOperands().get(0).getIdentifier().getName(), "time");
Assert.assertEquals(pinotQuery.getGroupByList().get(0).getIdentifier().getName(), "group");
}
@@ -1513,60 +1385,47 @@ public class CalciteSqlCompilerTest {
PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery("select CAST(25.65 AS int) from myTable");
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals("CAST", pinotQuery.getSelectList().get(0).getFunctionCall().getOperator());
- Assert.assertEquals(25.65,
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getLiteral().getDoubleValue());
- Assert.assertEquals("INTEGER",
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getStringValue());
+ Assert.assertEquals(25.65, pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getLiteral().getDoubleValue());
+ Assert.assertEquals("INTEGER", pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getStringValue());
pinotQuery = CalciteSqlParser.compileToPinotQuery("SELECT CAST('20170825' AS LONG) from myTable");
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals("CAST", pinotQuery.getSelectList().get(0).getFunctionCall().getOperator());
- Assert.assertEquals("20170825",
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getLiteral().getStringValue());
- Assert.assertEquals("LONG",
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getStringValue());
+ Assert.assertEquals("20170825", pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getLiteral().getStringValue());
+ Assert.assertEquals("LONG", pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getStringValue());
pinotQuery = CalciteSqlParser.compileToPinotQuery("SELECT CAST(20170825.0 AS Float) from myTable");
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals("CAST", pinotQuery.getSelectList().get(0).getFunctionCall().getOperator());
- Assert.assertEquals(20170825.0,
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getLiteral().getDoubleValue());
- Assert.assertEquals("FLOAT",
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getStringValue());
+ Assert.assertEquals(20170825.0, pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getLiteral().getDoubleValue());
+ Assert.assertEquals("FLOAT", pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getStringValue());
pinotQuery = CalciteSqlParser.compileToPinotQuery("SELECT CAST(20170825.0 AS dOuble) from myTable");
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals("CAST", pinotQuery.getSelectList().get(0).getFunctionCall().getOperator());
- Assert.assertEquals(20170825.0,
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getLiteral().getDoubleValue());
- Assert.assertEquals("DOUBLE",
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getStringValue());
+ Assert.assertEquals(20170825.0, pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getLiteral().getDoubleValue());
+ Assert.assertEquals("DOUBLE", pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getStringValue());
pinotQuery = CalciteSqlParser.compileToPinotQuery("SELECT CAST(column1 AS STRING) from myTable");
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals("CAST", pinotQuery.getSelectList().get(0).getFunctionCall().getOperator());
- Assert.assertEquals("column1",
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName());
- Assert.assertEquals("STRING",
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getStringValue());
+ Assert.assertEquals("column1", pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName());
+ Assert.assertEquals("STRING", pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getStringValue());
pinotQuery = CalciteSqlParser.compileToPinotQuery("SELECT CAST(column1 AS varchar) from myTable");
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals("CAST", pinotQuery.getSelectList().get(0).getFunctionCall().getOperator());
- Assert.assertEquals("column1",
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName());
- Assert.assertEquals("VARCHAR",
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getStringValue());
+ Assert.assertEquals("column1", pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName());
+ Assert.assertEquals("VARCHAR", pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getStringValue());
pinotQuery = CalciteSqlParser.compileToPinotQuery(
- "SELECT SUM(CAST(CAST(ArrTime AS STRING) AS LONG)) FROM mytable WHERE DaysSinceEpoch <> 16312 AND Carrier = 'DL'");
+ "SELECT SUM(CAST(CAST(ArrTime AS STRING) AS LONG)) FROM mytable WHERE DaysSinceEpoch <> 16312 AND Carrier = " + "'DL'");
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals("SUM", pinotQuery.getSelectList().get(0).getFunctionCall().getOperator());
+ Assert.assertEquals("CAST", pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator());
Assert.assertEquals("CAST",
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator());
- Assert.assertEquals("CAST",
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getFunctionCall().getOperator());
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getFunctionCall()
+ .getOperator());
}
@Test
@@ -1575,47 +1434,39 @@ public class CalciteSqlCompilerTest {
PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
Assert.assertEquals(pinotQuery.getSelectList().size(), 1);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "DISTINCTCOUNT");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
query = "SELECT count(distinct bar) FROM foo GROUP BY city";
pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
Assert.assertEquals(pinotQuery.getSelectList().size(), 1);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "DISTINCTCOUNT");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
query = "SELECT count(distinct bar), distinctCount(bar) FROM foo GROUP BY city";
pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
Assert.assertEquals(pinotQuery.getSelectList().size(), 2);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "DISTINCTCOUNT");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
Assert.assertEquals(pinotQuery.getSelectList().get(1).getFunctionCall().getOperator(), "DISTINCTCOUNT");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
+ Assert.assertEquals(pinotQuery.getSelectList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
query = "SELECT count(distinct bar), count(*), sum(a),min(a),max(b) FROM foo GROUP BY city";
pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
Assert.assertEquals(pinotQuery.getSelectList().size(), 5);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "DISTINCTCOUNT");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
query = "SELECT count(distinct bar) AS distinct_bar, count(*), sum(a),min(a),max(b) FROM foo GROUP BY city";
pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
Assert.assertEquals(pinotQuery.getSelectList().size(), 5);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "AS");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
"DISTINCTCOUNT");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "bar");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(),
- "distinct_bar");
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "bar");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "distinct_bar");
}
@Test
@@ -1626,10 +1477,8 @@ public class CalciteSqlCompilerTest {
Assert.assertEquals(pinotQuery.getSelectList().get(1).getIdentifier().getName(), "bar");
Assert.assertEquals(pinotQuery.getGroupByList().get(0).getIdentifier().getName(), "foo");
Assert.assertEquals(pinotQuery.getGroupByList().get(1).getIdentifier().getName(), "bar");
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "foo");
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "foo");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
query = "SELECT foo, bar, count(*) FROM t GROUP BY 2, 1 ORDER BY 2, 1 DESC";
pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
@@ -1637,31 +1486,24 @@ public class CalciteSqlCompilerTest {
Assert.assertEquals(pinotQuery.getSelectList().get(1).getIdentifier().getName(), "bar");
Assert.assertEquals(pinotQuery.getGroupByList().get(0).getIdentifier().getName(), "bar");
Assert.assertEquals(pinotQuery.getGroupByList().get(1).getIdentifier().getName(), "foo");
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "foo");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "foo");
query = "SELECT foo as f, bar as b, count(*) FROM t GROUP BY 2, 1 ORDER BY 2, 1 DESC";
pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
Assert.assertEquals(pinotQuery.getGroupByList().get(0).getIdentifier().getName(), "bar");
Assert.assertEquals(pinotQuery.getGroupByList().get(1).getIdentifier().getName(), "foo");
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "foo");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "bar");
+ Assert.assertEquals(pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "foo");
query = "select a, b + 2, array_sum(c) as array_sum_c, count(*) from data group by a, 2, array_sum_c";
pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
Assert.assertEquals(pinotQuery.getGroupByList().get(0).getIdentifier().getName(), "a");
Assert.assertEquals(pinotQuery.getGroupByList().get(1).getFunctionCall().getOperator(), "PLUS");
- Assert.assertEquals(
- pinotQuery.getGroupByList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "b");
- Assert.assertEquals(
- pinotQuery.getGroupByList().get(1).getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 2L);
+ Assert.assertEquals(pinotQuery.getGroupByList().get(1).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "b");
+ Assert.assertEquals(pinotQuery.getGroupByList().get(1).getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 2L);
Assert.assertEquals(pinotQuery.getGroupByList().get(2).getFunctionCall().getOperator(), "ARRAY_SUM");
- Assert.assertEquals(
- pinotQuery.getGroupByList().get(2).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "c");
+ Assert.assertEquals(pinotQuery.getGroupByList().get(2).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "c");
Assert.expectThrows(SqlCompilationException.class,
() -> CalciteSqlParser.compileToPinotQuery("SELECT foo, bar, count(*) FROM t GROUP BY 0"));
@@ -1671,15 +1513,12 @@ public class CalciteSqlCompilerTest {
@Test
public void testOrdinalsQueryRewriteWithDistinctOrderby() {
- String query =
- "SELECT baseballStats.playerName AS playerName FROM baseballStats GROUP BY baseballStats.playerName ORDER BY 1 ASC";
+ String query = "SELECT baseballStats.playerName AS playerName FROM baseballStats GROUP BY baseballStats.playerName ORDER BY " + "1 ASC";
PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
"baseballStats.playerName");
Assert.assertTrue(pinotQuery.getGroupByList().isEmpty());
- Assert.assertEquals(
- pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
+ Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
"baseballStats.playerName");
}
@@ -1749,8 +1588,7 @@ public class CalciteSqlCompilerTest {
PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
Function greaterThan = pinotQuery.getFilterExpression().getFunctionCall();
String today = greaterThan.getOperands().get(1).getLiteral().getStringValue();
- String expectedTodayStr =
- Instant.now().atZone(ZoneId.of("UTC")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd z"));
+ String expectedTodayStr = Instant.now().atZone(ZoneId.of("UTC")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd z"));
Assert.assertEquals(today, expectedTodayStr);
}
@@ -1797,8 +1635,7 @@ public class CalciteSqlCompilerTest {
expression = CalciteSqlParser.invokeCompileTimeFunctionExpression(expression);
Assert.assertNotNull(expression.getFunctionCall());
Assert.assertEquals(expression.getFunctionCall().getOperator(), "TODATETIME");
- Assert
- .assertEquals(expression.getFunctionCall().getOperands().get(0).getIdentifier().getName(), "millisSinceEpoch");
+ Assert.assertEquals(expression.getFunctionCall().getOperands().get(0).getIdentifier().getName(), "millisSinceEpoch");
expression = CalciteSqlParser.compileToExpression("reverse(playerName)");
Assert.assertNotNull(expression.getFunctionCall());
@@ -1831,10 +1668,8 @@ public class CalciteSqlCompilerTest {
public void testLiteralExpressionCheck() {
Assert.assertTrue(CalciteSqlParser.isLiteralOnlyExpression(CalciteSqlParser.compileToExpression("1123")));
Assert.assertTrue(CalciteSqlParser.isLiteralOnlyExpression(CalciteSqlParser.compileToExpression("'ab'")));
- Assert.assertTrue(
- CalciteSqlParser.isLiteralOnlyExpression(CalciteSqlParser.compileToExpression("AS('ab', randomStr)")));
- Assert.assertTrue(
- CalciteSqlParser.isLiteralOnlyExpression(CalciteSqlParser.compileToExpression("AS(123, randomTime)")));
+ Assert.assertTrue(CalciteSqlParser.isLiteralOnlyExpression(CalciteSqlParser.compileToExpression("AS('ab', randomStr)")));
+ Assert.assertTrue(CalciteSqlParser.isLiteralOnlyExpression(CalciteSqlParser.compileToExpression("AS(123, randomTime)")));
Assert.assertFalse(CalciteSqlParser.isLiteralOnlyExpression(CalciteSqlParser.compileToExpression("sum(abc)")));
Assert.assertFalse(CalciteSqlParser.isLiteralOnlyExpression(CalciteSqlParser.compileToExpression("count(*)")));
Assert.assertFalse(CalciteSqlParser.isLiteralOnlyExpression(CalciteSqlParser.compileToExpression("a+B")));
@@ -1872,9 +1707,7 @@ public class CalciteSqlCompilerTest {
pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
brokerRequest = converter.convert(pinotQuery);
Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperator(), "IS_NOT_NULL");
- Assert
- .assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getIdentifier().getName(),
- "col");
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getIdentifier().getName(), "col");
Assert.assertEquals(brokerRequest.getFilterQuery().getOperator(), FilterOperator.IS_NOT_NULL);
Assert.assertEquals(brokerRequest.getFilterQuery().getColumn(), "col");
@@ -1882,9 +1715,7 @@ public class CalciteSqlCompilerTest {
pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
brokerRequest = converter.convert(pinotQuery);
Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperator(), "IS_NOT_NULL");
- Assert
- .assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getIdentifier().getName(),
- "col");
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getIdentifier().getName(), "col");
Assert.assertEquals(brokerRequest.getFilterQuery().getOperator(), FilterOperator.IS_NOT_NULL);
Assert.assertEquals(brokerRequest.getFilterQuery().getColumn(), "col");
@@ -1892,9 +1723,7 @@ public class CalciteSqlCompilerTest {
pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
brokerRequest = converter.convert(pinotQuery);
Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperator(), "IS_NULL");
- Assert
- .assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getIdentifier().getName(),
- "col");
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getIdentifier().getName(), "col");
Assert.assertEquals(brokerRequest.getFilterQuery().getOperator(), FilterOperator.IS_NULL);
Assert.assertEquals(brokerRequest.getFilterQuery().getColumn(), "col");
@@ -1902,9 +1731,7 @@ public class CalciteSqlCompilerTest {
pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
brokerRequest = converter.convert(pinotQuery);
Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperator(), "IS_NULL");
- Assert
- .assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getIdentifier().getName(),
- "col");
+ Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getIdentifier().getName(), "col");
Assert.assertEquals(brokerRequest.getFilterQuery().getOperator(), FilterOperator.IS_NULL);
Assert.assertEquals(brokerRequest.getFilterQuery().getColumn(), "col");
}
@@ -1917,8 +1744,7 @@ public class CalciteSqlCompilerTest {
BrokerRequest brokerRequest = converter.convert(pinotQuery);
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator().toUpperCase(), "DISTINCT");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "col1");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "col1");
Assert.assertEquals(brokerRequest.getAggregationsInfo().size(), 1);
Assert.assertEquals(brokerRequest.getAggregationsInfo().get(0).getAggregationType().toUpperCase(), "DISTINCT");
@@ -1929,10 +1755,8 @@ public class CalciteSqlCompilerTest {
brokerRequest = converter.convert(pinotQuery);
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator().toUpperCase(), "DISTINCT");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "col1");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "col2");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "col1");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "col2");
Assert.assertEquals(brokerRequest.getAggregationsInfo().size(), 1);
Assert.assertEquals(brokerRequest.getAggregationsInfo().get(0).getAggregationType().toUpperCase(), "DISTINCT");
@@ -1943,52 +1767,46 @@ public class CalciteSqlCompilerTest {
brokerRequest = converter.convert(pinotQuery);
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator().toUpperCase(), "DISTINCT");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "PLUS");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "PLUS");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "col1");
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "col1");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getFunctionCall().getOperator(), "TIMES");
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall()
+ .getOperator(), "TIMES");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getFunctionCall().getOperands().get(0).getIdentifier().getName(), "col2");
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall()
+ .getOperands().get(0).getIdentifier().getName(), "col2");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 5L);
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall()
+ .getOperands().get(1).getLiteral().getLongValue(), 5L);
Assert.assertEquals(brokerRequest.getAggregationsInfo().size(), 1);
Assert.assertEquals(brokerRequest.getAggregationsInfo().get(0).getAggregationType().toUpperCase(), "DISTINCT");
- Assert.assertEquals(brokerRequest.getAggregationsInfo().get(0).getAggregationParams().get("column"),
- "plus(col1,times(col2,'5'))");
+ Assert.assertEquals(brokerRequest.getAggregationsInfo().get(0).getAggregationParams().get("column"), "plus(col1,times(col2,'5'))");
query = "SELECT col1+col2*5 AS col3 FROM foo GROUP BY col1, col2";
pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
brokerRequest = converter.convert(pinotQuery);
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator().toUpperCase(), "DISTINCT");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "PLUS");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "PLUS");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "col1");
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "col1");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getFunctionCall().getOperator(), "TIMES");
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall()
+ .getOperator(), "TIMES");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getFunctionCall().getOperands().get(0).getIdentifier().getName(), "col2");
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall()
+ .getOperands().get(0).getIdentifier().getName(), "col2");
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
- .getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 5L);
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1).getFunctionCall()
+ .getOperands().get(1).getLiteral().getLongValue(), 5L);
Assert.assertEquals(brokerRequest.getAggregationsInfo().size(), 1);
Assert.assertEquals(brokerRequest.getAggregationsInfo().get(0).getAggregationType().toUpperCase(), "DISTINCT");
- Assert.assertEquals(brokerRequest.getAggregationsInfo().get(0).getAggregationParams().get("column"),
- "plus(col1,times(col2,'5'))");
+ Assert.assertEquals(brokerRequest.getAggregationsInfo().get(0).getAggregationParams().get("column"), "plus(col1,times(col2,'5'))");
}
@Test(expectedExceptions = SqlCompilationException.class)
@@ -1998,7 +1816,7 @@ public class CalciteSqlCompilerTest {
CalciteSqlParser.compileToPinotQuery("SELECT col1+col2 FROM foo GROUP BY col1");
} catch (SqlCompilationException e) {
Assert.assertEquals(e.getMessage(),
- "For non-aggregation group by query, all the identifiers in select clause should be in groupBys. Found identifier: [col2]");
+ "For non-aggregation group by query, all the identifiers in select clause should be in groupBys. Found " + "identifier: [col2]");
throw e;
}
}
@@ -2048,8 +1866,8 @@ public class CalciteSqlCompilerTest {
}
{
- String query =
- "SELECT * FROM foo WHERE col1 > 0 AND ((col2 > 0 AND col3 > 0) AND (col1 <= 0 OR (col2 <= 0 OR (col3 <= 0 OR col4 <= 0) OR (col3 > 0 AND col4 > 0))))";
+ String query = "SELECT * FROM foo WHERE col1 > 0 AND ((col2 > 0 AND col3 > 0) AND (col1 <= 0 OR (col2 <= 0 OR (col3 <= 0 OR"
+ + " col4 <= 0) OR (col3 > 0 AND col4 > 0))))";
PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
Function functionCall = pinotQuery.getFilterExpression().getFunctionCall();
Assert.assertEquals(functionCall.getOperator(), SqlKind.AND.name());
@@ -2119,7 +1937,7 @@ public class CalciteSqlCompilerTest {
{
String query =
- "SELECT SUM(col1), col2 FROM foo WHERE true GROUP BY col2 HAVING SUM(col1) > 10 AND SUM(col3) > 5 AND SUM(col4) > 15";
+ "SELECT SUM(col1), col2 FROM foo WHERE true GROUP BY col2 HAVING SUM(col1) > 10 AND SUM(col3) > 5 AND SUM" + "(col4) > 15";
PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
Function functionCall = pinotQuery.getHavingExpression().getFunctionCall();
Assert.assertEquals(functionCall.getOperator(), SqlKind.AND.name());
@@ -2217,41 +2035,33 @@ public class CalciteSqlCompilerTest {
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "sumMV");
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().size(), 1);
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "a");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "a");
sql = "SELECT MIN(ARRAYMIN(a)) FROM Foo";
pinotQuery = CalciteSqlParser.compileToPinotQuery(sql);
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "minMV");
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().size(), 1);
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "a");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "a");
sql = "SELECT Max(ArrayMax(a)) FROM Foo";
pinotQuery = CalciteSqlParser.compileToPinotQuery(sql);
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "maxMV");
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().size(), 1);
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "a");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "a");
sql = "SELECT Max(ArrayMax(a)) + 1 FROM Foo";
pinotQuery = CalciteSqlParser.compileToPinotQuery(sql);
Assert.assertEquals(pinotQuery.getSelectListSize(), 1);
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperator(), "PLUS");
Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().size(), 2);
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "maxMV");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().size(), 1);
Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
- "maxMV");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().size(),
- 1);
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
- .getIdentifier().getName(), "a");
- Assert.assertEquals(
- pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 1L);
+ pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+ .getName(), "a");
+ Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 1L);
}
/**
@@ -2276,12 +2086,10 @@ public class CalciteSqlCompilerTest {
sql = "SELECT DISTINCT col1, col2 FROM foo ORDER BY col3";
testUnsupportedDistinctQuery(sql, "ORDER-BY columns should be included in the DISTINCT columns");
- sql =
- "SELECT DISTINCT add(col1, sub(col2, 3)), mod(col2, 10), div(col4, mult(col5, 5)) FROM foo ORDER BY col1, col2, col3";
+ sql = "SELECT DISTINCT add(col1, sub(col2, 3)), mod(col2, 10), div(col4, mult(col5, 5)) FROM foo ORDER BY col1, " + "col2, col3";
testUnsupportedDistinctQuery(sql, "ORDER-BY columns should be included in the DISTINCT columns");
- sql =
- "SELECT DISTINCT add(col1, sub(col2, 3)), mod(col2, 10), div(col4, mult(col5, 5)) FROM foo ORDER BY col1, mod(col2, 10)";
+ sql = "SELECT DISTINCT add(col1, sub(col2, 3)), mod(col2, 10), div(col4, mult(col5, 5)) FROM foo ORDER BY col1, mod" + "(col2, 10)";
testUnsupportedDistinctQuery(sql, "ORDER-BY columns should be included in the DISTINCT columns");
}
@@ -2302,16 +2110,15 @@ public class CalciteSqlCompilerTest {
sql = "SELECT DISTINCT col1, col2 FROM foo ORDER BY col1 DESC, col2 DESC";
testSupportedDistinctQuery(sql);
- sql =
- "SELECT DISTINCT add(col1, sub(col2, 3)), mod(col2, 10), div(col4, mult(col5, 5)) FROM foo ORDER BY add(col1, sub(col2, 3))";
+ sql = "SELECT DISTINCT add(col1, sub(col2, 3)), mod(col2, 10), div(col4, mult(col5, 5)) FROM foo ORDER BY add(col1," + " sub(col2, 3))";
testSupportedDistinctQuery(sql);
- sql =
- "SELECT DISTINCT add(col1, sub(col2, 3)), mod(col2, 10), div(col4, mult(col5, 5)) FROM foo ORDER BY mod(col2, 10), add(col1, sub(col2, 3))";
+ sql = "SELECT DISTINCT add(col1, sub(col2, 3)), mod(col2, 10), div(col4, mult(col5, 5)) FROM foo ORDER BY mod(col2,"
+ + " 10), add(col1, sub(col2, 3))";
testSupportedDistinctQuery(sql);
- sql =
- "SELECT DISTINCT add(col1, sub(col2, 3)), mod(col2, 10), div(col4, mult(col5, 5)) FROM foo ORDER BY add(col1, sub(col2, 3)), mod(col2, 10), div(col4, mult(col5, 5)) DESC";
+ sql = "SELECT DISTINCT add(col1, sub(col2, 3)), mod(col2, 10), div(col4, mult(col5, 5)) FROM foo ORDER BY"
+ + " add(col1, sub(col2, 3)), mod(col2, 10), div(col4, mult(col5, 5)) DESC";
testSupportedDistinctQuery(sql);
}
diff --git a/pinot-common/src/test/java/org/apache/pinot/util/TestUtils.java b/pinot-common/src/test/java/org/apache/pinot/util/TestUtils.java
index d2775f2..16a1117 100644
--- a/pinot-common/src/test/java/org/apache/pinot/util/TestUtils.java
+++ b/pinot-common/src/test/java/org/apache/pinot/util/TestUtils.java
@@ -35,6 +35,9 @@ import org.testng.Assert;
*
*/
public class TestUtils {
+ private TestUtils() {
+ }
+
private static final Logger LOGGER = LoggerFactory.getLogger(TestUtils.class);
public static String getFileFromResourceUrl(@Nonnull URL resourceUrl) {
@@ -83,8 +86,7 @@ public class TestUtils {
waitForCondition(condition, checkIntervalMs, timeoutMs, errorMessage, true);
}
- public static void waitForCondition(Function<Void, Boolean> condition, long timeoutMs,
- @Nullable String errorMessage) {
+ public static void waitForCondition(Function<Void, Boolean> condition, long timeoutMs, @Nullable String errorMessage) {
waitForCondition(condition, 100L, timeoutMs, errorMessage);
}
diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/ServerTableSizeReader.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/ServerTableSizeReader.java
index ce62402..6354f8b 100644
--- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/ServerTableSizeReader.java
+++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/ServerTableSizeReader.java
@@ -73,7 +73,7 @@ public class ServerTableSizeReader {
try {
TableSizeInfo tableSizeInfo =
JsonUtils.stringToObject(streamResponse.getValue(), TableSizeInfo.class);
- serverToSegmentSizeInfoListMap.put(streamResponse.getKey(), tableSizeInfo.segments);
+ serverToSegmentSizeInfoListMap.put(streamResponse.getKey(), tableSizeInfo.getSegments());
} catch (IOException e) {
failedParses++;
LOGGER.error("Unable to parse server {} response due to an error: ", streamResponse.getKey(), e);
diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/util/ServerSegmentMetadataReader.java b/pinot-controller/src/main/java/org/apache/pinot/controller/util/ServerSegmentMetadataReader.java
index 1ccfc65..a9139ab 100644
--- a/pinot-controller/src/main/java/org/apache/pinot/controller/util/ServerSegmentMetadataReader.java
+++ b/pinot-controller/src/main/java/org/apache/pinot/controller/util/ServerSegmentMetadataReader.java
@@ -24,6 +24,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
@@ -79,37 +80,40 @@ public class ServerSegmentMetadataReader {
CompletionServiceHelper.CompletionServiceResponse serviceResponse =
completionServiceHelper.doMultiGetRequest(serverUrls, tableNameWithType, false, timeoutMs);
- TableMetadataInfo aggregateTableMetadataInfo = new TableMetadataInfo();
+ long totalDiskSizeInBytes = 0;
int totalNumSegments = 0;
+ long totalNumRows = 0;
int failedParses = 0;
+ final Map<String, Double> columnLengthMap = new HashMap<>();
+ final Map<String, Double> columnCardinalityMap = new HashMap<>();
for (Map.Entry<String, String> streamResponse : serviceResponse._httpResponses.entrySet()) {
try {
TableMetadataInfo tableMetadataInfo =
JsonUtils.stringToObject(streamResponse.getValue(), TableMetadataInfo.class);
- aggregateTableMetadataInfo.diskSizeInBytes += tableMetadataInfo.diskSizeInBytes;
- aggregateTableMetadataInfo.numRows += tableMetadataInfo.numRows;
- totalNumSegments += tableMetadataInfo.numSegments;
- tableMetadataInfo.columnLengthMap
- .forEach((k, v) -> aggregateTableMetadataInfo.columnLengthMap.merge(k, v, Double::sum));
- tableMetadataInfo.columnCardinalityMap
- .forEach((k, v) -> aggregateTableMetadataInfo.columnCardinalityMap.merge(k, v, Double::sum));
+ totalDiskSizeInBytes += tableMetadataInfo.getDiskSizeInBytes();
+ totalNumRows += tableMetadataInfo.getNumRows();
+ totalNumSegments += tableMetadataInfo.getNumSegments();
+ tableMetadataInfo.getColumnLengthMap().forEach((k, v) -> columnLengthMap.merge(k, v, Double::sum));
+ tableMetadataInfo.getColumnCardinalityMap().forEach((k, v) -> columnCardinalityMap.merge(k, v, Double::sum));
} catch (IOException e) {
failedParses++;
LOGGER.error("Unable to parse server {} response due to an error: ", streamResponse.getKey(), e);
}
}
-
- aggregateTableMetadataInfo.numSegments = totalNumSegments;
- aggregateTableMetadataInfo.columnLengthMap.replaceAll((k, v) -> v / aggregateTableMetadataInfo.numSegments);
- aggregateTableMetadataInfo.columnCardinalityMap.replaceAll((k, v) -> v / aggregateTableMetadataInfo.numSegments);
+ int finalTotalNumSegments = totalNumSegments;
+ columnLengthMap.replaceAll((k, v) -> v / finalTotalNumSegments);
+ columnCardinalityMap.replaceAll((k, v) -> v / finalTotalNumSegments);
// Since table segments may have multiple replicas, divide diskSizeInBytes, numRows and numSegments by numReplica
// to avoid double counting, for columnAvgLengthMap and columnAvgCardinalityMap, dividing by numReplica is not
// needed since totalNumSegments already contains replicas.
- aggregateTableMetadataInfo.diskSizeInBytes /= numReplica;
- aggregateTableMetadataInfo.numRows /= numReplica;
- aggregateTableMetadataInfo.numSegments /= numReplica;
+ totalDiskSizeInBytes /= numReplica;
+ totalNumSegments /= numReplica;
+ totalNumRows /= numReplica;
+ TableMetadataInfo aggregateTableMetadataInfo =
+ new TableMetadataInfo("", totalDiskSizeInBytes, totalNumSegments, totalNumRows, columnLengthMap,
+ columnCardinalityMap);
if (failedParses != 0) {
LOGGER.warn("Failed to parse {} / {} aggregated segment metadata responses from servers.", failedParses,
serverUrls.size());
diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/util/TableSizeReader.java b/pinot-controller/src/main/java/org/apache/pinot/controller/util/TableSizeReader.java
index 2181252..8ca6748 100644
--- a/pinot-controller/src/main/java/org/apache/pinot/controller/util/TableSizeReader.java
+++ b/pinot-controller/src/main/java/org/apache/pinot/controller/util/TableSizeReader.java
@@ -167,7 +167,7 @@ public class TableSizeReader {
if (segmentSizeInfoList != null) {
for (SegmentSizeInfo segmentSizeInfo : segmentSizeInfoList) {
SegmentSizeDetails segmentSizeDetails =
- segmentToSizeDetailsMap.computeIfAbsent(segmentSizeInfo.segmentName, k -> new SegmentSizeDetails());
+ segmentToSizeDetailsMap.computeIfAbsent(segmentSizeInfo.getSegmentName(), k -> new SegmentSizeDetails());
segmentSizeDetails.serverInfo.put(server, segmentSizeInfo);
}
} else {
@@ -196,9 +196,9 @@ public class TableSizeReader {
long segmentLevelMax = -1L;
int errors = 0;
for (SegmentSizeInfo sizeInfo : sizeDetails.serverInfo.values()) {
- if (sizeInfo.diskSizeInBytes != -1) {
- sizeDetails.reportedSizeInBytes += sizeInfo.diskSizeInBytes;
- segmentLevelMax = Math.max(segmentLevelMax, sizeInfo.diskSizeInBytes);
+ if (sizeInfo.getDiskSizeInBytes() != -1) {
+ sizeDetails.reportedSizeInBytes += sizeInfo.getDiskSizeInBytes();
+ segmentLevelMax = Math.max(segmentLevelMax, sizeInfo.getDiskSizeInBytes());
} else {
errors++;
}
diff --git a/pinot-controller/src/test/java/org/apache/pinot/controller/api/ServerTableSizeReaderTest.java b/pinot-controller/src/test/java/org/apache/pinot/controller/api/ServerTableSizeReaderTest.java
index 3926c8c..5cfeb3d 100644
--- a/pinot-controller/src/test/java/org/apache/pinot/controller/api/ServerTableSizeReaderTest.java
+++ b/pinot-controller/src/test/java/org/apache/pinot/controller/api/ServerTableSizeReaderTest.java
@@ -96,16 +96,14 @@ public class ServerTableSizeReaderTest {
}
private TableSizeInfo createTableSizeInfo(String tableName, List<Integer> segmentIndexes) {
- TableSizeInfo tableSizeInfo = new TableSizeInfo();
- tableSizeInfo.tableName = tableName;
- tableSizeInfo.diskSizeInBytes = 0;
+ long tableSizeInBytes = 0;
+ List<SegmentSizeInfo> segments = new ArrayList<>();
for (int segmentIndex : segmentIndexes) {
long size = segmentIndexToSize(segmentIndex);
- tableSizeInfo.diskSizeInBytes += size;
- SegmentSizeInfo s = new SegmentSizeInfo("seg" + segmentIndex, size);
- tableSizeInfo.segments.add(s);
+ tableSizeInBytes += size;
+ segments.add(new SegmentSizeInfo("seg" + segmentIndex, size));
}
- return tableSizeInfo;
+ return new TableSizeInfo(tableName, tableSizeInBytes, segments);
}
private long segmentIndexToSize(int index) {
@@ -161,9 +159,9 @@ public class ServerTableSizeReaderTest {
Assert.assertTrue(serverSizes.containsKey(serverList.get(1)));
Assert.assertTrue(serverSizes.containsKey(serverList.get(5)));
- Assert.assertEquals(serverSizes.get(serverList.get(0)), tableInfo1.segments);
- Assert.assertEquals(serverSizes.get(serverList.get(1)), tableInfo2.segments);
- Assert.assertEquals(serverSizes.get(serverList.get(5)), tableInfo3.segments);
+ Assert.assertEquals(serverSizes.get(serverList.get(0)), tableInfo1.getSegments());
+ Assert.assertEquals(serverSizes.get(serverList.get(1)), tableInfo2.getSegments());
+ Assert.assertEquals(serverSizes.get(serverList.get(5)), tableInfo3.getSegments());
}
@Test
diff --git a/pinot-controller/src/test/java/org/apache/pinot/controller/api/TableSizeReaderTest.java b/pinot-controller/src/test/java/org/apache/pinot/controller/api/TableSizeReaderTest.java
index 84d83ad..500bc5a 100644
--- a/pinot-controller/src/test/java/org/apache/pinot/controller/api/TableSizeReaderTest.java
+++ b/pinot-controller/src/test/java/org/apache/pinot/controller/api/TableSizeReaderTest.java
@@ -151,12 +151,11 @@ public class TableSizeReaderTest {
}
}
- TableSizeInfo tableInfo = new TableSizeInfo("myTable", 0);
- tableInfo.segments = segmentSizes;
+ long tableSizeInBytes = 0;
for (SegmentSizeInfo segmentSize : segmentSizes) {
- tableInfo.diskSizeInBytes += segmentSize.diskSizeInBytes;
+ tableSizeInBytes += segmentSize.getDiskSizeInBytes();
}
-
+ TableSizeInfo tableInfo = new TableSizeInfo("myTable", tableSizeInBytes, segmentSizes);
String json = JsonUtils.objectToString(tableInfo);
httpExchange.sendResponseHeaders(status, json.length());
OutputStream responseBody = httpExchange.getResponseBody();
diff --git a/pinot-server/src/main/java/org/apache/pinot/server/api/resources/TableSizeResource.java b/pinot-server/src/main/java/org/apache/pinot/server/api/resources/TableSizeResource.java
index 3b8683f..652f353 100644
--- a/pinot-server/src/main/java/org/apache/pinot/server/api/resources/TableSizeResource.java
+++ b/pinot-server/src/main/java/org/apache/pinot/server/api/resources/TableSizeResource.java
@@ -23,6 +23,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
+import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import javax.ws.rs.DefaultValue;
@@ -75,10 +76,8 @@ public class TableSizeResource {
throw new WebApplicationException("Table: " + tableName + " is not found", Response.Status.NOT_FOUND);
}
- TableSizeInfo tableSizeInfo = new TableSizeInfo();
- tableSizeInfo.tableName = tableDataManager.getTableName();
- tableSizeInfo.diskSizeInBytes = 0L;
-
+ long tableSizeInBytes = 0L;
+ List<SegmentSizeInfo> segmentSizeInfos = new ArrayList<>();
List<SegmentDataManager> segmentDataManagers = tableDataManager.acquireAllSegments();
try {
for (SegmentDataManager segmentDataManager : segmentDataManagers) {
@@ -86,14 +85,12 @@ public class TableSizeResource {
ImmutableSegment immutableSegment = (ImmutableSegment) segmentDataManager.getSegment();
long segmentSizeBytes = immutableSegment.getSegmentSizeBytes();
if (detailed) {
- SegmentSizeInfo segmentSizeInfo = new SegmentSizeInfo(immutableSegment.getSegmentName(), segmentSizeBytes);
- tableSizeInfo.segments.add(segmentSizeInfo);
+ segmentSizeInfos.add(new SegmentSizeInfo(immutableSegment.getSegmentName(), segmentSizeBytes));
}
- tableSizeInfo.diskSizeInBytes += segmentSizeBytes;
+ tableSizeInBytes += segmentSizeBytes;
}
}
} finally {
-
// we could release segmentDataManagers as we iterate in the loop above
// but this is cleaner with clear semantics of usage. Also, above loop
// executes fast so duration of holding segments is not a concern
@@ -101,6 +98,8 @@ public class TableSizeResource {
tableDataManager.releaseSegment(segmentDataManager);
}
}
+
+ TableSizeInfo tableSizeInfo = new TableSizeInfo(tableDataManager.getTableName(), tableSizeInBytes, segmentSizeInfos);
//invalid to use the segmentDataManagers below
return ResourceUtils.convertToJsonString(tableSizeInfo);
}
diff --git a/pinot-server/src/main/java/org/apache/pinot/server/api/resources/TablesResource.java b/pinot-server/src/main/java/org/apache/pinot/server/api/resources/TablesResource.java
index 38c893c..dfc68c0 100644
--- a/pinot-server/src/main/java/org/apache/pinot/server/api/resources/TablesResource.java
+++ b/pinot-server/src/main/java/org/apache/pinot/server/api/resources/TablesResource.java
@@ -166,11 +166,11 @@ public class TablesResource {
}
Set<String> columnSet = allColumns ? null : new HashSet<>(decodedColumns);
- TableMetadataInfo tableMetadataInfo = new TableMetadataInfo();
- tableMetadataInfo.tableName = tableDataManager.getTableName();
-
List<SegmentDataManager> segmentDataManagers = tableDataManager.acquireAllSegments();
- tableMetadataInfo.numSegments = segmentDataManagers.size();
+ long totalSegmentSizeBytes = 0;
+ long totalNumRows = 0;
+ Map<String, Double> columnLengthMap = new HashMap<>();
+ Map<String, Double> columnCardinalityMap = new HashMap<>();
try {
for (SegmentDataManager segmentDataManager : segmentDataManagers) {
if (segmentDataManager instanceof ImmutableSegmentDataManager) {
@@ -179,8 +179,8 @@ public class TablesResource {
SegmentMetadataImpl segmentMetadata =
(SegmentMetadataImpl) segmentDataManager.getSegment().getSegmentMetadata();
- tableMetadataInfo.diskSizeInBytes += segmentSizeBytes;
- tableMetadataInfo.numRows += segmentMetadata.getTotalDocs();
+ totalSegmentSizeBytes += segmentSizeBytes;
+ totalNumRows += segmentMetadata.getTotalDocs();
if (columnSet == null) {
columnSet = segmentMetadata.getAllColumns();
@@ -208,8 +208,8 @@ public class TablesResource {
columnLength = FieldSpec.DEFAULT_MAX_LENGTH;
}
int columnCardinality = segmentMetadata.getColumnMetadataMap().get(column).getCardinality();
- tableMetadataInfo.columnLengthMap.merge(column, (double) columnLength, Double::sum);
- tableMetadataInfo.columnCardinalityMap.merge(column, (double) columnCardinality, Double::sum);
+ columnLengthMap.merge(column, (double) columnLength, Double::sum);
+ columnCardinalityMap.merge(column, (double) columnCardinality, Double::sum);
}
}
}
@@ -222,6 +222,9 @@ public class TablesResource {
}
}
+ TableMetadataInfo tableMetadataInfo =
+ new TableMetadataInfo(tableDataManager.getTableName(), totalSegmentSizeBytes, segmentDataManagers.size(),
+ totalNumRows, columnLengthMap, columnCardinalityMap);
return ResourceUtils.convertToJsonString(tableMetadataInfo);
}
diff --git a/pinot-server/src/test/java/org/apache/pinot/server/api/TableSizeResourceTest.java b/pinot-server/src/test/java/org/apache/pinot/server/api/TableSizeResourceTest.java
index 40ccc52..8c8eed6 100644
--- a/pinot-server/src/test/java/org/apache/pinot/server/api/TableSizeResourceTest.java
+++ b/pinot-server/src/test/java/org/apache/pinot/server/api/TableSizeResourceTest.java
@@ -43,12 +43,12 @@ public class TableSizeResourceTest extends BaseResourceTest {
String path = "/tables/" + expectedTableName + "/size";
TableSizeInfo tableSizeInfo = _webTarget.path(path).request().get(TableSizeInfo.class);
- Assert.assertEquals(tableSizeInfo.tableName, expectedTableName);
- Assert.assertEquals(tableSizeInfo.diskSizeInBytes, segment.getSegmentSizeBytes());
- Assert.assertEquals(tableSizeInfo.segments.size(), 1);
- Assert.assertEquals(tableSizeInfo.segments.get(0).segmentName, segment.getSegmentName());
- Assert.assertEquals(tableSizeInfo.segments.get(0).diskSizeInBytes, segment.getSegmentSizeBytes());
- Assert.assertEquals(tableSizeInfo.diskSizeInBytes, segment.getSegmentSizeBytes());
+ Assert.assertEquals(tableSizeInfo.getTableName(), expectedTableName);
+ Assert.assertEquals(tableSizeInfo.getDiskSizeInBytes(), segment.getSegmentSizeBytes());
+ Assert.assertEquals(tableSizeInfo.getSegments().size(), 1);
+ Assert.assertEquals(tableSizeInfo.getSegments().get(0).getSegmentName(), segment.getSegmentName());
+ Assert.assertEquals(tableSizeInfo.getSegments().get(0).getDiskSizeInBytes(), segment.getSegmentSizeBytes());
+ Assert.assertEquals(tableSizeInfo.getDiskSizeInBytes(), segment.getSegmentSizeBytes());
}
@Test
@@ -63,9 +63,9 @@ public class TableSizeResourceTest extends BaseResourceTest {
TableSizeInfo tableSizeInfo =
_webTarget.path(path).queryParam("detailed", "false").request().get(TableSizeInfo.class);
- Assert.assertEquals(tableSizeInfo.tableName, expectedTableName);
- Assert.assertEquals(tableSizeInfo.diskSizeInBytes, segment.getSegmentSizeBytes());
- Assert.assertEquals(tableSizeInfo.segments.size(), 0);
+ Assert.assertEquals(tableSizeInfo.getTableName(), expectedTableName);
+ Assert.assertEquals(tableSizeInfo.getDiskSizeInBytes(), segment.getSegmentSizeBytes());
+ Assert.assertEquals(tableSizeInfo.getSegments().size(), 0);
}
@Test
@@ -78,11 +78,11 @@ public class TableSizeResourceTest extends BaseResourceTest {
String path = "/table/" + expectedTableName + "/size";
TableSizeInfo tableSizeInfo = _webTarget.path(path).request().get(TableSizeInfo.class);
- Assert.assertEquals(tableSizeInfo.tableName, expectedTableName);
- Assert.assertEquals(tableSizeInfo.diskSizeInBytes, segment.getSegmentSizeBytes());
- Assert.assertEquals(tableSizeInfo.segments.size(), 1);
- Assert.assertEquals(tableSizeInfo.segments.get(0).segmentName, segment.getSegmentName());
- Assert.assertEquals(tableSizeInfo.segments.get(0).diskSizeInBytes, segment.getSegmentSizeBytes());
- Assert.assertEquals(tableSizeInfo.diskSizeInBytes, segment.getSegmentSizeBytes());
+ Assert.assertEquals(tableSizeInfo.getTableName(), expectedTableName);
+ Assert.assertEquals(tableSizeInfo.getDiskSizeInBytes(), segment.getSegmentSizeBytes());
+ Assert.assertEquals(tableSizeInfo.getSegments().size(), 1);
+ Assert.assertEquals(tableSizeInfo.getSegments().get(0).getSegmentName(), segment.getSegmentName());
+ Assert.assertEquals(tableSizeInfo.getSegments().get(0).getDiskSizeInBytes(), segment.getSegmentSizeBytes());
+ Assert.assertEquals(tableSizeInfo.getDiskSizeInBytes(), segment.getSegmentSizeBytes());
}
}
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/ConfigUtils.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/ConfigUtils.java
index 70d5d0f..46b34f3 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/ConfigUtils.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/ConfigUtils.java
@@ -44,8 +44,8 @@ public class ConfigUtils {
try {
jsonNode = applyConfigWithEnvVariables(config.toJsonNode());
} catch (RuntimeException e) {
- throw new RuntimeException(String
- .format("Unable to apply environment variables on json config class [%s].", config.getClass().getName()), e);
+ throw new RuntimeException(
+ String.format("Unable to apply environment variables on json config class [%s].", config.getClass().getName()), e);
}
try {
return (T) JsonUtils.jsonNodeToObject(jsonNode, config.getClass());
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/TableConfigs.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/TableConfigs.java
index 7020789..c33583a 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/TableConfigs.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/TableConfigs.java
@@ -42,8 +42,7 @@ public class TableConfigs extends BaseJsonConfig {
@JsonCreator
public TableConfigs(@JsonProperty(value = "tableName", required = true) String tableName,
- @JsonProperty(value = "schema", required = true) Schema schema,
- @JsonProperty(value = "offline") @Nullable TableConfig offline,
+ @JsonProperty(value = "schema", required = true) Schema schema, @JsonProperty(value = "offline") @Nullable TableConfig offline,
@JsonProperty(value = "realtime") @Nullable TableConfig realtime) {
Preconditions.checkState(StringUtils.isNotBlank(tableName), "'tableName' cannot be null or empty in TableConfigs");
Preconditions.checkNotNull(schema, "'schema' cannot be null in TableConfigs");
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/instance/Instance.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/instance/Instance.java
index 6e0b502..4694c36 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/instance/Instance.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/instance/Instance.java
@@ -57,12 +57,10 @@ public class Instance extends BaseJsonConfig {
private final boolean _queriesDisabled;
@JsonCreator
- public Instance(@JsonProperty(value = "host", required = true) String host,
- @JsonProperty(value = "port", required = true) int port,
- @JsonProperty(value = "type", required = true) InstanceType type,
- @JsonProperty("tags") @Nullable List<String> tags, @JsonProperty("pools") @Nullable Map<String, Integer> pools,
- @JsonProperty("grpcPort") int grpcPort, @JsonProperty("adminPort") int adminPort,
- @JsonProperty("queriesDisabled") boolean queriesDisabled) {
+ public Instance(@JsonProperty(value = "host", required = true) String host, @JsonProperty(value = "port", required = true) int port,
+ @JsonProperty(value = "type", required = true) InstanceType type, @JsonProperty("tags") @Nullable List<String> tags,
+ @JsonProperty("pools") @Nullable Map<String, Integer> pools, @JsonProperty("grpcPort") int grpcPort,
+ @JsonProperty("adminPort") int adminPort, @JsonProperty("queriesDisabled") boolean queriesDisabled) {
Preconditions.checkArgument(host != null, "'host' must be configured");
Preconditions.checkArgument(type != null, "'type' must be configured");
_host = host;
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/BloomFilterConfig.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/BloomFilterConfig.java
index 22af21b..8981fc6 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/BloomFilterConfig.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/BloomFilterConfig.java
@@ -32,8 +32,7 @@ public class BloomFilterConfig extends BaseJsonConfig {
private final boolean _loadOnHeap;
@JsonCreator
- public BloomFilterConfig(@JsonProperty(value = "fpp") double fpp,
- @JsonProperty(value = "maxSizeInBytes") int maxSizeInBytes,
+ public BloomFilterConfig(@JsonProperty(value = "fpp") double fpp, @JsonProperty(value = "maxSizeInBytes") int maxSizeInBytes,
@JsonProperty(value = "loadOnHeap") boolean loadOnHeap) {
if (fpp != 0.0) {
Preconditions.checkArgument(fpp > 0.0 && fpp < 1.0, "Invalid fpp (false positive probability): %s", fpp);
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/StarTreeIndexConfig.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/StarTreeIndexConfig.java
index ace3b65..9dc450f 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/StarTreeIndexConfig.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/StarTreeIndexConfig.java
@@ -38,15 +38,12 @@ public class StarTreeIndexConfig extends BaseJsonConfig {
private final int _maxLeafRecords;
@JsonCreator
- public StarTreeIndexConfig(
- @JsonProperty(value = "dimensionsSplitOrder", required = true) List<String> dimensionsSplitOrder,
+ public StarTreeIndexConfig(@JsonProperty(value = "dimensionsSplitOrder", required = true) List<String> dimensionsSplitOrder,
@JsonProperty("skipStarNodeCreationForDimensions") @Nullable List<String> skipStarNodeCreationForDimensions,
@JsonProperty(value = "functionColumnPairs", required = true) List<String> functionColumnPairs,
@JsonProperty("maxLeafRecords") int maxLeafRecords) {
- Preconditions
- .checkArgument(CollectionUtils.isNotEmpty(dimensionsSplitOrder), "'dimensionsSplitOrder' must be configured");
- Preconditions
- .checkArgument(CollectionUtils.isNotEmpty(functionColumnPairs), "'functionColumnPairs' must be configured");
+ Preconditions.checkArgument(CollectionUtils.isNotEmpty(dimensionsSplitOrder), "'dimensionsSplitOrder' must be configured");
+ Preconditions.checkArgument(CollectionUtils.isNotEmpty(functionColumnPairs), "'functionColumnPairs' must be configured");
_dimensionsSplitOrder = dimensionsSplitOrder;
_skipStarNodeCreationForDimensions = skipStarNodeCreationForDimensions;
_functionColumnPairs = functionColumnPairs;
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableConfig.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableConfig.java
index 984935d..f008d49 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableConfig.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableConfig.java
@@ -112,11 +112,10 @@ public class TableConfig extends BaseJsonConfig {
@JsonProperty(FIELD_CONFIG_LIST_KEY) @Nullable List<FieldConfig> fieldConfigList,
@JsonProperty(UPSERT_CONFIG_KEY) @Nullable UpsertConfig upsertConfig,
@JsonProperty(INGESTION_CONFIG_KEY) @Nullable IngestionConfig ingestionConfig,
- @JsonProperty(TIER_CONFIGS_LIST_KEY) @Nullable List<TierConfig> tierConfigsList,
- @JsonProperty(IS_DIM_TABLE_KEY) boolean dimTable, @JsonProperty(TUNER_CONFIG) @Nullable TunerConfig tunerConfig) {
+ @JsonProperty(TIER_CONFIGS_LIST_KEY) @Nullable List<TierConfig> tierConfigsList, @JsonProperty(IS_DIM_TABLE_KEY) boolean dimTable,
+ @JsonProperty(TUNER_CONFIG) @Nullable TunerConfig tunerConfig) {
Preconditions.checkArgument(tableName != null, "'tableName' must be configured");
- Preconditions.checkArgument(!tableName.contains(TABLE_NAME_FORBIDDEN_SUBSTRING),
- "'tableName' cannot contain double underscore ('__')");
+ Preconditions.checkArgument(!tableName.contains(TABLE_NAME_FORBIDDEN_SUBSTRING), "'tableName' cannot contain double underscore ('__')");
Preconditions.checkArgument(tableType != null, "'tableType' must be configured");
Preconditions.checkArgument(validationConfig != null, "'segmentsConfig' must be configured");
Preconditions.checkArgument(tenantConfig != null, "'tenants' must be configured");
@@ -240,8 +239,7 @@ public class TableConfig extends BaseJsonConfig {
return _instanceAssignmentConfigMap;
}
- public void setInstanceAssignmentConfigMap(
- Map<InstancePartitionsType, InstanceAssignmentConfig> instanceAssignmentConfigMap) {
+ public void setInstanceAssignmentConfigMap(Map<InstancePartitionsType, InstanceAssignmentConfig> instanceAssignmentConfigMap) {
_instanceAssignmentConfigMap = instanceAssignmentConfigMap;
}
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableStatus.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableStatus.java
index 77a55e68..16a0576 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableStatus.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableStatus.java
@@ -40,8 +40,7 @@ public class TableStatus {
private IngestionState _ingestionState;
private String _errorMessage;
- public IngestionStatus(@JsonProperty("ingestionState") String ingestionState,
- @JsonProperty("errorMessage") String errorMessage) {
+ public IngestionStatus(@JsonProperty("ingestionState") String ingestionState, @JsonProperty("errorMessage") String errorMessage) {
_ingestionState = IngestionState.valueOf(ingestionState);
_errorMessage = errorMessage;
}
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableTaskConfig.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableTaskConfig.java
index 40cca73..a37f868 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableTaskConfig.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableTaskConfig.java
@@ -29,8 +29,7 @@ public class TableTaskConfig extends BaseJsonConfig {
private final Map<String, Map<String, String>> _taskTypeConfigsMap;
@JsonCreator
- public TableTaskConfig(
- @JsonProperty(value = "taskTypeConfigsMap", required = true) Map<String, Map<String, String>> taskTypeConfigsMap) {
+ public TableTaskConfig(@JsonProperty(value = "taskTypeConfigsMap", required = true) Map<String, Map<String, String>> taskTypeConfigsMap) {
Preconditions.checkArgument(taskTypeConfigsMap != null, "'taskTypeConfigsMap' must be configured");
_taskTypeConfigsMap = taskTypeConfigsMap;
}
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TierConfig.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TierConfig.java
index 661a35d..2a710f2 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TierConfig.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TierConfig.java
@@ -44,16 +44,15 @@ public class TierConfig extends BaseJsonConfig {
@JsonPropertyDescription("For 'PINOT_SERVER' storageSelector, the tag with which to identify servers for this tier.")
private final String _serverTag;
- // TODO: only "serverTag" is supported currently. In next iteration, "InstanceAssignmentConfig _instanceAssignmentConfig" will be added here
+ // TODO: only "serverTag" is supported currently. In next iteration, "InstanceAssignmentConfig _instanceAssignmentConfig" will be added
+ // here
public TierConfig(@JsonProperty(value = "name", required = true) String name,
@JsonProperty(value = "segmentSelectorType", required = true) String segmentSelectorType,
- @JsonProperty("segmentAge") @Nullable String segmentAge,
- @JsonProperty(value = "storageType", required = true) String storageType,
+ @JsonProperty("segmentAge") @Nullable String segmentAge, @JsonProperty(value = "storageType", required = true) String storageType,
@JsonProperty("serverTag") @Nullable String serverTag) {
Preconditions.checkArgument(name != null, "Must provide non-null 'name' in tierConfig");
- Preconditions
- .checkArgument(segmentSelectorType != null, "Must provide non-null 'segmentSelectorType' in tierConfig");
+ Preconditions.checkArgument(segmentSelectorType != null, "Must provide non-null 'segmentSelectorType' in tierConfig");
Preconditions.checkArgument(storageType != null, "Must provide non-null 'storageType' in tierConfig");
_name = name;
_segmentSelectorType = segmentSelectorType;
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/assignment/InstanceAssignmentConfig.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/assignment/InstanceAssignmentConfig.java
index 69d2f70..9dca456 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/assignment/InstanceAssignmentConfig.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/assignment/InstanceAssignmentConfig.java
@@ -35,18 +35,15 @@ public class InstanceAssignmentConfig extends BaseJsonConfig {
+ " which filters out unqualified instances and sorts instances for picking priority")
private final InstanceConstraintConfig _constraintConfig;
- @JsonPropertyDescription(
- "Configuration for the instance replica-group and partition of the instance assignment (mandatory)")
+ @JsonPropertyDescription("Configuration for the instance replica-group and partition of the instance assignment (mandatory)")
private final InstanceReplicaGroupPartitionConfig _replicaGroupPartitionConfig;
@JsonCreator
- public InstanceAssignmentConfig(
- @JsonProperty(value = "tagPoolConfig", required = true) InstanceTagPoolConfig tagPoolConfig,
+ public InstanceAssignmentConfig(@JsonProperty(value = "tagPoolConfig", required = true) InstanceTagPoolConfig tagPoolConfig,
@JsonProperty("constraintConfig") @Nullable InstanceConstraintConfig constraintConfig,
@JsonProperty(value = "replicaGroupPartitionConfig", required = true) InstanceReplicaGroupPartitionConfig replicaGroupPartitionConfig) {
Preconditions.checkArgument(tagPoolConfig != null, "'tagPoolConfig' must be configured");
- Preconditions
- .checkArgument(replicaGroupPartitionConfig != null, "'replicaGroupPartitionConfig' must be configured");
+ Preconditions.checkArgument(replicaGroupPartitionConfig != null, "'replicaGroupPartitionConfig' must be configured");
_tagPoolConfig = tagPoolConfig;
_constraintConfig = constraintConfig;
_replicaGroupPartitionConfig = replicaGroupPartitionConfig;
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/assignment/InstanceReplicaGroupPartitionConfig.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/assignment/InstanceReplicaGroupPartitionConfig.java
index b78634e..cc49761 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/assignment/InstanceReplicaGroupPartitionConfig.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/assignment/InstanceReplicaGroupPartitionConfig.java
@@ -35,21 +35,23 @@ public class InstanceReplicaGroupPartitionConfig extends BaseJsonConfig {
@JsonPropertyDescription("Number of replica-groups for replica-group based selection")
private final int _numReplicaGroups;
- @JsonPropertyDescription("Number of instances per replica-group for replica-group based selection, select as many instances as possible if not specified")
+ @JsonPropertyDescription("Number of instances per replica-group for replica-group based selection, select as many instances as possible"
+ + " if not specified")
private final int _numInstancesPerReplicaGroup;
- @JsonPropertyDescription("Number of partitions for replica-group based selection, do not partition the replica-group (1 partition) if not specified")
+ @JsonPropertyDescription("Number of partitions for replica-group based selection, do not partition the replica-group (1 partition) if "
+ + "not specified")
private final int _numPartitions;
@JsonPropertyDescription(
- "Number of instances per partition (within a replica-group) for replica-group based selection, select all instances if not specified")
+ "Number of instances per partition (within a replica-group) for replica-group based selection, select all instances if not "
+ + "specified")
private final int _numInstancesPerPartition;
@JsonCreator
public InstanceReplicaGroupPartitionConfig(@JsonProperty("replicaGroupBased") boolean replicaGroupBased,
@JsonProperty("numInstances") int numInstances, @JsonProperty("numReplicaGroups") int numReplicaGroups,
- @JsonProperty("numInstancesPerReplicaGroup") int numInstancesPerReplicaGroup,
- @JsonProperty("numPartitions") int numPartitions,
+ @JsonProperty("numInstancesPerReplicaGroup") int numInstancesPerReplicaGroup, @JsonProperty("numPartitions") int numPartitions,
@JsonProperty("numInstancesPerPartition") int numInstancesPerPartition) {
_replicaGroupBased = replicaGroupBased;
_numInstances = numInstances;
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/assignment/InstanceTagPoolConfig.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/assignment/InstanceTagPoolConfig.java
index 1286b28..b77e2bf 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/assignment/InstanceTagPoolConfig.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/assignment/InstanceTagPoolConfig.java
@@ -35,16 +35,17 @@ public class InstanceTagPoolConfig extends BaseJsonConfig {
@JsonPropertyDescription("Whether to use pool based selection, false by default")
private final boolean _poolBased;
- @JsonPropertyDescription("Number of pools to select for pool based selection, contradict to pools, select all pools if neither of them are specified")
+ @JsonPropertyDescription("Number of pools to select for pool based selection, contradict to pools, select all pools if neither of them "
+ + "are specified")
private final int _numPools;
- @JsonPropertyDescription("Pools to select for pool based selection, contradict to numPools, select all pools if neither of them are specified")
+ @JsonPropertyDescription("Pools to select for pool based selection, contradict to numPools, select all pools if neither of them are "
+ + "specified")
private final List<Integer> _pools;
@JsonCreator
- public InstanceTagPoolConfig(@JsonProperty(value = "tag", required = true) String tag,
- @JsonProperty("poolBased") boolean poolBased, @JsonProperty("numPools") int numPools,
- @JsonProperty("pools") @Nullable List<Integer> pools) {
+ public InstanceTagPoolConfig(@JsonProperty(value = "tag", required = true) String tag, @JsonProperty("poolBased") boolean poolBased,
+ @JsonProperty("numPools") int numPools, @JsonProperty("pools") @Nullable List<Integer> pools) {
Preconditions.checkArgument(tag != null, "'tag' must be configured");
_tag = tag;
_poolBased = poolBased;
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/ingestion/TransformConfig.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/ingestion/TransformConfig.java
index 468308d..83f85cc 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/ingestion/TransformConfig.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/ingestion/TransformConfig.java
@@ -36,8 +36,7 @@ public class TransformConfig extends BaseJsonConfig {
private final String _transformFunction;
@JsonCreator
- public TransformConfig(@JsonProperty("columnName") String columnName,
- @JsonProperty("transformFunction") String transformFunction) {
+ public TransformConfig(@JsonProperty("columnName") String columnName, @JsonProperty("transformFunction") String transformFunction) {
_columnName = columnName;
_transformFunction = transformFunction;
}
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/config/tenant/Tenant.java b/pinot-spi/src/main/java/org/apache/pinot/spi/config/tenant/Tenant.java
index 285e1b1..af76baf 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/config/tenant/Tenant.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/config/tenant/Tenant.java
@@ -35,9 +35,8 @@ public class Tenant extends BaseJsonConfig {
@JsonCreator
public Tenant(@JsonProperty(value = "tenantRole", required = true) TenantRole tenantRole,
- @JsonProperty(value = "tenantName", required = true) String tenantName,
- @JsonProperty("numberOfInstances") int numberOfInstances, @JsonProperty("offlineInstances") int offlineInstances,
- @JsonProperty("realtimeInstances") int realtimeInstances) {
+ @JsonProperty(value = "tenantName", required = true) String tenantName, @JsonProperty("numberOfInstances") int numberOfInstances,
+ @JsonProperty("offlineInstances") int offlineInstances, @JsonProperty("realtimeInstances") int realtimeInstances) {
Preconditions.checkArgument(tenantRole != null, "'tenantRole' must be configured");
Preconditions.checkArgument(tenantName != null, "'tenantName' must be configured");
_tenantRole = tenantRole;
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFieldSpec.java b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFieldSpec.java
index 562b414..c197dde 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFieldSpec.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFieldSpec.java
@@ -78,10 +78,11 @@ public final class DateTimeFieldSpec extends FieldSpec {
}
/**
- * Constructs a DateTimeFieldSpec with basic fields - name, dataType, format, granularity - and also with defaultNullValue and transformFunction
+ * Constructs a DateTimeFieldSpec with basic fields - name, dataType, format, granularity - and also with defaultNullValue and
+ * transformFunction
*/
- public DateTimeFieldSpec(String name, DataType dataType, String format, String granularity,
- @Nullable Object defaultNullValue, @Nullable String transformFunction) {
+ public DateTimeFieldSpec(String name, DataType dataType, String format, String granularity, @Nullable Object defaultNullValue,
+ @Nullable String transformFunction) {
this(name, dataType, format, granularity);
setDefaultNullValue(defaultNullValue);
setTransformFunction(transformFunction);
@@ -127,8 +128,8 @@ public final class DateTimeFieldSpec extends FieldSpec {
@Override
public String toString() {
- return "< field type: DATE_TIME, field name: " + _name + ", datatype: " + _dataType + ", time column format: "
- + _format + ", time field granularity: " + _granularity + " >";
+ return "< field type: DATE_TIME, field name: " + _name + ", datatype: " + _dataType + ", time column format: " + _format
+ + ", time field granularity: " + _granularity + " >";
}
@Override
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatPatternSpec.java b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatPatternSpec.java
index e91c257..ca8c3b9 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatPatternSpec.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatPatternSpec.java
@@ -86,8 +86,8 @@ public class DateTimeFormatPatternSpec {
DateTimeFormatPatternSpec that = (DateTimeFormatPatternSpec) o;
- return EqualityUtils.isEqual(_timeFormat, that._timeFormat) && EqualityUtils.isEqual(_sdfPattern, that._sdfPattern)
- && EqualityUtils.isEqual(_dateTimeZone, that._dateTimeZone);
+ return EqualityUtils.isEqual(_timeFormat, that._timeFormat) && EqualityUtils.isEqual(_sdfPattern, that._sdfPattern) && EqualityUtils
+ .isEqual(_dateTimeZone, that._dateTimeZone);
}
@Override
@@ -100,7 +100,7 @@ public class DateTimeFormatPatternSpec {
@Override
public String toString() {
- return "DateTimeFormatPatternSpec{" + "_timeFormat=" + _timeFormat + ", _sdfPattern='" + _sdfPattern + '\''
- + ", _dateTimeZone=" + _dateTimeZone + ", _dateTimeFormatter=" + _dateTimeFormatter + '}';
+ return "DateTimeFormatPatternSpec{" + "_timeFormat=" + _timeFormat + ", _sdfPattern='" + _sdfPattern + '\'' + ", _dateTimeZone="
+ + _dateTimeZone + ", _dateTimeFormatter=" + _dateTimeFormatter + '}';
}
}
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatSpec.java b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatSpec.java
index e6dec59..0147883 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatSpec.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatSpec.java
@@ -57,8 +57,7 @@ public class DateTimeFormatSpec {
validateFormat(format);
String[] formatTokens = StringUtils.split(format, COLON_SEPARATOR, MAX_FORMAT_TOKENS);
if (formatTokens.length == MAX_FORMAT_TOKENS) {
- _patternSpec = new DateTimeFormatPatternSpec(formatTokens[FORMAT_TIMEFORMAT_POSITION],
- formatTokens[FORMAT_PATTERN_POSITION]);
+ _patternSpec = new DateTimeFormatPatternSpec(formatTokens[FORMAT_TIMEFORMAT_POSITION], formatTokens[FORMAT_PATTERN_POSITION]);
} else {
_patternSpec = new DateTimeFormatPatternSpec(formatTokens[FORMAT_TIMEFORMAT_POSITION], null);
}
@@ -189,15 +188,15 @@ public class DateTimeFormatSpec {
DateTimeFormatUnitSpec.validateUnitSpec(formatTokens[FORMAT_UNIT_POSITION]);
if (formatTokens.length == MIN_FORMAT_TOKENS) {
- Preconditions.checkState(formatTokens[FORMAT_TIMEFORMAT_POSITION].equals(TimeFormat.EPOCH.toString())
- || formatTokens[FORMAT_TIMEFORMAT_POSITION].equals(TimeFormat.TIMESTAMP.toString()),
+ Preconditions.checkState(
+ formatTokens[FORMAT_TIMEFORMAT_POSITION].equals(TimeFormat.EPOCH.toString()) || formatTokens[FORMAT_TIMEFORMAT_POSITION]
+ .equals(TimeFormat.TIMESTAMP.toString()),
"Incorrect format type: %s in format: %s. Must be of '[0-9]+:<TimeUnit>:EPOCH|TIMESTAMP'",
formatTokens[FORMAT_TIMEFORMAT_POSITION], format);
} else {
- Preconditions
- .checkState(formatTokens[FORMAT_TIMEFORMAT_POSITION].equals(TimeFormat.SIMPLE_DATE_FORMAT.toString()),
- "Incorrect format type: %s in format: %s. Must be of '[0-9]+:<TimeUnit>:SIMPLE_DATE_FORMAT:pattern'",
- formatTokens[FORMAT_TIMEFORMAT_POSITION], format);
+ Preconditions.checkState(formatTokens[FORMAT_TIMEFORMAT_POSITION].equals(TimeFormat.SIMPLE_DATE_FORMAT.toString()),
+ "Incorrect format type: %s in format: %s. Must be of '[0-9]+:<TimeUnit>:SIMPLE_DATE_FORMAT:pattern'",
+ formatTokens[FORMAT_TIMEFORMAT_POSITION], format);
}
}
@@ -228,7 +227,7 @@ public class DateTimeFormatSpec {
@Override
public String toString() {
- return "DateTimeFormatSpec{" + "_format='" + _format + '\'' + ", _size=" + _size + ", _unitSpec=" + _unitSpec
- + ", _patternSpec=" + _patternSpec + '}';
+ return "DateTimeFormatSpec{" + "_format='" + _format + '\'' + ", _size=" + _size + ", _unitSpec=" + _unitSpec + ", _patternSpec="
+ + _patternSpec + '}';
}
}
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatUnitSpec.java b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatUnitSpec.java
index 56c11e0..6d412ce 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatUnitSpec.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatUnitSpec.java
@@ -120,8 +120,7 @@ public class DateTimeFormatUnitSpec {
}
public static void validateUnitSpec(String unit) {
- Preconditions.checkState(
- EnumUtils.isValidEnum(TimeUnit.class, unit) || EnumUtils.isValidEnum(DateTimeTransformUnit.class, unit),
+ Preconditions.checkState(EnumUtils.isValidEnum(TimeUnit.class, unit) || EnumUtils.isValidEnum(DateTimeTransformUnit.class, unit),
"Unit: %s must belong to enum TimeUnit or DateTimeTransformUnit", unit);
}
@@ -137,8 +136,7 @@ public class DateTimeFormatUnitSpec {
... 2520 lines suppressed ...
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org