org.apache.hadoop.hive.serde2.lazybinary
Class LazyBinaryStruct

java.lang.Object
  extended by org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryObject<OI>
      extended by org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryNonPrimitive<LazyBinaryStructObjectInspector>
          extended by org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryStruct

public class LazyBinaryStruct
extends LazyBinaryNonPrimitive<LazyBinaryStructObjectInspector>

LazyBinaryStruct is serialized as follows: start A B A B A B end bytes[] -> |-----|---------|--- ... ---|-----|---------| Section A is one null-byte, corresponding to eight struct fields in Section B. Each bit indicates whether the corresponding field is null (0) or not null (1). Each field is a LazyBinaryObject. Following B, there is another section A and B. This pattern repeats until the all struct fields are serialized.


Field Summary
 
Fields inherited from class org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryNonPrimitive
bytes, length, start
 
Constructor Summary
protected LazyBinaryStruct(LazyBinaryStructObjectInspector oi)
          Construct a LazyBinaryStruct object with an ObjectInspector.
 
Method Summary
 Object getField(int fieldID)
          Get one field out of the struct.
 ArrayList<Object> getFieldsAsList()
          Get the values of the fields as an ArrayList.
 Object getObject()
          If the LazyBinaryObject is a primitive Object, then deserialize it and return the actual primitive Object.
 void init(ByteArrayRef bytes, int start, int length)
          Set the data for this LazyBinaryObject.
 
Methods inherited from class org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryNonPrimitive
hashCode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LazyBinaryStruct

protected LazyBinaryStruct(LazyBinaryStructObjectInspector oi)
Construct a LazyBinaryStruct object with an ObjectInspector.

Method Detail

init

public void init(ByteArrayRef bytes,
                 int start,
                 int length)
Description copied from class: LazyBinaryObject
Set the data for this LazyBinaryObject. We take ByteArrayRef instead of byte[] so that we will be able to drop the reference to byte[] by a single assignment. The ByteArrayRef object can be reused across multiple rows. Never call this function if the object represent a null!!!

Overrides:
init in class LazyBinaryNonPrimitive<LazyBinaryStructObjectInspector>
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:
ByteArrayRef

getField

public Object getField(int fieldID)
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).

Parameters:
fieldID - The field ID
Returns:
The field as a LazyObject

getFieldsAsList

public ArrayList<Object> getFieldsAsList()
Get the values of the fields as an ArrayList.

Returns:
The values of the fields as an ArrayList.

getObject

public Object getObject()
Description copied from class: LazyBinaryObject
If the LazyBinaryObject is a primitive Object, then deserialize it and return the actual primitive Object. Otherwise (string, list, map, struct), return this.

Overrides:
getObject in class LazyBinaryNonPrimitive<LazyBinaryStructObjectInspector>


Copyright © 2011 The Apache Software Foundation