public interface SizeMarshaller
extends net.openhft.chronicle.wire.Marshallable
int
, 8 bytes for long
is rather wasteful for marshalling purposes, when the number (size) to store is usually very
small, and 1-2 bytes could be enough to encode it (this is how stopBit()
marshaller
works). Also, this interface allows to generalize storing constantly-sized and variable-sized
blocks of data. Constantly-sized don't require to store the size actually, the corresponding
constant(long)
SizeMarshaller
consumes 0 bytes.
Some SizeMarshaller
implementations couldn't store the whole long
range, for
example each constant(long)
SizeMarshaller
is able to "store" only a single specific
value (it's constant size). If the marshaller is fed with the size it is not able store, it could
throw an IllegalArgumentException
.
Modifier and Type | Method and Description |
---|---|
static SizeMarshaller |
constant(long constantSize)
Returns a
SizeMarshaller , that consumes 0 bytes and is above to "store" only a single
constant number, provided to this factory method. |
long |
maxStorableSize()
Returns the maximum size this
SizeMarshaller is able to store. |
int |
maxStoringLengthOfSizesInRange(long minSize,
long maxSize)
Returns the maximum storing length this
SizeMarshaller produces for some value in the
given range (both bounds are inclusive). |
long |
minStorableSize()
Returns the minimum size this
SizeMarshaller is able to store. |
int |
minStoringLengthOfSizesInRange(long minSize,
long maxSize)
Returns the minimum storing length this
SizeMarshaller produces for some size in the
given range (both bounds are inclusive). |
long |
readSize(net.openhft.chronicle.bytes.Bytes in)
Reads and returns a size from the input.
|
static SizeMarshaller |
stopBit()
Returns a
SizeMarshaller which stores number using so-called stop bit encoding. |
int |
storingLength(long size)
Calculates how many bytes is takes to store the given
size with this SizeMarshaller . |
void |
writeSize(net.openhft.chronicle.bytes.Bytes out,
long sizeToWrite)
Writes the given size into the streaming output.
|
$equals, $fieldInfoMap, $fieldInfos, $hashCode, $toString, className, copyFrom, copyTo, deepCopy, fromFile, fromFile, fromFileAsMap, fromFileAsMap, fromHexString, fromString, fromString, fromString, getField, getLongField, mergeToMap, readMarshallable, reset, setField, setLongField, streamFromFile, streamFromFile, writeMarshallable
static SizeMarshaller stopBit()
SizeMarshaller
which stores number using so-called stop bit encoding. This marshaller is used as the default marshaller for keys' and
values' sizes in Chronicle Map, unless Chronicle Map could figure out (or hinted in ChronicleMapBuilder
) that keys or values are constant-sized, in which case constant(long)
SizeMarshaller
is used.static SizeMarshaller constant(long constantSize)
SizeMarshaller
, that consumes 0 bytes and is above to "store" only a single
constant number, provided to this factory method. This size marshaller is used in Chronicle
Map to serialize keys' or values' sizes, when Chronicle Map could figure out (or was hinted
in ChronicleMapBuilder
) that keys or values are constant-sized.constantSize
- the single constant size the returned SizeMarshaller
is able to
"store"SizeMarshaller
, that is able to "store" only the given constant sizeint storingLength(long size)
size
with this SizeMarshaller
.size
- the size to storeIllegalArgumentException
- might be thrown, if the given size if not storable by this
SizeMarshaller
long minStorableSize()
SizeMarshaller
is able to store.SizeMarshaller
is able to storelong maxStorableSize()
SizeMarshaller
is able to store.SizeMarshaller
is able to storeint minStoringLengthOfSizesInRange(long minSize, long maxSize)
SizeMarshaller
produces for some size in the
given range (both bounds are inclusive).minSize
- the lower bound of the range (inclusive)maxSize
- the upper bound of the range (inclusive)maxStoringLengthOfSizesInRange(long, long)
int maxStoringLengthOfSizesInRange(long minSize, long maxSize)
SizeMarshaller
produces for some value in the
given range (both bounds are inclusive).minSize
- the lower bound of the range (inclusive)maxSize
- the upper bound of the range (inclusive)minStoringLengthOfSizesInRange(long, long)
void writeSize(net.openhft.chronicle.bytes.Bytes out, long sizeToWrite)
out
- the StreamingDataOutput
to write the size tosizeToWrite
- the size to writeIllegalArgumentException
- might be thrown, if the given size if not storable by this
SizeMarshaller
readSize(Bytes)
long readSize(net.openhft.chronicle.bytes.Bytes in)
in
- the StreamingDataInput
to read the size fromwriteSize(Bytes, long)
Copyright © 2021. All rights reserved.