Skip to content

Commit

Permalink
Cleanup: Fix grammar in error message, also improve readability. (#13451
Browse files Browse the repository at this point in the history
)

* Fixed grammar.
* Now logging table name first, before the list of segments, for better readability.
  • Loading branch information
mayankshriv authored Jun 24, 2024
1 parent fe3411d commit d1cf485
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@

public class MultiStageBrokerRequestHandler extends BaseBrokerRequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(MultiStageBrokerRequestHandler.class);
private static final int NUM_UNAVAILABLE_SEGMENTS_TO_LOG = 10;

private final WorkerManager _workerManager;
private final QueryDispatcher _queryDispatcher;
Expand Down Expand Up @@ -241,9 +242,11 @@ protected BrokerResponse handleRequest(long requestId, String query, @Nullable S
for (Map.Entry<String, Set<String>> entry : dispatchableSubPlan.getTableToUnavailableSegmentsMap().entrySet()) {
String tableName = entry.getKey();
Set<String> unavailableSegments = entry.getValue();
numUnavailableSegments += unavailableSegments.size();
int unavailableSegmentsInSubPlan = unavailableSegments.size();
numUnavailableSegments += unavailableSegmentsInSubPlan;
brokerResponse.addException(QueryException.getException(QueryException.SERVER_SEGMENT_MISSING_ERROR,
String.format("Find unavailable segments: %s for table: %s", unavailableSegments, tableName)));
String.format("Found %d unavailable segments for table %s: %s", unavailableSegmentsInSubPlan, tableName,
toSizeLimitedString(unavailableSegments, NUM_UNAVAILABLE_SEGMENTS_TO_LOG))));
}
requestContext.setNumUnavailableSegments(numUnavailableSegments);

Expand Down Expand Up @@ -359,4 +362,15 @@ public boolean cancelQuery(long queryId, int timeoutMs, Executor executor, HttpC
// TODO: Support query cancellation for multi-stage engine
throw new UnsupportedOperationException();
}

/**
* Returns the string representation of the Set of Strings with a limit on the number of elements.
* @param setOfStrings Set of strings
* @param limit Limit on the number of elements
* @return String representation of the set of the form [a,b,c...].
*/
private static String toSizeLimitedString(Set<String> setOfStrings, int limit) {
return setOfStrings.stream().limit(limit)
.collect(Collectors.joining(", ", "[", setOfStrings.size() > limit ? "...]" : "]"));
}
}

0 comments on commit d1cf485

Please sign in to comment.