K
- key type of the maps, produced by this builderV
- value type of the maps, produced by this builderpublic abstract class AbstractChronicleMapBuilder<K,V,B extends AbstractChronicleMapBuilder<K,V,B>> extends Object implements Cloneable, ChronicleHashBuilder<K,ChronicleMap<K,V>,B>
AbstractChronicleMapBuilder
manages most of ChronicleMap
configurations; has two
concrete subclasses: ChronicleMapBuilder
should be used to create maps with ordinary
values, OffHeapUpdatableChronicleMapBuilder
-- maps with Byteable
values, which
point directly to off-heap memory; could be used as a classic builder and/or factory. This means
that in addition to the standard builder usage pattern: ChronicleMap<Key, Value> map = ChronicleMapBuilder
.of(Key.class, Value.class)
.entries(100500)
// ... other configurations
.create();
one of concrete AbstractChronicleMapBuilder
subclasses, ChronicleMapBuilder
or
OffHeapUpdatableChronicleMapBuilder
, could be prepared and used to create many similar
maps: OffHeapUpdatableChronicleMapBuilder<Key, Value> builder = OffHeapUpdatableChronicleMapBuilder
.of(Key.class, Value.class)
.entries(100500);
ChronicleMap<Key, Value> map1 = builder.create();
ChronicleMap<Key, Value> map2 = builder.create();
i. e. created ChronicleMap
instances don't depend on the builder.
AbstractChronicleMapBuilder
and it's subclasses are mutable, see a note in ChronicleHashBuilder
interface documentation.
Later in this documentation,
"ChronicleMap" means "ChronicleMaps, created by AbstractChronicleMapBuilder
", unless
specified different, because theoretically someone might provide ChronicleMap
implementations with completely different properties.
ChronicleMap
("ChronicleMaps, created by AbstractChronicleMapBuilder
") currently doesn't support
resizing. That is why you should always configure number of
entries you are going to insert into the created map at most. See entries(long)
method documentation for more information on this.
ChronicleMap
allocates memory
by equally sized chunks. This size is called entry size, you are
strongly recommended to configure it to achieve least memory consumption and best speed. See
entrySize(int)
method documentation for more information on this.
ChronicleMap
,
ChronicleSetBuilder
Modifier and Type | Method and Description |
---|---|
B |
actualEntriesPerSegment(long actualEntriesPerSegment) |
B |
actualSegments(int actualSegments) |
B |
bytesMarshallerFactory(BytesMarshallerFactory bytesMarshallerFactory)
Configures a
BytesMarshallerFactory to be used with BytesMarshallableSerializer , which is a default ObjectSerializer ,
to serialize/deserialize data to/from off-heap memory in hash containers, created by this
builder. |
B |
channel(ChannelProvider.ChronicleChannel chronicleChannel)
Configures replication of the hash containers, created by this builder, via so called
"channels".
|
B |
clone()
Clones this builder.
|
B |
constantKeySizeBySample(K sampleKey)
Configures the constant number of bytes, taken by serialized form of keys, put into hash
containers, created by this builder.
|
ChronicleMap<K,V> |
create()
Creates a new hash container, storing it's data in off-heap memory, not mapped to any file.
|
ChronicleMap<K,V> |
createWithFile(File file) |
B |
defaultValue(V defaultValue)
Specifies the value to be put for each key queried in
acquireUsing() method, if the key is absent in the map, created by this builder. |
B |
defaultValueProvider(DefaultValueProvider<K,V> defaultValueProvider)
Specifies the function to obtain a value for the key during
acquireUsing() calls, if the key is absent in the map, created by this builder. |
B |
disableReplication()
Specifies that hash containers, created by this builder, shouldn't replicate their data over
network.
|
B |
entries(long entries)
Configures the maximum number of "entry size chunks", which
could be taken by the maximum number of entries, inserted into the hash containers, created
by this builder.
|
B |
entrySize(int entrySize)
Configures the size in bytes of allocation unit of hash container instances, created by this
builder.
|
boolean |
equals(Object o) |
B |
errorListener(ChronicleHashErrorListener errorListener) |
B |
eventListener(MapEventListener<K,V,ChronicleMap<K,V>> eventListener) |
B |
file(File file)
Specifies that hash containers us the specified file, if create is called and this is not set
the map will be created in off-heap memory, and changes will not be persisted to disk.
|
int |
hashCode() |
byte |
identifier() |
B |
immutableKeys()
Specifies that key objects, queried with the hash containers, created by this builder, are
inherently immutable.
|
B |
keyDeserializationFactory(ObjectFactory<K> keyDeserializationFactory)
Configures factory which is used to create a new key instance, if key class is either
Byteable , BytesMarshallable or Externalizable subclass in maps,
created by this builder. |
B |
keyMarshaller(BytesMarshaller<K> keyMarshaller)
Configures the
BytesMarshaller used to serialize/deserialize keys to/from off-heap
memory in hash containers, created by this builder. |
B |
keySize(int keySize)
Configures the optimal number of bytes, taken by serialized form of keys, put into hash
containers, created by this builder.
|
B |
lockTimeOut(long lockTimeOut,
TimeUnit unit)
Configures timeout of locking on segments of hash
containers, created by this builder, when performing any queries, as well as bulk operations
like iteration.
|
B |
metaDataBytes(int metaDataBytes) |
B |
minSegments(int minSegments)
Set minimum number of segments in hash containers, constructed by this builder.
|
B |
objectSerializer(ObjectSerializer objectSerializer)
Configures the serializer used to serialize/deserialize data to/from off-heap memory, when
specified class doesn't implement a specific serialization interface like
Externalizable or BytesMarshallable (for example, if data is loosely typed and just
Object is specified as the data class), or nullable data, and if custom marshaller is
not configured, in hash containers, created by
this builder. |
protected static boolean |
offHeapReference(Class valueClass) |
B |
putReturnsNull(boolean putReturnsNull)
Configures if the maps created by this builder should return
null instead of previous
mapped values on ChornicleMap.put(key, value)
calls. |
B |
removeReturnsNull(boolean removeReturnsNull)
Configures if the maps created by this builder should return
null instead of the last
mapped value on ChronicleMap.remove(key) calls. |
B |
replicators(byte identifier,
ReplicationConfig... replicationConfigs)
Configures replication of the hash containers, created by this builder (via independent
replicators).
|
int |
segmentHeaderSize() |
B |
stateless(StatelessBuilder statelessBuilder)
Specifies that hash containers, created by this builder, should be a stateless
implementation, this stateless implementation will be referred to as a stateless client as it
will not hold any of its own data locally, the stateless client will perform Remote Procedure
Calls ( RPC ) to another
ChronicleMap or ChronicleSet which we will refer to
as the server. |
B |
timeProvider(TimeProvider timeProvider)
Configures a time provider, used by hash containers, created by this builder, for needs of
replication consensus protocol (conflicting data updates resolution).
|
String |
toString() |
B |
valueDeserializationFactory(ObjectFactory<V> valueDeserializationFactory)
Configures factory which is used to create a new value instance, if value class is either
Byteable , BytesMarshallable or Externalizable subclass in maps,
created by this builder. |
protected static boolean offHeapReference(Class valueClass)
public B clone()
ChronicleHashBuilder
ChronicleHashBuilder
s are mutable and changed on each configuration method call. Original
and cloned builders are independent.clone
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
clone
in class Object
public B keySize(int keySize)
ChronicleHashBuilder.constantKeySizeBySample(Object)
method instead of this one.
If key size varies moderately, specify the size higher than average, but lower than the maximum possible, to minimize average memory overuse. If key size varies in a wide range, it's better to use entry size in "chunk" mode and configure it directly.
Example: if keys in your map(s) are English words in String
form, keys size 10
(a bit more than average English word length) would be a good choice:
ChronicleMap<String, LongValue> wordFrequencies = OffHeapUpdatableChronicleMapBuilder
.of(String.class, LongValue.class)
.entries(50000)
.keySize(10)
// shouldn't specify valueSize(), because it is statically known
.create();
(Note that 10 is chosen as key size in bytes despite strings in Java are UTF-16 encoded (and
each character takes 2 bytes on-heap), because default off-heap String
encoding is
UTF-8 in ChronicleMap
.)keySize
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
keySize
- number of bytes, taken by serialized form of keysconstantKeySizeBySample(Object)
,
entrySize(int)
public B constantKeySizeBySample(K sampleKey)
sampleKey
, all
keys should take the same number of bytes in serialized form, as this sample object.
If keys are of boxed primitive type or Byteable
subclass, i. e. if key size is
known statically, it is automatically accounted and this method shouldn't be called.
If key size varies, method ChronicleHashBuilder.keySize(int)
or ChronicleHashBuilder.entrySize(int)
should be
called instead of this one.
For example, if your keys are Git commit hashes:
Map<byte[], String> gitCommitMessagesByHash =
ChronicleMapBuilder.of(byte[].class, String.class)
.constantKeySizeBySample(new byte[20])
.create();
constantKeySizeBySample
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
sampleKey
- the sample keykeySize(int)
public B entrySize(int entrySize)
ChronicleMap
and ChronicleSet
store their data off-heap, so it is required
to serialize key (and values, in ChronicleMap
case) (unless they are direct Byteable
instances). Serialized key bytes (+ serialized value bytes, in ChronicleMap
case) + some metadata bytes comprise "entry space", which ChronicleMap
or ChronicleSet
should allocate. So entry size is a minimum allocation portion in the
hash containers, created by this builder. E. g. if entry size is 100, the created container
could only allocate 100, 200, 300... bytes for an entry. If say 150 bytes of entry space are
required by the entry, 200 bytes will be allocated, 150 used and 50 wasted. To minimize
memory overuse and improve speed, you should pay decent attention to this configuration.
There are three major patterns of this configuration usage:
ChronicleMap
case) sizes are constant. Configure them via ChronicleHashBuilder.constantKeySizeBySample(Object)
and ChronicleMapBuilder.constantValueSizeBySample(Object)
methods, and you will experience no memory waste at all.ChronicleMap
case) varies moderately. Specify them using corresponding methods, or
specify entry size directly by calling this method, by sizes somewhere between average and
maximum possible. The idea is to have most (90% or more) entries to fit a single "entry size"
with moderate memory waste (10-20% on average), rest 10% or less of entries should take 2
"entry sizes", thus with ~50% memory overuse.ChronicleMap
case) varies in a wide range. Then it's best to use entry size configuration in
chunk mode. Specify entry size so that most entries should take from 5 to several
dozens of "chunks". With this approach, average memory waste should be very low.
However, remember that
IllegalArgumentException
is thrown
on attempt to insert too large entry, compared to the configured or computed entry size.Example: if values in your ChronicleMap
are adjacency lists of some social graph,
where nodes are represented as long
ids, and adjacency lists are serialized in
efficient manner, for example as long[]
arrays. Typical number of connections is
100-300, maximum is 3000. In this case entry size of
50 * (8 bytes for each id) = 400 bytes would be a good choice:
Map<Long, long[]> socialGraph = ChronicleMapBuilder
.of(Long.class, long[].class)
// given that graph should have of 1 billion nodes, and 150 average adjacency list size
// => values takes 3 chuncks on average
.entries(1_000_000_000L * (150 / 50))
.entrySize(50 * 8)
.create();
It is minimum possible (because 3000 friends / 50 friends = 60 is close to 64 "max chunks by
single entry" limit, and ensures moderate average memory overuse (not more than 20%). In fully default case you can expect entry size to be about 256 bytes. But it is strongly recommended always to configure key size and value size, if they couldn't be derived statically.
If entry size is not configured explicitly by calling this method, it is computed based on meta data bytes, plus key size, plus value size, plus a few bytes required by implementations.
entrySize
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
entrySize
- the "chunk size" in bytesentries(long)
public B entries(long entries)
ChronicleHashBuilder
IllegalStateException
might be
thrown, because currently ChronicleMap
and ChronicleSet
doesn't support
resizing.
ChronicleMap
case) is constant, this number
is equal to the maximum number of entries (because each entry takes exactly one "entry size"
memory unit).ChronicleMap
case) size varies
moderately, you should pass to this method the maximum number of entries + 5-25%, depending
on your data properties and configured key/value/entry sizes.ChronicleHashBuilder.entrySize(int)
method.You shouldn't put additional margin over the number, computed according the rules above.
This bad practice was popularized by HashMap.HashMap(int)
and HashSet.HashSet(int)
constructors, which accept "capacity", that should be multiplied by
"load factor" to obtain actual maximum expected number of entries. ChronicleMap
and
ChronicleSet
don't have a notion of load factor.
Default value is 2^20 (~ 1 million).
entries
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
entries
- maximum size of the created maps, in memory allocation units, so-called "entry
size"ChronicleHashBuilder.entrySize(int)
public B actualEntriesPerSegment(long actualEntriesPerSegment)
actualEntriesPerSegment
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
public B minSegments(int minSegments)
ChronicleHashBuilder
ConcurrentHashMap
.minSegments
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
minSegments
- the minimum number of segments in containers, constructed by this builderpublic B actualSegments(int actualSegments)
actualSegments
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
public B lockTimeOut(long lockTimeOut, TimeUnit unit)
ChronicleHashBuilder
ChronicleHashErrorListener.onLockTimeout(long)
is
called, and then thread tries to obtain the segment lock one more time, and so in a loop,
until thread is interrupted. However, you can configure error listener to throw an exception on the first (or n-th) lock
acquisition fail.
Default lock time out is 2 seconds.
lockTimeOut
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
lockTimeOut
- new lock timeout for segments of containers created by this builder, in
the given time unitsunit
- time unit of the given lock timeoutpublic B errorListener(ChronicleHashErrorListener errorListener)
errorListener
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
public B putReturnsNull(boolean putReturnsNull)
null
instead of previous
mapped values on ChornicleMap.put(key, value)
calls.
Map.put()
returns the previous value, functionality which
is rarely used but fairly cheap for HashMap
. In the case, for an off heap collection,
it has to create a new object and deserialize the data from off-heap memory. It's expensive
for something you probably don't use.
By default, of cause, ChronicleMap
conforms the general Map
contract and returns the previous mapped value on put()
calls.
putReturnsNull
- true
if you want ChronicleMap.put()
to not return the value that was replaced but
instead return null
removeReturnsNull(boolean)
public B removeReturnsNull(boolean removeReturnsNull)
null
instead of the last
mapped value on ChronicleMap.remove(key)
calls.
Map.remove()
returns the previous value, functionality which is
rarely used but fairly cheap for HashMap
. In the case, for an off heap collection, it
has to create a new object and deserialize the data from off-heap memory. It's expensive for
something you probably don't use.
removeReturnsNull
- true
if you want ChronicleMap.remove()
to not return the value of the removed entry
but instead return null
putReturnsNull(boolean)
public B metaDataBytes(int metaDataBytes)
metaDataBytes
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
public B replicators(byte identifier, ReplicationConfig... replicationConfigs)
ChronicleHashBuilder
Another way to establish replication is ChronicleHashBuilder.channel(ChannelProvider.ChronicleChannel)
method.
By default, hash containers, created by this builder doesn't replicate their data.
This method call overrides all previous replication configurations of this builder, made
either by this method or ChronicleHashBuilder.channel(ChannelProvider.ChronicleChannel)
method.
replicators
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
identifier
- the new identifier of the containers,
created by this builderreplicationConfigs
- several replicators, used to sync the data across replicating nodes
independentlyChronicleHashBuilder.channel(ChannelProvider.ChronicleChannel)
,
ChronicleHashBuilder.disableReplication()
public B channel(ChannelProvider.ChronicleChannel chronicleChannel)
ChronicleHashBuilder
Another way to establish replication if ChronicleHashBuilder.replicators(byte, ReplicationConfig[])
method.
By default, hash containers, created by this builder doesn't replicate their data.
This method call overrides all previous replication configurations of this builder, made
either by means of this method or ChronicleHashBuilder.replicators(byte, ReplicationConfig[])
method
calls.
channel
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
chronicleChannel
- the channel responsible for gathering updates of hash containers,
created by this builder, and replicating them over networkChronicleHashBuilder.replicators(byte, ReplicationConfig[])
,
ChronicleHashBuilder.disableReplication()
public B disableReplication()
ChronicleHashBuilder
ChronicleHashBuilder.replicators(byte, ReplicationConfig[])
or ChronicleHashBuilder.channel(ChannelProvider.ChronicleChannel)
method call.
By default replication is not configured, so this method is useful only to ensure that hash containers, created by some inherited or passed builder, wouldn't replicate. I. e. in rare cases.
disableReplication
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
ChronicleHashBuilder.replicators(byte, ReplicationConfig[])
,
ChronicleHashBuilder.channel(ChannelProvider.ChronicleChannel)
public B timeProvider(TimeProvider timeProvider)
ChronicleHashBuilder
Default time provider is TimeProvider.SYSTEM
.
timeProvider
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
timeProvider
- a new time provider for replication needsChronicleHashBuilder.replicators(byte, ReplicationConfig[])
,
ChronicleHashBuilder.channel(ChannelProvider.ChronicleChannel)
public B bytesMarshallerFactory(BytesMarshallerFactory bytesMarshallerFactory)
ChronicleHashBuilder
BytesMarshallerFactory
to be used with BytesMarshallableSerializer
, which is a default ObjectSerializer
,
to serialize/deserialize data to/from off-heap memory in hash containers, created by this
builder.
Default BytesMarshallerFactory
is an instance of VanillaBytesMarshallerFactory
. This is a convenience configuration method, it has no effect
on the resulting hash containers, if custom data
marshallers are configured, data types extends one of specific serialization interfaces,
recognized by this builder (e. g. Externalizable
or BytesMarshallable
), or
ObjectSerializer
is configured.
bytesMarshallerFactory
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
bytesMarshallerFactory
- the marshaller factory to be used with the default ObjectSerializer
, i. e. BytesMarshallableSerializer
ChronicleHashBuilder.objectSerializer(ObjectSerializer)
public B objectSerializer(ObjectSerializer objectSerializer)
ChronicleHashBuilder
Externalizable
or BytesMarshallable
(for example, if data is loosely typed and just
Object
is specified as the data class), or nullable data, and if custom marshaller is
not configured, in hash containers, created by
this builder. Please read ObjectSerializer
docs for more info and available options.
Default serializer is BytesMarshallableSerializer
, configured with the specified
or default BytesMarshallerFactory
.
objectSerializer
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
objectSerializer
- the serializer used to serialize loosely typed or nullable data if
custom marshaller is not configuredChronicleHashBuilder.bytesMarshallerFactory(BytesMarshallerFactory)
,
ChronicleHashBuilder.keyMarshaller(BytesMarshaller)
public B keyMarshaller(@NotNull BytesMarshaller<K> keyMarshaller)
BytesMarshaller
used to serialize/deserialize keys to/from off-heap
memory in hash containers, created by this builder. See the
section about serialization in ChronicleMap manual for more information.
Example:
keyMarshaller
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
keyMarshaller
- the marshaller used to serialize keysChronicleHashBuilder.objectSerializer(ObjectSerializer)
public B keyDeserializationFactory(@NotNull ObjectFactory<K> keyDeserializationFactory)
ChronicleHashBuilder
Byteable
, BytesMarshallable
or Externalizable
subclass in maps,
created by this builder. If custom key
marshaller is configured, this configuration is unused, because it is incapsulated in
BytesMarshaller.read(Bytes)
method (without provided instance to read the data into),
i. e. it's is the user-side responsibility.
Default key deserialization factory is NewInstanceObjectFactory
, which creates
a new key instance using Class.newInstance()
default constructor. You could provide
an AllocateInstanceObjectFactory
, which uses Unsafe.allocateInstance(Class)
(you might want to do this for better performance or if you don't want to initialize fields),
or a factory which calls a key class constructor with some arguments, or a factory which
internally delegates to instance pool or ThreadLocal
, to reduce allocations.
keyDeserializationFactory
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
keyDeserializationFactory
- the key factory used to produce instances to deserialize
data inpublic B immutableKeys()
ChronicleHashBuilder
ChronicleMap
or ChronicleSet
are not required
to be immutable, as in ordinary Map
or Set
implementations, because they are
serialized off-heap. However, ChronicleMap
and ChronicleSet
implementations
can benefit from the knowledge that keys are not mutated between queries.
By default, ChronicleHashBuilder
s detects immutability automatically only for very
few standard JDK types (for example, for String
), it is not recommended to rely on
ChronicleHashBuilder
to be smart enough about this.
immutableKeys
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
public B stateless(@NotNull StatelessBuilder statelessBuilder)
ChronicleHashBuilder
ChronicleMap
or ChronicleSet
which we will refer to
as the server. The server will hold all your data, the server can not it’s self be a
stateless client. Your stateless client must be connected to the server via TCP/IP. The
stateless client will delegate all your method calls to the remote sever. The stateless
client operations will block, in other words the stateless client will wait for the server to
send a response before continuing to the next operation. The stateless client could be
consider to be a ClientProxy to ChronicleMap
or ChronicleSet
running on
another hoststateless
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
statelessBuilder
- Stateless Client Config, null
demotes no statelessBuilderpublic B file(File file) throws IOException
ChronicleHashBuilder
file
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
file
- the file with existing hash container or a desired location of a new off-heap
persisted hash containerIOException
- If the file cannot be created and read.ChronicleHash.file()
,
ChronicleHash.close()
public B valueDeserializationFactory(@NotNull ObjectFactory<V> valueDeserializationFactory)
Byteable
, BytesMarshallable
or Externalizable
subclass in maps,
created by this builder.
Default value deserialization factory is NewInstanceObjectFactory
, which creates a
new value instance using Class.newInstance()
default constructor. You could provide
an AllocateInstanceObjectFactory
, which uses Unsafe.allocateInstance(Class)
(you might want to do this for better performance or if you don't want to initialize fields),
or a factory which calls a value class constructor with some arguments, or a factory which
internally delegates to instance pool or ThreadLocal
, to reduce allocations.
valueDeserializationFactory
- the value factory used to produce instances to deserialize
data inpublic B eventListener(MapEventListener<K,V,ChronicleMap<K,V>> eventListener)
public B defaultValue(V defaultValue)
acquireUsing()
method, if the key is absent in the map, created by this builder.
This configuration overrides any previous defaultValueProvider(DefaultValueProvider)
configuration to this AbstractChronicleMapBuilder
.
defaultValue
- the default value to be put to the map for absent keys during acquireUsing()
callspublic B defaultValueProvider(@NotNull DefaultValueProvider<K,V> defaultValueProvider)
acquireUsing()
calls, if the key is absent in the map, created by this builder.
This configuration overrides any previous defaultValue(Object)
configuration to
this AbstractChronicleMapBuilder
.
defaultValueProvider
- the strategy to obtain a default value by the absent keypublic ChronicleMap<K,V> createWithFile(File file) throws IOException
IOException
public ChronicleMap<K,V> create() throws IOException
ChronicleHashBuilder
ChronicleHash.close()
called on the returned container, or after the container
object is collected during GC, or on JVM shutdown the off-heap memory used by the returned
container is freed.create
in interface ChronicleHashBuilder<K,ChronicleMap<K,V>,B extends AbstractChronicleMapBuilder<K,V,B>>
IOException
- if any IO error relates to off-heap memory allocation occursChronicleHashBuilder.create()
public byte identifier()
public int segmentHeaderSize()
Copyright © 2014. All rights reserved.