Package org.apache.druid.segment
Class AutoTypeColumnMerger
java.lang.Object
org.apache.druid.segment.AutoTypeColumnMerger
- All Implemented Interfaces:
DimensionMerger,DimensionMergerV9
Column merger for
AutoTypeColumnIndexer to eventually produce some form of
NestedCommonFormatColumn.
Depending on the types of values encountered
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator<com.google.common.collect.PeekingIterator<Double>>static final Comparator<com.google.common.collect.PeekingIterator<Long>>static final Comparator<com.google.common.collect.PeekingIterator<String>> -
Constructor Summary
ConstructorsConstructorDescriptionAutoTypeColumnMerger(String name, String outputName, ColumnType castToType, NestedCommonFormatColumnFormatSpec columnFormatSpec, SegmentWriteOutMedium segmentWriteOutMedium, File segmentBaseDir, Closer closer) -
Method Summary
Modifier and TypeMethodDescriptionvoidattachParent(DimensionMergerV9 parent, List<IndexableAdapter> projectionAdapters) Attaches theDimensionMergerV9of a "projection" parent column so that stuff like value dictionaries can be shared between parent and child.convertSortedSegmentRowValuesToMergedRowValues(int segmentIndex, ColumnValueSelector source) Creates a value selector, which converts values with per-segment, _sorted order_ (seeDimensionIndexer.convertUnsortedValuesToSorted(org.apache.druid.segment.ColumnValueSelector)) encoding from the given selector to their equivalent representation in the merged set of rows.protected DictionaryIdLookupbooleanReturns true if this dimension has no data besides nulls.Return a ColumnDescriptor containing ColumnPartSerde objects appropriate for this DimensionMerger's value metadata, sequence of row values, and index structures.voidprocessMergedRow(ColumnValueSelector selector) Process a column value(s) (potentially multi-value) of a row from the given selector and update the DimensionMerger's internal state.voidwriteIndexes(List<IntBuffer> segmentRowNumConversions) Internally construct any index structures relevant to this DimensionMerger.voidwriteMergedValueDictionary(List<IndexableAdapter> adapters) Given a list of segment adapters: - Read _sorted order_ (e.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.druid.segment.DimensionMergerV9
markAsParent
-
Field Details
-
STRING_MERGING_COMPARATOR
public static final Comparator<com.google.common.collect.PeekingIterator<String>> STRING_MERGING_COMPARATOR -
LONG_MERGING_COMPARATOR
public static final Comparator<com.google.common.collect.PeekingIterator<Long>> LONG_MERGING_COMPARATOR -
DOUBLE_MERGING_COMPARATOR
public static final Comparator<com.google.common.collect.PeekingIterator<Double>> DOUBLE_MERGING_COMPARATOR
-
-
Constructor Details
-
AutoTypeColumnMerger
public AutoTypeColumnMerger(String name, String outputName, @Nullable ColumnType castToType, NestedCommonFormatColumnFormatSpec columnFormatSpec, SegmentWriteOutMedium segmentWriteOutMedium, File segmentBaseDir, Closer closer) - Parameters:
name- column nameoutputName- output smoosh file name. if this is a base table column, it will be the equivalent to name, however if this merger is for a projection, this will be prefixed with the projection name so that multiple projections can store the same column name at different smoosh file "paths"castToType- optional mechanism to enforce that all values are a specific typecolumnFormatSpec- column level storage options such as compression format and bitmap typesegmentWriteOutMedium- temporary storage location to stage segment outputs before finalizing into the segmentcloser- resource closer if this merger needs to attach any closables that should be cleaned up when the segment is finished writing
-
-
Method Details
-
writeMergedValueDictionary
Description copied from interface:DimensionMergerGiven a list of segment adapters: - Read _sorted order_ (e. g. seeIncrementalIndexAdapter.getDimValueLookup(String)) dictionary encoding information from the adapters - Merge those sorted order dictionary into a one big sorted order dictionary and write this merged dictionary. The implementer should maintain knowledge of the "index number" of the adapters in the input list, i.e., the position of each adapter in the input list. This "index number" will be used to refer to specific segments later inDimensionMerger.convertSortedSegmentRowValuesToMergedRowValues(int, org.apache.druid.segment.ColumnValueSelector).- Specified by:
writeMergedValueDictionaryin interfaceDimensionMerger- Parameters:
adapters- List of adapters to be merged.- Throws:
IOException- See Also:
-
convertSortedSegmentRowValuesToMergedRowValues
public ColumnValueSelector convertSortedSegmentRowValuesToMergedRowValues(int segmentIndex, ColumnValueSelector source) Description copied from interface:DimensionMergerCreates a value selector, which converts values with per-segment, _sorted order_ (seeDimensionIndexer.convertUnsortedValuesToSorted(org.apache.druid.segment.ColumnValueSelector)) encoding from the given selector to their equivalent representation in the merged set of rows. This method is used by the index merging process to build the merged sequence of rows. The implementing class is expected to use the merged value metadata constructed duringDimensionMerger.writeMergedValueDictionary(List), if applicable. For example, an implementation of this function for a dictionary-encoded String column would convert the segment-specific, sorted order dictionary values within the row to the common merged dictionary values determined duringDimensionMerger.writeMergedValueDictionary(List).- Specified by:
convertSortedSegmentRowValuesToMergedRowValuesin interfaceDimensionMerger- Parameters:
segmentIndex- indicates which segment the row originated from, in the order established inDimensionMerger.writeMergedValueDictionary(List)source- the selector from which to take values to convert- Returns:
- a selector with converted values
-
processMergedRow
Description copied from interface:DimensionMergerProcess a column value(s) (potentially multi-value) of a row from the given selector and update the DimensionMerger's internal state. After constructing a merged sequence of rows across segments, the index merging process will iterate through these rows and on each iteration, for each column, pass the column value selector to the corresponding DimensionMerger. This allows each DimensionMerger to build its internal view of the sequence of merged rows, to be written out to a segment later.- Specified by:
processMergedRowin interfaceDimensionMerger- Throws:
IOException
-
writeIndexes
Description copied from interface:DimensionMergerInternally construct any index structures relevant to this DimensionMerger. After receiving the sequence of merged rows via iteratedDimensionMerger.processMergedRow(org.apache.druid.segment.ColumnValueSelector)calls, the DimensionMerger can now build any index structures it needs. For example, a dictionary encoded String implementation would create its bitmap indexes for the merged segment during this step. The index merger will provide a list of row number conversion IntBuffer objects. Each IntBuffer is associated with one of the segments being merged; the position of the IntBuffer in the list corresponds to the position of segment adapters within the input list ofDimensionMerger.writeMergedValueDictionary(List). For example, suppose there are two segments A and B. Row 24 from segment A maps to row 99 in the merged sequence of rows, The IntBuffer for segment A would have a mapping of 24 -> 99.- Specified by:
writeIndexesin interfaceDimensionMerger- Parameters:
segmentRowNumConversions- A list of row number conversion IntBuffer objects.
-
hasOnlyNulls
public boolean hasOnlyNulls()Description copied from interface:DimensionMergerReturns true if this dimension has no data besides nulls. SeeNullColumnPartSerdefor how null-only columns are stored in the segment.- Specified by:
hasOnlyNullsin interfaceDimensionMerger
-
makeColumnDescriptor
Description copied from interface:DimensionMergerV9Return a ColumnDescriptor containing ColumnPartSerde objects appropriate for this DimensionMerger's value metadata, sequence of row values, and index structures.- Specified by:
makeColumnDescriptorin interfaceDimensionMergerV9- Returns:
- ColumnDescriptor that IndexMergerV9 will use to build a column.
-
getIdLookup
-
attachParent
public void attachParent(DimensionMergerV9 parent, List<IndexableAdapter> projectionAdapters) throws IOException Description copied from interface:DimensionMergerV9Attaches theDimensionMergerV9of a "projection" parent column so that stuff like value dictionaries can be shared between parent and child. This method is called during merging instead ofDimensionMerger.writeMergedValueDictionary(List)if the parent column exists.- Specified by:
attachParentin interfaceDimensionMergerV9- Throws:
IOException- See Also:
-