public KryoSerialization () { this(new Kryo()); kryo.setReferences(false); kryo.setRegistrationRequired(true); }
/** * 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; }
/** * 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; }
private void checkKryoInitialized() { if (this.kryo == null) { this.kryo = getKryoInstance(); // Enable reference tracking. kryo.setReferences(true); // Throwable and all subclasses should be serialized via java serialization // Note: the registered JavaSerializer is Flink's own implementation, and not Kryo's. // This is due to a know issue with Kryo's JavaSerializer. See FLINK-6025 for details. kryo.addDefaultSerializer(Throwable.class, new JavaSerializer()); // Add default serializers first, so that the type registrations without a serializer // are registered with a default serializer for (Map.Entry<Class<?>, ExecutionConfig.SerializableSerializer<?>> entry: defaultSerializers.entrySet()) { kryo.addDefaultSerializer(entry.getKey(), entry.getValue().getSerializer()); } for (Map.Entry<Class<?>, Class<? extends Serializer<?>>> entry: defaultSerializerClasses.entrySet()) { kryo.addDefaultSerializer(entry.getKey(), entry.getValue()); } KryoUtils.applyRegistrations(this.kryo, kryoRegistrations.values()); kryo.setRegistrationRequired(false); kryo.setClassLoader(Thread.currentThread().getContextClassLoader()); } }
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; } };
@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 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 protected Kryo initialValue() throws Exception { Kryo kryo = new Kryo(); for (Class<?> type : useJavaSerializerTypes) { kryo.addDefaultSerializer(type, JavaSerializer.class); } kryo.setInstantiatorStrategy(new StdInstantiatorStrategy()); kryo.setRegistrationRequired(false); kryo.setReferences(false); return kryo; } };
@Override protected Kryo initialValue() throws Exception { Kryo kryo = new Kryo(); for (Class<?> type : useJavaSerializerTypes) { kryo.addDefaultSerializer(type, JavaSerializer.class); } kryo.setInstantiatorStrategy(new StdInstantiatorStrategy()); kryo.setRegistrationRequired(false); kryo.setReferences(false); return kryo; } };
kryo.setReferences(true); kryo.addDefaultSerializer(TPrimitiveHash.class, ExternalizableSerializer.class); kryo.register(TIntArrayList.class, new TIntArrayListSerializer());
@Override public Kryo build() { Kryo k = this.buildFrom(KryoBuilder.this); k.setReferences(references); return k; } };
@Override public void customize(Kryo kryo) { kryo.setReferences(true); kryo.register( GrailsFlashScope.class, new FieldSerializer( kryo, GrailsFlashScope.class ) ); }
@Override protected void configureKryoInstance(Kryo kryo) { kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); if (this.kryoRegistrar != null) { this.kryoRegistrar.registerTypes(kryo); } kryo.setReferences(this.useReferences); }
@Override protected Kryo initialValue() { Kryo ret = new Kryo(); ret.setReferences(true); ret.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); ret.register(Arrays.asList("").getClass(), new ArraysAsListSerializer()); ret.register(Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer()); ret.register(Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer()); ret.register(Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer()); ret.register(Collections.singletonList("").getClass(), new CollectionsSingletonListSerializer()); ret.register(Collections.singleton("").getClass(), new CollectionsSingletonSetSerializer()); ret.register(Collections.singletonMap("", "").getClass(), new CollectionsSingletonMapSerializer()); ret.register(GregorianCalendar.class, new GregorianCalendarSerializer()); ret.register(InvocationHandler.class, new JdkProxySerializer()); UnmodifiableCollectionsSerializer.registerSerializers(ret); SynchronizedCollectionsSerializer.registerSerializers(ret); // custom serializers for non-jdk libs // register CGLibProxySerializer, works in combination with the appropriate action in handleUnregisteredClass (see below) ret.register(CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer()); // joda DateTime, LocalDate and LocalDateTime ret.register(LocalDate.class, new JodaLocalDateSerializer()); ret.register(LocalDateTime.class, new JodaLocalDateTimeSerializer()); // guava ImmutableList, ImmutableSet, ImmutableMap, ImmutableMultimap, UnmodifiableNavigableSet ImmutableListSerializer.registerSerializers(ret); ImmutableSetSerializer.registerSerializers(ret); ImmutableMapSerializer.registerSerializers(ret); ImmutableMultimapSerializer.registerSerializers(ret); return ret; } };
@Override protected Kryo initialValue() { Kryo ret = new Kryo(); ret.setReferences(true); ret.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
/** * 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); }
/** * create a new kryo object to application use * * @return */ public KryoHolder creatInstnce() { Kryo kryo = new Kryo(); kryo.setReferences(false);// return new KryoHolder(kryo); }
@Override protected Kryo initialValue() throws Exception { Kryo kryo = new Kryo(); for (Class<?> type : useJavaSerializerTypes) { kryo.addDefaultSerializer(type, JavaSerializer.class); } kryo.setInstantiatorStrategy(new StdInstantiatorStrategy()); kryo.setRegistrationRequired(false); kryo.setReferences(false); return kryo; } };
protected void configureKryoInstance(Kryo kryo) { kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); if (this.kryoRegistrar != null) { this.kryoRegistrar.registerTypes(kryo); } kryo.setReferences(this.useReferences); }
@Override protected void configureKryoInstance(Kryo kryo) { kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); if (this.kryoRegistrar != null) { this.kryoRegistrar.registerTypes(kryo); } kryo.setReferences(this.useReferences); }