Class GenericRow
- java.lang.Object
-
- org.apache.pinot.spi.data.readers.GenericRow
-
- All Implemented Interfaces:
Serializable
public class GenericRow extends Object implements Serializable
The generic row is the value holder returned fromRecordReader.next()and {RecordReader#next(GenericRow)}, and can be modified with {RecordTransformer}. The generic row returned from the {NullValueTransformer} should havedefaultNullValuefilled to the fields withnullvalue, so that for fields withnullvalue,getValue(String)will return thedefaultNullValueandisNullValue(String)will returntrue. The fixed set of allowed data types for the fields in the GenericRow should be: Integer, Long, Float, Double, String, byte[], Object[] of the single-value types This is the fixed set of data types to be used by RecordExtractor and RecordReader to extract fields from the row, and by the ExpressionEvaluator to evaluate the result FIXME: Based on the current behavior, we support the following data types: SV: Boolean, Byte, Character, Short, Integer, Long, Float, Double, String, byte[] MV: Object[] or List of Byte, Character, Short, Integer, Long, Float, Double, String We should not be using Boolean, Byte, Character and Short to keep it simple- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringINCOMPLETE_RECORD_KEYThis key is used by transformers to indicate some error might have occurred while doing transform on a column and a default/null value has been put in place of actual value.static StringMULTIPLE_RECORDS_KEYThis key is used by a Decoder/RecordReader to handle 1 record to many records flattening.static StringSKIP_RECORD_KEYThis key is used by the FilterTransformer to skip records during ingestion The FilterTransformer puts this key into the GenericRow with value true, if the record matches the filtering criteria, based on FilterConfig
-
Constructor Summary
Constructors Constructor Description GenericRow()
-
Method Summary
Modifier and Type Method Description voidaddNullValueField(String fieldName)Marks a field asnull.voidclear()Removes all the fields from the row.GenericRowcopy()static GenericRowcreateOrReuseRow(GenericRow row)Deprecated.booleanequals(Object obj)static GenericRowfromBytes(byte[] buffer)Deprecated.Set<Map.Entry<String,Object>>getEntrySet()Deprecated.String[]getFieldNames()Deprecated.Map<String,Object>getFieldToValueMap()Returns the map from fields to values.Set<String>getNullValueFields()Returns the fields withnullvalue.PrimaryKeygetPrimaryKey(List<String> primaryKeyColumns)ObjectgetValue(String fieldName)Returns the value for the given field.inthashCode()booleanhasNullValues()Returns whether this row has null values for any of the columnsvoidinit(Map<String,Object> fieldToValueMap)Deprecated.voidinit(GenericRow row)Initializes the generic row from the given generic row (shallow copy).booleanisNullValue(String fieldName)Returns whether the value isnullfor the given field.voidputDefaultNullValue(String fieldName, Object defaultNullValue)Sets thedefaultNullValuefor the givennullField.voidputField(String fieldName, Object value)Deprecated.voidputValue(String fieldName, Object value)Sets the value for the given field.booleanremoveNullValueField(String fieldName)Marks a field asnon-nulland returns whether the field was marked asnull.ObjectremoveValue(String fieldName)byte[]toBytes()Deprecated.StringtoString()
-
-
-
Field Detail
-
MULTIPLE_RECORDS_KEY
public static final String MULTIPLE_RECORDS_KEY
This key is used by a Decoder/RecordReader to handle 1 record to many records flattening. If a Decoder/RecordReader produces multiple GenericRows from the given record, they must be put into the destination GenericRow as a Listwith this key. The segment generation drivers handle this key as a special case and process the multiple records. - See Also:
- Constant Field Values
-
SKIP_RECORD_KEY
public static final String SKIP_RECORD_KEY
This key is used by the FilterTransformer to skip records during ingestion The FilterTransformer puts this key into the GenericRow with value true, if the record matches the filtering criteria, based on FilterConfig- See Also:
- Constant Field Values
-
INCOMPLETE_RECORD_KEY
public static final String INCOMPLETE_RECORD_KEY
This key is used by transformers to indicate some error might have occurred while doing transform on a column and a default/null value has been put in place of actual value. Only used when continueOnError is set to true- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init(GenericRow row)
Initializes the generic row from the given generic row (shallow copy). The row should be new created or cleared before calling this method.
-
getFieldToValueMap
public Map<String,Object> getFieldToValueMap()
Returns the map from fields to values.Before setting the
defaultNullValuefor a field by callingputDefaultNullValue(String, Object), the value for the field can benull.
-
getNullValueFields
public Set<String> getNullValueFields()
Returns the fields withnullvalue.The
nullFieldwill be set when setting thenullDefaultValuefor field by callingputDefaultNullValue(String, Object).
-
getValue
public Object getValue(String fieldName)
Returns the value for the given field.Before setting the
defaultNullValuefor a field by callingputDefaultNullValue(String, Object), the value for the field can benull.
-
isNullValue
public boolean isNullValue(String fieldName)
Returns whether the value isnullfor the given field.The
nullFieldwill be set when setting thenullDefaultValuefor field by callingputDefaultNullValue(String, Object).
-
hasNullValues
public boolean hasNullValues()
Returns whether this row has null values for any of the columns
-
copy
public GenericRow copy()
- Returns:
- a deep copy of the generic row
-
putValue
public void putValue(String fieldName, @Nullable Object value)
Sets the value for the given field.
-
getPrimaryKey
public PrimaryKey getPrimaryKey(List<String> primaryKeyColumns)
-
putDefaultNullValue
public void putDefaultNullValue(String fieldName, Object defaultNullValue)
Sets thedefaultNullValuefor the givennullField.
-
addNullValueField
public void addNullValueField(String fieldName)
Marks a field asnull.
-
removeNullValueField
public boolean removeNullValueField(String fieldName)
Marks a field asnon-nulland returns whether the field was marked asnull.
-
clear
public void clear()
Removes all the fields from the row.
-
init
@Deprecated public void init(Map<String,Object> fieldToValueMap)
Deprecated.
-
getEntrySet
@Deprecated public Set<Map.Entry<String,Object>> getEntrySet()
Deprecated.
-
getFieldNames
@Deprecated public String[] getFieldNames()
Deprecated.
-
putField
@Deprecated public void putField(String fieldName, @Nullable Object value)
Deprecated.
-
fromBytes
@Deprecated public static GenericRow fromBytes(byte[] buffer) throws IOException
Deprecated.- Throws:
IOException
-
toBytes
@Deprecated public byte[] toBytes() throws IOException
Deprecated.- Throws:
IOException
-
createOrReuseRow
@Deprecated public static GenericRow createOrReuseRow(GenericRow row)
Deprecated.
-
-