Documentation of 'org.mapdb.Serializer' Java class
Serializer
org.mapdb

Class Serializer<A>

    • Field Detail

      • CHAR

        public static final Serializer<java.lang.Character> CHAR
      • STRING_XXHASH

        public static final Serializer<java.lang.String> STRING_XXHASH

        Serializes strings using UTF8 encoding. Stores string size so can be used as collection serializer. Does not handle null values

        Unlike STRING this method hashes String with more reliable XXHash.

      • STRING

        public static final Serializer<java.lang.String> STRING
        Serializes strings using UTF8 encoding. Stores string size so can be used as collection serializer. Does not handle null values
      • STRING_INTERN

        public static final Serializer<java.lang.String> STRING_INTERN
        Serializes strings using UTF8 encoding. Deserialized String is interned String.intern(), so it could save some memory. Stores string size so can be used as collection serializer. Does not handle null values
      • STRING_ASCII

        public static final Serializer<java.lang.String> STRING_ASCII
        Serializes strings using ASCII encoding (8 bit character). Is faster compared to UTF8 encoding. Stores string size so can be used as collection serializer. Does not handle null values
      • STRING_NOSIZE

        public static final Serializer<java.lang.String> STRING_NOSIZE
        Serializes strings using UTF8 encoding. Used mainly for testing. Does not handle null values.
      • LONG

        public static final Serializer<java.lang.Long> LONG
        Serializes Long into 8 bytes, used mainly for testing. Does not handle null values.
      • LONG_PACKED

        public static final Serializer<java.lang.Long> LONG_PACKED
        Packs positive LONG, so smaller positive values occupy less than 8 bytes. Large and negative values could occupy 8 or 9 bytes.
      • LONG_PACKED_ZIGZAG

        public static final Serializer<java.lang.Long> LONG_PACKED_ZIGZAG
        packs Long so small values occupy less than 8 bytes. Large (positive and negative) values could occupy more 8 to 9 bytes. It uses zigzag conversion before packing, number is multiplied by two, with last bite indicating negativity.
      • INTEGER

        public static final Serializer<java.lang.Integer> INTEGER
        Serializes Integer into 4 bytes, used mainly for testing. Does not handle null values.
      • INTEGER_PACKED

        public static final Serializer<java.lang.Integer> INTEGER_PACKED
        Packs positive Integer, so smaller positive values occupy less than 4 bytes. Large and negative values could occupy 4 or 5 bytes.
      • INTEGER_PACKED_ZIGZAG

        public static final Serializer<java.lang.Integer> INTEGER_PACKED_ZIGZAG
        packs Integer so small values occupy less than 4 bytes. Large (positive and negative) values could occupy more 4 to 5 bytes. It uses zigzag conversion before packing, number is multiplied by two, with last bite indicating negativity.
      • BOOLEAN

        public static final Serializer<java.lang.Boolean> BOOLEAN
      • RECID

        public static final Serializer<java.lang.Long> RECID
        Packs recid + it adds 3bits checksum.
      • RECID_ARRAY

        public static final Serializer<long[]> RECID_ARRAY
      • ILLEGAL_ACCESS

        public static final Serializer<java.lang.Object> ILLEGAL_ACCESS
        Always throws IllegalAccessError when invoked. Useful for testing and assertions.
      • BYTE_ARRAY

        public static final Serializer<byte[]> BYTE_ARRAY
        Serializes byte[] it adds header which contains size information
      • BYTE_ARRAY_NOSIZE

        public static final Serializer<byte[]> BYTE_ARRAY_NOSIZE
        Serializes byte[] directly into underlying store It does not store size, so it can not be used in Maps and other collections.
      • CHAR_ARRAY

        public static final Serializer<char[]> CHAR_ARRAY
        Serializes char[] it adds header which contains size information
      • INT_ARRAY

        public static final Serializer<int[]> INT_ARRAY
        Serializes int[] it adds header which contains size information
      • LONG_ARRAY

        public static final Serializer<long[]> LONG_ARRAY
        Serializes long[] it adds header which contains size information
      • DOUBLE_ARRAY

        public static final Serializer<double[]> DOUBLE_ARRAY
        Serializes double[] it adds header which contains size information
      • JAVA

        public static final Serializer<java.lang.Object> JAVA
        Serializer which uses standard Java Serialization with ObjectInputStream and ObjectOutputStream
      • UUID

        public static final Serializer<java.util.UUID> UUID
        Serializers UUID class
      • BYTE

        public static final Serializer<java.lang.Byte> BYTE
      • FLOAT

        public static final Serializer<java.lang.Float> FLOAT
      • DOUBLE

        public static final Serializer<java.lang.Double> DOUBLE
      • SHORT

        public static final Serializer<java.lang.Short> SHORT
      • BOOLEAN_ARRAY

        public static final Serializer<boolean[]> BOOLEAN_ARRAY
      • SHORT_ARRAY

        public static final Serializer<short[]> SHORT_ARRAY
      • FLOAT_ARRAY

        public static final Serializer<float[]> FLOAT_ARRAY
      • BIG_INTEGER

        public static final Serializer<java.math.BigInteger> BIG_INTEGER
      • BIG_DECIMAL

        public static final Serializer<java.math.BigDecimal> BIG_DECIMAL
      • CLASS

        public static final Serializer<java.lang.Class<?>> CLASS
      • DATE

        public static final Serializer<java.util.Date> DATE
      • BASIC

        public static final Serializer<java.lang.Object> BASIC
        Basic serializer for most classes in java.lang and java.util packages. It does not handle custom POJO classes. It also does not handle classes which require access to DB itself.
    • Constructor Detail

      • Serializer

        public Serializer()
    • Method Detail

      • serialize

        public abstract void serialize(java.io.DataOutput out,
                                       A value)
                                throws java.io.IOException
        Serialize the content of an object into a ObjectOutput
        Parameters:
        out - ObjectOutput to save object into
        value - Object to serialize
        Throws:
        java.io.IOException - in case of IO error
      • deserialize

        public abstract A deserialize(java.io.DataInput in,
                                      int available)
                               throws java.io.IOException
        Deserialize the content of an object from a DataInput.
        Parameters:
        in - to read serialized data from
        available - how many bytes are available in DataInput for reading, may be -1 (in streams) or 0 (null).
        Returns:
        deserialized object
        Throws:
        java.io.IOException - in case of IO error
      • fixedSize

        public int fixedSize()
        Data could be serialized into record with variable size or fixed size. Some optimizations can be applied to serializers with fixed size
        Returns:
        fixed size or -1 for variable size
      • isTrusted

        public boolean isTrusted()

        MapDB has relax record size boundary checking. It expect deserializer to read exactly as many bytes as were writen during serialization. If deserializer reads more bytes it might start reading others record data in store.

        Some serializers (Kryo) have problems with this. To prevent this we can not read data directly from store, but must copy them into separate byte[]. So zero copy optimalizations is disabled by default, and must be explicitly enabled here.

        This flag indicates if this serializer was 'verified' to read as many bytes as it writes. It should be also much better tested etc.

        Returns:
        true if this serializer is well tested and writes as many bytes as it reads.
      • equals

        public boolean equals(A a1,
                              A a2)
      • hashCode

        public int hashCode(A a,
                            int seed)
      • valueArraySerialize

        public void valueArraySerialize(java.io.DataOutput out,
                                        java.lang.Object vals)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • valueArrayDeserialize

        public java.lang.Object valueArrayDeserialize(java.io.DataInput in,
                                                      int size)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • valueArrayGet

        public A valueArrayGet(java.lang.Object vals,
                               int pos)
      • valueArraySize

        public int valueArraySize(java.lang.Object vals)
      • valueArrayEmpty

        public java.lang.Object valueArrayEmpty()
      • valueArrayPut

        public java.lang.Object valueArrayPut(java.lang.Object vals,
                                              int pos,
                                              A newValue)
      • valueArrayUpdateVal

        public java.lang.Object valueArrayUpdateVal(java.lang.Object vals,
                                                    int pos,
                                                    A newValue)
      • valueArrayFromArray

        public java.lang.Object valueArrayFromArray(java.lang.Object[] objects)
      • valueArrayCopyOfRange

        public java.lang.Object valueArrayCopyOfRange(java.lang.Object vals,
                                                      int from,
                                                      int to)
      • valueArrayDeleteValue

        public java.lang.Object valueArrayDeleteValue(java.lang.Object vals,
                                                      int pos)
      • getBTreeKeySerializer

        public BTreeKeySerializer getBTreeKeySerializer(java.util.Comparator comparator)

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.