Search in sources :

Example 6 with LazyBinaryStruct

use of org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryStruct in project hive by apache.

the class TestLazyBinaryStruct method testEmptyStruct.

@Test
public void testEmptyStruct() {
    LazyBinaryStructObjectInspector oi = LazyBinaryObjectInspectorFactory.getLazyBinaryStructObjectInspector(new ArrayList<>(), new ArrayList<>());
    ByteArrayRef byteRef = new ByteArrayRef();
    byteRef.setData(new byte[] { 0 });
    LazyBinaryStruct data = (LazyBinaryStruct) LazyBinaryFactory.createLazyBinaryObject(oi);
    data.init(byteRef, 0, 0);
    assertEquals(data.getRawDataSerializedSize(), 0);
}
Also used : ByteArrayRef(org.apache.hadoop.hive.serde2.lazy.ByteArrayRef) LazyBinaryStructObjectInspector(org.apache.hadoop.hive.serde2.lazybinary.objectinspector.LazyBinaryStructObjectInspector) Test(org.junit.Test)

Example 7 with LazyBinaryStruct

use of org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryStruct in project hive by apache.

the class LazyBinarySerDe method initialize.

/**
 * Initialize the SerDe with configuration and table information.
 */
@Override
public void initialize(Configuration configuration, Properties tableProperties, Properties partitionProperties) throws SerDeException {
    super.initialize(configuration, tableProperties, partitionProperties);
    // Create row related objects
    rowTypeInfo = TypeInfoFactory.getStructTypeInfo(getColumnNames(), getColumnTypes());
    // Create the object inspector and the lazy binary struct object
    cachedObjectInspector = LazyBinaryUtils.getLazyBinaryObjectInspectorFromTypeInfo(rowTypeInfo);
    cachedLazyBinaryStruct = (LazyBinaryStruct) LazyBinaryFactory.createLazyBinaryObject(cachedObjectInspector);
    // output debug info
    log.debug("LazyBinarySerDe initialized with: columnNames={} columnTypes={}", getColumnNames(), getColumnTypes());
    serializedSize = 0;
    stats = new SerDeStats();
    lastOperationSerialize = false;
    lastOperationDeserialize = false;
}
Also used : SerDeStats(org.apache.hadoop.hive.serde2.SerDeStats)

Aggregations

BytesWritable (org.apache.hadoop.io.BytesWritable)3 Output (org.apache.hadoop.hive.serde2.ByteStream.Output)2 LazyBinaryStruct (org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryStruct)2 LazyBinaryDeserializeRead (org.apache.hadoop.hive.serde2.lazybinary.fast.LazyBinaryDeserializeRead)2 LazyBinarySerializeWrite (org.apache.hadoop.hive.serde2.lazybinary.fast.LazyBinarySerializeWrite)2 LazyBinaryStructObjectInspector (org.apache.hadoop.hive.serde2.lazybinary.objectinspector.LazyBinaryStructObjectInspector)2 UnionObject (org.apache.hadoop.hive.serde2.objectinspector.UnionObject)2 PrimitiveTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo)2 Writable (org.apache.hadoop.io.Writable)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Date (org.apache.hadoop.hive.common.type.Date)1 HiveChar (org.apache.hadoop.hive.common.type.HiveChar)1 HiveDecimal (org.apache.hadoop.hive.common.type.HiveDecimal)1 HiveIntervalDayTime (org.apache.hadoop.hive.common.type.HiveIntervalDayTime)1 HiveIntervalYearMonth (org.apache.hadoop.hive.common.type.HiveIntervalYearMonth)1 HiveVarchar (org.apache.hadoop.hive.common.type.HiveVarchar)1 Timestamp (org.apache.hadoop.hive.common.type.Timestamp)1 SerDeStats (org.apache.hadoop.hive.serde2.SerDeStats)1