本文整理汇总了Java中com.esotericsoftware.kryo.Kryo.setReferences方法的典型用法代码示例。如果您正苦于以下问题:Java Kryo.setReferences方法的具体用法?Java Kryo.setReferences怎么用?Java Kryo.setReferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.esotericsoftware.kryo.Kryo
的用法示例。
在下文中一共展示了Kryo.setReferences方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createKryoInstance
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
private Kryo createKryoInstance() {
Kryo kryo = new Kryo();
kryo.register(RakTable.class);
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
kryo.setReferences(false);
kryo.register(Collections.singletonList("").getClass(), new ArraysAsListSerializer());
UnmodifiableCollectionsSerializer.registerSerializers(kryo);
SynchronizedCollectionsSerializer.registerSerializers(kryo);
kryo.addDefaultSerializer(new ArrayList<>().subList(0, 0).getClass(), new CollectionSerializer());
kryo.addDefaultSerializer(new LinkedList<>().subList(0, 0).getClass(), new CollectionSerializer());
kryo.register(UUID.class, new UUIDSerializer());
for (Class<?> clazz : mCustomSerializers.keySet()) {
kryo.register(clazz, mCustomSerializers.get(clazz));
}
kryo.setInstantiatorStrategy(
new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
return kryo;
}
示例2: serializationObject
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
private <T extends Serializable> byte[] serializationObject(T obj) {
Kryo kryo = new Kryo();
kryo.setReferences(false);
kryo.register(obj.getClass(), new JavaSerializer());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Output output = new Output(baos);
kryo.writeClassAndObject(output, obj);
output.flush();
output.close();
byte[] b = baos.toByteArray();
try {
baos.flush();
baos.close();
} catch (IOException e) {
e.printStackTrace();
}
return b;
}
示例3: createInstance
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
/**
* 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;
}
示例4: testKyro
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public void testKyro() {
Kryo kryo = new Kryo();
kryo.setReferences(false);
//byte[] test = new byte[10];
//kryo.register(test.getClass(), new JavaSerializer());
byte[] sequence = "TGGGATGAGAGCATGAGAAGGTGGAGCTAAGGTGGGAGACCGTCTACCCCCGACCCTGTGTGGTGCACTGACCGTGACTCTCTGCACCTTCTCGTGGGGGA".getBytes();
byte[] quality = "DCDE8EFFFFBEEEEFGGGGEFEGGGFGGGFF6FF/>@[email protected]@@B=8B64A########################################".getBytes();
byte[] serialSequence = serializationObject(kryo, sequence);
byte[] serialQual = serializationObject(kryo, quality);
System.out.println(sequence.length + " " + serialSequence.length);
System.out.println(quality.length + " " + serialQual.length);
}
示例5: deserializationObject
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <T extends Serializable> T deserializationObject(byte[] obj,
Class<T> clazz) {
Kryo kryo = new Kryo();
kryo.setReferences(false);
kryo.register(clazz, new JavaSerializer());
ByteArrayInputStream bais = new ByteArrayInputStream(
obj);
Input input = new Input(bais);
return (T) kryo.readClassAndObject(input);
}
示例6: create
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public Kryo create () {
Kryo kryo = new Kryo();
kryo.setReferences(false);
kryo.setRegistrationRequired(false);
return kryo;
}
示例7: init
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public void init(Map<String, Object> config) {
kryo = new Kryo();
kryo.setReferences(false);
kryoOut = new Output(2000, 2000000000);
kryoIn = new Input(1);
}
示例8: creatInstnce
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
/**
* create a new kryo object to application use
* @return KryoHolder instance
*/
public KryoHolder creatInstnce() {
Kryo kryo = new Kryo();
kryo.setReferences(false);//
return new KryoHolder(kryo);
}