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);
}
}
Aggregations