public class StoreHeap extends Store implements Serializable
Modifier and Type | Field and Description |
---|---|
protected Queue<Long> |
freeRecids
Queue of deleted recids, those are reused for new records
|
protected AtomicLong |
maxRecid
Maximal returned recid, incremented if there are no free recids
|
protected static Object |
NULL |
protected ConcurrentNavigableMap<Long,Fun.Tuple2> |
records
All commited records in store
|
protected ConcurrentNavigableMap<Long,Fun.Tuple2> |
rollback
All not-yet commited records in store
|
protected static Fun.Tuple2 |
TOMBSTONE |
checksum, CHECKSUM_FLAG_MASK, CHUNK_SIZE, CHUNK_SIZE_MOD_MASK, compress, COMPRESS_FLAG_MASK, encrypt, ENCRYPT_FLAG_MASK, encryptionXTEA, locks, LOG, LZF, newRecidLock, password, recycledDataOuts, serializerPojo, serializerPojoInitLock, structuralLock
CATALOG_RECID, CHECK_RECORD, CLASS_INFO_RECID, LAST_RESERVED_RECID
Constructor and Description |
---|
StoreHeap() |
Modifier and Type | Method and Description |
---|---|
String |
calculateStatistics()
get some statistics about store.
|
boolean |
canRollback() |
void |
clearCache()
clears any underlying cache
|
void |
close()
Close store/cache.
|
void |
commit()
Makes all changes made since the previous commit/rollback permanent.
|
void |
compact() |
<A> boolean |
compareAndSwap(long recid,
A expectedOldValue,
A newValue,
Serializer<A> serializer)
Updates existing record in atomic (Compare And Swap) manner.
|
<A> void |
delete(long recid,
Serializer<A> serializer)
Remove existing record from store/cache
Recid must be a number returned by 'put' method.
|
<A> A |
get(long recid,
Serializer<A> serializer)
Get existing record.
|
long |
getCurrSize()
returns current size occupied by physical store (does not include index).
|
Iterator<Long> |
getFreeRecids() |
long |
getFreeSize()
returns free size in physical store (does not include index).
|
long |
getMaxRecid() |
ByteBuffer |
getRaw(long recid) |
long |
getSizeLimit()
returns maximal store size or `0` if there is no limit
|
boolean |
isClosed()
Checks whether Engine was closed.
|
boolean |
isReadOnly()
Check if you can write into this Engine.
|
long |
preallocate()
Preallocates recid for not yet created record.
|
void |
preallocate(long[] recids)
Preallocates recids for not yet created record.
|
<A> long |
put(A value,
Serializer<A> serializer)
Insert new record.
|
void |
rollback()
Undoes all changes made in the current transaction.
|
<A> void |
update(long recid,
A value,
Serializer<A> serializer)
Update existing record with new value.
|
void |
updateRaw(long recid,
ByteBuffer data) |
canSnapshot, closeListenerRegister, closeListenerUnregister, deserialize, expectedMasks, forDB, forEngine, getSerializerPojo, lockAllWrite, lockPos, newDataOut2, printStatistics, serialize, snapshot, unlockAllWrite
protected static final Fun.Tuple2 TOMBSTONE
protected static final Object NULL
protected final ConcurrentNavigableMap<Long,Fun.Tuple2> records
protected final ConcurrentNavigableMap<Long,Fun.Tuple2> rollback
protected final Queue<Long> freeRecids
protected final AtomicLong maxRecid
public long preallocate()
Engine
preallocate
in interface Engine
public void preallocate(long[] recids)
Engine
preallocate
in interface Engine
recids
- array to put result intopublic <A> long put(A value, Serializer<A> serializer)
Engine
public <A> A get(long recid, Serializer<A> serializer)
Engine
public <A> void update(long recid, A value, Serializer<A> serializer)
Engine
public <A> boolean compareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer)
Engine
oldValue==expectedOldValue
when old value is found in instance cacheoldValue
using serializer
and checking oldValue.equals(expectedOldValue)
expectedOldValue
using serializer
and comparing binary array with already serialized oldValue
compareAndSwap
in interface Engine
recid
- (record identifier) under which record was persisted.expectedOldValue
- old value to be compared with existing recordnewValue
- to be written if values are matchingserializer
- used to serialize record into binary formpublic <A> void delete(long recid, Serializer<A> serializer)
Engine
public void close()
Engine
NullPointerException
There is an configuration option DBMaker.closeOnJvmShutdown()
which uses shutdown hook to automatically
close Engine when JVM shutdowns.public boolean isClosed()
Engine
public void commit()
Engine
public void rollback() throws UnsupportedOperationException
Engine
UnsupportedOperationException
.rollback
in interface Engine
UnsupportedOperationException
- if transactions are disabledpublic boolean isReadOnly()
Engine
isReadOnly
in interface Engine
public void clearCache()
Engine
clearCache
in interface Engine
public boolean canRollback()
canRollback
in interface Engine
public long getMaxRecid()
getMaxRecid
in class Store
public ByteBuffer getRaw(long recid)
public Iterator<Long> getFreeRecids()
getFreeRecids
in class Store
public void updateRaw(long recid, ByteBuffer data)
public long getSizeLimit()
Store
getSizeLimit
in class Store
public long getCurrSize()
Store
getCurrSize
in class Store
public long getFreeSize()
Store
getFreeSize
in class Store
public String calculateStatistics()
Store
calculateStatistics
in class Store
Copyright © 2019. All rights reserved.