Class ArrayOfStringsSerDe

java.lang.Object
org.apache.datasketches.common.ArrayOfItemsSerDe<String>
org.apache.datasketches.common.ArrayOfStringsSerDe

public class ArrayOfStringsSerDe extends ArrayOfItemsSerDe<String>
Methods of serializing and deserializing arrays of String. This class serializes strings in UTF-8 format, which is more compact compared to ArrayOfUtf16StringsSerDe. In an extreme case when all strings are in ASCII, this method is 2 times more compact, but it takes more time to encode and decode by a factor of 1.5 to 2.

The serialization

Author:
Alexander Saydakov
  • Constructor Details

    • ArrayOfStringsSerDe

      public ArrayOfStringsSerDe()
      No argument constructor.
  • Method Details

    • serializeToByteArray

      public byte[] serializeToByteArray(String item)
      Description copied from class: ArrayOfItemsSerDe
      Serialize a single unserialized item to a byte array.
      Specified by:
      serializeToByteArray in class ArrayOfItemsSerDe<String>
      Parameters:
      item - the item to be serialized
      Returns:
      serialized representation of the given item
    • serializeToByteArray

      public byte[] serializeToByteArray(String[] items)
      Description copied from class: ArrayOfItemsSerDe
      Serialize an array of unserialized items to a byte array of contiguous serialized items.
      Specified by:
      serializeToByteArray in class ArrayOfItemsSerDe<String>
      Parameters:
      items - array of items to be serialized
      Returns:
      contiguous, serialized representation of the given array of unserialized items
    • deserializeFromMemorySegment

      public String[] deserializeFromMemorySegment(MemorySegment seg, int numItems)
      Description copied from class: ArrayOfItemsSerDe
      Deserialize a contiguous sequence of serialized items from the given MemorySegment starting at a MemorySegment offset of zero and extending numItems.
      Overrides:
      deserializeFromMemorySegment in class ArrayOfItemsSerDe<String>
      Parameters:
      seg - MemorySegment containing a contiguous sequence of serialized items
      numItems - number of items in the contiguous serialized sequence.
      Returns:
      array of deserialized items
      See Also:
    • deserializeFromMemorySegment

      public String[] deserializeFromMemorySegment(MemorySegment seg, long offsetBytes, int numItems)
      Description copied from class: ArrayOfItemsSerDe
      Deserialize a contiguous sequence of serialized items from the given MemorySegment starting at the given MemorySegment offsetBytes and extending numItems.
      Specified by:
      deserializeFromMemorySegment in class ArrayOfItemsSerDe<String>
      Parameters:
      seg - MemorySegment containing a contiguous sequence of serialized items
      offsetBytes - the starting offset in the given MemorySegment.
      numItems - number of items in the contiguous serialized sequence.
      Returns:
      array of deserialized items
    • sizeOf

      public int sizeOf(String item)
      Description copied from class: ArrayOfItemsSerDe
      Returns the serialized size in bytes of a single unserialized item.
      Specified by:
      sizeOf in class ArrayOfItemsSerDe<String>
      Parameters:
      item - a specific item
      Returns:
      the serialized size in bytes of a single unserialized item.
    • sizeOf

      public int sizeOf(MemorySegment seg, long offsetBytes, int numItems)
      Description copied from class: ArrayOfItemsSerDe
      Returns the serialized size in bytes of the number of contiguous serialized items in MemorySegment. The capacity of the given MemorySegment can be much larger that the required size of the items.
      Specified by:
      sizeOf in class ArrayOfItemsSerDe<String>
      Parameters:
      seg - the given MemorySegment.
      offsetBytes - the starting offset in the given MemorySegment.
      numItems - the number of serialized items contained in the MemorySegment
      Returns:
      the serialized size in bytes of the given number of items.
    • toString

      public String toString(String item)
      Description copied from class: ArrayOfItemsSerDe
      Returns a human readable string of an item.
      Specified by:
      toString in class ArrayOfItemsSerDe<String>
      Parameters:
      item - a specific item
      Returns:
      a human readable string of an item.
    • getClassOfT

      public Class<String> getClassOfT()
      Description copied from class: ArrayOfItemsSerDe
      Returns the concrete class of type T
      Specified by:
      getClassOfT in class ArrayOfItemsSerDe<String>
      Returns:
      the concrete class of type T