Class BunchedTupleSerializer

    • Method Detail

      • instance

        public static BunchedTupleSerializer instance()
        Get the serializer singleton.
        Returns:
        the BunchedTupleSerializer singleton
      • serializeEntries

        @Nonnull
        public byte[] serializeEntries​(@Nonnull
                                       List<Map.Entry<Tuple,​Tuple>> entries)
        Serialize an entry list to bytes. This will place a prefix at the beginning of the list in order to support versioning of the entry list data structure in the future. Otherwise, it concatenates serialized entries together.
        Specified by:
        serializeEntries in interface BunchedSerializer<Tuple,​Tuple>
        Parameters:
        entries - the list of entries to serialize
        Returns:
        the serialized entry list
      • deserializeKey

        @Nonnull
        public Tuple deserializeKey​(@Nonnull
                                    byte[] data,
                                    int offset,
                                    int length)
        Description copied from interface: BunchedSerializer
        Deserialize a slice of a byte array into a key. This will only deserialize the portion of the array starting at offset and going for length bytes.
        Specified by:
        deserializeKey in interface BunchedSerializer<Tuple,​Tuple>
        Parameters:
        data - source data to deserialize
        offset - beginning offset of serialized key (indexed from 0)
        length - length of serialized key
        Returns:
        key deserialized from reading data
      • deserializeEntries

        @Nonnull
        public List<Map.Entry<Tuple,​Tuple>> deserializeEntries​(@Nonnull
                                                                     Tuple key,
                                                                     @Nonnull
                                                                     byte[] data)
        Description copied from interface: BunchedSerializer
        Deserialize raw data to a list of entries. This should be the inverse of serializeEntries. Note that the order of elements returned within the list should be the same as their sort order. The key that this entry list is stored under is passed in so that implementations that wish to can choose to omit the first key of the entry list from the serialized value.
        Specified by:
        deserializeEntries in interface BunchedSerializer<Tuple,​Tuple>
        Parameters:
        key - key under which the serialized entry list was stored
        data - source list to deserialize
        Returns:
        entry list deserialized from reading data
      • canAppend

        public boolean canAppend()
        Returns true. This format supports appending serialized entries to the end of a serialized entry list to create the serialized bytes of the original list with the new entry at the end.
        Specified by:
        canAppend in interface BunchedSerializer<Tuple,​Tuple>
        Returns:
        true as this serialization format supports appending