Package org.apache.datasketches.common
Class ArrayOfBooleansSerDe
- java.lang.Object
-
- org.apache.datasketches.common.ArrayOfItemsSerDe<Boolean>
-
- org.apache.datasketches.common.ArrayOfBooleansSerDe
-
public class ArrayOfBooleansSerDe extends ArrayOfItemsSerDe<Boolean>
Methods of serializing and deserializing arrays of Boolean as a bit array.- Author:
- Jon Malkin
-
-
Constructor Summary
Constructors Constructor Description ArrayOfBooleansSerDe()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static int
computeBytesNeeded(int arrayLength)
Computes number of bytes needed for packed bit encoding of the array of booleans.Boolean[]
deserializeFromMemory(org.apache.datasketches.memory.Memory mem, int numItems)
Deprecated.Boolean[]
deserializeFromMemory(org.apache.datasketches.memory.Memory mem, long offsetBytes, int numItems)
Deserialize a contiguous sequence of serialized items from a given Memory.Class<Boolean>
getClassOfT()
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.int
sizeOf(Boolean item)
Returns the serialized size in bytes of a single unserialized item.int
sizeOf(Boolean[] items)
Returns the serialized size in bytes of the array of items.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.String
toString(Boolean item)
Returns a human readable string of an item.
-
-
-
Method Detail
-
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
public byte[] serializeToByteArray(Boolean item)
Description copied from class:ArrayOfItemsSerDe
Serialize a single unserialized item to a byte array.- Specified by:
serializeToByteArray
in classArrayOfItemsSerDe<Boolean>
- Parameters:
item
- the item to be serialized- Returns:
- serialized representation of the given item
-
serializeToByteArray
public byte[] serializeToByteArray(Boolean[] items)
Description copied from class:ArrayOfItemsSerDe
Serialize an array of unserialized items to a byte array of contiguous serialized items.- Specified by:
serializeToByteArray
in classArrayOfItemsSerDe<Boolean>
- Parameters:
items
- array of items to be serialized- Returns:
- contiguous, serialized representation of the given array of unserialized items
-
deserializeFromMemory
@Deprecated public Boolean[] deserializeFromMemory(org.apache.datasketches.memory.Memory mem, int numItems)
Deprecated.Description copied from class:ArrayOfItemsSerDe
Deserialize a contiguous sequence of serialized items from a given Memory.- Specified by:
deserializeFromMemory
in classArrayOfItemsSerDe<Boolean>
- Parameters:
mem
- Memory containing a contiguous sequence of serialized itemsnumItems
- number of items in the contiguous serialized sequence.- Returns:
- array of deserialized items
-
deserializeFromMemory
public Boolean[] deserializeFromMemory(org.apache.datasketches.memory.Memory mem, long offsetBytes, int numItems)
Description copied from class:ArrayOfItemsSerDe
Deserialize a contiguous sequence of serialized items from a given Memory.- Specified by:
deserializeFromMemory
in classArrayOfItemsSerDe<Boolean>
- 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
public int sizeOf(Boolean item)
Description copied from class:ArrayOfItemsSerDe
Returns the serialized size in bytes of a single unserialized item.- Specified by:
sizeOf
in classArrayOfItemsSerDe<Boolean>
- Parameters:
item
- a specific item- Returns:
- the serialized size in bytes of a single unserialized item.
-
sizeOf
public int sizeOf(Boolean[] items)
Description copied from class:ArrayOfItemsSerDe
Returns the serialized size in bytes of the array of items.- Overrides:
sizeOf
in classArrayOfItemsSerDe<Boolean>
- Parameters:
items
- an array of items.- Returns:
- the serialized size in bytes of the array of items.
-
sizeOf
public int sizeOf(org.apache.datasketches.memory.Memory mem, long offsetBytes, int numItems)
Description copied from class:ArrayOfItemsSerDe
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.- Specified by:
sizeOf
in classArrayOfItemsSerDe<Boolean>
- 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
public String toString(Boolean item)
Description copied from class:ArrayOfItemsSerDe
Returns a human readable string of an item.- Specified by:
toString
in classArrayOfItemsSerDe<Boolean>
- Parameters:
item
- a specific item- Returns:
- a human readable string of an item.
-
getClassOfT
public Class<Boolean> getClassOfT()
Description copied from class:ArrayOfItemsSerDe
Returns the concrete class of type T- Specified by:
getClassOfT
in classArrayOfItemsSerDe<Boolean>
- Returns:
- the concrete class of type T
-
-