本文整理汇总了Java中org.apache.thrift.protocol.TCompactProtocol.Factory方法的典型用法代码示例。如果您正苦于以下问题:Java TCompactProtocol.Factory方法的具体用法?Java TCompactProtocol.Factory怎么用?Java TCompactProtocol.Factory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.thrift.protocol.TCompactProtocol
的用法示例。
在下文中一共展示了TCompactProtocol.Factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
serializer = new TSerializer(new TCompactProtocol.Factory());
deserializer = new TDeserializer(new TCompactProtocol.Factory());
testData = serializer.serialize(testObject);
}
示例2: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
byteArrayOutputStream = new ByteArrayOutputStream();
TCompactProtocol.Factory protocolFactory = new TCompactProtocol.Factory();
protocol = protocolFactory.getProtocol(new TIOStreamTransport(byteArrayOutputStream));
}
示例3: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
ThriftTestWriteObject testObject = new ThriftTestWriteObject();
testObject.setField1(Arrays.asList("1", "2", "3", "4", "5",
"1", "2", "3", "4", "5",
"1", "2", "3", "4", "5"));
HashMap<String, List<String>> field2 = new HashMap<>();
field2.put("1", Arrays.asList("1", "2", "3", "4", "5"));
field2.put("2", Arrays.asList("1", "2", "3", "4", "5"));
field2.put("3", Arrays.asList("1", "2", "3", "4", "5"));
testObject.setField2(field2);
testObject.setField3("x-3");
serializer = new TSerializer(new TCompactProtocol.Factory());
deserializer = new TDeserializer(new TCompactProtocol.Factory());
testData = serializer.serialize(testObject);
}
示例4: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.addToField1(31.415926);
testObject.addToField1(61.415923);
testObject.addToField1(31.415269);
testObject.addToField1(53.141926);
testObject.addToField1(13.145926);
testObject.addToField1(43.115926);
testObject.addToField1(31.419265);
testObject.addToField1(23.141596);
testObject.addToField1(43.161592);
testObject.addToField1(0.112);
byteArrayOutputStream = new ByteArrayOutputStream();
TCompactProtocol.Factory protocolFactory = new TCompactProtocol.Factory();
protocol = protocolFactory.getProtocol(new TIOStreamTransport(byteArrayOutputStream));
}
示例5: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.addToField1(31.415926);
testObject.addToField1(61.415923);
testObject.addToField1(31.415269);
testObject.addToField1(53.141926);
testObject.addToField1(13.145926);
testObject.addToField1(43.115926);
testObject.addToField1(31.419265);
testObject.addToField1(23.141596);
testObject.addToField1(43.161592);
testObject.addToField1(0.112);
serializer = new TSerializer(new TCompactProtocol.Factory());
deserializer = new TDeserializer(new TCompactProtocol.Factory());
testData = serializer.serialize(testObject);
}
示例6: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.setField1("1");
testObject.setField2("2");
testObject.setField3("3");
testObject.setField4("4");
testObject.setField5("5");
testObject.setField6("6");
testObject.setField7("7");
testObject.setField8("8");
testObject.setField9("9");
testObject.setField10("10");
byteArrayOutputStream = new ByteArrayOutputStream();
TCompactProtocol.Factory protocolFactory = new TCompactProtocol.Factory();
protocol = protocolFactory.getProtocol(new TIOStreamTransport(byteArrayOutputStream));
}
示例7: ThriftTestingSource
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
public ThriftTestingSource(String handlerName, int port, String protocol) throws Exception {
TNonblockingServerTransport serverTransport =
new TNonblockingServerSocket(new InetSocketAddress("0.0.0.0", port));
ThriftSourceProtocol.Iface handler = getHandler(handlerName);
TProtocolFactory transportProtocolFactory = null;
if (protocol != null && protocol == ThriftRpcClient.BINARY_PROTOCOL) {
transportProtocolFactory = new TBinaryProtocol.Factory();
} else {
transportProtocolFactory = new TCompactProtocol.Factory();
}
server = new THsHaServer(new THsHaServer.Args(serverTransport).processor(
new ThriftSourceProtocol.Processor(handler)).protocolFactory(
transportProtocolFactory));
Executors.newSingleThreadExecutor().submit(new Runnable() {
@Override
public void run() {
server.serve();
}
});
}
示例8: getProtocolFactory
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
private TProtocolFactory getProtocolFactory() {
if (protocol.equals(BINARY_PROTOCOL)) {
logger.info("Using TBinaryProtocol");
return new TBinaryProtocol.Factory();
} else {
logger.info("Using TCompactProtocol");
return new TCompactProtocol.Factory();
}
}
示例9: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.setField1(31415926);
testObject.setField2(61415923);
testObject.setField3(31415269);
testObject.setField4(53141926);
testObject.setField5(13145926);
testObject.setField6(43115926);
testObject.setField7(31419265);
testObject.setField8(23141596);
testObject.setField9(43161592);
testObject.setField10(112);
serializer = new TSerializer(new TCompactProtocol.Factory());
deserializer = new TDeserializer(new TCompactProtocol.Factory());
testData = serializer.serialize(testObject);
}
示例10: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.setField1(31415926);
testObject.setField2(61415923);
testObject.setField3(31415269);
testObject.setField4(53141926);
testObject.setField5(13145926);
testObject.setField6(43115926);
testObject.setField7(31419265);
testObject.setField8(23141596);
testObject.setField9(43161592);
testObject.setField10(112);
byteArrayOutputStream = new ByteArrayOutputStream();
TCompactProtocol.Factory protocolFactory = new TCompactProtocol.Factory();
protocol = protocolFactory.getProtocol(new TIOStreamTransport(byteArrayOutputStream));
}
示例11: gtsOp
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
@Override
protected Object gtsOp(Map<String, Object> params, GeoTimeSerie gts) throws WarpScriptException {
GTSWrapper wrapper;
if (opt) {
wrapper = GTSWrapperHelper.fromGTSToGTSWrapper(gts, true, 1.0, true);
} else {
wrapper = GTSWrapperHelper.fromGTSToGTSWrapper(gts, true);
}
TSerializer serializer = new TSerializer(new TCompactProtocol.Factory());
try {
byte[] bytes = serializer.serialize(wrapper);
return bytes;
} catch (TException te) {
throw new WarpScriptException(getName() + " failed to wrap GTS.");
}
}
示例12: pack
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
public static String pack(GeoXPShape shape) throws WarpScriptException {
long[] cells = GeoXPLib.getCells(shape);
GTSEncoder encoder = new GTSEncoder();
try {
for (long cell: cells) {
encoder.addValue(cell, GeoTimeSerie.NO_LOCATION, GeoTimeSerie.NO_ELEVATION, true);
}
} catch (IOException ioe) {
throw new WarpScriptException(ioe);
}
GTSWrapper wrapper = GTSWrapperHelper.fromGTSEncoderToGTSWrapper(encoder, true);
TSerializer serializer = new TSerializer(new TCompactProtocol.Factory());
try {
byte[] serialized = serializer.serialize(wrapper);
return new String(OrderPreservingBase64.encode(serialized, 0, serialized.length), Charsets.US_ASCII);
} catch (TException te) {
throw new WarpScriptException(te);
}
}
示例13: toSerializationFormat
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
/**
* Returns the {@link SerializationFormat} for the specified {@link TProtocolFactory}.
*
* @throws IllegalArgumentException if the specified {@link TProtocolFactory} is not known by this class
*/
public static SerializationFormat toSerializationFormat(TProtocolFactory protoFactory) {
requireNonNull(protoFactory, "protoFactory");
if (protoFactory instanceof TBinaryProtocol.Factory) {
return ThriftSerializationFormats.BINARY;
} else if (protoFactory instanceof TCompactProtocol.Factory) {
return ThriftSerializationFormats.COMPACT;
} else if (protoFactory instanceof TJSONProtocol.Factory) {
return ThriftSerializationFormats.JSON;
} else if (protoFactory instanceof TTextProtocol.Factory) {
return ThriftSerializationFormats.TEXT;
} else {
throw new IllegalArgumentException(
"unsupported TProtocolFactory: " + protoFactory.getClass().getName());
}
}
示例14: test
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
@Test
public void test() throws TException {
TCompactProtocol.Factory factory = new TCompactProtocol.Factory();
ByteArrayOutputStream baos = new ByteArrayOutputStream(16);
TIOStreamTransport transport = new TIOStreamTransport(baos);
TProtocol protocol = factory.getProtocol(transport);
long l = TimeUnit.DAYS.toMillis(1);
logger.debug("day:{}", l);
long currentTime = System.currentTimeMillis();
logger.debug("currentTime:{}" + currentTime);
protocol.writeI64(l);
byte[] buffer = baos.toByteArray();
logger.debug("{}", buffer.length);
}
示例15: createFile
import org.apache.thrift.protocol.TCompactProtocol; //导入方法依赖的package包/类
private <T extends TBase<?,?>> Path createFile(T... tObjs) throws IOException, InterruptedException, TException {
final Path fileToCreate = new Path("target/test/TestThriftToParquetFileWriter/"+tObjs[0].getClass()+".parquet");
LOG.info("File created: {}", fileToCreate.toString());
Configuration conf = new Configuration();
final FileSystem fs = fileToCreate.getFileSystem(conf);
if (fs.exists(fileToCreate)) {
fs.delete(fileToCreate, true);
}
TProtocolFactory protocolFactory = new TCompactProtocol.Factory();
TaskAttemptID taskId = new TaskAttemptID("local", 0, true, 0, 0);
ThriftToParquetFileWriter w = new ThriftToParquetFileWriter(fileToCreate, ContextUtil.newTaskAttemptContext(conf, taskId), protocolFactory, (Class<? extends TBase<?, ?>>) tObjs[0].getClass());
for(T tObj:tObjs) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final TProtocol protocol = protocolFactory.getProtocol(new TIOStreamTransport(baos));
tObj.write(protocol);
w.write(new BytesWritable(baos.toByteArray()));
}
w.close();
return fileToCreate;
}