本文整理了Java中com.esotericsoftware.kryo.io.Output.toBytes()
方法的一些代码示例,展示了Output.toBytes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Output.toBytes()
方法的具体详情如下:
包路径:com.esotericsoftware.kryo.io.Output
类名称:Output
方法名:toBytes
[英]Returns a new byte array containing the bytes currently in the buffer between zero and #position().
[中]返回一个新字节数组,其中包含缓冲区中当前介于0和#position()之间的字节。
代码示例来源:origin: apache/storm
@Override
public byte[] serialize(T obj) {
output.get().clear();
kryo.get().writeClassAndObject(output.get(), obj);
return output.get().toBytes();
}
代码示例来源:origin: apache/rocketmq-externals
public byte[] write(final Event value) {
Output output = new Output(bufferSize, maxBufferSize);
this.kryo.writeClassAndObject(output, value);
return output.toBytes();
}
}
代码示例来源:origin: apache/storm
/**
* Serializes the given object into a byte array using Kryo serialization.
*
* @param obj Object to be serialized.
*/
public byte[] serialize(Object obj) {
output.clear();
kryo.writeClassAndObject(output, obj);
return output.toBytes();
}
代码示例来源:origin: apache/storm
public byte[] serialize(List<Object> values) {
_kryoOut.clear();
serializeInto(values, _kryoOut);
return _kryoOut.toBytes();
}
代码示例来源:origin: apache/storm
public byte[] serializeObject(Object obj) {
_kryoOut.clear();
_kryo.writeClassAndObject(_kryoOut, obj);
return _kryoOut.toBytes();
}
}
代码示例来源:origin: alibaba/jstorm
@Override
public byte[] serialize(T obj) {
output.clear();
kryo.writeClassAndObject(output, obj);
return output.toBytes();
}
代码示例来源:origin: alibaba/jstorm
@Override
public byte[] serialize(T obj) {
output.clear();
kryo.writeClassAndObject(output, obj);
return output.toBytes();
}
代码示例来源:origin: alibaba/jstorm
@Override
protected byte[] serialize(Object obj) {
output.clear();
kryo.writeObject(output, obj);
return output.toBytes();
}
代码示例来源:origin: alibaba/jstorm
public byte[] serializeObject(Object obj) {
_kryoOut.clear();
_kryo.writeClassAndObject(_kryoOut, obj);
return _kryoOut.toBytes();
}
代码示例来源:origin: alibaba/jstorm
public byte[] serialize(Tuple tuple) {
_kryoOut.clear();
serializeTuple(_kryoOut, tuple);
return _kryoOut.toBytes();
}
代码示例来源:origin: apache/kylin
public static byte[] serialize(Object obj) {
Kryo kryo = getKryo();
Output output = new Output(1024, 8 * 1024 * 1024);
kryo.writeObject(output, obj);
return output.toBytes();
}
代码示例来源:origin: alibaba/jstorm
public byte[] serialize(List<Object> values) throws IOException {
_kryoOut.clear();
serializeInto(values, _kryoOut);
return _kryoOut.toBytes();
}
代码示例来源:origin: qiujiayu/AutoLoadCache
@Override
public byte[] serialize(Object obj, int bufferSize) {
Kryo kryo = pool.borrow();
try (Output output = new Output(new ByteArrayOutputStream(), bufferSize)) {
kryo.writeClassAndObject(output, obj);
return output.toBytes();
} finally {
pool.release(kryo);
}
}
代码示例来源:origin: yu199195/myth
@Override
public byte[] serialize(final Object obj) throws MythException {
byte[] bytes;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Output output = new Output(outputStream)) {
//获取kryo对象
Kryo kryo = new Kryo();
kryo.writeObject(output, obj);
bytes = output.toBytes();
output.flush();
} catch (IOException ex) {
throw new MythException("kryo serialize error" + ex.getMessage());
}
return bytes;
}
代码示例来源:origin: yu199195/Raincat
@Override
public byte[] serialize(final Object obj) throws TransactionException {
byte[] bytes;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Output output = new Output(outputStream)) {
//获取kryo对象
Kryo kryo = new Kryo();
kryo.writeObject(output, obj);
bytes = output.toBytes();
output.flush();
} catch (IOException ex) {
throw new TransactionException("kryo serialize error" + ex.getMessage());
}
return bytes;
}
代码示例来源:origin: yu199195/hmily
/**
* 序列化.
*
* @param obj 需要序更列化的对象
* @return 序列化后的byte 数组
* @throws HmilyException 异常
*/
@Override
public byte[] serialize(final Object obj) throws HmilyException {
byte[] bytes;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Output output = new Output(outputStream)) {
//获取kryo对象
Kryo kryo = new Kryo();
kryo.writeObject(output, obj);
bytes = output.toBytes();
output.flush();
} catch (IOException ex) {
throw new HmilyException("kryo serialize error" + ex.getMessage());
}
return bytes;
}
代码示例来源:origin: apache/hive
public static String toKryo(SearchArgument sarg) {
Output out = new Output(4 * 1024, 10 * 1024 * 1024);
new Kryo().writeObject(out, sarg);
out.close();
return Base64.encodeBase64String(out.toBytes());
}
代码示例来源:origin: fengjiachun/Jupiter
@Override
public <T> byte[] writeObject(T obj) {
Output output = Outputs.getOutput();
Kryo kryo = kryoThreadLocal.get();
try {
kryo.writeObject(output, obj);
return output.toBytes();
} finally {
Outputs.clearOutput(output);
}
}
代码示例来源:origin: fengjiachun/Jupiter
@Override
public <T> byte[] writeObject(T obj) {
Output output = Outputs.getOutput();
Kryo kryo = kryoThreadLocal.get();
try {
kryo.writeObject(output, obj);
return output.toBytes();
} finally {
Outputs.clearOutput(output);
}
}
代码示例来源:origin: apache/storm
public byte[] serialize(Tuple tuple) {
try {
_kryoOut.clear();
_kryoOut.writeInt(tuple.getSourceTask(), true);
_kryoOut.writeInt(_ids.getStreamId(tuple.getSourceComponent(), tuple.getSourceStreamId()), true);
tuple.getMessageId().serialize(_kryoOut);
_kryo.serializeInto(tuple.getValues(), _kryoOut);
return _kryoOut.toBytes();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!