本文整理了Java中com.esotericsoftware.kryo.Kryo.getGraphContext()
方法的一些代码示例,展示了Kryo.getGraphContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Kryo.getGraphContext()
方法的具体详情如下:
包路径:com.esotericsoftware.kryo.Kryo
类名称:Kryo
方法名:getGraphContext
[英]Name/value pairs that are available to all serializers and are cleared after each object graph is serialized or deserialized.
[中]所有序列化程序都可以使用的名称/值对,并且在序列化或反序列化每个对象图后清除。
代码示例来源:origin: apache/flink
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void write(Kryo kryo, Output output, T o) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectOutputStream objectStream = (ObjectOutputStream)graphContext.get(this);
if (objectStream == null) {
objectStream = new ObjectOutputStream(output);
graphContext.put(this, objectStream);
}
objectStream.writeObject(o);
objectStream.flush();
} catch (Exception ex) {
throw new KryoException("Error during Java serialization.", ex);
}
}
代码示例来源:origin: apache/flink
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public T read(Kryo kryo, Input input, Class aClass) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectInputStream objectStream = (ObjectInputStream)graphContext.get(this);
if (objectStream == null) {
// make sure we use Kryo's classloader
objectStream = new InstantiationUtil.ClassLoaderObjectInputStream(input, kryo.getClassLoader());
graphContext.put(this, objectStream);
}
return (T) objectStream.readObject();
} catch (Exception ex) {
throw new KryoException("Error during Java deserialization.", ex);
}
}
代码示例来源:origin: com.esotericsoftware/kryo-shaded
public void write (Kryo kryo, Output output, Object object) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectOutputStream objectStream = (ObjectOutputStream)graphContext.get(this);
if (objectStream == null) {
objectStream = new ObjectOutputStream(output);
graphContext.put(this, objectStream);
}
objectStream.writeObject(object);
objectStream.flush();
} catch (Exception ex) {
throw new KryoException("Error during Java serialization.", ex);
}
}
代码示例来源:origin: com.esotericsoftware/kryo
public void write (Kryo kryo, Output output, Object object) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectOutputStream objectStream = (ObjectOutputStream)graphContext.get(this);
if (objectStream == null) {
objectStream = new ObjectOutputStream(output);
graphContext.put(this, objectStream);
}
objectStream.writeObject(object);
objectStream.flush();
} catch (Exception ex) {
throw new KryoException("Error during Java serialization.", ex);
}
}
代码示例来源:origin: com.esotericsoftware.kryo/kryo
public void write (Kryo kryo, Output output, Object object) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectOutputStream objectStream = (ObjectOutputStream)graphContext.get(this);
if (objectStream == null) {
objectStream = new ObjectOutputStream(output);
graphContext.put(this, objectStream);
}
objectStream.writeObject(object);
objectStream.flush();
} catch (Exception ex) {
throw new KryoException("Error during Java serialization.", ex);
}
}
代码示例来源:origin: com.esotericsoftware.kryo/kryo
public Object read (Kryo kryo, Input input, Class type) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectInputStream objectStream = (ObjectInputStream)graphContext.get(this);
if (objectStream == null) {
objectStream = new ObjectInputStream(input);
graphContext.put(this, objectStream);
}
return objectStream.readObject();
} catch (Exception ex) {
throw new KryoException("Error during Java deserialization.", ex);
}
}
}
代码示例来源:origin: com.alibaba.blink/flink-core
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void write(Kryo kryo, Output output, T o) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectOutputStream objectStream = (ObjectOutputStream)graphContext.get(this);
if (objectStream == null) {
objectStream = new ObjectOutputStream(output);
graphContext.put(this, objectStream);
}
objectStream.writeObject(o);
objectStream.flush();
} catch (Exception ex) {
throw new KryoException("Error during Java serialization.", ex);
}
}
代码示例来源:origin: org.apache.flink/flink-core
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void write(Kryo kryo, Output output, T o) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectOutputStream objectStream = (ObjectOutputStream)graphContext.get(this);
if (objectStream == null) {
objectStream = new ObjectOutputStream(output);
graphContext.put(this, objectStream);
}
objectStream.writeObject(o);
objectStream.flush();
} catch (Exception ex) {
throw new KryoException("Error during Java serialization.", ex);
}
}
代码示例来源:origin: inspectIT/inspectIT
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
public void serialize(Object object, Output output, Map<?, ?> kryoPreferences) throws SerializationException {
if (MapUtils.isNotEmpty(kryoPreferences)) {
ObjectMap<Object, Object> graphContext = kryo.getGraphContext();
for (Entry<?, ?> entry : kryoPreferences.entrySet()) {
graphContext.put(entry.getKey(), entry.getValue());
}
}
try {
kryo.writeClassAndObject(output, object);
output.flush();
} catch (Exception exception) {
throw new SerializationException("Serialization failed.\n" + exception.getMessage(), exception);
}
}
代码示例来源:origin: com.esotericsoftware/kryo-shaded
public Object read (Kryo kryo, Input input, Class type) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectInputStream objectStream = (ObjectInputStream)graphContext.get(this);
if (objectStream == null) {
objectStream = new ObjectInputStreamWithKryoClassLoader(input, kryo);
graphContext.put(this, objectStream);
}
return objectStream.readObject();
} catch (Exception ex) {
throw new KryoException("Error during Java deserialization.", ex);
}
}
代码示例来源:origin: com.esotericsoftware/kryo
public Object read (Kryo kryo, Input input, Class type) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectInputStream objectStream = (ObjectInputStream)graphContext.get(this);
if (objectStream == null) {
objectStream = new ObjectInputStreamWithKryoClassLoader(input, kryo);
graphContext.put(this, objectStream);
}
return objectStream.readObject();
} catch (Exception ex) {
throw new KryoException("Error during Java deserialization.", ex);
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-global
@Override
public Object read(Kryo kryo, Input input, Class type) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectInputStream objectStream = (ObjectInputStream) graphContext.get(this);
if (objectStream == null) {
objectStream = new ObjectInputStream(input) {
@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
return ClassUtils.getClass(KryoSerialization.class.getClassLoader(), desc.getName());
}
};
graphContext.put(this, objectStream);
}
return objectStream.readObject();
} catch (Exception ex) {
throw new KryoException("Error during Java deserialization.", ex);
}
}
}
代码示例来源:origin: org.apache.apex/malhar-library
@Override
public Object read(Kryo kryo, Input input, Class type)
{
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectInputStream objectStream = (ObjectInputStream)graphContext.get(this);
if (objectStream == null) {
objectStream = new ObjectInputStreamWithKryoClassLoader(input, kryo);
graphContext.put(this, objectStream);
}
return objectStream.readObject();
} catch (Exception ex) {
throw new KryoException("Error during Java deserialization.", ex);
}
}
代码示例来源:origin: inspectIT/inspectIT
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public void write(Kryo kryo, Output output, T object) {
ObjectMap<Object, Object> garphContext = kryo.getGraphContext();
if (Boolean.FALSE.equals(garphContext.get(KryoSerializationPreferences.WRITE_INVOCATION_AFFILIATION_DATA))) {
Map<Long, MutableInt> temp = object.getInvocationsParentsIdMap();
object.setInvocationsParentsIdMap(Collections.<Long, MutableInt> emptyMap());
super.write(kryo, output, object);
object.setInvocationsParentsIdMap(temp);
} else {
super.write(kryo, output, object);
}
}
}
代码示例来源:origin: org.apache.flink/flink-core
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public T read(Kryo kryo, Input input, Class aClass) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectInputStream objectStream = (ObjectInputStream)graphContext.get(this);
if (objectStream == null) {
// make sure we use Kryo's classloader
objectStream = new InstantiationUtil.ClassLoaderObjectInputStream(input, kryo.getClassLoader());
graphContext.put(this, objectStream);
}
return (T) objectStream.readObject();
} catch (Exception ex) {
throw new KryoException("Error during Java deserialization.", ex);
}
}
代码示例来源:origin: com.alibaba.blink/flink-core
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public T read(Kryo kryo, Input input, Class aClass) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectInputStream objectStream = (ObjectInputStream)graphContext.get(this);
if (objectStream == null) {
// make sure we use Kryo's classloader
objectStream = new InstantiationUtil.ClassLoaderObjectInputStream(input, kryo.getClassLoader());
graphContext.put(this, objectStream);
}
return (T) objectStream.readObject();
} catch (Exception ex) {
throw new KryoException("Error during Java deserialization.", ex);
}
}
代码示例来源:origin: svn2github/kryo
public void write (Kryo kryo, Output output, T object) {
CachedField[] fields = getFields();
ObjectMap context = kryo.getGraphContext();
if (!context.containsKey(this)) {
context.put(this, null);
if (TRACE) trace("kryo", "Write " + fields.length + " field names.");
output.writeVarInt(fields.length, true);
for (int i = 0, n = fields.length; i < n; i++)
output.writeString(fields[i].field.getName());
}
OutputChunked outputChunked = new OutputChunked(output, 1024);
for (int i = 0, n = fields.length; i < n; i++) {
fields[i].write(outputChunked, object);
outputChunked.endChunks();
}
}
代码示例来源:origin: com.esotericsoftware.kryo/kryo
public void write (Kryo kryo, Output output, T object) {
CachedField[] fields = getFields();
ObjectMap context = kryo.getGraphContext();
if (!context.containsKey(this)) {
context.put(this, null);
if (TRACE) trace("kryo", "Write " + fields.length + " field names.");
output.writeVarInt(fields.length, true);
for (int i = 0, n = fields.length; i < n; i++)
output.writeString(fields[i].field.getName());
}
OutputChunked outputChunked = new OutputChunked(output, 1024);
for (int i = 0, n = fields.length; i < n; i++) {
fields[i].write(outputChunked, object);
outputChunked.endChunks();
}
}
代码示例来源:origin: com.esotericsoftware/kryo
public void write (Kryo kryo, Output output, T object) {
CachedField[] fields = getFields();
ObjectMap context = kryo.getGraphContext();
if (!context.containsKey(this)) {
context.put(this, null);
if (TRACE) trace("kryo", "Write " + fields.length + " field names.");
output.writeVarInt(fields.length, true);
for (int i = 0, n = fields.length; i < n; i++)
output.writeString(getCachedFieldName(fields[i]));
}
OutputChunked outputChunked = new OutputChunked(output, 1024);
for (int i = 0, n = fields.length; i < n; i++) {
fields[i].write(outputChunked, object);
outputChunked.endChunks();
}
}
代码示例来源:origin: com.esotericsoftware/kryo-shaded
public void write (Kryo kryo, Output output, T object) {
CachedField[] fields = getFields();
ObjectMap context = kryo.getGraphContext();
if (!context.containsKey(this)) {
context.put(this, null);
if (TRACE) trace("kryo", "Write " + fields.length + " field names.");
output.writeVarInt(fields.length, true);
for (int i = 0, n = fields.length; i < n; i++)
output.writeString(getCachedFieldName(fields[i]));
}
OutputChunked outputChunked = new OutputChunked(output, 1024);
for (int i = 0, n = fields.length; i < n; i++) {
fields[i].write(outputChunked, object);
outputChunked.endChunks();
}
}
内容来源于网络,如有侵权,请联系作者删除!