jon-wei commented on a change in pull request #7547: Add support minor
compaction with segment locking
URL: https://github.com/apache/incubator-druid/pull/7547#discussion_r306596249
##########
File path:
indexing-service/src/main/java/org/apache/druid/indexing/common/task/CachingLocalSegmentAllocator.java
##########
@@ -38,24 +44,50 @@
import java.util.stream.IntStream;
/**
- * CachingSegmentAllocator which allocates segments locally.
+ * Allocates all necessary segments at the beginning and reuse them.
*/
-class CachingLocalSegmentAllocator extends CachingSegmentAllocator
+class CachingLocalSegmentAllocator implements IndexTaskSegmentAllocator
{
+ private final TaskToolbox toolbox;
+ private final String taskId;
+ private final String dataSource;
+ private final Map<Interval, Pair<ShardSpecFactory, Integer>> allocateSpec;
+ @Nullable
+ private final ShardSpecs shardSpecs;
+
+ // sequenceName -> segmentId
+ private final Map<String, SegmentIdWithShardSpec> sequenceNameToSegmentId;
+
CachingLocalSegmentAllocator(
TaskToolbox toolbox,
String taskId,
String dataSource,
Map<Interval, Pair<ShardSpecFactory, Integer>> allocateSpec
) throws IOException
{
- // This segment allocator doesn't need inputPartitionIds because the newly
created segments don't have to store
- // direcOvershadowingSegments
- super(toolbox, taskId, dataSource, allocateSpec);
+ this.toolbox = toolbox;
+ this.taskId = taskId;
+ this.dataSource = dataSource;
+ this.allocateSpec = allocateSpec;
+ this.sequenceNameToSegmentId = new HashMap<>();
+
+ final Map<Interval, List<SegmentIdWithShardSpec>> intervalToIds =
getIntervalToSegmentIds();
+ final Map<Interval, List<ShardSpec>> shardSpecMap = new HashMap<>();
+
+ for (Map.Entry<Interval, List<SegmentIdWithShardSpec>> entry :
intervalToIds.entrySet()) {
+ final Interval interval = entry.getKey();
+ final List<SegmentIdWithShardSpec> idsPerInterval =
intervalToIds.get(interval);
+
+ for (SegmentIdWithShardSpec segmentIdentifier : idsPerInterval) {
+ shardSpecMap.computeIfAbsent(interval, k -> new
ArrayList<>()).add(segmentIdentifier.getShardSpec());
+ // The shardSpecs for partitinoing and publishing can be different if
isExtendableShardSpecs = true.
Review comment:
partitinoing -> partitioning
----------------------------------------------------------------
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]