Package org.apache.druid.segment
Class IdMapping.Builder
- java.lang.Object
-
- org.apache.druid.segment.IdMapping.Builder
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addForwardMapping(int forwardId)
Adds a lookup for the 'forwarded' index to the current highest index value.void
addMapping(int forwardId)
Adds a lookup for the 'forwarded' index to the current highest index value, and a reverse lookup from this substitute index back to the original.IdMapping
build()
static IdMapping.Builder
ofCardinality(int cardinality)
Create aIdMapping
where the cardinality is known, to use withaddMapping(int)
to simultaneously populate bothforwardMapping
andreverseMapping
.static IdMapping.Builder
ofUnknownCardinality()
Create anIdMapping
where the cardinality is not known up front.
-
-
-
Method Detail
-
ofCardinality
public static IdMapping.Builder ofCardinality(int cardinality)
Create aIdMapping
where the cardinality is known, to use withaddMapping(int)
to simultaneously populate bothforwardMapping
andreverseMapping
.
-
ofUnknownCardinality
public static IdMapping.Builder ofUnknownCardinality()
Create anIdMapping
where the cardinality is not known up front. Since cardinality is unknown,reverseMapping
is initialized to an empty array, andaddForwardMapping(int)
should be used to build theforwardMapping
, whenbuild()
is calledreverseMapping
will be computed to produce the completedIdMapping
. This is less efficient thanofCardinality(int)
, so it should be preferred if the value cardinality is in fact known
-
addMapping
public void addMapping(int forwardId)
Adds a lookup for the 'forwarded' index to the current highest index value, and a reverse lookup from this substitute index back to the original. This method can only be called when cardinality is known, to ensure thatreverseMapping
is initialized correctly.
-
addForwardMapping
public void addForwardMapping(int forwardId)
Adds a lookup for the 'forwarded' index to the current highest index value. This method can only be used when the cardinality is unknown, otherwiseaddMapping(int)
should be used instead since thereverseMapping
is only computed ifknownCardinality
is false
-
build
public IdMapping build()
-
-