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


Java TSerializer.serialize方法代码示例

本文整理汇总了Java中org.apache.thrift.TSerializer.serialize方法的典型用法代码示例。如果您正苦于以下问题:Java TSerializer.serialize方法的具体用法?Java TSerializer.serialize怎么用?Java TSerializer.serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.thrift.TSerializer的用法示例。


在下文中一共展示了TSerializer.serialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: benchSetup

import org.apache.thrift.TSerializer; //导入方法依赖的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.TSerializer; //导入方法依赖的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

示例3: benchSetup

import org.apache.thrift.TSerializer; //导入方法依赖的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

示例4: benchSetup

import org.apache.thrift.TSerializer; //导入方法依赖的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

示例5: gtsOp

import org.apache.thrift.TSerializer; //导入方法依赖的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

示例6: gtsOp

import org.apache.thrift.TSerializer; //导入方法依赖的package包/类
@Override
protected Object gtsOp(Map<String, Object> params, GeoTimeSerie gts) throws WarpScriptException {

  GTSWrapper wrapper;
  
  if (opt) {
    wrapper = GTSWrapperHelper.fromGTSToGTSWrapper(gts, this.compress, 1.0, true);
  } else {
    wrapper = GTSWrapperHelper.fromGTSToGTSWrapper(gts, this.compress);
  }
  
  TSerializer serializer = new TSerializer(new TCompactProtocol.Factory());
  
  try {
    byte[] bytes = serializer.serialize(wrapper);
    
    return new String(OrderPreservingBase64.encode(bytes), Charsets.US_ASCII);
  } catch (TException te) {
    throw new WarpScriptException(getName() + " failed to wrap GTS.");
  }        
}
 
开发者ID:cityzendata,项目名称:warp10-platform,代码行数:22,代码来源:WRAP.java

示例7: pack

import org.apache.thrift.TSerializer; //导入方法依赖的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

示例8: serializeLoggingEvent

import org.apache.thrift.TSerializer; //导入方法依赖的package包/类
public static final String serializeLoggingEvent(KeyStore keystore, LoggingEvent event) {
  if (null == event) {
    return null;
  }
  
  TSerializer serializer = new TSerializer(new TCompactProtocol.Factory());
  
  byte[] serialized = null;
  
  try {
    serialized = serializer.serialize(event);
  } catch (TException te) {
    return null;
  }
  
  if (!checkedAESKey) {
    checkedAESKey = true;
    loggingAESKey = keystore.getKey(KeyStore.AES_LOGGING);      
  }
  if (null != loggingAESKey) {
    serialized = CryptoUtils.wrap(loggingAESKey, serialized);
  }
  
  return new String(OrderPreservingBase64.encode(serialized), Charsets.US_ASCII); 
}
 
开发者ID:cityzendata,项目名称:warp10-platform,代码行数:26,代码来源:LogUtil.java

示例9: benchmark

import org.apache.thrift.TSerializer; //导入方法依赖的package包/类
protected void benchmark() throws Exception {
  for (int trial = 0; trial < NUM_TRIALS; trial++) {
    TSerializer ser = new TSerializer(getFactory());
    byte[] serialized = null;
    long serStart = System.currentTimeMillis();
    for (int rep = 0; rep < NUM_REPS; rep++) {
      serialized = ser.serialize(Fixtures.holyMoley);
    }
    long serEnd = System.currentTimeMillis();
    long serElapsed = serEnd - serStart;
    System.out.println("Ser:\t" + serElapsed + "ms\t" 
        + ((double)serElapsed / NUM_REPS) + "ms per serialization");

    HolyMoley cpts = new HolyMoley();
    TDeserializer deser = new TDeserializer(getFactory());
    long deserStart = System.currentTimeMillis();
    for (int rep = 0; rep < NUM_REPS; rep++) {
      deser.deserialize(cpts, serialized);
    }
    long deserEnd = System.currentTimeMillis();
    long deserElapsed = deserEnd - deserStart;
    System.out.println("Des:\t" + deserElapsed + "ms\t" 
        + ((double)deserElapsed / NUM_REPS) + "ms per deserialization");
  }
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:26,代码来源:ProtocolTestBase.java

示例10: toByteArray

import org.apache.thrift.TSerializer; //导入方法依赖的package包/类
public static byte[] toByteArray(Message m){
	TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
	ch.usi.da.dlog.thrift.gen.Message msg = new ch.usi.da.dlog.thrift.gen.Message();
	msg.setId(m.getID());
	msg.setFrom(m.getFrom());
	msg.setTo(m.getTo());
	List<Cmd> cmds = new ArrayList<Cmd>();
	for(Command c : m.getCommands()){
		cmds.add(Command.toCmd(c));
	}
	msg.setCommands(cmds);
	try {
		return serializer.serialize(msg);
	} catch (TException e) {
		return new byte[0];
	}
}
 
开发者ID:sambenz,项目名称:URingPaxos,代码行数:18,代码来源:Message.java

示例11: benchSetup

import org.apache.thrift.TSerializer; //导入方法依赖的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");
    serializer = new TSerializer(new TCompactProtocol.Factory());
    deserializer = new TDeserializer(new TCompactProtocol.Factory());
    testData = serializer.serialize(testObject);
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:18,代码来源:DeserThrift.java

示例12: benchSetup

import org.apache.thrift.TSerializer; //导入方法依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
    testObject = new ThriftTestObject();
    testObject.setField1(31.415926);
    testObject.setField2(61.415923);
    testObject.setField3(31.415269);
    testObject.setField4(53.141926);
    testObject.setField5(13.145926);
    testObject.setField6(43.115926);
    testObject.setField7(31.419265);
    testObject.setField8(23.141596);
    testObject.setField9(43.161592);
    testObject.setField10(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

示例13: benchSetup

import org.apache.thrift.TSerializer; //导入方法依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
    testObject = new ThriftTestObject();
    testObject.setField1(24.646182098202726);
    serializer = new TSerializer(new TCompactProtocol.Factory());
    deserializer = new TDeserializer(new TCompactProtocol.Factory());
    testData = serializer.serialize(testObject);
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:9,代码来源:DeserThrift.java

示例14: benchSetup

import org.apache.thrift.TSerializer; //导入方法依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
    testObject = new ThriftTestObject();
    testObject.setField1("1");
    serializer = new TSerializer(new TCompactProtocol.Factory());
    deserializer = new TDeserializer(new TCompactProtocol.Factory());
    testData = serializer.serialize(testObject);
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:9,代码来源:DeserThrift.java

示例15: benchSetup

import org.apache.thrift.TSerializer; //导入方法依赖的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");
    serializer = new TSerializer(new TCompactProtocol.Factory());
    deserializer = new TDeserializer(new TCompactProtocol.Factory());
    testData = serializer.serialize(testObject);
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:13,代码来源:DeserThrift.java


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