当前位置: 首页>>代码示例>>Java>>正文


Java TCompactProtocol.Factory方法代码示例

本文整理汇总了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);
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:27,代码来源:DeserThrift.java

示例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));
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:27,代码来源:SerThrift.java

示例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);
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:17,代码来源:DeserThrift.java

示例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));
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:18,代码来源:SerThrift.java

示例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);
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:18,代码来源:DeserThrift.java

示例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));
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:18,代码来源:SerThrift.java

示例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();
    }
  });
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:22,代码来源:ThriftTestingSource.java

示例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();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:10,代码来源:ThriftSource.java

示例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);
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:18,代码来源:DeserThrift.java

示例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));
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:18,代码来源:SerThrift.java

示例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.");
  }        
}
 
开发者ID:cityzendata,项目名称:warp10-platform,代码行数:22,代码来源:WRAPRAW.java

示例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);
  }
}
 
开发者ID:cityzendata,项目名称:warp10-platform,代码行数:26,代码来源:GEOPACK.java

示例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());
    }
}
 
开发者ID:line,项目名称:armeria,代码行数:22,代码来源:ThriftProtocolFactories.java

示例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);

}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:18,代码来源:ByteSizeTest.java

示例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;
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:26,代码来源:TestThriftToParquetFileWriter.java


注:本文中的org.apache.thrift.protocol.TCompactProtocol.Factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。