Class ComplexTypeTransformer
- java.lang.Object
-
- org.apache.pinot.segment.local.recordtransformer.ComplexTypeTransformer
-
- All Implemented Interfaces:
Serializable,RecordTransformer
public class ComplexTypeTransformer extends Object implements RecordTransformer
A transformer to handle the complex types such as Map and Collection, with flattening and unnesting.The map flattening rule will recursively flatten all the map types, except for those under the collection that is not marked as to unnest. For example:
{ "t1":{ "array":[ { "t2":{ "a":"v1" } } ] } }flattens to{ "t1.array":[ { "t2.a":"v1" } ] }The unnesting rule will flatten all the collections provided, which are the paths navigating to the collections. For the same example above. If the the collectionToUnnest is provided as "t1.array", then the rule will unnest the previous output to:[ { "t1.arrayt2.a": "v1", } ]Note the unnest rule will output a collection of generic rows under the fieldGenericRow.MULTIPLE_RECORDS_KEY. TODO: support multi-dimensional array handling- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static ComplexTypeConfig.CollectionNotUnnestedToJsonDEFAULT_COLLECTION_TO_JSON_MODEstatic StringDEFAULT_DELIMITER
-
Constructor Summary
Constructors Constructor Description ComplexTypeTransformer(TableConfig tableConfig)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidflattenMap(GenericRow record, List<String> columns)Recursively flatten all the Maps in the record.static ComplexTypeTransformergetComplexTypeTransformer(TableConfig tableConfig)protected static booleanisNonPrimitiveArray(Object obj)protected voidrenamePrefixes(GenericRow record)Loops through all columns and renames the column's prefix with the corresponding replacement if the prefix matches.GenericRowtransform(GenericRow record)Transforms a record based on some custom rules.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.pinot.segment.local.recordtransformer.RecordTransformer
isNoOp
-
-
-
-
Field Detail
-
DEFAULT_DELIMITER
public static final String DEFAULT_DELIMITER
- See Also:
- Constant Field Values
-
DEFAULT_COLLECTION_TO_JSON_MODE
public static final ComplexTypeConfig.CollectionNotUnnestedToJson DEFAULT_COLLECTION_TO_JSON_MODE
-
-
Constructor Detail
-
ComplexTypeTransformer
public ComplexTypeTransformer(TableConfig tableConfig)
-
-
Method Detail
-
getComplexTypeTransformer
@Nullable public static ComplexTypeTransformer getComplexTypeTransformer(TableConfig tableConfig)
- Returns:
- the complex type transformer defined table config, null if the table config does not have the config
-
transform
public GenericRow transform(GenericRow record)
Description copied from interface:RecordTransformerTransforms a record based on some custom rules.- Specified by:
transformin interfaceRecordTransformer- Parameters:
record- Record to transform- Returns:
- Transformed record, or
nullif the record does not follow certain rules.
-
flattenMap
protected void flattenMap(GenericRow record, List<String> columns)
Recursively flatten all the Maps in the record. It will also navigate into the collections marked as "unnest" and flatten the nested maps.
-
renamePrefixes
protected void renamePrefixes(GenericRow record)
Loops through all columns and renames the column's prefix with the corresponding replacement if the prefix matches.
-
isNonPrimitiveArray
protected static boolean isNonPrimitiveArray(Object obj)
-
-