AmatyaAvadhanula commented on code in PR #15169:
URL: https://github.com/apache/druid/pull/15169#discussion_r1368236302
##########
server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java:
##########
@@ -258,9 +258,73 @@ public int markSegmentsAsUnusedWithinInterval(String
dataSource, Interval interv
/**
* Fetches all the pending segments, whose interval overlaps with the given
- * search interval from the metadata store. Returns a Map from the
- * pending segment ID to the sequence name.
+ * search interval and has a sequence_name that begins with one of the
prefixes in sequenceNamePrefixFilter
+ * from the metadata store. Returns a Map from the pending segment ID to the
sequence name.
*/
+ @VisibleForTesting
+ Map<SegmentIdWithShardSpec, String> getPendingSegmentsForIntervalWithHandle(
+ final Handle handle,
+ final String dataSource,
+ final Interval interval,
+ final Set<String> sequenceNamePrefixFilter
+ ) throws IOException
+ {
+ if (sequenceNamePrefixFilter.isEmpty()) {
+ return Collections.emptyMap();
+ }
+
+ final List<String> sequenceNamePrefixes = new
ArrayList<>(sequenceNamePrefixFilter);
+ StringBuilder sql = new StringBuilder(
+ "SELECT sequence_name, payload FROM "
+ + dbTables.getPendingSegmentsTable()
+ + " WHERE dataSource = :dataSource AND start < :end AND "
+ + connector.getQuoteString() + "end" + connector.getQuoteString() + "
> :start"
+ );
+
+ sql.append(" AND ( ");
+
+ for (int i = 1; i < sequenceNamePrefixes.size(); i++) {
+ sql.append("(sequence_name LIKE ")
+ .append(StringUtils.format(":prefix%d", i))
+ .append(")")
+ .append(" OR ");
+ }
+
+ sql.append("(sequence_name LIKE ")
+ .append(StringUtils.format(":prefix%d", sequenceNamePrefixes.size()))
+ .append(")");
Review Comment:
There needs to be an OR in between the first size - 1 conditions and the
immediately next ones. Did you mean that it's better to use 0 indexing rather
than 1 based?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]