Class DimensionRangeShardSpec
java.lang.Object
org.apache.druid.timeline.partition.BaseDimensionRangeShardSpec
org.apache.druid.timeline.partition.DimensionRangeShardSpec
- All Implemented Interfaces:
ShardSpec
- Direct Known Subclasses:
SingleDimensionShardSpec
ShardSpec for partitioning based on ranges of one or more dimensions.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.druid.timeline.partition.ShardSpec
ShardSpec.Type -
Field Summary
FieldsFields inherited from class org.apache.druid.timeline.partition.BaseDimensionRangeShardSpec
dimensions, end, start, virtualColumns -
Constructor Summary
ConstructorsConstructorDescriptionDimensionRangeShardSpec(List<String> dimensions, VirtualColumns virtualColumns, StringTuple start, StringTuple end, int partitionNum, Integer numCorePartitions) -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whetherShardSpec.createChunk(T)returns aNumberedPartitionChunkinstance.<T> PartitionChunk<T>createChunk(T obj) booleanGet dimensions who have possible range for the rows this shard contains.If any of the columns inShardSpec.getDomainDimensions()was computed with an expression and was not stored, theVirtualColumnwhich computes it is stored here.intintReturns the partition ID of this segment.getType()Get the type name of this ShardSpec.inthashCode()booleanbooleanpossibleInDomain(Map<String, com.google.common.collect.RangeSet<String>> domain) Set[:i] is the cartesian product of Set[0],...,Set[i - 1] EffectiveDomain[:i] is defined as QueryDomain[:i] INTERSECTION SegmentRange[:i] i = 1 If EffectiveDomain[:i] == {start[:i]} || EffectiveDomain == {end[:i]}: if i == index.dimensions.size: ACCEPT segment else: REPEAT with i = i + 1 else if EffectiveDomain[:i] == {}: PRUNE segment else: ACCEPT segment Example: Index on (Hour, Minute, Second).toString()withCorePartitions(int partitions) Creates a new ShardSpec with the specified number of core partitions.withPartitionNum(int partitionNum) Creates a new ShardSpec with the specified partition number.Methods inherited from class org.apache.druid.timeline.partition.BaseDimensionRangeShardSpec
getInputRowTuple, getLookupMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.druid.timeline.partition.ShardSpec
getAtomicUpdateGroupSize, getEndRootPartitionId, getMinorVersion, getStartRootPartitionId, sharePartitionSpace
-
Field Details
-
UNKNOWN_NUM_CORE_PARTITIONS
public static final int UNKNOWN_NUM_CORE_PARTITIONS- See Also:
-
-
Constructor Details
-
DimensionRangeShardSpec
public DimensionRangeShardSpec(List<String> dimensions, @Nullable VirtualColumns virtualColumns, @Nullable StringTuple start, @Nullable StringTuple end, int partitionNum, @Nullable Integer numCorePartitions) - Parameters:
dimensions- partition dimensionsstart- inclusive start of this rangeend- exclusive end of this rangepartitionNum- unique ID for this shard
-
-
Method Details
-
getDimensions
-
getVirtualColumns
-
getStartTuple
-
getEndTuple
-
getPartitionNum
public int getPartitionNum()Description copied from interface:ShardSpecReturns the partition ID of this segment. -
getNumCorePartitions
public int getNumCorePartitions() -
withPartitionNum
Description copied from interface:ShardSpecCreates a new ShardSpec with the specified partition number. -
withCorePartitions
Description copied from interface:ShardSpecCreates a new ShardSpec with the specified number of core partitions. -
isNumCorePartitionsUnknown
public boolean isNumCorePartitionsUnknown() -
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().- Returns:
- list of dimensions who has its possible range. Dimensions with unknown possible range are not listed.
-
getDomainVirtualColumns
Description copied from interface:ShardSpecIf any of the columns inShardSpec.getDomainDimensions()was computed with an expression and was not stored, theVirtualColumnwhich computes it is stored here. This allows matching ranges even when the value is not stored in the shard so long asVirtualColumns.findEquivalent(VirtualColumns, VirtualColumn)exists.- Returns:
VirtualColumnsassociated with columns listed inShardSpec.getDomainDimensions().
-
possibleInDomain
Set[:i] is the cartesian product of Set[0],...,Set[i - 1] EffectiveDomain[:i] is defined as QueryDomain[:i] INTERSECTION SegmentRange[:i] i = 1 If EffectiveDomain[:i] == {start[:i]} || EffectiveDomain == {end[:i]}: if i == index.dimensions.size: ACCEPT segment else: REPEAT with i = i + 1 else if EffectiveDomain[:i] == {}: PRUNE segment else: ACCEPT segment Example: Index on (Hour, Minute, Second). Index.size is 3 I) start = (3, 25, 10) end = (5, 10, 30) query domain = {3} * [0, 10] * {10, 20, 30, 40} EffectiveDomain[:1] == {3} == start[:1] EffectiveDomain[:2] == {3} * ([0, 10] INTERSECTION [25, INF)) == {} -> PRUNE II) start = (3, 25, 10) end = (5, 15, 30) query domain = {4} * [0, 10] * {10, 20, 30, 40} EffectiveDomain[:1] == {4} (!= {} && != start[:1] && != {end[:1]}) -> ACCEPT III) start = (3, 25, 10) end = (5, 15, 30) query domain = {5} * [0, 10] * {10, 20, 30, 40} EffectiveDomain[:1] == {5} == end[:1] EffectiveDomain[:2] == {5} * ([0, 10] INTERSECTION (-INF, 15]) == {5} * [0, 10] (! ={} && != {end[:2]}) -> ACCEPT IV) start = (3, 25, 10) end = (5, 15, 30) query domain = {5} * [15, 40] * {10, 20, 30, 40} EffectiveDomain[:1] == {5} == end[:1] EffectiveDomain[:2] == {5} * ([15, 40] INTERSECTION (-INF, 15]) == {5} * {15} == {end[:2]} EffectiveDomain[:3] == {5} * {15} * ({10, 20, 30, 40} * (-INF, 30]) == {5} * {15} * {10, 20, 30} != {} -> ACCEPT V) start = (3, 25, 10) end = (5, 15, 30) query domain = {5} * [15, 40] * {50} EffectiveDomain[:1] == {5} == end[:1] EffectiveDomain[:2] == {5} * ([15, 40] INTERSECTION (-INF, 15]) == {5} * {15} == {end[:2]} EffectiveDomain[:3] == {5} * {15} * ({40} * (-INF, 30]) == {5} * {15} * {} == {} -> PRUNE- Parameters:
domain- The domain inferred from the query. Assumed to be non-emtpy- Returns:
- true if segment needs to be considered for query, false if it can be pruned
-
canCreateNumberedPartitionChunk
public boolean canCreateNumberedPartitionChunk()Description copied from interface:ShardSpecReturns whetherShardSpec.createChunk(T)returns aNumberedPartitionChunkinstance. This is necessary for supportingPartitionHolder.isComplete()if updating to a new corePartitions spec. -
createChunk
-
getType
Description copied from interface:ShardSpecGet the type name of this ShardSpec. -
equals
-
hashCode
public int hashCode() -
toString
-