@Override public void writeObject(Object v) throws IOException { // TODO carries class info every time. kryo.writeClassAndObject(output, v); }
@Override public Kryo create() { return new Kryo(); } }, true);
@Override protected Collection createCopy(Kryo kryo, Collection original) { return kryo.newInstance(this.type); } }
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); } } // --------------------------------------------------------------------------------------------
/** * 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; }
@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; } };
@Override public Object readObject() throws IOException, ClassNotFoundException { // TODO optimization try { return kryo.readClassAndObject(input); } catch (KryoException e) { throw new IOException(e); } }
public void decorate(Kryo k) { k.register(TestSerObject.class); } }
@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(); } };
@Override public ListDelegate read(Kryo kryo, Input input, Class<ListDelegate> type) { return kryo.readObject(input, ListDelegate.class, serializer); } }
@Override public void write(Kryo kryo, Output output, ListDelegate object) { kryo.writeObject(output, object, serializer); }
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); } }
/** * 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; }
@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; } };
public KryoCodec() { super(new Kryo(), true); }
@Override public void writeObject(Object v) throws IOException { // TODO carries class info every time. kryo.writeClassAndObject(output, v); }
@Override public Object readObject() throws IOException, ClassNotFoundException { // TODO optimization try { return kryo.readClassAndObject(input); } catch (KryoException e) { throw new IOException(e); } }
public void decorate(Kryo k) { k.register(TestSerObject.class); } }
@Override protected Collection create(Kryo kryo, Input input, Class<Collection> type) { return kryo.newInstance(this.type); }
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); } }