This is an automated email from the ASF dual-hosted git repository. jackie 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 8333688e4e Replace More String.format() Usages With Concatenation (#14539) 8333688e4e is described below commit 8333688e4ecec030b334f4d3239b6737ef17fdea Author: ashishjayamohan <46698969+ashishjayamo...@users.noreply.github.com> AuthorDate: Tue Nov 26 11:41:17 2024 -0800 Replace More String.format() Usages With Concatenation (#14539) --- .../pinot/core/auth/FineGrainedAuthUtils.java | 4 +- .../core/common/datablock/DataBlockBuilder.java | 10 ++- .../manager/realtime/IngestionDelayTracker.java | 4 +- .../realtime/RealtimeSegmentDataManager.java | 42 ++++++------ .../manager/realtime/RealtimeTableDataManager.java | 20 +++--- .../function/BaseBooleanAggregationFunction.java | 8 +-- .../query/executor/ServerQueryExecutorV1Impl.java | 13 ++-- .../postaggregation/PostAggregationFunction.java | 7 +- .../core/query/reduce/BrokerReduceService.java | 5 +- .../pinot/core/query/scheduler/QueryScheduler.java | 6 +- .../query/selection/SelectionOperatorUtils.java | 10 ++- .../core/query/utils/OrderByComparatorFactory.java | 5 +- .../pinot/core/util/DataBlockExtractUtils.java | 76 +++++++++------------- .../org/apache/pinot/core/util/GapfillUtils.java | 2 +- .../apache/pinot/core/util/ListenerConfigUtil.java | 2 +- .../apache/pinot/spi/data/DateTimeFormatSpec.java | 4 +- .../apache/pinot/spi/data/readers/PrimaryKey.java | 8 +-- .../pinot/spi/env/CommonsConfigurationUtils.java | 4 +- .../spi/ingestion/batch/IngestionJobLauncher.java | 5 +- .../org/apache/pinot/spi/plugin/PluginManager.java | 2 +- .../java/org/apache/pinot/spi/utils/JsonUtils.java | 16 ++--- .../org/apache/pinot/spi/utils/TimestampUtils.java | 4 +- .../apache/pinot/spi/config/ConfigUtilsTest.java | 4 +- .../spi/env/CommonsConfigurationUtilsTest.java | 3 +- 24 files changed, 116 insertions(+), 148 deletions(-) diff --git a/pinot-core/src/main/java/org/apache/pinot/core/auth/FineGrainedAuthUtils.java b/pinot-core/src/main/java/org/apache/pinot/core/auth/FineGrainedAuthUtils.java index d55d6e8b71..5f2480727d 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/auth/FineGrainedAuthUtils.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/auth/FineGrainedAuthUtils.java @@ -117,8 +117,8 @@ public class FineGrainedAuthUtils { } catch (Throwable t) { // catch and log Throwable for NoSuchMethodError which can happen when there are classpath conflicts // otherwise, grizzly will return a 500 without any logs or indication of what failed - String errorMsg = String.format("Failed to check for access for target type %s and target ID %s with action %s", - auth.targetType(), targetId, auth.action()); + String errorMsg = "Failed to check for access for target type " + auth.targetType() + " and target ID " + + targetId + " with action " + auth.action(); LOGGER.error(errorMsg, t); throw new WebApplicationException(errorMsg, t, Response.Status.INTERNAL_SERVER_ERROR); } diff --git a/pinot-core/src/main/java/org/apache/pinot/core/common/datablock/DataBlockBuilder.java b/pinot-core/src/main/java/org/apache/pinot/core/common/datablock/DataBlockBuilder.java index 99fa3f8cbf..c795f5af25 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/common/datablock/DataBlockBuilder.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/common/datablock/DataBlockBuilder.java @@ -147,9 +147,8 @@ public class DataBlockBuilder { break; default: - throw new IllegalStateException( - String.format("Unsupported stored type: %s for column: %s", storedTypes[colId], - dataSchema.getColumnName(colId))); + throw new IllegalStateException("Unsupported stored type: " + storedTypes[colId] + " for column: " + + dataSchema.getColumnName(colId)); } } } @@ -402,9 +401,8 @@ public class DataBlockBuilder { break; default: - throw new IllegalStateException( - String.format("Unsupported stored type: %s for column: %s", storedType, - dataSchema.getColumnName(colId))); + throw new IllegalStateException("Unsupported stored type: " + storedType + " for column: " + + dataSchema.getColumnName(colId)); } } diff --git a/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/IngestionDelayTracker.java b/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/IngestionDelayTracker.java index fd31d8f72b..048f7564b1 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/IngestionDelayTracker.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/IngestionDelayTracker.java @@ -152,8 +152,8 @@ public class IngestionDelayTracker { _isServerReadyToServeQueries = isServerReadyToServeQueries; // Handle negative timer values if (scheduledExecutorThreadTickIntervalMs <= 0) { - throw new RuntimeException(String.format("Illegal timer timeout argument, expected > 0, got=%d for table=%s", - scheduledExecutorThreadTickIntervalMs, _tableNameWithType)); + throw new RuntimeException("Illegal timer timeout argument, expected > 0, got=" + + scheduledExecutorThreadTickIntervalMs + " for table=" + _tableNameWithType); } // ThreadFactory to set the thread's name diff --git a/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java b/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java index 8336a6f369..35e8aa3c46 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java @@ -514,9 +514,8 @@ public class RealtimeSegmentDataManager extends SegmentDataManager { if (idleTimeoutMillis >= 0 && (timeSinceStreamLastCreatedOrConsumedMs > idleTimeoutMillis)) { // Create a new stream consumer wrapper, in case we are stuck on something. - recreateStreamConsumer( - String.format("Total idle time: %d ms exceeded idle timeout: %d ms", - timeSinceStreamLastCreatedOrConsumedMs, idleTimeoutMillis)); + recreateStreamConsumer("Total idle time: " + timeSinceStreamLastCreatedOrConsumedMs + + " ms exceeded idle timeout: " + idleTimeoutMillis + " ms"); _idleTimer.markStreamCreated(); } } @@ -624,9 +623,8 @@ public class RealtimeSegmentDataManager extends SegmentDataManager { _numBytesDropped += rowSizeInBytes; // when exception happens we prefer abandoning the whole batch and not partially indexing some rows reusedResult.getTransformedRows().clear(); - String errorMessage = - String.format("Caught exception while transforming the record at offset: %s , row: %s", offset, - decodedRow.getResult()); + String errorMessage = "Caught exception while transforming the record at offset: " + offset + " , row: " + + decodedRow.getResult(); _segmentLogger.error(errorMessage, e); _realtimeTableDataManager.addSegmentError(_segmentNameStr, new SegmentErrorInfo(now(), errorMessage, e)); } @@ -666,9 +664,8 @@ public class RealtimeSegmentDataManager extends SegmentDataManager { } catch (Exception e) { _numRowsErrored++; _numBytesDropped += rowSizeInBytes; - String errorMessage = - String.format("Caught exception while indexing the record at offset: %s , row: %s", offset, - transformedRow); + String errorMessage = "Caught exception while indexing the record at offset: " + offset + " , row: " + + transformedRow; _segmentLogger.error(errorMessage, e); _realtimeTableDataManager.addSegmentError(_segmentNameStr, new SegmentErrorInfo(now(), errorMessage, e)); } @@ -977,9 +974,9 @@ public class RealtimeSegmentDataManager extends SegmentDataManager { private void reportDataLoss(MessageBatch messageBatch) { if (messageBatch.hasDataLoss()) { _serverMetrics.setValueOfTableGauge(_tableStreamName, ServerGauge.STREAM_DATA_LOSS, 1L); - String message = String.format("Message loss detected in stream partition: %s for table: %s startOffset: %s " - + "batchFirstOffset: %s", _partitionGroupId, _tableNameWithType, _startOffset, - messageBatch.getFirstMessageOffset()); + String message = "Message loss detected in stream partition: " + _partitionGroupId + " for table: " + + _tableNameWithType + " startOffset: " + _startOffset + " batchFirstOffset: " + + messageBatch.getFirstMessageOffset(); _segmentLogger.error(message); _realtimeTableDataManager.addSegmentError(_segmentNameStr, new SegmentErrorInfo(now(), message, null)); } @@ -1084,8 +1081,8 @@ public class RealtimeSegmentDataManager extends SegmentDataManager { try { FileUtils.moveDirectory(tempIndexDir, indexDir); } catch (IOException e) { - String errorMessage = - String.format("Caught exception while moving index directory from: %s to: %s", tempIndexDir, indexDir); + String errorMessage = "Caught exception while moving index directory from: " + tempIndexDir + " to: " + + indexDir; _segmentLogger.error(errorMessage, e); _realtimeTableDataManager.addSegmentError(_segmentNameStr, new SegmentErrorInfo(now(), errorMessage, e)); return null; @@ -1104,8 +1101,8 @@ public class RealtimeSegmentDataManager extends SegmentDataManager { try { TarCompressionUtils.createCompressedTarFile(indexDir, segmentTarFile); } catch (IOException e) { - String errorMessage = - String.format("Caught exception while taring index directory from: %s to: %s", indexDir, segmentTarFile); + String errorMessage = "Caught exception while taring index directory from: " + indexDir + " to: " + + segmentTarFile; _segmentLogger.error(errorMessage, e); _realtimeTableDataManager.addSegmentError(_segmentNameStr, new SegmentErrorInfo(now(), errorMessage, e)); return null; @@ -1113,16 +1110,16 @@ public class RealtimeSegmentDataManager extends SegmentDataManager { File metadataFile = SegmentDirectoryPaths.findMetadataFile(indexDir); if (metadataFile == null) { - String errorMessage = String.format("Failed to find file: %s under index directory: %s", - V1Constants.MetadataKeys.METADATA_FILE_NAME, indexDir); + String errorMessage = "Failed to find file: " + V1Constants.MetadataKeys.METADATA_FILE_NAME + + " under index directory: " + indexDir; _segmentLogger.error(errorMessage); _realtimeTableDataManager.addSegmentError(_segmentNameStr, new SegmentErrorInfo(now(), errorMessage, null)); return null; } File creationMetaFile = SegmentDirectoryPaths.findCreationMetaFile(indexDir); if (creationMetaFile == null) { - String errorMessage = String.format("Failed to find file: %s under index directory: %s", - V1Constants.SEGMENT_CREATION_META, indexDir); + String errorMessage = "Failed to find file: " + V1Constants.SEGMENT_CREATION_META + " under index directory: " + + indexDir; _segmentLogger.error(errorMessage); _realtimeTableDataManager.addSegmentError(_segmentNameStr, new SegmentErrorInfo(now(), errorMessage, null)); return null; @@ -1716,9 +1713,8 @@ public class RealtimeSegmentDataManager extends SegmentDataManager { try { return _partitionMetadataProvider.fetchStreamPartitionOffset(offsetCriteria, maxWaitTimeMs); } catch (Exception e) { - String logMessage = String.format( - "Cannot fetch stream offset with criteria %s for clientId %s and partitionGroupId %d with maxWaitTime %d", - offsetCriteria, _clientId, _partitionGroupId, maxWaitTimeMs); + String logMessage = "Cannot fetch stream offset with criteria " + offsetCriteria + " for clientId " + _clientId + + " and partitionGroupId " + _partitionGroupId + " with maxWaitTime " + maxWaitTimeMs; if (!useDebugLog) { _segmentLogger.warn(logMessage, e); } else { diff --git a/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeTableDataManager.java b/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeTableDataManager.java index 34e2366966..2b4778d390 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeTableDataManager.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeTableDataManager.java @@ -424,9 +424,8 @@ public class RealtimeTableDataManager extends BaseTableDataManager { } String segmentName = zkMetadata.getSegmentName(); Integer partitionId = SegmentUtils.getRealtimeSegmentPartitionId(segmentName, zkMetadata, null); - Preconditions.checkState(partitionId != null, - String.format("Failed to get partition id for segment: %s in upsert-enabled table: %s", segmentName, - _tableNameWithType)); + Preconditions.checkState(partitionId != null, "Failed to get partition id for segment: " + segmentName + + " in upsert-enabled table: " + _tableNameWithType); _tableUpsertMetadataManager.getOrCreatePartitionManager(partitionId).preloadSegments(indexLoadingConfig); } @@ -439,9 +438,8 @@ public class RealtimeTableDataManager extends BaseTableDataManager { } String segmentName = zkMetadata.getSegmentName(); Integer partitionId = SegmentUtils.getRealtimeSegmentPartitionId(segmentName, zkMetadata, null); - Preconditions.checkState(partitionId != null, - String.format("Failed to get partition id for segment: %s in dedup-enabled table: %s", segmentName, - _tableNameWithType)); + Preconditions.checkState(partitionId != null, "Failed to get partition id for segment: " + segmentName + + " in dedup-enabled table: " + _tableNameWithType); _tableDedupMetadataManager.getOrCreatePartitionManager(partitionId).preloadSegments(indexLoadingConfig); } @@ -598,9 +596,8 @@ public class RealtimeTableDataManager extends BaseTableDataManager { _logger.info("Adding immutable segment: {} with dedup enabled", segmentName); Integer partitionId = SegmentUtils.getRealtimeSegmentPartitionId(segmentName, _tableNameWithType, _helixManager, null); - Preconditions.checkNotNull(partitionId, - String.format("PartitionId is not available for segment: '%s' (dedup-enabled table: %s)", segmentName, - _tableNameWithType)); + Preconditions.checkNotNull(partitionId, "PartitionId is not available for segment: '" + segmentName + + "' (dedup-enabled table: " + _tableNameWithType + ")"); PartitionDedupMetadataManager partitionDedupMetadataManager = _tableDedupMetadataManager.getOrCreatePartitionManager(partitionId); immutableSegment.enableDedup(partitionDedupMetadataManager); @@ -627,9 +624,8 @@ public class RealtimeTableDataManager extends BaseTableDataManager { Integer partitionId = SegmentUtils.getRealtimeSegmentPartitionId(segmentName, _tableNameWithType, _helixManager, null); - Preconditions.checkNotNull(partitionId, - String.format("Failed to get partition id for segment: %s (upsert-enabled table: %s)", segmentName, - _tableNameWithType)); + Preconditions.checkNotNull(partitionId, "Failed to get partition id for segment: " + segmentName + + " (upsert-enabled table: " + _tableNameWithType + ")"); PartitionUpsertMetadataManager partitionUpsertMetadataManager = _tableUpsertMetadataManager.getOrCreatePartitionManager(partitionId); diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/BaseBooleanAggregationFunction.java b/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/BaseBooleanAggregationFunction.java index 5c14c44dcc..fa08ffc028 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/BaseBooleanAggregationFunction.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/BaseBooleanAggregationFunction.java @@ -106,8 +106,8 @@ public abstract class BaseBooleanAggregationFunction extends NullableSingleInput BlockValSet blockValSet = blockValSetMap.get(_expression); if (blockValSet.getValueType() != FieldSpec.DataType.BOOLEAN) { - throw new IllegalArgumentException( - String.format("Unsupported data type %s for %s", getType().getName(), blockValSet.getValueType())); + throw new IllegalArgumentException("Unsupported data type " + getType().getName() + " for " + + blockValSet.getValueType()); } int[] bools = blockValSet.getIntValuesSV(); @@ -150,8 +150,8 @@ public abstract class BaseBooleanAggregationFunction extends NullableSingleInput BlockValSet blockValSet = blockValSetMap.get(_expression); if (blockValSet.getValueType() != FieldSpec.DataType.BOOLEAN) { - throw new IllegalArgumentException( - String.format("Unsupported data type %s for %s", getType().getName(), blockValSet.getValueType())); + throw new IllegalArgumentException("Unsupported data type " + getType().getName() + " for " + + blockValSet.getValueType()); } int[] bools = blockValSet.getIntValuesSV(); diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/executor/ServerQueryExecutorV1Impl.java b/pinot-core/src/main/java/org/apache/pinot/core/query/executor/ServerQueryExecutorV1Impl.java index 58d3befb56..16cde432c1 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/query/executor/ServerQueryExecutorV1Impl.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/query/executor/ServerQueryExecutorV1Impl.java @@ -186,9 +186,8 @@ public class ServerQueryExecutorV1Impl implements QueryExecutor { long querySchedulingTimeMs = System.currentTimeMillis() - queryArrivalTimeMs; if (querySchedulingTimeMs >= queryTimeoutMs) { _serverMetrics.addMeteredTableValue(tableNameWithType, ServerMeter.SCHEDULING_TIMEOUT_EXCEPTIONS, 1); - String errorMessage = - String.format("Query scheduling took %dms (longer than query timeout of %dms) on server: %s", - querySchedulingTimeMs, queryTimeoutMs, _instanceDataManager.getInstanceId()); + String errorMessage = "Query scheduling took " + querySchedulingTimeMs + "ms (longer than query timeout of " + + queryTimeoutMs + "ms) on server: " + _instanceDataManager.getInstanceId(); InstanceResponseBlock instanceResponse = new InstanceResponseBlock(); instanceResponse.addException( QueryException.getException(QueryException.QUERY_SCHEDULING_TIMEOUT_ERROR, errorMessage)); @@ -198,8 +197,8 @@ public class ServerQueryExecutorV1Impl implements QueryExecutor { TableDataManager tableDataManager = _instanceDataManager.getTableDataManager(tableNameWithType); if (tableDataManager == null) { - String errorMessage = String.format("Failed to find table: %s on server: %s", tableNameWithType, - _instanceDataManager.getInstanceId()); + String errorMessage = "Failed to find table: " + tableNameWithType + " on server: " + + _instanceDataManager.getInstanceId(); InstanceResponseBlock instanceResponse = new InstanceResponseBlock(); instanceResponse.addException( QueryException.getException(QueryException.SERVER_TABLE_MISSING_ERROR, errorMessage)); @@ -373,8 +372,8 @@ public class ServerQueryExecutorV1Impl implements QueryExecutor { int numMissingSegments = missingSegments.size(); if (numMissingSegments > 0) { instanceResponse.addException(QueryException.getException(QueryException.SERVER_SEGMENT_MISSING_ERROR, - String.format("%d segments %s missing on server: %s", numMissingSegments, missingSegments, - _instanceDataManager.getInstanceId()))); + numMissingSegments + " segments " + missingSegments + " missing on server: " + + _instanceDataManager.getInstanceId())); _serverMetrics.addMeteredTableValue(tableNameWithType, ServerMeter.NUM_MISSING_SEGMENTS, numMissingSegments); } } diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/postaggregation/PostAggregationFunction.java b/pinot-core/src/main/java/org/apache/pinot/core/query/postaggregation/PostAggregationFunction.java index 1ad0fdfaf4..610fcca413 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/query/postaggregation/PostAggregationFunction.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/query/postaggregation/PostAggregationFunction.java @@ -43,11 +43,10 @@ public class PostAggregationFunction { FunctionInfo functionInfo = FunctionRegistry.lookupFunctionInfo(canonicalName, argumentTypes); if (functionInfo == null) { if (FunctionRegistry.contains(canonicalName)) { - throw new IllegalArgumentException( - String.format("Unsupported function: %s with argument types: %s", functionName, - Arrays.toString(argumentTypes))); + throw new IllegalArgumentException("Unsupported function: " + functionName + " with argument types: " + + Arrays.toString(argumentTypes)); } else { - throw new IllegalArgumentException(String.format("Unsupported function: %s", functionName)); + throw new IllegalArgumentException("Unsupported function: " + functionName); } } _functionInvoker = new FunctionInvoker(functionInfo); diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/reduce/BrokerReduceService.java b/pinot-core/src/main/java/org/apache/pinot/core/query/reduce/BrokerReduceService.java index 03d801941e..b9b0f7bb51 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/query/reduce/BrokerReduceService.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/query/reduce/BrokerReduceService.java @@ -121,9 +121,8 @@ public class BrokerReduceService extends BaseReduceService { // Report the servers with conflicting data schema. if (!serversWithConflictingDataSchema.isEmpty()) { - String errorMessage = - String.format("%s: responses for table: %s from servers: %s got dropped due to data schema inconsistency.", - QueryException.MERGE_RESPONSE_ERROR.getMessage(), tableName, serversWithConflictingDataSchema); + String errorMessage = QueryException.MERGE_RESPONSE_ERROR.getMessage() + ": responses for table: " + tableName + + " from servers: " + serversWithConflictingDataSchema + " got dropped due to data schema inconsistency."; LOGGER.warn(errorMessage); brokerMetrics.addMeteredTableValue(rawTableName, BrokerMeter.RESPONSE_MERGE_EXCEPTIONS, 1); brokerResponseNative.addException( diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java b/pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java index f4c2a241e7..fb5378a414 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java @@ -164,9 +164,9 @@ public abstract class QueryScheduler { Map<String, String> queryOptions = queryRequest.getQueryContext().getQueryOptions(); Long maxResponseSizeBytes = QueryOptionsUtils.getMaxServerResponseSizeBytes(queryOptions); if (maxResponseSizeBytes != null && responseBytes != null && responseBytes.length > maxResponseSizeBytes) { - String errMsg = - String.format("Serialized query response size %d exceeds threshold %d for requestId %d from broker %s", - responseBytes.length, maxResponseSizeBytes, queryRequest.getRequestId(), queryRequest.getBrokerId()); + String errMsg = "Serialized query response size " + responseBytes.length + " exceeds threshold " + + maxResponseSizeBytes + " for requestId " + queryRequest.getRequestId() + " from broker " + + queryRequest.getBrokerId(); LOGGER.error(errMsg); _serverMetrics.addMeteredTableValue(queryRequest.getTableNameWithType(), ServerMeter.LARGE_QUERY_RESPONSE_SIZE_EXCEPTIONS, 1); diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/selection/SelectionOperatorUtils.java b/pinot-core/src/main/java/org/apache/pinot/core/query/selection/SelectionOperatorUtils.java index 4614b2f20b..20b52876ea 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/query/selection/SelectionOperatorUtils.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/query/selection/SelectionOperatorUtils.java @@ -440,9 +440,8 @@ public class SelectionOperatorUtils { break; default: - throw new IllegalStateException( - String.format("Unsupported data type: %s for column: %s", storedColumnDataTypes[i], - dataSchema.getColumnName(i))); + throw new IllegalStateException("Unsupported data type: " + storedColumnDataTypes + " for column: " + + dataSchema.getColumnName(i)); } } dataTableBuilder.finishRow(); @@ -519,9 +518,8 @@ public class SelectionOperatorUtils { break; default: - throw new IllegalStateException( - String.format("Unsupported data type: %s for column: %s", storedColumnDataTypes[i], - dataSchema.getColumnName(i))); + throw new IllegalStateException("Unsupported data type: " + storedColumnDataTypes[i] + " for column: " + + dataSchema.getColumnName(i)); } } diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/utils/OrderByComparatorFactory.java b/pinot-core/src/main/java/org/apache/pinot/core/query/utils/OrderByComparatorFactory.java index c9d063ead3..65ddad8a78 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/query/utils/OrderByComparatorFactory.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/query/utils/OrderByComparatorFactory.java @@ -45,9 +45,8 @@ public class OrderByComparatorFactory { for (int i = from; i < to; i++) { if (!orderByColumnContexts[i].isSingleValue()) { // MV columns should not be part of the selection order-by list - throw new BadQueryRequestException( - String.format("MV expression: %s should not be included in the ORDER-BY clause", - orderByExpressions.get(i))); + throw new BadQueryRequestException("MV expression: " + orderByExpressions.get(i) + + " should not be included in the ORDER-BY clause"); } } diff --git a/pinot-core/src/main/java/org/apache/pinot/core/util/DataBlockExtractUtils.java b/pinot-core/src/main/java/org/apache/pinot/core/util/DataBlockExtractUtils.java index 45e35aca34..76b0a62322 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/util/DataBlockExtractUtils.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/util/DataBlockExtractUtils.java @@ -102,8 +102,8 @@ public final class DataBlockExtractUtils { return ObjectSerDeUtils.deserialize(dataBlock.getCustomObject(rowId, colId)); default: - throw new IllegalStateException(String.format("Unsupported stored type: %s for column: %s", storedType, - dataBlock.getDataSchema().getColumnName(colId))); + throw new IllegalStateException("Unsupported stored type: " + storedType + " for column: " + + dataBlock.getDataSchema().getColumnName(colId)); } } @@ -235,8 +235,8 @@ public final class DataBlockExtractUtils { } break; default: - throw new IllegalStateException(String.format("Cannot extract int values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract int values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } else { switch (storedType) { @@ -276,8 +276,8 @@ public final class DataBlockExtractUtils { } break; default: - throw new IllegalStateException(String.format("Cannot extract int values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract int values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } return values; @@ -318,9 +318,8 @@ public final class DataBlockExtractUtils { } break; default: - throw new IllegalStateException( - String.format("Cannot extract long values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract long values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } else { switch (storedType) { @@ -360,9 +359,8 @@ public final class DataBlockExtractUtils { } break; default: - throw new IllegalStateException( - String.format("Cannot extract long values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract long values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } return values; @@ -403,9 +401,8 @@ public final class DataBlockExtractUtils { } break; default: - throw new IllegalStateException( - String.format("Cannot extract float values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract float values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } else { switch (storedType) { @@ -445,9 +442,8 @@ public final class DataBlockExtractUtils { } break; default: - throw new IllegalStateException( - String.format("Cannot extract float values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract float values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } return values; @@ -488,9 +484,8 @@ public final class DataBlockExtractUtils { } break; default: - throw new IllegalStateException( - String.format("Cannot extract double values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract double values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } else { switch (storedType) { @@ -530,9 +525,8 @@ public final class DataBlockExtractUtils { } break; default: - throw new IllegalStateException( - String.format("Cannot extract double values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract double values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } return values; @@ -577,9 +571,8 @@ public final class DataBlockExtractUtils { } break; default: - throw new IllegalStateException( - String.format("Cannot extract BigDecimal values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract BigDecimal values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } else { switch (storedType) { @@ -616,9 +609,8 @@ public final class DataBlockExtractUtils { } break; default: - throw new IllegalStateException( - String.format("Cannot extract BigDecimal values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract BigDecimal values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } return values; @@ -706,8 +698,8 @@ public final class DataBlockExtractUtils { values[matchedRowId] = dataBlock.getBigDecimal(rowId, colId).intValue(); break; default: - throw new IllegalStateException(String.format("Cannot extract int values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract int values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } return values; @@ -742,9 +734,8 @@ public final class DataBlockExtractUtils { values[matchedRowId] = dataBlock.getBigDecimal(rowId, colId).longValue(); break; default: - throw new IllegalStateException( - String.format("Cannot extract long values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract long values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } return values; @@ -779,9 +770,8 @@ public final class DataBlockExtractUtils { values[matchedRowId] = dataBlock.getBigDecimal(rowId, colId).floatValue(); break; default: - throw new IllegalStateException( - String.format("Cannot extract float values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract float values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } return values; @@ -816,9 +806,8 @@ public final class DataBlockExtractUtils { values[matchedRowId] = dataBlock.getBigDecimal(rowId, colId).doubleValue(); break; default: - throw new IllegalStateException( - String.format("Cannot extract double values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract double values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } return values; @@ -858,9 +847,8 @@ public final class DataBlockExtractUtils { values[matchedRowId] = dataBlock.getBigDecimal(rowId, colId); break; default: - throw new IllegalStateException( - String.format("Cannot extract BigDecimal values for column: %s with stored type: %s", - dataBlock.getDataSchema().getColumnName(colId), storedType)); + throw new IllegalStateException("Cannot extract BigDecimal values for column: " + + dataBlock.getDataSchema().getColumnName(colId) + " with stored type: " + storedType); } } return values; diff --git a/pinot-core/src/main/java/org/apache/pinot/core/util/GapfillUtils.java b/pinot-core/src/main/java/org/apache/pinot/core/util/GapfillUtils.java index c353115dcf..d5e75de3f3 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/util/GapfillUtils.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/util/GapfillUtils.java @@ -107,7 +107,7 @@ public class GapfillUtils { case BYTES_ARRAY: return new byte[0][0]; default: - throw new IllegalStateException(String.format("Cannot provide the default value for the type: %s", dataType)); + throw new IllegalStateException("Cannot provide the default value for the type: " + dataType); } } diff --git a/pinot-core/src/main/java/org/apache/pinot/core/util/ListenerConfigUtil.java b/pinot-core/src/main/java/org/apache/pinot/core/util/ListenerConfigUtil.java index 1bff874ff8..4c6c788160 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/util/ListenerConfigUtil.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/util/ListenerConfigUtil.java @@ -310,7 +310,7 @@ public final class ListenerConfigUtil { return tempFile; } catch (Exception e) { - throw new IllegalStateException(String.format("Could not retrieve and cache keystore from '%s'", sourceUrl), e); + throw new IllegalStateException("Could not retrieve and cache keystore from '" + sourceUrl + "'", e); } } } 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 e88e001d20..d3242c04b6 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 @@ -190,8 +190,8 @@ public class DateTimeFormatSpec { tokens.length > PIPE_FORMAT_PATTERN_POSITION ? tokens[PIPE_FORMAT_PATTERN_POSITION] : null; _patternSpec = new DateTimeFormatPatternSpec(TimeFormat.SIMPLE_DATE_FORMAT, pattern); } catch (Exception e) { - throw new IllegalArgumentException(String.format("Invalid SIMPLE_DATE_FORMAT pattern: %s in format: %s", - tokens[PIPE_FORMAT_PATTERN_POSITION], format)); + throw new IllegalArgumentException("Invalid SIMPLE_DATE_FORMAT pattern: " + + tokens[PIPE_FORMAT_PATTERN_POSITION] + " in format: " + format); } } break; diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/data/readers/PrimaryKey.java b/pinot-spi/src/main/java/org/apache/pinot/spi/data/readers/PrimaryKey.java index 7b31312ee8..a3f9d9c604 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/data/readers/PrimaryKey.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/data/readers/PrimaryKey.java @@ -68,8 +68,8 @@ public final class PrimaryKey { cache[i] = BigDecimalUtils.serialize((BigDecimal) value); sizeInBytes += cache[i].length + Integer.BYTES; } else { - throw new IllegalStateException( - String.format("Unsupported value: %s of type: %s", value, value != null ? value.getClass() : null)); + throw new IllegalStateException("Unsupported value: " + value + " of type: " + (value != null ? value.getClass() + : null)); } } @@ -117,8 +117,8 @@ public final class PrimaryKey { } else if (value instanceof BigDecimal) { return BigDecimalUtils.serialize((BigDecimal) value); } else { - throw new IllegalStateException( - String.format("Unsupported value: %s of type: %s", value, value != null ? value.getClass() : null)); + throw new IllegalStateException("Unsupported value: " + value + " of type: " + (value != null ? value.getClass() + : null)); } } diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/env/CommonsConfigurationUtils.java b/pinot-spi/src/main/java/org/apache/pinot/spi/env/CommonsConfigurationUtils.java index 10c9f7151d..e0cd61e847 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/env/CommonsConfigurationUtils.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/env/CommonsConfigurationUtils.java @@ -372,7 +372,7 @@ public class CommonsConfigurationUtils { try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String fileFirstLine = reader.readLine(); // header version is written as a comment and start with '# ' - String versionHeaderCommentPrefix = String.format("# %s", VERSION_HEADER_IDENTIFIER); + String versionHeaderCommentPrefix = "# " + VERSION_HEADER_IDENTIFIER; // check whether the file has the version header or not if (StringUtils.startsWith(fileFirstLine, versionHeaderCommentPrefix)) { String[] headerKeyValue = StringUtils.splitByWholeSeparator(fileFirstLine, VERSIONED_CONFIG_SEPARATOR, 2); @@ -391,6 +391,6 @@ public class CommonsConfigurationUtils { // Returns the version header string based on the version header value provided. // The return statement follow the pattern 'version = <value>' static String getVersionHeaderString(String versionHeaderValue) { - return String.format("%s%s%s", VERSION_HEADER_IDENTIFIER, VERSIONED_CONFIG_SEPARATOR, versionHeaderValue); + return VERSION_HEADER_IDENTIFIER + VERSIONED_CONFIG_SEPARATOR + versionHeaderValue; } } diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/ingestion/batch/IngestionJobLauncher.java b/pinot-spi/src/main/java/org/apache/pinot/spi/ingestion/batch/IngestionJobLauncher.java index a2b80b0af7..4c7b203339 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/ingestion/batch/IngestionJobLauncher.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/ingestion/batch/IngestionJobLauncher.java @@ -56,8 +56,7 @@ public class IngestionJobLauncher { try { properties.load(FileUtils.openInputStream(new File(propertyFilePath))); } catch (IOException e) { - throw new RuntimeException( - String.format("Unable to read property file [%s] into properties.", propertyFilePath), e); + throw new RuntimeException("Unable to read property file [" + propertyFilePath + "] into properties.", e); } } Map<String, Object> propertiesMap = (Map) properties; @@ -75,7 +74,7 @@ public class IngestionJobLauncher { try { jobSpecTemplate = IOUtils.toString(new BufferedReader(new FileReader(jobSpecFilePath))); } catch (IOException e) { - throw new RuntimeException(String.format("Unable to read ingestion job spec file [%s].", jobSpecFilePath), e); + throw new RuntimeException("Unable to read ingestion job spec file [" + jobSpecFilePath + "].", e); } String jobSpecStr; try { diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/plugin/PluginManager.java b/pinot-spi/src/main/java/org/apache/pinot/spi/plugin/PluginManager.java index 4484dc2c12..fd14c2fe2a 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/plugin/PluginManager.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/plugin/PluginManager.java @@ -216,7 +216,7 @@ public class PluginManager { for (String pluginsDirectory : directories) { if (!new File(pluginsDirectory).exists()) { - throw new IllegalArgumentException(String.format("Plugins dir [%s] doesn't exist.", pluginsDirectory)); + throw new IllegalArgumentException("Plugins dir [" + pluginsDirectory + "] doesn't exist."); } Collection<File> jarFiles = diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/JsonUtils.java b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/JsonUtils.java index 2dd3bedf39..1f80cc9fc0 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/JsonUtils.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/JsonUtils.java @@ -324,7 +324,7 @@ public class JsonUtils { throw new IllegalArgumentException("Failed to extract binary value"); } default: - throw new IllegalArgumentException(String.format("Unsupported data type %s", dataType)); + throw new IllegalArgumentException("Unsupported data type " + dataType); } } @@ -372,12 +372,11 @@ public class JsonUtils { try { return flatten(node, jsonIndexConfig, 0, "$", false, createTree(jsonIndexConfig)); } catch (OutOfMemoryError oom) { - throw new OutOfMemoryError( - String.format("Flattening JSON node: %s with config: %s requires too much memory, please adjust the config", - node, jsonIndexConfig)); + throw new OutOfMemoryError("Flattening JSON node: " + node + " with config: " + jsonIndexConfig + " requires too " + + "much memory, please adjust the config"); } catch (Exception e) { - throw new IllegalArgumentException( - String.format("Caught exception while flattening JSON node: %s with config: %s", node, jsonIndexConfig), e); + throw new IllegalArgumentException("Caught exception while flattening JSON node: " + node + " with config: " + + jsonIndexConfig, e); } } @@ -661,7 +660,7 @@ public class JsonUtils { fieldTypeMap, timeUnit, fieldsToUnnest, delimiter, collectionNotUnnestedToJson); } } else { - throw new IllegalArgumentException(String.format("Unsupported json node type for class %s", jsonNode.getClass())); + throw new IllegalArgumentException("Unsupported json node type for class " + jsonNode.getClass()); } } @@ -675,8 +674,7 @@ public class JsonUtils { case NON_PRIMITIVE: return !childNode.isValueNode(); default: - throw new IllegalArgumentException( - String.format("Unsupported collectionNotUnnestedToJson %s", collectionNotUnnestedToJson)); + throw new IllegalArgumentException("Unsupported collectionNotUnnestedToJson " + collectionNotUnnestedToJson); } } diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/TimestampUtils.java b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/TimestampUtils.java index 3157dfbd11..4274b7ff92 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/TimestampUtils.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/TimestampUtils.java @@ -95,7 +95,7 @@ public class TimestampUtils { LocalDateTime dateTime = LocalDateTime.parse(timestampString, UNIVERSAL_DATE_TIME_FORMATTER); return Timestamp.valueOf(dateTime); } catch (Exception e) { - throw new IllegalArgumentException(String.format("Invalid timestamp: '%s'", timestampString)); + throw new IllegalArgumentException("Invalid timestamp: '" + timestampString + "'"); } } @@ -129,7 +129,7 @@ public class TimestampUtils { LocalDateTime dateTime = LocalDateTime.parse(timestampString, UNIVERSAL_DATE_TIME_FORMATTER); return dateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); } catch (Exception e) { - throw new IllegalArgumentException(String.format("Invalid timestamp: '%s'", timestampString)); + throw new IllegalArgumentException("Invalid timestamp: '" + timestampString + "'"); } } } diff --git a/pinot-spi/src/test/java/org/apache/pinot/spi/config/ConfigUtilsTest.java b/pinot-spi/src/test/java/org/apache/pinot/spi/config/ConfigUtilsTest.java index 296bd00d27..4cbda36441 100644 --- a/pinot-spi/src/test/java/org/apache/pinot/spi/config/ConfigUtilsTest.java +++ b/pinot-spi/src/test/java/org/apache/pinot/spi/config/ConfigUtilsTest.java @@ -82,8 +82,8 @@ public class ConfigUtilsTest { String defaultConsumerFactoryClass = "org.apache.pinot.plugin.stream.kafka20.StreamConsumerFactory"; String defaultDecoderClass = "org.apache.pinot.plugin.inputformat.avro.KafkaAvroMessageDecoder"; - String consumerFactoryClass = String.format("${CONSUMER_FACTORY_CLASS:%s}", defaultConsumerFactoryClass); - String decoderClass = String.format("${DECODER_CLASS:%s}", defaultDecoderClass); + String consumerFactoryClass = "${CONSUMER_FACTORY_CLASS:" + defaultConsumerFactoryClass + "}"; + String decoderClass = "${DECODER_CLASS:" + defaultDecoderClass + "}"; Map<String, String> streamConfigMap = new HashMap<>(); streamConfigMap.put(StreamConfigProperties.STREAM_TYPE, streamType); diff --git a/pinot-spi/src/test/java/org/apache/pinot/spi/env/CommonsConfigurationUtilsTest.java b/pinot-spi/src/test/java/org/apache/pinot/spi/env/CommonsConfigurationUtilsTest.java index 19a7e83b2f..61d1a2f45e 100644 --- a/pinot-spi/src/test/java/org/apache/pinot/spi/env/CommonsConfigurationUtilsTest.java +++ b/pinot-spi/src/test/java/org/apache/pinot/spi/env/CommonsConfigurationUtilsTest.java @@ -75,8 +75,7 @@ public class CommonsConfigurationUtilsTest { assertNotNull(config); assertEquals(config.getHeader(), "# version = 2"); } catch (Exception ex) { - Assert.fail(String.format("should not throw ConfigurationException exception with valid file, %s", - ex.getMessage())); + Assert.fail("should not throw ConfigurationException exception with valid file, " + ex.getMessage()); } // load the non-existing file and expect the exception --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org