K
- the key type of ChronicleMap
, on which acquireUsing()
is queriedV
- the value type of ChronicleMap
, on which acquireUsing()
is queriedpublic interface PrepareValueBytes<K,V> extends Serializable
Byteable
value during chronicleMap.acquireUsing()
call, when the given key is absent in the map. Example: if you
want 1L
to be the off-heap updatable ChronicleMap's default value.
PrepareValueBytes) configure} custom PrepareValueBytes
strategy in ChronicleMapBuilder
: ChronicleMapBuilder.of(Key.class, LongValue.class)
.prepareDefaultValueBytes((bytes, k) -> bytes.writeLong(1L))
...
.create();
Although the value type is not used in the API, PrepareValueBytes
is not intended
to be generic by value type, because strategy should know the value layout and
how much bytes does it take in memory.
void prepare(Bytes bytes, K key)
Byteable
. The given bytes' position
corresponds to the start of value bytes to be assigned into. This method should increment
the given bytes' position by the value size. Bytes' contents
outside of this range shouldn't be altered.bytes
- the bytes, positioned at the first value byte. Bytes' limit and BytesCommon.remaining() are not specified, but it is guaranteed that
the latter is not less than the value size.key
- the key which is absent in the ChronicleMap
during acquireUsing()
call and value bytes are prepared
forCopyright © 2015. All rights reserved.