本文整理汇总了Java中org.apache.tajo.datum.ProtobufDatumFactory.newBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java ProtobufDatumFactory.newBuilder方法的具体用法?Java ProtobufDatumFactory.newBuilder怎么用?Java ProtobufDatumFactory.newBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tajo.datum.ProtobufDatumFactory
的用法示例。
在下文中一共展示了ProtobufDatumFactory.newBuilder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreate
import org.apache.tajo.datum.ProtobufDatumFactory; //导入方法依赖的package包/类
@Test
public void testCreate() throws IOException, NoSuchMethodException, ClassNotFoundException {
TajoDataTypes.DataType.Builder builder = TajoDataTypes.DataType.newBuilder();
builder.setType(TajoDataTypes.Type.PROTOBUF);
builder.setCode(TajoIdProtos.QueryIdProto.class.getName());
ProtobufDatumFactory factory = ProtobufDatumFactory.get(builder.build());
TajoIdProtos.QueryIdProto.Builder queryIdBuilder = factory.newBuilder();
queryIdBuilder.setId(String.valueOf(System.currentTimeMillis()));
queryIdBuilder.setSeq(1);
TajoIdProtos.QueryIdProto queryId = queryIdBuilder.build();
ProtobufDatum datum = factory.createDatum(queryId);
ProtobufJsonFormat formatter = ProtobufJsonFormat.getInstance();
String json = formatter.printToString(datum.get());
TajoIdProtos.QueryIdProto.Builder fromJson = factory.newBuilder();
formatter.merge(TextUtils.toInputStream(json), fromJson);
assertEquals(queryId, fromJson.build());
}
示例2: addBinary
import org.apache.tajo.datum.ProtobufDatumFactory; //导入方法依赖的package包/类
@Override
final public void addBinary(Binary value) {
try {
ProtobufDatumFactory factory =
ProtobufDatumFactory.get(dataType.getCode());
Message.Builder builder = factory.newBuilder();
builder.mergeFrom(value.getBytes());
parent.add(factory.createDatum(builder));
} catch (InvalidProtocolBufferException e) {
throw new RuntimeException(e);
}
}