Class GenericRow

  • All Implemented Interfaces:
    Serializable

    public class GenericRow
    extends Object
    implements Serializable
    The generic row is the value holder returned from RecordReader.next() and {RecordReader#next(GenericRow)}, and can be modified with {RecordTransformer}. The generic row returned from the {NullValueTransformer} should have defaultNullValue filled to the fields with null value, so that for fields with null value, getValue(String) will return the defaultNullValue and isNullValue(String) will return true. 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 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 List with 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
    • Constructor Detail

      • GenericRow

        public GenericRow()
    • 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.
      • removeValue

        public Object removeValue​(String fieldName)
      • isNullValue

        public boolean isNullValue​(String fieldName)
        Returns whether the value is null for the given field.

        The nullField will be set when setting the nullDefaultValue for field by calling putDefaultNullValue(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.
      • putDefaultNullValue

        public void putDefaultNullValue​(String fieldName,
                                        Object defaultNullValue)
        Sets the defaultNullValue for the given nullField.
      • addNullValueField

        public void addNullValueField​(String fieldName)
        Marks a field as null.
      • removeNullValueField

        public boolean removeNullValueField​(String fieldName)
        Marks a field as non-null and returns whether the field was marked as null.
      • clear

        public void clear()
        Removes all the fields from the row.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object