public class ArrayOfNumbersSerDe extends ArrayOfItemsSerDe<Number>
This class serializes numbers with a leading byte (ASCII character) indicating the type. The class keeps the values byte aligned, even though only 3 bits are strictly necessary to encode one of the 6 different primitives with object types that extend Number.
Classes handled are: Long
, Integer
, Short
,
Byte
, Double
, and Float
.
Constructor and Description |
---|
ArrayOfNumbersSerDe() |
Modifier and Type | Method and Description |
---|---|
Number[] |
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.
|
Number[] |
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.
|
Class<Number> |
getClassOfT()
Returns the concrete class of type T
|
byte[] |
serializeToByteArray(Number item)
Serialize a single unserialized item to a byte array.
|
byte[] |
serializeToByteArray(Number[] items)
Serialize an array of unserialized items to a byte array of contiguous serialized 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.
|
int |
sizeOf(Number item)
Returns the serialized size in bytes of a single unserialized item.
|
int |
sizeOf(Number[] items)
Returns the serialized size in bytes of the array of items.
|
String |
toString(Number item)
Returns a human readable string of an item.
|
public byte[] serializeToByteArray(Number item)
ArrayOfItemsSerDe
serializeToByteArray
in class ArrayOfItemsSerDe<Number>
item
- the item to be serializedpublic byte[] serializeToByteArray(Number[] items)
ArrayOfItemsSerDe
serializeToByteArray
in class ArrayOfItemsSerDe<Number>
items
- array of items to be serializedpublic Number[] deserializeFromMemory(org.apache.datasketches.memory.Memory mem, int numItems)
ArrayOfItemsSerDe
deserializeFromMemory
in class ArrayOfItemsSerDe<Number>
mem
- Memory containing a contiguous sequence of serialized itemsnumItems
- number of items in the contiguous serialized sequence.ArrayOfItemsSerDe.deserializeFromMemory(Memory, long, int)
public Number[] deserializeFromMemory(org.apache.datasketches.memory.Memory mem, long offsetBytes, int numItems)
ArrayOfItemsSerDe
deserializeFromMemory
in class ArrayOfItemsSerDe<Number>
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.public int sizeOf(Number item)
ArrayOfItemsSerDe
sizeOf
in class ArrayOfItemsSerDe<Number>
item
- a specific itempublic int sizeOf(Number[] items)
ArrayOfItemsSerDe
sizeOf
in class ArrayOfItemsSerDe<Number>
items
- an array of items.public int sizeOf(org.apache.datasketches.memory.Memory mem, long offsetBytes, int numItems)
ArrayOfItemsSerDe
sizeOf
in class ArrayOfItemsSerDe<Number>
mem
- the given Memory.offsetBytes
- the starting offset in the given Memory.numItems
- the number of serialized items contained in the Memorypublic String toString(Number item)
ArrayOfItemsSerDe
toString
in class ArrayOfItemsSerDe<Number>
item
- a specific itempublic Class<Number> getClassOfT()
ArrayOfItemsSerDe
getClassOfT
in class ArrayOfItemsSerDe<Number>
Copyright © 2015–2024 The Apache Software Foundation. All rights reserved.