jtao15 commented on a change in pull request #7651:
URL: https://github.com/apache/pinot/pull/7651#discussion_r737910924



##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
##########
@@ -593,6 +593,78 @@ public String getCrypterClassNameFromTableConfig(String 
tableNameWithType) {
     return ZKMetadataProvider.getSegments(_propertyStore, tableNameWithType);
   }
 
+  /**
+   * Returns the segments for the given table based on the start and end 
timestamp.
+   *
+   * @param tableNameWithType  Table name with type suffix
+   * @param startTimestamp  start timestamp in milliseconds (inclusive)
+   * @param endTimestamp  end timestamp in milliseconds (exclusive)
+   * @param excludeOverlapping  whether to exclude the segments overlapping 
with the timestamps
+   */
+  public List<String> getSegmentsForTableWithTimestamps(String 
tableNameWithType, long startTimestamp,
+      long endTimestamp, boolean excludeOverlapping) {
+    List<String> selectedSegments = new ArrayList<>();
+    List<String> segmentNames = getSegmentsFor(tableNameWithType);
+    // If no start and end timestamp specified, just select all the segments.
+    if (startTimestamp == Long.MIN_VALUE && endTimestamp == Long.MAX_VALUE) {
+      selectedSegments = segmentNames;
+    } else {
+      String segmentZKMetadataPathPrefix =

Review comment:
       Can we reuse the function `getSegmentsZKMetadata()`?

##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java
##########
@@ -657,6 +663,42 @@ public String getServerMetadata(
     return segmentsMetadata;
   }
 
+  @GET
+  @Path("segments/{tableName}/select")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Get the selected segments given the (inclusive) start 
and (exclusive) end timestamps"
+      + " in milliseconds. If no timestamps are provided, all the segments 
will be returned.",
+      notes = "Get the selected segments given the start and end timestamps in 
milliseconds")
+  public List<Map<TableType, List<String>>> getSelectedSegments(

Review comment:
       How do we handle the edge case that caller include start & end time for 
refresh table?




-- 
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]

Reply via email to