org.apache.hadoop.hive.serde2.lazy
Class LazyStruct

java.lang.Object
  extended by org.apache.hadoop.hive.serde2.lazy.LazyNonPrimitive
      extended by org.apache.hadoop.hive.serde2.lazy.LazyStruct
All Implemented Interfaces:
LazyObject

public class LazyStruct
extends LazyNonPrimitive

LazyObject for storing a struct. The field of a struct can be primitive or non-primitive. LazyStruct does not deal with the case of a NULL struct. That is handled by LazySimpleStructObjectInspector.


Field Summary
 
Fields inherited from class org.apache.hadoop.hive.serde2.lazy.LazyNonPrimitive
bytes, length, start
 
Constructor Summary
LazyStruct(TypeInfo typeInfo)
          Construct a LazyStruct object with the TypeInfo.
 
Method Summary
 Object getField(int fieldID, byte separator, org.apache.hadoop.io.Text nullSequence, boolean lastColumnTakesRest)
          Get one field out of the struct.
 ArrayList<Object> getFieldsAsList(byte separator, org.apache.hadoop.io.Text nullSequence, boolean lastColumnTakesRest)
          Get the values of the fields as an ArrayList.
 Object getObject()
          If the LazyObject is a primitive Object, then deserialize it and return the actual primitive Object.
 void init(ByteArrayRef bytes, int start, int length)
          Set the row data for this LazyStruct.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LazyStruct

public LazyStruct(TypeInfo typeInfo)
Construct a LazyStruct object with the TypeInfo.

Parameters:
typeInfo - the TypeInfo representing the type of this LazyStruct.
Method Detail

init

public void init(ByteArrayRef bytes,
                 int start,
                 int length)
Set the row data for this LazyStruct.

Specified by:
init in interface LazyObject
Overrides:
init in class LazyNonPrimitive
Parameters:
bytes - The wrapper of the byte[].
start - The start position inside the bytes.
length - The length of the data, starting from "start"
See Also:
LazyObject.init(ByteArrayRef, int, int)

getField

public Object getField(int fieldID,
                       byte separator,
                       org.apache.hadoop.io.Text nullSequence,
                       boolean lastColumnTakesRest)
Get one field out of the struct. If the field is a primitive field, return the actual object. Otherwise return the LazyObject. This is because PrimitiveObjectInspector does not have control over the object used by the user - the user simply directly use the Object instead of going through Object PrimitiveObjectInspector.get(Object). NOTE: separator and nullSequence has to be the same each time this method is called. These two parameters are used only once to parse each record.

Parameters:
fieldID - The field ID
separator - The separator for delimiting the fields in the byte[]
nullSequence - The sequence for null value
lastColumnTakesRest - Whether the additional fields should be all put into the last column in case the data contains more columns than the schema.
Returns:
The field as a LazyObject

getFieldsAsList

public ArrayList<Object> getFieldsAsList(byte separator,
                                         org.apache.hadoop.io.Text nullSequence,
                                         boolean lastColumnTakesRest)
Get the values of the fields as an ArrayList.

Parameters:
separator - The separator for delimiting the fields in the byte[]
nullSequence - The sequence for the NULL value
lastColumnTakesRest - Whether the additional fields should be all put into the last column in case the data contains more columns than the schema.
Returns:
The values of the fields as an ArrayList.

getObject

public Object getObject()
Description copied from interface: LazyObject
If the LazyObject is a primitive Object, then deserialize it and return the actual primitive Object. Otherwise (array, map, struct), return this.

Specified by:
getObject in interface LazyObject
Overrides:
getObject in class LazyNonPrimitive


Copyright © 2009 The Apache Software Foundation