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 Modifier and Type Method Description static intcomputeBytesNeeded(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 length)Deserialize an array of items from a given Memory object.byte[]serializeToByteArray(Boolean[] items)Serialize an array of items to byte array.
-
-
-
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[] items)
Description copied from class:ArrayOfItemsSerDeSerialize an array of items to byte array. The size of the array doesn't need to be serialized. This method is called by the sketch serialization process.- Specified by:
serializeToByteArrayin classArrayOfItemsSerDe<Boolean>- Parameters:
items- array of items to be serialized- Returns:
- serialized representation of the given array of items
-
deserializeFromMemory
public Boolean[] deserializeFromMemory(org.apache.datasketches.memory.Memory mem, int length)
Description copied from class:ArrayOfItemsSerDeDeserialize an array of items from a given Memory object. This method is called by the sketch deserialization process.- Specified by:
deserializeFromMemoryin classArrayOfItemsSerDe<Boolean>- Parameters:
mem- Memory containing a serialized array of itemslength- number of items in the serialized array- Returns:
- deserialized array of items
-
-