Package org.apache.druid.data.input.impl
Class MapInputRowParser
- java.lang.Object
-
- org.apache.druid.data.input.impl.MapInputRowParser
-
- All Implemented Interfaces:
InputRowParser<Map<String,Object>>
public class MapInputRowParser extends Object implements InputRowParser<Map<String,Object>>
-
-
Constructor Summary
Constructors Constructor Description MapInputRowParser(ParseSpec parseSpec)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static List<String>findDimensions(TimestampSpec timestampSpec, DimensionsSpec dimensionsSpec, Set<String> fields)Finds the final set of dimension names to use forInputRow.ParseSpecgetParseSpec()static InputRowparse(TimestampSpec timestampSpec, List<String> dimensions, Map<String,Object> theMap)static InputRowparse(InputRowSchema inputRowSchema, Map<String,Object> theMap)List<InputRow>parseBatch(Map<String,Object> theMap)Parse an input into list ofInputRow.static org.joda.time.DateTimeparseTimestamp(TimestampSpec timestampSpec, Map<String,Object> theMap)static org.joda.time.DateTimeparseTimestampOrThrowParseException(Object timeValue, TimestampSpec timestampSpec, Supplier<Map<String,?>> rawMapSupplier)Given a plain Java Object, extract a timestamp from it using the providedTimestampSpec, or throw aParseExceptionif we can't.InputRowParserwithParseSpec(ParseSpec parseSpec)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.data.input.impl.InputRowParser
parse
-
-
-
-
Constructor Detail
-
MapInputRowParser
public MapInputRowParser(ParseSpec parseSpec)
-
-
Method Detail
-
parseBatch
public List<InputRow> parseBatch(Map<String,Object> theMap)
Description copied from interface:InputRowParserParse an input into list ofInputRow. List can contains null for rows that should be thrown away, or throwsParseExceptionif the input is unparseable. This method should never return null otherwise lots of things will break.- Specified by:
parseBatchin interfaceInputRowParser<Map<String,Object>>
-
parse
public static InputRow parse(InputRowSchema inputRowSchema, Map<String,Object> theMap) throws ParseException
- Throws:
ParseException
-
parse
public static InputRow parse(TimestampSpec timestampSpec, List<String> dimensions, Map<String,Object> theMap) throws ParseException
- Throws:
ParseException
-
findDimensions
public static List<String> findDimensions(TimestampSpec timestampSpec, DimensionsSpec dimensionsSpec, Set<String> fields)
Finds the final set of dimension names to use forInputRow. There are 3 cases here. 1) IfDimensionsSpec.isIncludeAllDimensions()is set, the returned list includes _both_DimensionsSpec.getDimensionNames()and the dimensions in the given map (rawInputRow#keySet()). 2) If isIncludeAllDimensions is not set andDimensionsSpec.getDimensionNames()is not empty, the dimensions in dimensionsSpec is returned. 3) If isIncludeAllDimensions is not set andDimensionsSpec.getDimensionNames()is empty, the dimensions in the given map is returned. In any case, the returned list does not include any dimensions inDimensionsSpec.getDimensionExclusions()orTimestampSpec.getTimestampColumn().
-
parseTimestamp
public static org.joda.time.DateTime parseTimestamp(TimestampSpec timestampSpec, Map<String,Object> theMap)
-
parseTimestampOrThrowParseException
public static org.joda.time.DateTime parseTimestampOrThrowParseException(Object timeValue, TimestampSpec timestampSpec, Supplier<Map<String,?>> rawMapSupplier)
Given a plain Java Object, extract a timestamp from it using the providedTimestampSpec, or throw aParseExceptionif we can't.- Parameters:
timeValue- object to interpret as timestmaptimestampSpec- timestamp specrawMapSupplier- supplier of the original raw data that this object came from. Used for error messages.
-
getParseSpec
public ParseSpec getParseSpec()
- Specified by:
getParseSpecin interfaceInputRowParser<Map<String,Object>>
-
withParseSpec
public InputRowParser withParseSpec(ParseSpec parseSpec)
- Specified by:
withParseSpecin interfaceInputRowParser<Map<String,Object>>
-
-