Package org.apache.druid.data.input
Class ListBasedInputRow
- java.lang.Object
-
- org.apache.druid.data.input.ListBasedInputRow
-
- All Implemented Interfaces:
Comparable<Row>,InputRow,Row
public class ListBasedInputRow extends Object implements InputRow
Input row backed by aList. This implementation is most useful when the columns and dimensions are known ahead of time, prior to encountering any data. It is used in concert withListBasedInputRowAdapter, which enables
-
-
Constructor Summary
Constructors Constructor Description ListBasedInputRow(RowSignature signature, org.joda.time.DateTime timestamp, List<String> dimensions, List<Object> data)Create a row.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>asMap()intcompareTo(Row o)booleanequals(Object o)List<String>getDimension(String dimension)Returns the list of dimension values for the given column name.List<String>getDimensions()Returns the dimensions that exist in this row.NumbergetMetric(String metric)Returns the metric column value for the given column name.ObjectgetRaw(int columnNumber)ObjectgetRaw(String columnName)Returns the raw dimension value for the given column name.org.joda.time.DateTimegetTimestamp()Returns the timestamp from the epoch as an org.joda.time.DateTime.longgetTimestampFromEpoch()Returns the timestamp from the epoch in milliseconds.inthashCode()static InputRowparse(RowSignature signature, TimestampSpec timestampSpec, List<String> dimensions, List<Object> data)Create a row and parse a timestamp.StringtoString()
-
-
-
Constructor Detail
-
ListBasedInputRow
public ListBasedInputRow(RowSignature signature, org.joda.time.DateTime timestamp, List<String> dimensions, List<Object> data)
Create a row.- Parameters:
signature- signature; must match the "data" listtimestamp- row timestampdimensions- dimensions to be reported bygetDimensions()data- row data
-
-
Method Detail
-
parse
public static InputRow parse(RowSignature signature, TimestampSpec timestampSpec, List<String> dimensions, List<Object> data)
Create a row and parse a timestamp. ThrowsParseExceptionif the timestamp cannot be parsed.- Parameters:
signature- signature; must match the "data" listtimestampSpec- timestamp specdimensions- dimensions to be reported bygetDimensions()data- row data
-
getDimensions
public List<String> getDimensions()
Description copied from interface:InputRowReturns the dimensions that exist in this row.- Specified by:
getDimensionsin interfaceInputRow- Returns:
- the dimensions that exist in this row.
-
getTimestampFromEpoch
public long getTimestampFromEpoch()
Description copied from interface:RowReturns the timestamp from the epoch in milliseconds. If the event happened _right now_, this would return the same thing as System.currentTimeMillis();- Specified by:
getTimestampFromEpochin interfaceRow- Returns:
- the timestamp from the epoch in milliseconds.
-
getTimestamp
public org.joda.time.DateTime getTimestamp()
Description copied from interface:RowReturns the timestamp from the epoch as an org.joda.time.DateTime. If the event happened _right now_, this would return the same thing as new DateTime();- Specified by:
getTimestampin interfaceRow- Returns:
- the timestamp from the epoch as an org.joda.time.DateTime object.
-
getDimension
public List<String> getDimension(String dimension)
Description copied from interface:RowReturns the list of dimension values for the given column name.- Specified by:
getDimensionin interfaceRow- Parameters:
dimension- the column name of the dimension requested- Returns:
- the list of values for the provided column name
-
getRaw
@Nullable public Object getRaw(String columnName)
Description copied from interface:RowReturns the raw dimension value for the given column name. This is different fromRow.getDimension(java.lang.String)which converts all values to strings before returning them.
-
getMetric
@Nullable public Number getMetric(String metric)
Description copied from interface:RowReturns the metric column value for the given column name. This method is different fromRow.getRaw(java.lang.String)in two aspects: 1. If the column is absent in the row, either numeric zero or null will be returned, depending on the value of druid.generic.useDefaultValueForNull. 2. If the column has string value, an attempt is made to parse this value as a number.
-
compareTo
public int compareTo(Row o)
- Specified by:
compareToin interfaceComparable<Row>
-
-