use of com.twitter.elephantbird.pig.piggybank.ThriftBytesToTuple in project elephant-bird by twitter.
the class TestThriftToPig method bytesToTuple.
static <M extends TBase<?, ?>> Tuple bytesToTuple(M obj) throws TException, ExecException, IOException {
// test ThriftBytesToTuple UDF.
// first serialize obj and then invoke the UDF.
TypeRef<M> typeRef = new TypeRef<M>(obj.getClass()) {
};
ThriftConverter<M> converter = ThriftConverter.newInstance(typeRef);
ThriftBytesToTuple<M> tTuple = new ThriftBytesToTuple<M>(obj.getClass().getName());
Tuple tuple = tupleFactory.newTuple(1);
tuple.set(0, new DataByteArray(converter.toBytes(obj)));
return tTuple.exec(tuple);
}
Aggregations