Class ArrayOfBooleansSerDe
java.lang.Object
org.apache.datasketches.common.ArrayOfItemsSerDe<Boolean>
org.apache.datasketches.common.ArrayOfBooleansSerDe
Methods of serializing and deserializing arrays of Boolean as a bit array.
- Author:
- Jon Malkin
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcomputeBytesNeeded(int arrayLength) Computes number of bytes needed for packed bit encoding of the array of booleans.Boolean[]deserializeFromMemorySegment(MemorySegment seg, int numItems) Deserialize a contiguous sequence of serialized items from the given MemorySegment starting at a MemorySegment offset of zero and extending numItems.Boolean[]deserializeFromMemorySegment(MemorySegment seg, long offsetBytes, int numItems) Deserialize a contiguous sequence of serialized items from the given MemorySegment starting at the given MemorySegment offsetBytes and extending numItems.Returns the concrete class of type Tbyte[]serializeToByteArray(Boolean item) Serialize a single unserialized item to a byte array.byte[]serializeToByteArray(Boolean[] 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.intReturns the serialized size in bytes of the array of items.intsizeOf(MemorySegment seg, long offsetBytes, int numItems) Returns the serialized size in bytes of the number of contiguous serialized items in MemorySegment.Returns a human readable string of an item.
-
Constructor Details
-
ArrayOfBooleansSerDe
public ArrayOfBooleansSerDe()No argument constructor.
-
-
Method Details
-
computeBytesNeeded
public static int computeBytesNeeded(int arrayLength) Computes number of bytes needed for packed bit encoding of the array of booleans. Rounds partial bytes up to return a whole number of bytes.- Parameters:
arrayLength- Number of items in the array to serialize- Returns:
- Number of bytes needed to encode the array
-
serializeToByteArray
Description copied from class:ArrayOfItemsSerDeSerialize a single unserialized item to a byte array.- Specified by:
serializeToByteArrayin classArrayOfItemsSerDe<Boolean>- 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<Boolean>- Parameters:
items- array of items to be serialized- Returns:
- contiguous, serialized representation of the given array of unserialized items
-
deserializeFromMemorySegment
Description copied from class:ArrayOfItemsSerDeDeserialize a contiguous sequence of serialized items from the given MemorySegment starting at a MemorySegment offset of zero and extending numItems.- Overrides:
deserializeFromMemorySegmentin classArrayOfItemsSerDe<Boolean>- Parameters:
seg- MemorySegment containing a contiguous sequence of serialized itemsnumItems- number of items in the contiguous serialized sequence.- Returns:
- array of deserialized items
- See Also:
-
deserializeFromMemorySegment
Description copied from class:ArrayOfItemsSerDeDeserialize a contiguous sequence of serialized items from the given MemorySegment starting at the given MemorySegment offsetBytes and extending numItems.- Specified by:
deserializeFromMemorySegmentin classArrayOfItemsSerDe<Boolean>- Parameters:
seg- MemorySegment containing a contiguous sequence of serialized itemsoffsetBytes- the starting offset in the given MemorySegment.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<Boolean>- Parameters:
item- a specific item- Returns:
- the serialized size in bytes of a single unserialized item.
-
sizeOf
Description copied from class:ArrayOfItemsSerDeReturns the serialized size in bytes of the array of items.- Overrides:
sizeOfin classArrayOfItemsSerDe<Boolean>- Parameters:
items- an array of items.- Returns:
- the serialized size in bytes of the array of items.
-
sizeOf
Description copied from class:ArrayOfItemsSerDeReturns 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:
sizeOfin classArrayOfItemsSerDe<Boolean>- 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
Description copied from class:ArrayOfItemsSerDeReturns a human readable string of an item.- Specified by:
toStringin classArrayOfItemsSerDe<Boolean>- 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<Boolean>- Returns:
- the concrete class of type T
-