Class SingleDimensionShardSpec
- java.lang.Object
-
- org.apache.druid.timeline.partition.BaseDimensionRangeShardSpec
-
- org.apache.druid.timeline.partition.DimensionRangeShardSpec
-
- org.apache.druid.timeline.partition.SingleDimensionShardSpec
-
- All Implemented Interfaces:
ShardSpec
public class SingleDimensionShardSpec extends DimensionRangeShardSpec
ShardSpecfor range partitioning based on a single dimension
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.druid.timeline.partition.ShardSpec
ShardSpec.Type
-
-
Field Summary
Fields Modifier and Type Field Description static intUNKNOWN_NUM_CORE_PARTITIONS-
Fields inherited from class org.apache.druid.timeline.partition.BaseDimensionRangeShardSpec
dimensions
-
-
Constructor Summary
Constructors Constructor Description SingleDimensionShardSpec(String dimension, String start, String end, int partitionNum, Integer numCorePartitions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> PartitionChunk<T>createChunk(T obj)booleanequals(Object o)StringgetDimension()StringgetEnd()Map<String,Object>getSerializableObject()Returns a Map to be used for serializing objects of this class.StringgetStart()StringgetType()Get the type name of this ShardSpec.inthashCode()booleanpossibleInDomain(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).StringtoString()-
Methods inherited from class org.apache.druid.timeline.partition.DimensionRangeShardSpec
getDimensions, getDomainDimensions, getEndTuple, getNumCorePartitions, getPartitionNum, getStartTuple, isNumCorePartitionsUnknown
-
Methods inherited from class org.apache.druid.timeline.partition.BaseDimensionRangeShardSpec
getInputRowTuple, getLookup
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.druid.timeline.partition.ShardSpec
getAtomicUpdateGroupSize, getEndRootPartitionId, getMinorVersion, getStartRootPartitionId, sharePartitionSpace
-
-
-
-
Field Detail
-
UNKNOWN_NUM_CORE_PARTITIONS
public static final int UNKNOWN_NUM_CORE_PARTITIONS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SingleDimensionShardSpec
public SingleDimensionShardSpec(String dimension, @Nullable String start, @Nullable String end, int partitionNum, @Nullable Integer numCorePartitions)
- Parameters:
dimension- partition dimensionstart- inclusive start of this rangeend- exclusive end of this rangepartitionNum- unique ID for this shard
-
-
Method Detail
-
getSerializableObject
public Map<String,Object> getSerializableObject()
Returns a Map to be used for serializing objects of this class. This is to ensure that a new field added inDimensionRangeShardSpecdoes not get serialized when serializing aSingleDimensionShardSpec.- Returns:
- A map containing only the keys
"dimension","start","end","partitionNum"and"numCorePartitions".
-
getDimension
public String getDimension()
-
possibleInDomain
public boolean possibleInDomain(Map<String,com.google.common.collect.RangeSet<String>> domain)
Description copied from class:DimensionRangeShardSpecSet[: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- Specified by:
possibleInDomainin interfaceShardSpec- Overrides:
possibleInDomainin classDimensionRangeShardSpec- 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
-
createChunk
public <T> PartitionChunk<T> createChunk(T obj)
- Specified by:
createChunkin interfaceShardSpec- Overrides:
createChunkin classDimensionRangeShardSpec
-
getType
public String getType()
Description copied from interface:ShardSpecGet the type name of this ShardSpec.- Specified by:
getTypein interfaceShardSpec- Overrides:
getTypein classDimensionRangeShardSpec
-
equals
public boolean equals(Object o)
- Overrides:
equalsin classDimensionRangeShardSpec
-
hashCode
public int hashCode()
- Overrides:
hashCodein classDimensionRangeShardSpec
-
toString
public String toString()
- Overrides:
toStringin classDimensionRangeShardSpec
-
-