Class MapSerializer<T extends Map>

    • Constructor Detail

      • MapSerializer

        public MapSerializer()
    • Method Detail

      • setKeysCanBeNull

        public void setKeysCanBeNull​(boolean keysCanBeNull)
        Parameters:
        keysCanBeNull - False if all keys are not null. This saves 1 byte per key if keyClass is set. True if it is not known (default).
      • setKeyClass

        public void setKeyClass​(Class keyClass)
        The concrete class of the keys for this map, or null if it is not known. This saves 1-2 bytes. Only set to a non-null value if the keys for this map are known to be of the specified type (or null).
      • getKeyClass

        public Class getKeyClass()
      • setKeySerializer

        public void setKeySerializer​(Serializer keySerializer)
        The serializer to be used for the keys in this map, or null to use the serializer registered with Kryo for the type. Default is null.
      • getKeySerializer

        public Serializer getKeySerializer()
      • setValueClass

        public void setValueClass​(Class valueClass)
        The concrete class of the values for this map, or null if it is not known. This saves 1-2 bytes. Only set to a non-null value if the values for this map are known to be of the specified type (or null).
      • getValueClass

        public Class getValueClass()
      • setValueSerializer

        public void setValueSerializer​(Serializer valueSerializer)
        The serializer to be used for this field, or null to use the serializer registered with Kryo for the type. Default is null.
      • getValueSerializer

        public Serializer getValueSerializer()
      • setValuesCanBeNull

        public void setValuesCanBeNull​(boolean valuesCanBeNull)
        Parameters:
        valuesCanBeNull - True if values are not null. This saves 1 byte per value if keyClass is set. False if it is not known (default).
      • write

        public void write​(Kryo kryo,
                          Output output,
                          T map)
        Description copied from class: Serializer
        Writes the bytes for the object to the output.

        This method should not be called directly, instead this serializer can be passed to Kryo write methods that accept a serialier.

        Specified by:
        write in class Serializer<T extends Map>
        map - May be null if Serializer.getAcceptsNull() is true.
      • create

        protected T create​(Kryo kryo,
                           Input input,
                           Class<? extends T> type,
                           int size)
        Used by read(Kryo, Input, Class) to create the new object. This can be overridden to customize object creation, eg to call a constructor with arguments. The default implementation uses Kryo.newInstance(Class) with a special case for HashMap.
      • read

        public T read​(Kryo kryo,
                      Input input,
                      Class<? extends T> type)
        Description copied from class: Serializer
        Reads bytes and returns a new object of the specified concrete type.

        Before Kryo can be used to read child objects, Kryo.reference(Object) must be called with the parent object to ensure it can be referenced by the child objects. Any serializer that uses Kryo to read a child object may need to be reentrant.

        This method should not be called directly, instead this serializer can be passed to Kryo read methods that accept a serialier.

        Specified by:
        read in class Serializer<T extends Map>
        Returns:
        May be null if Serializer.getAcceptsNull() is true.
      • createCopy

        protected T createCopy​(Kryo kryo,
                               T original)
      • copy

        public T copy​(Kryo kryo,
                      T original)
        Description copied from class: Serializer
        Returns a copy of the specified object. The default implementation returns the original if Serializer.isImmutable() is true, else throws KryoException. Subclasses can optionall override this method to support Kryo.copy(Object).

        Before Kryo can be used to copy child objects, Kryo.reference(Object) must be called with the copy to ensure it can be referenced by the child objects. A serializer that uses Kryo to copy a child object may need to be reentrant.

        This method should not be called directly, instead this serializer can be passed to Kryo copy methods that accept a serialier.

        Overrides:
        copy in class Serializer<T extends Map>