From a51b1d10ebc46d8e38745e0bf0cc78669d762785 Mon Sep 17 00:00:00 2001 From: ashishjayamohan <46698969+ashishjayamohan@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:37:30 -0800 Subject: [PATCH] Refactor `String.format` to Concatenation (#14418) --- .../pinot/core/auth/BasicAuthUtils.java | 6 +-- .../function/DateTruncTransformFunction.java | 4 +- .../scheduler/MultiLevelPriorityQueue.java | 14 +++--- .../scheduler/SecondaryWorkloadQueue.java | 18 ++++---- .../pinot/core/util/ListenerConfigUtil.java | 2 +- .../pinot/spi/data/DateTimeFormatSpec.java | 45 ++++++++++--------- .../spi/data/DateTimeGranularitySpec.java | 9 ++-- .../org/apache/pinot/spi/data/FieldSpec.java | 4 +- .../org/apache/pinot/spi/data/Schema.java | 32 ++++++------- .../spi/env/VersionedPropertyReader.java | 4 +- .../builder/ControllerRequestURLBuilder.java | 30 ++++++------- 11 files changed, 83 insertions(+), 85 deletions(-) diff --git a/pinot-core/src/main/java/org/apache/pinot/core/auth/BasicAuthUtils.java b/pinot-core/src/main/java/org/apache/pinot/core/auth/BasicAuthUtils.java index 9ad74943b633..ab4caa91b3ce 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/auth/BasicAuthUtils.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/auth/BasicAuthUtils.java @@ -68,11 +68,11 @@ public static List extractBasicAuthPrincipals(PinotConfigura String name = rawName.trim(); Preconditions.checkArgument(StringUtils.isNotBlank(name), "%s is not a valid name", name); - String password = configuration.getProperty(String.format("%s.%s.%s", prefix, name, PASSWORD)); + String password = configuration.getProperty(prefix + "." + name + "." + PASSWORD); Preconditions.checkArgument(StringUtils.isNotBlank(password), "must provide a password for %s", name); - Set tables = extractSet(configuration, String.format("%s.%s.%s", prefix, name, TABLES)); - Set permissions = extractSet(configuration, String.format("%s.%s.%s", prefix, name, PERMISSIONS)); + Set tables = extractSet(configuration, prefix + "." + name + "." + TABLES); + Set permissions = extractSet(configuration, prefix + "." + name + "." + PERMISSIONS); return new BasicAuthPrincipal(name, org.apache.pinot.common.auth.BasicAuthUtils.toBasicAuthToken(name, password), tables, permissions); diff --git a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/DateTruncTransformFunction.java b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/DateTruncTransformFunction.java index 53aee59ba86b..50d3059d1c45 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/DateTruncTransformFunction.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/DateTruncTransformFunction.java @@ -82,8 +82,8 @@ */ public class DateTruncTransformFunction extends BaseTransformFunction { public static final String FUNCTION_NAME = "dateTrunc"; - public static final String EXAMPLE_INVOCATION = - String.format("%s('week', time_expression, 'seconds', , )", FUNCTION_NAME); + public static final String EXAMPLE_INVOCATION = FUNCTION_NAME + "('week', time_expression, 'seconds', , " + + ")"; private static final String UTC_TZ = TimeZoneKey.UTC_KEY.getId(); private TransformFunction _mainTransformFunction; private TransformResultMetadata _resultMetadata; diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/MultiLevelPriorityQueue.java b/pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/MultiLevelPriorityQueue.java index 284f90f78bc9..0ba448a2386a 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/MultiLevelPriorityQueue.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/MultiLevelPriorityQueue.java @@ -193,9 +193,9 @@ private SchedulerQueryContext takeNextInternal() { if (currentWinnerGroup != null) { ServerQueryRequest queryRequest = currentWinnerGroup.peekFirst().getQueryRequest(); if (LOGGER.isDebugEnabled()) { - sb.append(String.format(" Winner: %s: [%d,%d,%d,%d]", currentWinnerGroup.name(), - queryRequest.getTimerContext().getQueryArrivalTimeMs(), queryRequest.getRequestId(), - queryRequest.getSegmentsToQuery().size(), startTime)); + sb.append(" Winner: " + currentWinnerGroup.name() + ": [" + + queryRequest.getTimerContext().getQueryArrivalTimeMs() + "," + queryRequest.getRequestId() + "," + + queryRequest.getSegmentsToQuery().size() + "," + startTime + "]"); } query = currentWinnerGroup.removeFirst(); } @@ -209,10 +209,10 @@ private void checkGroupHasCapacity(SchedulerGroup groupContext) throws OutOfCapacityException { if (groupContext.numPending() >= _maxPendingPerGroup && groupContext.totalReservedThreads() >= _resourceManager.getTableThreadsHardLimit()) { - throw new OutOfCapacityException(String.format( - "SchedulerGroup %s is out of capacity. numPending: %d, maxPending: %d, reservedThreads: %d " - + "threadsHardLimit: %d", groupContext.name(), groupContext.numPending(), _maxPendingPerGroup, - groupContext.totalReservedThreads(), _resourceManager.getTableThreadsHardLimit())); + throw new OutOfCapacityException( + "SchedulerGroup " + groupContext.name() + " is out of capacity. numPending: " + groupContext.numPending() + + ", maxPending: " + _maxPendingPerGroup + ", reservedThreads: " + groupContext.totalReservedThreads() + + " threadsHardLimit: " + _resourceManager.getTableThreadsHardLimit()); } } diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/SecondaryWorkloadQueue.java b/pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/SecondaryWorkloadQueue.java index 82736dbf0f2b..abc2a02ae074 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/SecondaryWorkloadQueue.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/SecondaryWorkloadQueue.java @@ -144,24 +144,24 @@ private SchedulerQueryContext takeNextInternal() { StringBuilder sb = new StringBuilder("SchedulerInfo:"); sb.append(_schedulerGroup.toString()); ServerQueryRequest queryRequest = _schedulerGroup.peekFirst().getQueryRequest(); - sb.append(String.format(" Group: %s: [%d,%d,%d,%d]", _schedulerGroup.name(), - queryRequest.getTimerContext().getQueryArrivalTimeMs(), queryRequest.getRequestId(), - queryRequest.getSegmentsToQuery().size(), startTimeMs)); + sb.append(" Group: " + _schedulerGroup.name() + ": [" + queryRequest.getTimerContext().getQueryArrivalTimeMs() + + "," + queryRequest.getRequestId() + "," + queryRequest.getSegmentsToQuery().size() + "," + startTimeMs + + "]"); LOGGER.debug(sb.toString()); } - SchedulerQueryContext query = _schedulerGroup.removeFirst(); - return query; + return _schedulerGroup.removeFirst(); } private void checkSchedulerGroupCapacity(SchedulerQueryContext query) throws OutOfCapacityException { if (_schedulerGroup.numPending() >= _maxPendingPerGroup && _schedulerGroup.totalReservedThreads() >= _resourceManager.getTableThreadsHardLimit()) { - throw new OutOfCapacityException(String.format( - "SchedulerGroup %s is out of capacity. numPending: %d, maxPending: %d, reservedThreads: %d " - + "threadsHardLimit: %d", _schedulerGroup.name(), _schedulerGroup.numPending(), _maxPendingPerGroup, - _schedulerGroup.totalReservedThreads(), _resourceManager.getTableThreadsHardLimit())); + throw new OutOfCapacityException( + "SchedulerGroup " + _schedulerGroup.name() + " is out of capacity. numPending: " + + _schedulerGroup.numPending() + ", maxPending: " + _maxPendingPerGroup + ", reservedThreads: " + + _schedulerGroup.totalReservedThreads() + " threadsHardLimit: " + + _resourceManager.getTableThreadsHardLimit()); } } } 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 9a5969c23864..1bff874ff824 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 @@ -289,7 +289,7 @@ private static HttpServerThreadPoolConfig buildServerThreadPoolConfig(PinotConfi public static String toString(Collection listenerConfigs) { return StringUtils.join(listenerConfigs.stream() - .map(listener -> String.format("%s://%s:%d", listener.getProtocol(), listener.getHost(), listener.getPort())) + .map(listener -> listener.getProtocol() + "://" + listener.getHost() + ":" + listener.getPort()) .toArray(), ", "); } 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 33df6a55c35b..e88e001d2050 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 @@ -79,14 +79,14 @@ public DateTimeFormatSpec(String format) { String[] tokens = StringUtil.split(format, COLON_SEPARATOR, COLON_FORMAT_MAX_TOKENS); Preconditions.checkArgument(tokens.length >= COLON_FORMAT_MIN_TOKENS && tokens.length <= COLON_FORMAT_MAX_TOKENS, - "Invalid format: %s, must be of format 'size:timeUnit:timeFormat(:patternWithTz)'", format); + "Invalid format:" + format + ", must be of format 'size:timeUnit:timeFormat(:patternWithTz)'"); TimeFormat timeFormat; try { timeFormat = TimeFormat.valueOf(tokens[COLON_FORMAT_TIME_FORMAT_POSITION]); } catch (Exception e) { - throw new IllegalArgumentException( - String.format("Invalid time format: %s in format: %s", tokens[COLON_FORMAT_TIME_FORMAT_POSITION], format)); + throw new IllegalArgumentException("Invalid time format: " + tokens[COLON_FORMAT_TIME_FORMAT_POSITION] + + " in format: " + format); } switch (timeFormat) { @@ -95,15 +95,15 @@ public DateTimeFormatSpec(String format) { try { _size = Integer.parseInt(sizeStr); } catch (Exception e) { - throw new IllegalArgumentException(String.format("Invalid size: %s in format: %s", sizeStr, format)); + throw new IllegalArgumentException("Invalid size: " + sizeStr + " in format: " + format); } - Preconditions.checkArgument(_size > 0, "Invalid size: %s in format: %s, must be positive", _size, format); + Preconditions.checkArgument(_size > 0, "Invalid size: " + _size + " in format: " + format + + ", must be positive"); String timeUnitStr = tokens[COLON_FORMAT_TIME_UNIT_POSITION]; try { _unitSpec = new DateTimeFormatUnitSpec(timeUnitStr); } catch (Exception e) { - throw new IllegalArgumentException( - String.format("Invalid time unit: %s in format: %s", timeUnitStr, format)); + throw new IllegalArgumentException("Invalid time unit: " + timeUnitStr + " in format: " + format); } _patternSpec = DateTimeFormatPatternSpec.EPOCH; break; @@ -120,8 +120,8 @@ public DateTimeFormatSpec(String format) { try { _patternSpec = new DateTimeFormatPatternSpec(TimeFormat.SIMPLE_DATE_FORMAT, patternStr); } catch (Exception e) { - throw new IllegalArgumentException( - String.format("Invalid SIMPLE_DATE_FORMAT pattern: %s in format: %s", patternStr, format)); + throw new IllegalArgumentException("Invalid SIMPLE_DATE_FORMAT pattern: " + patternStr + " in format: " + + format); } break; default: @@ -132,15 +132,15 @@ public DateTimeFormatSpec(String format) { String[] tokens = StringUtil.split(format, PIPE_SEPARATOR, PIPE_FORMAT_MAX_TOKENS); Preconditions.checkArgument(tokens.length >= PIPE_FORMAT_MIN_TOKENS && tokens.length <= PIPE_FORMAT_MAX_TOKENS, - "Invalid format: %s, must be of format 'EPOCH|(|)' or " - + "'SIMPLE_DATE_FORMAT|(|)' or 'TIMESTAMP'", format); + "Invalid format: " + format + ", must be of format 'EPOCH|(|)' or " + + "'SIMPLE_DATE_FORMAT|(|)' or 'TIMESTAMP'"); TimeFormat timeFormat; try { timeFormat = TimeFormat.valueOf(tokens[PIPE_FORMAT_TIME_FORMAT_POSITION]); } catch (Exception e) { - throw new IllegalArgumentException( - String.format("Invalid time format: %s in format: %s", tokens[PIPE_FORMAT_TIME_FORMAT_POSITION], format)); + throw new IllegalArgumentException("Invalid time format: " + tokens[PIPE_FORMAT_TIME_FORMAT_POSITION] + + " in format: " + format); } switch (timeFormat) { @@ -149,10 +149,11 @@ public DateTimeFormatSpec(String format) { try { _size = Integer.parseInt(tokens[PIPE_FORMAT_SIZE_POSITION]); } catch (Exception e) { - throw new IllegalArgumentException( - String.format("Invalid size: %s in format: %s", tokens[COLON_FORMAT_SIZE_POSITION], format)); + throw new IllegalArgumentException("Invalid size: " + tokens[COLON_FORMAT_SIZE_POSITION] + " in format: " + + format); } - Preconditions.checkArgument(_size > 0, "Invalid size: %s in format: %s, must be positive", _size, format); + Preconditions.checkArgument(_size > 0, "Invalid size: " + _size + " in format: " + format + + ", must be positive"); } else { _size = 1; } @@ -160,8 +161,8 @@ public DateTimeFormatSpec(String format) { _unitSpec = tokens.length > PIPE_FORMAT_TIME_UNIT_POSITION ? new DateTimeFormatUnitSpec( tokens[PIPE_FORMAT_TIME_UNIT_POSITION]) : DateTimeFormatUnitSpec.MILLISECONDS; } catch (Exception e) { - throw new IllegalArgumentException( - String.format("Invalid time unit: %s in format: %s", tokens[PIPE_FORMAT_TIME_UNIT_POSITION], format)); + throw new IllegalArgumentException("Invalid time unit: " + tokens[PIPE_FORMAT_TIME_UNIT_POSITION] + + " in format: " + format); } _patternSpec = DateTimeFormatPatternSpec.EPOCH; break; @@ -179,9 +180,9 @@ public DateTimeFormatSpec(String format) { new DateTimeFormatPatternSpec(TimeFormat.SIMPLE_DATE_FORMAT, tokens[PIPE_FORMAT_PATTERN_POSITION], tokens[PIPE_FORMAT_TIME_ZONE_POSITION]); } catch (Exception e) { - throw new IllegalArgumentException( - String.format("Invalid SIMPLE_DATE_FORMAT pattern: %s, time zone: %s in format: %s", - tokens[PIPE_FORMAT_PATTERN_POSITION], tokens[PIPE_FORMAT_TIME_ZONE_POSITION], format)); + throw new IllegalArgumentException("Invalid SIMPLE_DATE_FORMAT pattern: " + + tokens[PIPE_FORMAT_PATTERN_POSITION] + ", time zone: " + tokens[PIPE_FORMAT_TIME_ZONE_POSITION] + + " in format: " + format); } } else { try { @@ -215,7 +216,7 @@ public static DateTimeFormatSpec forEpoch(String timeUnit) { } public static DateTimeFormatSpec forEpoch(int size, String timeUnit) { - Preconditions.checkArgument(size > 0, "Invalid size: %s, must be positive", size); + Preconditions.checkArgument(size > 0, "Invalid size: " + size + ", must be positive"); Preconditions.checkArgument(timeUnit != null, "Must provide time unit"); return new DateTimeFormatSpec(size, new DateTimeFormatUnitSpec(timeUnit), DateTimeFormatPatternSpec.EPOCH); } diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeGranularitySpec.java b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeGranularitySpec.java index 036432ee043e..4feed35aae38 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeGranularitySpec.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeGranularitySpec.java @@ -82,9 +82,8 @@ public DateTimeGranularitySpec(String granularity) { try { _timeUnit = TimeUnit.valueOf(granularityTokens[timeUnitPosition]); } catch (Exception e) { - throw new IllegalArgumentException( - String.format("Invalid time unit: %s in granularity: %s", granularityTokens[timeUnitPosition], - granularity)); + throw new IllegalArgumentException("Invalid time unit: " + granularityTokens[timeUnitPosition] + + " in granularity: " + granularity); } // New format without explicitly setting size - use default size = 1 @@ -96,8 +95,8 @@ public DateTimeGranularitySpec(String granularity) { try { _size = Integer.parseInt(granularityTokens[sizePosition]); } catch (Exception e) { - throw new IllegalArgumentException( - String.format("Invalid size: %s in granularity: %s", granularityTokens[sizePosition], granularity)); + throw new IllegalArgumentException("Invalid size: " + granularityTokens[sizePosition] + " in granularity: " + + granularity); } Preconditions.checkArgument(_size > 0, "Invalid size: %s in granularity: %s, must be positive", _size, granularity); } diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/data/FieldSpec.java b/pinot-spi/src/main/java/org/apache/pinot/spi/data/FieldSpec.java index b08c9b1286c6..b56ef1c82952 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/data/FieldSpec.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/data/FieldSpec.java @@ -629,7 +629,7 @@ public Object convert(String value) { throw new IllegalStateException(); } } catch (Exception e) { - throw new IllegalArgumentException(String.format("Cannot convert value: '%s' to type: %s", value, this)); + throw new IllegalArgumentException("Cannot convert value: '" + value + "' to type: " + this); } } @@ -721,7 +721,7 @@ public Comparable convertInternal(String value) { throw new IllegalStateException(); } } catch (Exception e) { - throw new IllegalArgumentException(String.format("Cannot convert value: '%s' to type: %s", value, this)); + throw new IllegalArgumentException("Cannot convert value: '" + value + "' to type: " + this); } } diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/data/Schema.java b/pinot-spi/src/main/java/org/apache/pinot/spi/data/Schema.java index d15482574611..8956ff9756b0 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/data/Schema.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/data/Schema.java @@ -962,30 +962,30 @@ private static String constructTransformFunctionString(String incomingName, int break; case SECONDS: if (incomingTimeSize > 1) { - innerFunction = String.format("fromEpochSecondsBucket(%s, %d)", incomingName, incomingTimeSize); + innerFunction = "fromEpochSecondsBucket(" + incomingName + ", " + incomingTimeSize + ")"; } else { - innerFunction = String.format("fromEpochSeconds(%s)", incomingName); + innerFunction = "fromEpochSeconds(" + incomingName + ")"; } break; case MINUTES: if (incomingTimeSize > 1) { - innerFunction = String.format("fromEpochMinutesBucket(%s, %d)", incomingName, incomingTimeSize); + innerFunction = "fromEpochMinutesBucket(" + incomingName + ", " + incomingTimeSize + ")"; } else { - innerFunction = String.format("fromEpochMinutes(%s)", incomingName); + innerFunction = "fromEpochMinutes(" + incomingName + ")"; } break; case HOURS: if (incomingTimeSize > 1) { - innerFunction = String.format("fromEpochHoursBucket(%s, %d)", incomingName, incomingTimeSize); + innerFunction = "fromEpochHoursBucket(" + incomingName + ", " + incomingTimeSize + ")"; } else { - innerFunction = String.format("fromEpochHours(%s)", incomingName); + innerFunction = "fromEpochHours(" + incomingName + ")"; } break; case DAYS: if (incomingTimeSize > 1) { - innerFunction = String.format("fromEpochDaysBucket(%s, %d)", incomingName, incomingTimeSize); + innerFunction = "fromEpochDaysBucket(" + incomingName + ", " + incomingTimeSize + ")"; } else { - innerFunction = String.format("fromEpochDays(%s)", incomingName); + innerFunction = "fromEpochDays(" + incomingName + ")"; } break; default: @@ -998,30 +998,30 @@ private static String constructTransformFunctionString(String incomingName, int break; case SECONDS: if (outgoingTimeSize > 1) { - outerFunction = String.format("toEpochSecondsBucket(%s, %d)", innerFunction, outgoingTimeSize); + outerFunction = "toEpochSecondsBucket(" + innerFunction + ", " + outgoingTimeSize + ")"; } else { - outerFunction = String.format("toEpochSeconds(%s)", innerFunction); + outerFunction = "toEpochSeconds(" + innerFunction + ")"; } break; case MINUTES: if (outgoingTimeSize > 1) { - outerFunction = String.format("toEpochMinutesBucket(%s, %d)", innerFunction, outgoingTimeSize); + outerFunction = "toEpochMinutesBucket(" + innerFunction + ", " + outgoingTimeSize + ")"; } else { - outerFunction = String.format("toEpochMinutes(%s)", innerFunction); + outerFunction = "toEpochMinutes(" + innerFunction + ")"; } break; case HOURS: if (outgoingTimeSize > 1) { - outerFunction = String.format("toEpochHoursBucket(%s, %d)", innerFunction, outgoingTimeSize); + outerFunction = "toEpochHoursBucket(" + innerFunction + ", " + outgoingTimeSize + ")"; } else { - outerFunction = String.format("toEpochHours(%s)", innerFunction); + outerFunction = "toEpochHours(" + innerFunction + ")"; } break; case DAYS: if (outgoingTimeSize > 1) { - outerFunction = String.format("toEpochDaysBucket(%s, %d)", innerFunction, outgoingTimeSize); + outerFunction = "toEpochDaysBucket(" + innerFunction + ", " + outgoingTimeSize + ")"; } else { - outerFunction = String.format("toEpochDays(%s)", innerFunction); + outerFunction = "toEpochDays(" + innerFunction + ")"; } break; default: diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/env/VersionedPropertyReader.java b/pinot-spi/src/main/java/org/apache/pinot/spi/env/VersionedPropertyReader.java index c108bfebcca6..808cc9ff0be7 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/env/VersionedPropertyReader.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/env/VersionedPropertyReader.java @@ -43,8 +43,8 @@ protected void parseProperty(final String line) { // getPropertySeparator(), in general returns the PropertiesConfiguration `DEFAULT_SEPARATOR` value i.e. ' = '. String separator = getPropertySeparator(); Preconditions.checkArgument(CommonsConfigurationUtils.VERSIONED_CONFIG_SEPARATOR.equals(separator), - String.format("Versioned property configuration separator '%s' should be equal to '%s'", - separator, CommonsConfigurationUtils.VERSIONED_CONFIG_SEPARATOR)); + "Versioned property configuration separator '" + separator + "' should be equal to '" + + CommonsConfigurationUtils.VERSIONED_CONFIG_SEPARATOR + "'"); String[] keyValue = StringUtils.splitByWholeSeparator(line, separator, 2); Preconditions.checkArgument(keyValue.length == 2, "property content split should result in key and value"); diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/builder/ControllerRequestURLBuilder.java b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/builder/ControllerRequestURLBuilder.java index 98a2a5aefeb5..335f251995f6 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/builder/ControllerRequestURLBuilder.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/builder/ControllerRequestURLBuilder.java @@ -118,7 +118,7 @@ public String forUpdateUserConfig(String username, String componentTypeStr, bool if (StringUtils.isNotBlank(username)) { params.append("?component=" + componentTypeStr); } - params.append(String.format("&&passwordChanged=%s", passwordChanged)); + params.append("&&passwordChanged=" + passwordChanged); return StringUtil.join("/", _baseUrl, "users", username, params.toString()); } @@ -235,12 +235,12 @@ public String forForceCommitJobStatus(String jobId) { } public String forTableReload(String tableName, TableType tableType, boolean forceDownload) { - String query = String.format("reload?type=%s&forceDownload=%s", tableType.name(), forceDownload); + String query = "reload?type=" + tableType.name() + "&forceDownload=" + forceDownload; return StringUtil.join("/", _baseUrl, "segments", tableName, query); } public String forTableNeedReload(String tableNameWithType, boolean verbose) { - String query = String.format("needReload?verbose=%s", verbose); + String query = "needReload?verbose=" + verbose; return StringUtil.join("/", _baseUrl, "segments", tableNameWithType, query); } @@ -249,7 +249,7 @@ public String forTableRebalanceStatus(String jobId) { } public String forTableReset(String tableNameWithType, @Nullable String targetInstance) { - String query = targetInstance == null ? "reset" : String.format("reset?targetInstance=%s", targetInstance); + String query = targetInstance == null ? "reset" : "reset?targetInstance=" + targetInstance; return StringUtil.join("/", _baseUrl, "segments", tableNameWithType, query); } @@ -372,7 +372,7 @@ public String forSegmentReload(String tableName, String segmentName, boolean for } public String forSegmentReset(String tableNameWithType, String segmentName, String targetInstance) { - String query = targetInstance == null ? "reset" : String.format("reset?targetInstance=%s", targetInstance); + String query = targetInstance == null ? "reset" : "reset?targetInstance=" + targetInstance; return StringUtil.join("/", _baseUrl, "segments", tableNameWithType, encode(segmentName), query); } @@ -465,7 +465,7 @@ public String forSegmentDeleteWithTimeWindowAPI(String tableName, long startTime long endTimeInMilliSeconds) { StringBuilder url = new StringBuilder(); url.append(StringUtil.join("/", _baseUrl, "segments", tableName, - String.format("choose?startTimestamp=%d&endTimestamp=%d", startTimeInMilliSeconds, endTimeInMilliSeconds))); + "choose?startTimestamp=" + startTimeInMilliSeconds + "&endTimestamp=" + endTimeInMilliSeconds)); return url.toString(); } @@ -522,28 +522,26 @@ public String forInstanceReplace(String tableName, @Nullable InstancePartitionsT } public String forIngestFromFile(String tableNameWithType, String batchConfigMapStr) { - return String.format("%s?tableNameWithType=%s&batchConfigMapStr=%s", - StringUtil.join("/", _baseUrl, "ingestFromFile"), tableNameWithType, - URLEncoder.encode(batchConfigMapStr, StandardCharsets.UTF_8)); + return StringUtil.join("/", _baseUrl, "ingestFromFile") + "?tableNameWithType=" + tableNameWithType + + "&batchConfigMapStr=" + URLEncoder.encode(batchConfigMapStr, StandardCharsets.UTF_8); } public String forIngestFromFile(String tableNameWithType, Map batchConfigMap) { String batchConfigMapStr = - batchConfigMap.entrySet().stream().map(e -> String.format("\"%s\":\"%s\"", e.getKey(), e.getValue())) + batchConfigMap.entrySet().stream().map(e -> "\"" + e.getKey() + "\":\"" + e.getValue() + "\"") .collect(Collectors.joining(",", "{", "}")); return forIngestFromFile(tableNameWithType, batchConfigMapStr); } public String forIngestFromURI(String tableNameWithType, String batchConfigMapStr, String sourceURIStr) { - return String.format("%s?tableNameWithType=%s&batchConfigMapStr=%s&sourceURIStr=%s", - StringUtil.join("/", _baseUrl, "ingestFromURI"), tableNameWithType, - URLEncoder.encode(batchConfigMapStr, StandardCharsets.UTF_8), - URLEncoder.encode(sourceURIStr, StandardCharsets.UTF_8)); + return StringUtil.join("/", _baseUrl, "ingestFromURI") + "?tableNameWithType=" + tableNameWithType + + "&batchConfigMapStr=" + URLEncoder.encode(batchConfigMapStr, StandardCharsets.UTF_8) + "&sourceURIStr=" + + URLEncoder.encode(sourceURIStr, StandardCharsets.UTF_8); } public String forIngestFromURI(String tableNameWithType, Map batchConfigMap, String sourceURIStr) { String batchConfigMapStr = - batchConfigMap.entrySet().stream().map(e -> String.format("\"%s\":\"%s\"", e.getKey(), e.getValue())) + batchConfigMap.entrySet().stream().map(e -> "\"" + e.getKey() + "\":\"" + e.getValue() + "\"") .collect(Collectors.joining(",", "{", "}")); return forIngestFromURI(tableNameWithType, batchConfigMapStr, sourceURIStr); } @@ -598,7 +596,7 @@ public String forPauseStatus(String tableName) { } public String forUpdateTagsValidation() { - return String.format("%s/instances/updateTags/validate", _baseUrl); + return _baseUrl + "/instances/updateTags/validate"; } private static String encode(String s) {