Package org.apache.datasketches.common
Class ArrayOfUtf16StringsSerDe
java.lang.Object
org.apache.datasketches.common.ArrayOfItemsSerDe<String>
org.apache.datasketches.common.ArrayOfUtf16StringsSerDe
Methods of serializing and deserializing arrays of String.
This class serializes strings using internal Java representation as char[], where each char
is a 16-bit code. The result is larger than one from
ArrayOfStringsSerDe.
In an extreme case when all strings are in ASCII, the size is doubled. However it takes
less time to serialize and deserialize by a factor of 1.5 to 2.- Author:
- Alexander Saydakov
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]deserializeFromMemory(org.apache.datasketches.memory.Memory mem, int numItems) Deserialize a contiguous sequence of serialized items from the given Memory starting at a Memory offset of zero and extending numItems.String[]deserializeFromMemory(org.apache.datasketches.memory.Memory mem, long offsetBytes, int numItems) Deserialize a contiguous sequence of serialized items from the given Memory starting at the given Memory offsetBytes and extending numItems.Returns the concrete class of type Tbyte[]serializeToByteArray(String item) Serialize a single unserialized item to a byte array.byte[]serializeToByteArray(String[] items) Serialize an array of unserialized items to a byte array of contiguous serialized items.intReturns the serialized size in bytes of a single unserialized item.intsizeOf(org.apache.datasketches.memory.Memory mem, long offsetBytes, int numItems) Returns the serialized size in bytes of the number of contiguous serialized items in Memory.Returns a human readable string of an item.Methods inherited from class org.apache.datasketches.common.ArrayOfItemsSerDe
sizeOf
-
Constructor Details
-
ArrayOfUtf16StringsSerDe
public ArrayOfUtf16StringsSerDe()
-
-
Method Details
-
serializeToByteArray
Description copied from class:ArrayOfItemsSerDeSerialize a single unserialized item to a byte array.- Specified by:
serializeToByteArrayin classArrayOfItemsSerDe<String>- Parameters:
item- the item to be serialized- Returns:
- serialized representation of the given item
-
serializeToByteArray
Description copied from class:ArrayOfItemsSerDeSerialize an array of unserialized items to a byte array of contiguous serialized items.- Specified by:
serializeToByteArrayin classArrayOfItemsSerDe<String>- Parameters:
items- array of items to be serialized- Returns:
- contiguous, serialized representation of the given array of unserialized items
-
deserializeFromMemory
Description copied from class:ArrayOfItemsSerDeDeserialize a contiguous sequence of serialized items from the given Memory starting at a Memory offset of zero and extending numItems.- Overrides:
deserializeFromMemoryin classArrayOfItemsSerDe<String>- Parameters:
mem- Memory containing a contiguous sequence of serialized itemsnumItems- number of items in the contiguous serialized sequence.- Returns:
- array of deserialized items
- See Also:
-
deserializeFromMemory
public String[] deserializeFromMemory(org.apache.datasketches.memory.Memory mem, long offsetBytes, int numItems) Description copied from class:ArrayOfItemsSerDeDeserialize a contiguous sequence of serialized items from the given Memory starting at the given Memory offsetBytes and extending numItems.- Specified by:
deserializeFromMemoryin classArrayOfItemsSerDe<String>- Parameters:
mem- Memory containing a contiguous sequence of serialized itemsoffsetBytes- the starting offset in the given Memory.numItems- number of items in the contiguous serialized sequence.- Returns:
- array of deserialized items
-
sizeOf
Description copied from class:ArrayOfItemsSerDeReturns the serialized size in bytes of a single unserialized item.- Specified by:
sizeOfin classArrayOfItemsSerDe<String>- Parameters:
item- a specific item- Returns:
- the serialized size in bytes of a single unserialized item.
-
sizeOf
public int sizeOf(org.apache.datasketches.memory.Memory mem, long offsetBytes, int numItems) Description copied from class:ArrayOfItemsSerDeReturns the serialized size in bytes of the number of contiguous serialized items in Memory. The capacity of the given Memory can be much larger that the required size of the items.- Specified by:
sizeOfin classArrayOfItemsSerDe<String>- Parameters:
mem- the given Memory.offsetBytes- the starting offset in the given Memory.numItems- the number of serialized items contained in the Memory- Returns:
- the serialized size in bytes of the given number of items.
-
toString
Description copied from class:ArrayOfItemsSerDeReturns a human readable string of an item.- Specified by:
toStringin classArrayOfItemsSerDe<String>- Parameters:
item- a specific item- Returns:
- a human readable string of an item.
-
getClassOfT
Description copied from class:ArrayOfItemsSerDeReturns the concrete class of type T- Specified by:
getClassOfTin classArrayOfItemsSerDe<String>- Returns:
- the concrete class of type T
-