本文整理了Java中com.esotericsoftware.kryo.Kryo.<init>()
方法的一些代码示例,展示了Kryo.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Kryo.<init>()
方法的具体详情如下:
包路径:com.esotericsoftware.kryo.Kryo
类名称:Kryo
方法名:<init>
[英]Creates a new Kryo with a DefaultClassResolver and a MapReferenceResolver.
[中]使用DefaultClassResolver和MapReferenceResolver创建新的Kryo。
代码示例来源:origin: redisson/redisson
@Override
public Kryo create() {
return new Kryo();
}
}, true);
代码示例来源:origin: redisson/redisson
public KryoCodec() {
super(new Kryo(), true);
}
代码示例来源:origin: jersey/jersey
public Kryo create() {
final Kryo kryo = new Kryo();
//TODO: configure kryo instance, customize settings
//TODO: e.g. looking for Kryo via ContextResolver (like Jackson)
return kryo;
}
};
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override protected Kryo initialValue() {
return new Kryo();
}
};
代码示例来源:origin: alibaba/jstorm
/**
* Constructs a {@link DefaultStateSerializer} instance with the given list
* of classes registered in kryo.
*
* @param classesToRegister the classes to register.
*/
public DefaultStateSerializer(List<Class<?>> classesToRegister) {
kryo = new Kryo();
output = new Output(2000, 2000000000);
for (Class<?> klazz : classesToRegister) {
kryo.register(klazz);
}
}
代码示例来源:origin: apache/storm
private Object getKryoDeserializedObject (final byte[] ser) {
final Kryo kryo = new Kryo();
final Input input = new Input(new ByteArrayInputStream(ser));
kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
return kryo.readClassAndObject(input);
}
代码示例来源:origin: apache/storm
private byte[] getKryoSerializedBytes (final Object obj) {
final Kryo kryo = new Kryo();
final ByteArrayOutputStream os = new ByteArrayOutputStream();
final Output output = new Output(os);
kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
kryo.writeClassAndObject(output, obj);
output.flush();
return os.toByteArray();
}
代码示例来源:origin: alibaba/jstorm
public KryoSerializer() {
kryo = new Kryo();
kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
output = new Output(200, 2000000000);
input = new Input(1);
}
代码示例来源:origin: redisson/redisson
/**
* Sub classes can customize the Kryo instance by overriding this method
*
* @return create Kryo instance
*/
protected Kryo createInstance() {
Kryo kryo = new Kryo();
if (classLoader != null) {
kryo.setClassLoader(classLoader);
}
kryo.setReferences(false);
for (Class<?> clazz : classes) {
kryo.register(clazz);
}
return kryo;
}
代码示例来源:origin: redisson/redisson
/**
* Sub classes can customize the Kryo instance by overriding this method
*
* @return create Kryo instance
*/
protected Kryo createInstance() {
Kryo kryo = new Kryo();
if (classLoader != null) {
kryo.setClassLoader(classLoader);
}
kryo.setReferences(false);
for (Class<?> clazz : classes) {
kryo.register(clazz);
}
return kryo;
}
代码示例来源:origin: apache/flink
private void checkKryoInitialized() {
if (this.kryo == null) {
this.kryo = new Kryo();
Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
kryo.setInstantiatorStrategy(instantiatorStrategy);
this.kryo.setAsmEnabled(true);
KryoUtils.applyRegistrations(this.kryo, kryoRegistrations.values());
}
}
代码示例来源:origin: changmingxie/tcc-transaction
@Override
protected Kryo initialValue() {
Kryo kryo = new Kryo();
kryo.setReferences(true);
kryo.setRegistrationRequired(false);
//Fix the NPE bug when deserializing Collections.
((Kryo.DefaultInstantiatorStrategy) kryo.getInstantiatorStrategy())
.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
return kryo;
}
};
代码示例来源:origin: apache/flink
private void checkKryoInitialized() {
if (this.kryo == null) {
this.kryo = new Kryo();
Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
kryo.setInstantiatorStrategy(instantiatorStrategy);
this.kryo.setAsmEnabled(true);
this.kryo.register(typeClass);
}
}
// --------------------------------------------------------------------------------------------
代码示例来源:origin: changmingxie/tcc-transaction
@Override
protected Kryo initialValue() {
Kryo kryo = new Kryo();
kryo.setReferences(true);
kryo.setRegistrationRequired(false);
//Fix the NPE bug when deserializing Collections.
((Kryo.DefaultInstantiatorStrategy) kryo.getInstantiatorStrategy())
.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
return kryo;
}
};
代码示例来源:origin: apache/flink
private void checkKryoInitialized() {
if (this.kryo == null) {
this.kryo = new Kryo();
Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
kryo.setInstantiatorStrategy(instantiatorStrategy);
this.kryo.setAsmEnabled(true);
this.kryo.register(type);
}
}
代码示例来源:origin: changmingxie/tcc-transaction
public Kryo create() {
Kryo kryo = new Kryo();
kryo.setReferences(true);
kryo.setRegistrationRequired(false);
//Fix the NPE bug when deserializing Collections.
((Kryo.DefaultInstantiatorStrategy) kryo.getInstantiatorStrategy())
.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
return kryo;
}
};
代码示例来源:origin: apache/flink
private void checkKryoInitialized() {
if (this.kryo == null) {
this.kryo = new Kryo();
Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
kryo.setInstantiatorStrategy(instantiatorStrategy);
this.kryo.setAsmEnabled(true);
this.kryo.register(type);
}
}
代码示例来源: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: apache/storm
@Override
protected Kryo initialValue() {
Kryo obj = new Kryo();
if (context != null && topoConf != null) {
KryoTupleSerializer ser = new KryoTupleSerializer(topoConf, context);
KryoTupleDeserializer deser = new KryoTupleDeserializer(topoConf, context);
obj.register(TupleImpl.class, new TupleSerializer(ser, deser));
}
if (!registrations.isEmpty()) {
SerializationFactory.register(obj, registrations);
}
obj.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
return obj;
}
};
代码示例来源:origin: apache/hive
@Override
protected Kryo initialValue() {
Kryo kryo = new Kryo();
int count = 0;
for (Class<?> klass : messages) {
kryo.register(klass, REG_ID_BASE + count);
count++;
}
kryo.register(BaseProtocol.JobResult.class, new JobResultSerializer(), count);
kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
return kryo;
}
};
内容来源于网络,如有侵权,请联系作者删除!