Java Code Examples for com.esotericsoftware.kryo.Kryo#newInstance()
The following examples show how to use
com.esotericsoftware.kryo.Kryo#newInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelTraitSerializers.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public RelTraitSet read(final Kryo kryo, final Input input, final Class<RelTraitSet> type) { final int size = kryo.readObject(input, Integer.class); final RelTrait[] traits = new RelTrait[size]; for (int i = 0; i < size; i++) { final RelTrait trait = (RelTrait) kryo.readClassAndObject(input); // normalize trait so that stupid calcite won't complain about == checks. traits[i] = trait.getTraitDef().canonize(trait); } final String digest = kryo.readObject(input, String.class); final Object cache = kryo.readClassAndObject(input); final RelTraitSet traitSet = kryo.newInstance(type); try { getField(NAME_CACHE).set(traitSet, cache); getField(NAME_TRAITS).set(traitSet, traits); getField(NAME_STRING).set(traitSet, digest); } catch (final NoSuchFieldException|IllegalAccessException e) { throw new RuntimeException("unable to deserialize TraitSet", e); } kryo.reference(traitSet); return traitSet; }
Example 2
Source File: RelDataTypeSerializer.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public T read(final Kryo kryo, final Input input, final Class<T> type) { // do not use delegate.read because we do not want it to cache the object. Rather, we will cache the normalized type. final T dataType = kryo.newInstance(type); final FieldSerializer.CachedField[] fields = delegate.getFields(); for (int i = 0, n = fields.length; i < n; i++) { fields[i].read(input, dataType); } // be gentle to calcite and normalize the returned data type. normalization here means to use same type instances. final T result = (T) typeFactory.copyType(dataType); kryo.reference(result); return result; }
Example 3
Source File: WritableSerializer.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public T read(final Kryo kryo, final Input input, final Class<T> type) { try { final T object = kryo.newInstance(type); kryo.reference(object); object.readFields(new DataInputStream(input)); return object; } catch (final IOException e) { throw new RuntimeException("unable to deserialize Writable object", e); } }
Example 4
Source File: KryoSerialization.java From cuba with Apache License 2.0 | 5 votes |
@Override public Collection read(Kryo kryo, Input input, Class<Collection> type) { boolean isNotInstantiated = input.readBoolean(); if (!isNotInstantiated) { return super.read(kryo, input, type); } else { IndirectCollection indirectCollection = (IndirectCollection) kryo.newInstance((Class) type); indirectCollection.setValueHolder(new UnfetchedValueHolder()); return (Collection) indirectCollection; } }
Example 5
Source File: ListDataTypeSerializer.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public T read(Kryo kryo, Input input, Class<T> type) { try { T dvd = kryo.newInstance(type); readValue(kryo, input, dvd); return dvd; } catch (StandardException e) { throw new RuntimeException(e); } }
Example 6
Source File: DataValueDescriptorSerializer.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public T read(Kryo kryo, Input input, Class<T> type) { try { T dvd = kryo.newInstance(type); if(!input.readBoolean()) readValue(kryo,input,dvd); return dvd; } catch (StandardException e) { throw new RuntimeException(e); } }
Example 7
Source File: ExternalizableSerializer.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public Externalizable read(Kryo kryo, Input input, Class<Externalizable> type) { try { Externalizable e = kryo.newInstance(type); KryoObjectInput koi = new KryoObjectInput(input,kryo); e.readExternal(koi); return e; } catch (IOException | ClassNotFoundException e1) { throw new RuntimeException(e1); } }
Example 8
Source File: Serializers.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override protected Collection create(Kryo kryo, Input input, Class<Collection> type) { return kryo.newInstance(this.type); }
Example 9
Source File: Serializers.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override protected Collection createCopy(Kryo kryo, Collection original) { return kryo.newInstance(this.type); }
Example 10
Source File: Serializers.java From flink with Apache License 2.0 | 4 votes |
@Override protected Collection create(Kryo kryo, Input input, Class<Collection> type) { return kryo.newInstance(this.type); }
Example 11
Source File: Serializers.java From flink with Apache License 2.0 | 4 votes |
@Override protected Collection createCopy(Kryo kryo, Collection original) { return kryo.newInstance(this.type); }
Example 12
Source File: Serializers.java From flink with Apache License 2.0 | 4 votes |
@Override protected Collection create(Kryo kryo, Input input, Class<Collection> type) { return kryo.newInstance(this.type); }
Example 13
Source File: Serializers.java From flink with Apache License 2.0 | 4 votes |
@Override protected Collection createCopy(Kryo kryo, Collection original) { return kryo.newInstance(this.type); }
Example 14
Source File: SimpleObjectSerializer.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
@Override public T read(Kryo kryo, Input input, Class<T> type) { T dvd = kryo.newInstance(type); readValue(kryo, input, dvd); return dvd; }