本文整理了Java中com.esotericsoftware.kryo.Kryo.setAutoReset()
方法的一些代码示例,展示了Kryo.setAutoReset()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Kryo.setAutoReset()
方法的具体详情如下:
包路径:com.esotericsoftware.kryo.Kryo
类名称:Kryo
方法名:setAutoReset
[英]If true (the default), #reset() is called automatically after an entire object graph has been read or written. If false, #reset() must be called manually, which allows unregistered class names, references, and other information to span multiple object graphs.
[中]如果为true(默认值),则在读取或写入整个对象图形后自动调用#reset()。如果为false,则必须手动调用#reset(),这允许未注册的类名、引用和其他信息跨多个对象图。
代码示例来源:origin: orbit/orbit
kryo.setAutoReset(true);
代码示例来源:origin: Nepxion/Thunder
public static Kryo createKryo(int maxDepth) {
Kryo kryo = new Kryo();
kryo.setRegistrationRequired(false);
kryo.setAsmEnabled(true);
kryo.setMaxDepth(maxDepth);
kryo.setAutoReset(true);
return kryo;
}
代码示例来源:origin: com.vmware.dcp/dcp-common
public static Kryo create(boolean isObjectSerializer) {
Kryo k = new Kryo();
k.setDefaultSerializer(VersionFieldSerializer.class);
// Custom serializers for Java 8 date/time
k.addDefaultSerializer(ZonedDateTime.class, ZonedDateTimeSerializer.INSTANCE);
k.addDefaultSerializer(Instant.class, InstantSerializer.INSTANCE);
k.addDefaultSerializer(ZoneId.class, ZoneIdSerializer.INSTANCE);
// Add non-cloning serializers for all immutable types bellow
k.addDefaultSerializer(UUID.class, UUIDSerializer.INSTANCE);
k.addDefaultSerializer(URI.class, URISerializer.INSTANCE);
if (isObjectSerializer) {
// To avoid monotonic increase of memory use, due to reference tracking, we must
// reset kryo after each use.
k.setAutoReset(true);
} else {
// For performance reasons, and to avoid memory use, assume documents do not
// require object graph serialization with duplicate or recursive references
k.setReferences(false);
}
return k;
}
}
代码示例来源:origin: com.vmware.xenon/xenon-common
private static Kryo createKryo(boolean isObjectSerializer) {
Kryo k = new Kryo();
// handle classes with missing default constructors
k.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
// supports addition of fields if the @since annotation is used
k.setDefaultSerializer(VersionFieldSerializer.class);
if (!isObjectSerializer) {
// For performance reasons, and to avoid memory use, assume documents do not
// require object graph serialization with duplicate or recursive references
k.setReferences(false);
} else {
// To avoid monotonic increase of memory use, due to reference tracking, we must
// reset after each use.
k.setAutoReset(true);
}
k.register(ExampleServiceState.class, EXAMPLE_SERVICE_CLASS_ID);
HashMap<String, String> map = new HashMap<>();
k.register(map.getClass());
return k;
}
代码示例来源:origin: vmware/xenon
private static Kryo createKryo(boolean isObjectSerializer) {
Kryo k = new Kryo();
// handle classes with missing default constructors
k.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
// supports addition of fields if the @since annotation is used
k.setDefaultSerializer(VersionFieldSerializer.class);
if (!isObjectSerializer) {
// For performance reasons, and to avoid memory use, assume documents do not
// require object graph serialization with duplicate or recursive references
k.setReferences(false);
} else {
// To avoid monotonic increase of memory use, due to reference tracking, we must
// reset after each use.
k.setAutoReset(true);
}
k.register(ExampleServiceState.class, EXAMPLE_SERVICE_CLASS_ID);
HashMap<String, String> map = new HashMap<>();
k.register(map.getClass());
return k;
}
代码示例来源:origin: vmware/xenon
k.setAutoReset(true);
内容来源于网络,如有侵权,请联系作者删除!