Search in sources :

Example 6 with ByteStream

use of org.apache.hadoop.hive.serde2.ByteStream in project elephant-bird by twitter.

the class RCFilePigStorage method putNext.

@SuppressWarnings("unchecked")
@Override
public void putNext(Tuple t) throws IOException {
    if (rowWritable == null) {
        // initialize
        if (numColumns < 1) {
            throw new IOException("number of columns is not set");
        }
        byteStream = new ByteStream.Output();
        rowWritable = new BytesRefArrayWritable();
        colValRefs = new BytesRefWritable[numColumns];
        for (int i = 0; i < numColumns; i++) {
            colValRefs[i] = new BytesRefWritable();
            rowWritable.set(i, colValRefs[i]);
        }
    }
    byteStream.reset();
    // write each field as a text (just like PigStorage)
    int sz = t.size();
    int startPos = 0;
    for (int i = 0; i < sz && i < numColumns; i++) {
        StorageUtil.putField(byteStream, t.get(i));
        colValRefs[i].set(byteStream.getData(), startPos, byteStream.getCount() - startPos);
        startPos = byteStream.getCount();
    }
    try {
        writer.write(null, rowWritable);
    } catch (InterruptedException e) {
        throw new IOException(e);
    }
}
Also used : BytesRefArrayWritable(org.apache.hadoop.hive.serde2.columnar.BytesRefArrayWritable) ByteStream(org.apache.hadoop.hive.serde2.ByteStream) IOException(java.io.IOException) BytesRefWritable(org.apache.hadoop.hive.serde2.columnar.BytesRefWritable)

Aggregations

ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)4 PrimitiveObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector)4 ArrayList (java.util.ArrayList)3 BooleanObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector)3 ByteObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.ByteObjectInspector)3 DoubleObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.DoubleObjectInspector)3 FloatObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.FloatObjectInspector)3 IntObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.IntObjectInspector)3 LongObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.LongObjectInspector)3 ShortObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.ShortObjectInspector)3 VectorExpressionWriter (org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpressionWriter)2 HiveDecimalWritable (org.apache.hadoop.hive.serde2.io.HiveDecimalWritable)2 ListObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector)2 MapObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector)2 StructObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector)2 UnionObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.UnionObjectInspector)2 BinaryObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.BinaryObjectInspector)2 DateObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.DateObjectInspector)2 HiveCharObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveCharObjectInspector)2 HiveDecimalObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveDecimalObjectInspector)2