本文整理了Java中com.esotericsoftware.kryo.Kryo.writeObject()
方法的一些代码示例,展示了Kryo.writeObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Kryo.writeObject()
方法的具体详情如下:
包路径:com.esotericsoftware.kryo.Kryo
类名称:Kryo
方法名:writeObject
[英]Writes an object using the registered serializer.
[中]使用已注册的序列化程序写入对象。
代码示例来源:origin: apache/storm
@Override
public void write(Kryo kryo, Output output, ListDelegate object) {
kryo.writeObject(output, object, serializer);
}
代码示例来源:origin: jersey/jersey
public Object execute(Kryo kryo) {
kryo.writeObject(output, object);
return null;
}
});
代码示例来源:origin: apache/storm
public void serializeInto(List<Object> values, Output out) {
// this ensures that list of values is always written the same way, regardless
// of whether it's a java collection or one of clojure's persistent collections
// (which have different serializers)
// Doing this lets us deserialize as ArrayList and avoid writing the class here
_delegate.setDelegate(values);
_kryo.writeObject(out, _delegate);
}
代码示例来源:origin: alibaba/jstorm
public void serialize(List<Object> values, Output out) throws IOException {
// this ensures that list of values is always written the same way, regardless
// of whether it's a java collection or one of clojure's persistent collections
// (which have different serializers)
// Doing this lets us deserialize as ArrayList and avoid writing the class here
_delegate.setDelegate(values);
_kryo.writeObject(out, _delegate);
}
代码示例来源: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
@Override
protected byte[] serialize(Object obj) {
output.clear();
kryo.writeObject(output, obj);
return output.toBytes();
}
代码示例来源:origin: apache/hive
private static byte[] serializeObjectToKryo(Serializable object) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Output output = new Output(baos);
Kryo kryo = borrowKryo();
try {
kryo.writeObject(output, object);
} finally {
releaseKryo(kryo);
}
output.close();
return baos.toByteArray();
}
代码示例来源:origin: apache/hive
public static byte[] serialize(Object object) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Output output = new Output(stream);
Kryo kryo = SerializationUtilities.borrowKryo();
kryo.setClassLoader(Thread.currentThread().getContextClassLoader());
try {
kryo.writeObject(output, object);
} finally {
SerializationUtilities.releaseKryo(kryo);
}
output.close(); // close() also calls flush()
return stream.toByteArray();
}
代码示例来源:origin: redisson/redisson
@Override
public byte[] apply(OUT o) {
UnsafeMemoryOutput out = new UnsafeMemoryOutput(Buffer.SMALL_BUFFER_SIZE, Buffer.MAX_BUFFER_SIZE);
engine.writeObject(out, o);
out.flush();
return out.toBytes();
}
};
代码示例来源:origin: orbit/orbit
@Override
public void write(Kryo kryo, Output output, Object object)
{
RemoteReference reference = (RemoteReference) object;
ReferenceReplacement replacement = new ReferenceReplacement();
replacement.address = reference.address;
replacement.interfaceClass = reference._interfaceClass();
replacement.id = reference.id;
kryo.writeObject(output, replacement);
}
代码示例来源:origin: orbit/orbit
@Override
public void write(Kryo kryo, Output output, Object object)
{
RemoteReference reference = ((AbstractActor) object).reference;
ReferenceReplacement replacement = new ReferenceReplacement();
replacement.address = reference.address;
replacement.interfaceClass = reference._interfaceClass();
replacement.id = reference.id;
kryo.writeObject(output, replacement);
}
代码示例来源:origin: fengjiachun/Jupiter
@Override
public <T> OutputBuf writeObject(OutputBuf outputBuf, T obj) {
Output output = Outputs.getOutput(outputBuf);
Kryo kryo = kryoThreadLocal.get();
kryo.writeObject(output, obj);
return outputBuf;
}
代码示例来源:origin: apache/hive
/**
* @param plan Usually of type MapredWork, MapredLocalWork etc.
* @param out stream in which serialized plan is written into
*/
private static void serializeObjectByKryo(Kryo kryo, Object plan, OutputStream out) {
Output output = new Output(out);
kryo.setClassLoader(Utilities.getSessionSpecifiedClassLoader());
kryo.writeObject(output, plan);
output.close();
}
代码示例来源:origin: alibaba/jstorm
@Override
public void write(Kryo kryo, Output output, TradeCustomer inner) {
kryo.writeObject(output, inner.getCustomer());
kryo.writeObject(output, inner.getTrade());
output.writeLong(inner.getTimestamp());
output.writeString(inner.getBuffer());
}
代码示例来源:origin: apache/ignite
@Override public void apply(TestObject obj) {
out.reset();
Output kryoOut = null;
try {
kryoOut = new Output(out);
kryo.writeObject(kryoOut, obj);
}
finally {
U.close(kryoOut, log);
}
}
};
代码示例来源: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: redisson/redisson
@Override
public byte[] apply(OUT o) {
final Kryo kryo = engine.borrow();
try {
UnsafeMemoryOutput out = new UnsafeMemoryOutput(Buffer.SMALL_BUFFER_SIZE, Buffer.MAX_BUFFER_SIZE);
kryo.writeObject(out, o);
out.flush();
return out.toBytes();
} finally {
engine.release(kryo);
}
}
};
代码示例来源:origin: apache/kylin
public static byte[] serialize(final Kryo kryo, final Object o) {
if (o == null) {
throw new NullPointerException("Can't serialize null");
}
final Output output = new Output(4096);
kryo.writeObject(output, o);
output.flush();
return output.getBuffer();
}
代码示例来源:origin: orbit/orbit
@Override
public void write(Kryo kryo, Output output, Object object)
{
ActorObserver objectReference = BasicRuntime.getRuntime().registerObserver(null, (ActorObserver) object);
RemoteReference reference = (RemoteReference) objectReference;
ReferenceReplacement replacement = new ReferenceReplacement();
replacement.address = reference.address;
replacement.interfaceClass = reference._interfaceClass();
replacement.id = reference.id;
kryo.writeObject(output, replacement);
}
代码示例来源: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!