Package org.apache.datasketches.common
Class ArrayOfItemsSerDe<T>
java.lang.Object
org.apache.datasketches.common.ArrayOfItemsSerDe<T>
- Type Parameters:
T
- Type of item
- Direct Known Subclasses:
ArrayOfBooleansSerDe
,ArrayOfDoublesSerDe
,ArrayOfLongsSerDe
,ArrayOfNumbersSerDe
,ArrayOfStringsSerDe
,ArrayOfUtf16StringsSerDe
Base class for serializing and deserializing custom types.
- Author:
- Alexander Saydakov
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionT[]
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.abstract T[]
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 Tabstract byte[]
serializeToByteArray
(T item) Serialize a single unserialized item to a byte array.abstract byte[]
serializeToByteArray
(T[] items) Serialize an array of unserialized items to a byte array of contiguous serialized items.abstract int
sizeOf
(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.abstract int
Returns the serialized size in bytes of a single unserialized item.int
Returns the serialized size in bytes of the array of items.abstract String
Returns a human readable string of an item.
-
Constructor Details
-
ArrayOfItemsSerDe
public ArrayOfItemsSerDe()
-
-
Method Details
-
serializeToByteArray
Serialize a single unserialized item to a byte array.- Parameters:
item
- the item to be serialized- Returns:
- serialized representation of the given item
-
serializeToByteArray
Serialize an array of unserialized items to a byte array of contiguous serialized items.- Parameters:
items
- array of items to be serialized- Returns:
- contiguous, serialized representation of the given array of unserialized items
-
deserializeFromMemory
Deserialize a contiguous sequence of serialized items from the given Memory starting at a Memory offset of zero and extending numItems.- 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 abstract T[] 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.- 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
Returns the serialized size in bytes of a single unserialized item.- Parameters:
item
- a specific item- Returns:
- the serialized size in bytes of a single unserialized item.
-
sizeOf
Returns the serialized size in bytes of the array of items.- Parameters:
items
- an array of items.- Returns:
- the serialized size in bytes of the array of items.
-
sizeOf
public abstract int sizeOf(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. The capacity of the given Memory can be much larger that the required size of the items.- 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
Returns a human readable string of an item.- Parameters:
item
- a specific item- Returns:
- a human readable string of an item.
-
getClassOfT
Returns the concrete class of type T- Returns:
- the concrete class of type T
-