Refine search
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); } } // --------------------------------------------------------------------------------------------
public KryoSerializer() { kryo = new Kryo(); kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); output = new Output(200, 2000000000); input = new Input(1); }
Kryo kryo = new Kryo(); kryo.setRegistrationRequired(false); kryo.setReferences(true); kryo.addDefaultSerializer(TPrimitiveHash.class, ExternalizableSerializer.class); kryo.register(TIntArrayList.class, new TIntArrayListSerializer()); kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new SerializingInstantiatorStrategy())); return kryo;
/** * Creates a Kryo instance. * * @return Kryo instance */ @Override public Kryo create() { LOGGER.trace("Creating Kryo instance for {}", this); Kryo kryo = new Kryo(); kryo.setClassLoader(classLoader); kryo.setRegistrationRequired(registrationRequired); // If compatible serialization is enabled, override the default serializer. if (compatible) { kryo.setDefaultSerializer(CompatibleFieldSerializer::new); } // TODO rethink whether we want to use StdInstantiatorStrategy kryo.setInstantiatorStrategy( new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); for (RegistrationBlock block : registeredBlocks) { int id = block.begin(); if (id == FLOATING_ID) { id = kryo.getNextRegistrationId(); } for (Pair<Class<?>[], Serializer<?>> entry : block.types()) { register(kryo, entry.getLeft(), entry.getRight(), id++); } } return kryo; }
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; }
@Override public Kryo create() Kryo kryo = new Kryo(new DefaultClassResolver() kryo.setAutoReset(true); kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); kryo.register(Object[].class);
@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 Kryo create() { Kryo kryo = new Kryo(); try { kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer()); kryo.register(Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer()); kryo.register(Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer()); kryo.register(Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer()); kryo.register(SINGLETON_LIST.getClass(), new CollectionsSingletonListSerializer()); kryo.register(SINGLETON_SET.getClass(), new CollectionsSingletonSetSerializer()); kryo.register(SINGLETON_MAP.getClass(), new CollectionsSingletonMapSerializer()); kryo.setRegistrationRequired(false); UnmodifiableCollectionsSerializer.registerSerializers(kryo); SynchronizedCollectionsSerializer.registerSerializers(kryo); ((Kryo.DefaultInstantiatorStrategy) kryo.getInstantiatorStrategy()).setFallbackInstantiatorStrategy(new StdInstantiatorStrategy()); } catch (Exception e) { logger.error("Exception occurred", e); } return kryo; } };
public static Kryo create(boolean isObjectSerializer) { Kryo k = new Kryo(); k.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); k.setDefaultSerializer(VersionFieldSerializer.class); k.addDefaultSerializer(ZonedDateTime.class, ZonedDateTimeSerializer.INSTANCE);
classLoader, customConverterClassNames, copyCollectionsForSerialization); }.withInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); kryo.setDefaultSerializer(new KryoDefaultSerializerFactory.SerializerFactoryAdapter(_defaultSerializerFactory)); kryo.setClassLoader( classLoader ); kryo.setRegistrationRequired(false); kryo.register( Arrays.asList( "" ).getClass(), new ArraysAsListSerializer() ); kryo.register(InvocationHandler.class, new JdkProxySerializer());
/** * Returns a new {@link LogicalPlanSerializer} * @param cluster cluster to used during serialization */ public static LogicalPlanSerializer forSerialization(final RelOptCluster cluster) { final Kryo kryo = new Kryo(); // use objenesis for creating mock objects kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); final DremioCatalogReader catalog = kryo.newInstance(DremioCatalogReader.class); final KryoRelSerializer serializer = KryoRelSerializer.newBuilder(kryo, cluster, catalog).build(); return new LogicalPlanSerializer() { @Override public byte[] serializeToBytes(final RelNode plan) { return serializer.serialize(plan); } @Override public String serializeToJson(RelNode plan) { ExplainJson jsonObj = new ExplainJson(RelOptUtil.toString(plan, SqlExplainLevel.ALL_ATTRIBUTES)); try { return MAPPER.writeValueAsString(jsonObj); } catch (JsonProcessingException e) { throw new RuntimeException(e); } } }; }
@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); }
private Kryo initKryo() { if (this.kryo == null) { this.kryo = new Kryo(); ((Kryo.DefaultInstantiatorStrategy) kryo.getInstantiatorStrategy()) .setFallbackInstantiatorStrategy(new StdInstantiatorStrategy()); serializers.forEach((k, v) -> kryo.addDefaultSerializer(k, v.getSerializer())); registeredClasses.forEach(kryo::register); } return this.kryo; }
@Override public void init(Kryo kryo) { kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); kryo.register(BitSet.class, new BitSetSerializer()); }
public Kryo create() { Kryo kryo = new Kryo(); kryo.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new SerializingInstantiatorStrategy())); return kryo; } }).softReferences().build();
protected void setup(final Kryo kryo) { kryo.setWarnUnregisteredClasses(false); kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); kryo.setDefaultSerializer(new SerializerFactory() { @Override public Serializer makeSerializer(final Kryo kryo, final Class<?> type) {
@Override public Kryo getKryo(Map conf) { KryoSerializableDefault k = new KryoSerializableDefault(); k.setRegistrationRequired(Boolean.valueOf(conf.get(Config.TOPOLOGY_KRYO_REGISTER_REQUIRED).toString())); k.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); k.setReferences(false); return k; }
/** * {@inheritDoc} * * @see marshalsec.Kryo#makeKryo() */ @Override protected com.esotericsoftware.kryo.Kryo makeKryo () { com.esotericsoftware.kryo.Kryo k = super.makeKryo(); k.setInstantiatorStrategy(new com.esotericsoftware.kryo.Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); return k; }
/** * Returns the Chill Kryo Serializer which is implicitly added to the classpath via flink-runtime. * Falls back to the default Kryo serializer if it can't be found. * @return The Kryo serializer instance. */ private Kryo getKryoInstance() { try { // check if ScalaKryoInstantiator is in class path (coming from Twitter's Chill library). // This will be true if Flink's Scala API is used. Class<?> chillInstantiatorClazz = Class.forName("org.apache.flink.runtime.types.FlinkScalaKryoInstantiator"); Object chillInstantiator = chillInstantiatorClazz.newInstance(); // obtain a Kryo instance through Twitter Chill Method m = chillInstantiatorClazz.getMethod("newKryo"); return (Kryo) m.invoke(chillInstantiator); } catch (ClassNotFoundException | InstantiationException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { LOG.warn("Falling back to default Kryo serializer because Chill serializer couldn't be found.", e); Kryo.DefaultInstantiatorStrategy initStrategy = new Kryo.DefaultInstantiatorStrategy(); initStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy()); Kryo kryo = new Kryo(); kryo.setInstantiatorStrategy(initStrategy); return kryo; } }
Kryo kryo; if (COUNT_CLASS_INSTANCES) { kryo = new Kryo(new InstanceCountingClassResolver(), new MapReferenceResolver(), new DefaultStreamFactory()); } else { kryo = new Kryo(); kryo.setRegistrationRequired(false); kryo.setReferences(true); kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new SerializingInstantiatorStrategy())); return kryo;