Interface BuildingShardSpec<T extends ShardSpec>
- All Superinterfaces:
ShardSpec
- All Known Implementing Classes:
BuildingDimensionRangeShardSpec,BuildingHashBasedNumberedShardSpec,BuildingNumberedShardSpec,BuildingSingleDimensionShardSpec
This is one of the special shardSpecs which are temporarily used during batch ingestion. In Druid, there is a
concept of core partition set which is a set of segments atomically becoming queryable together in Brokers. The core
partition set is represented as a range of partitionIds, i.e., [0,
ShardSpec.getNumCorePartitions()).
In streaming ingestion, the core partition set size cannot be determined since it's impossible to know how many
segments will be created per time chunk upfront. However, in batch ingestion with time chunk locking, the core
partition set is the set of segments created by an initial task or an overwriting task. Since the core partition
set is determined when the task publishes segments at the end, the task postpones creating proper ShardSpec
until the end.
This BuildingShardSpec is used for such use case. A non-appending batch task can use this shardSpec until it
publishes segments at last. When it publishes segments, it should convert the buildingShardSpec of those segments
to a proper shardSpec type BuildingShardSpec. See SegmentPublisherHelper#annotateShardSpec for converting shardSpec.
Note that, when the segment lock is used, the Overlord coordinates the segment allocation and this class is never
used. Instead, the task sends PartialShardSpec to the Overlord to allocate a new segment. The result segment
could have either a ShardSpec (for root generation segments) or an OverwriteShardSpec (for non-root
generation segments).
This class should be Jackson-serializable as the subtasks can send it to the parallel task in parallel ingestion.
This interface doesn't really have to extend ShardSpec. The only reason is the ShardSpec is used in many
places such as DataSegment, and we have to modify those places to allow other
types than ShardSpec which seems pretty invasive. Maybe we could clean up this mess someday in the future.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.druid.timeline.partition.ShardSpec
ShardSpec.Type -
Method Summary
Modifier and TypeMethodDescriptionconvert(int numCorePartitions) intGet dimensions who have possible range for the rows this shard contains.default ShardSpecLookupBucketNumberedShardSpecshould be used for shard spec lookup.default intdefault booleanpossibleInDomain(Map<String, com.google.common.collect.RangeSet<String>> domain) if given domain ranges are not possible in this shard, return false; otherwise return true;Methods inherited from interface org.apache.druid.timeline.partition.ShardSpec
canCreateNumberedPartitionChunk, createChunk, getAtomicUpdateGroupSize, getDomainVirtualColumns, getEndRootPartitionId, getMinorVersion, getPartitionNum, getStartRootPartitionId, getType, sharePartitionSpace, withCorePartitions, withPartitionNum
-
Method Details
-
getBucketId
int getBucketId() -
convert
-
getNumCorePartitions
default int getNumCorePartitions()- Specified by:
getNumCorePartitionsin interfaceShardSpec
-
getLookup
BucketNumberedShardSpecshould be used for shard spec lookup. -
getDomainDimensions
Description copied from interface:ShardSpecGet dimensions who have possible range for the rows this shard contains. These columns might be physical columns stored in the shard, or computed expressions, in which case the manner in which they were computed is available inShardSpec.getDomainVirtualColumns().- Specified by:
getDomainDimensionsin interfaceShardSpec- Returns:
- list of dimensions who has its possible range. Dimensions with unknown possible range are not listed.
-
possibleInDomain
Description copied from interface:ShardSpecif given domain ranges are not possible in this shard, return false; otherwise return true;- Specified by:
possibleInDomainin interfaceShardSpec- Returns:
- possibility of in domain
-