本文整理了Java中com.esotericsoftware.kryo.io.Output.clear()
方法的一些代码示例,展示了Output.clear()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Output.clear()
方法的具体详情如下:
包路径:com.esotericsoftware.kryo.io.Output
类名称:Output
方法名:clear
[英]Sets the position and total to zero.
[中]将位置和总数设置为零。
代码示例来源:origin: apache/storm
@Override
public byte[] serialize(T obj) {
output.get().clear();
kryo.get().writeClassAndObject(output.get(), obj);
return output.get().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
public byte[] serialize(List<Object> values) throws IOException {
_kryoOut.clear();
serializeInto(values, _kryoOut);
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/storm
/**
* Serializes the given object into a {@link ByteBuffer} backed by the byte array returned by Kryo serialization.
*
* @param obj Object to be serialized.
*/
public ByteBuffer serializeToByteBuffer(Object obj) {
output.clear();
kryo.writeClassAndObject(output, obj);
return ByteBuffer.wrap(output.getBuffer(), 0, output.position());
}
代码示例来源:origin: fengjiachun/Jupiter
public static void clearOutput(Output output) {
output.clear();
// 防止hold过大的内存块一直不释放
byte[] bytes = output.getBuffer();
if (bytes == null) {
return;
}
if (bytes.length > MAX_CACHED_BUF_SIZE) {
output.setBuffer(new byte[DEFAULT_BUF_SIZE], -1);
}
}
代码示例来源:origin: fengjiachun/Jupiter
public static void clearOutput(Output output) {
output.clear();
// 防止hold过大的内存块一直不释放
byte[] bytes = output.getBuffer();
if (bytes == null) {
return;
}
if (bytes.length > MAX_CACHED_BUF_SIZE) {
output.setBuffer(new byte[DEFAULT_BUF_SIZE], -1);
}
}
代码示例来源:origin: alibaba/jetcache
@Override
public byte[] apply(Object value) {
try {
Object[] kryoAndOutput = kryoThreadLocal.get();
Kryo kryo = (Kryo) kryoAndOutput[0];
WeakReference<Output> ref = (WeakReference<Output>) kryoAndOutput[1];
Output output = ref.get();
if (output == null) {
output = new Output(INIT_BUFFER_SIZE, -1);
kryoAndOutput[1] = new WeakReference<>(output);
}
try {
if (useIdentityNumber) {
output.writeInt(IDENTITY_NUMBER);
}
kryo.writeClassAndObject(output, value);
return output.toBytes();
} finally {
//reuse buffer if possible
output.clear();
}
} catch (Exception e) {
StringBuilder sb = new StringBuilder("Kryo Encode error. ");
sb.append("msg=").append(e.getMessage());
throw new CacheEncodeException(sb.toString(), e);
}
}
代码示例来源:origin: apache/flink
output.clear();
代码示例来源: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);
}
}
代码示例来源:origin: tv.cntt/chill-scala-2-11
/** Call this when to reset the state to the initial state */
public void clear() {
input.setBuffer(EMPTY_BUFFER);
output.clear();
}
代码示例来源:origin: org.apache.storm/storm-core
public byte[] serialize(List<Object> values) throws IOException {
_kryoOut.clear();
serializeInto(values, _kryoOut);
return _kryoOut.toBytes();
}
代码示例来源:origin: com.n3twork.storm/storm-core
public byte[] serialize(List<Object> values) throws IOException {
_kryoOut.clear();
serializeInto(values, _kryoOut);
return _kryoOut.toBytes();
}
代码示例来源:origin: com.n3twork.storm/storm-core
public byte[] serializeObject(Object obj) {
_kryoOut.clear();
_kryo.writeClassAndObject(_kryoOut, obj);
return _kryoOut.toBytes();
}
}
内容来源于网络,如有侵权,请联系作者删除!