surekhasaharan commented on a change in pull request #7494: API to drop data by
interval
URL: https://github.com/apache/incubator-druid/pull/7494#discussion_r277103682
##########
File path:
server/src/main/java/org/apache/druid/metadata/SQLMetadataSegmentManager.java
##########
@@ -407,6 +407,55 @@ public boolean removeSegment(SegmentId segmentId)
}
}
+ @Override
+ public boolean disableSegments(String dataSource, Collection<String>
segmentIds)
+ {
+ if (segmentIds.isEmpty()) {
+ return false;
+ }
+ try {
+ connector.getDBI().withHandle(handle -> {
+ Batch batch = handle.createBatch();
+ segmentIds
+ .forEach(segmentId -> batch.add(
+ StringUtils.format(
+ "UPDATE %s SET used=false WHERE id = '%s'",
+ getSegmentsTable(),
+ segmentId
+ )
+ ));
+ return batch.execute();
+ });
+ }
+ catch (Exception e) {
+ log.error(e, e.toString());
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean disableSegments(String datasource, Interval interval)
+ {
+ try {
+ final int removed = connector.getDBI().withHandle(
+ handle -> handle
+ .createStatement(StringUtils.format(
+ "UPDATE %s SET used=false WHERE start = :start and end =
:end",
Review comment:
makes sense, will change to range query. I don't have any preferences,
whatever we decide for the inclusive/exclusive behaviour of interval. I
suggested [start, end) in the doc comment above.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]