|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.h2.mvstore.MVStore
public class MVStore
A persistent storage for maps.
| Nested Class Summary | |
|---|---|
static class |
MVStore.Builder
A builder for an MVStore. |
| Field Summary | |
|---|---|
static boolean |
ASSERT
Whether assertions are enabled. |
| Method Summary | ||
|---|---|---|
void |
close()
Close the file and the store. |
|
void |
closeImmediately()
Close the file and the store, without writing anything. |
|
long |
commit()
Commit the changes. |
|
boolean |
compact(int fillRate)
Try to reduce the file size by re-writing partially full chunks. |
|
boolean |
compactMoveChunks()
Compact the store by moving all chunks next to each other, if there is free space between chunks. |
|
long |
getCommittedVersion()
Get the last committed version. |
|
long |
getCurrentVersion()
Get the current version of the data. |
|
FileStore |
getFileStore()
Get the file store. |
|
MVMap<java.lang.String,java.lang.String> |
getMetaMap()
Get the metadata map. |
|
int |
getPageSplitSize()
|
|
long |
getRetainVersion()
Get the oldest version to retain in memory. |
|
int |
getRetentionTime()
|
|
boolean |
getReuseSpace()
|
|
java.util.Map<java.lang.String,java.lang.String> |
getStoreHeader()
Get the store header. |
|
int |
getStoreVersion()
Get the store version. |
|
int |
getUnsavedPageCount()
Get the estimated number of unsaved pages. |
|
int |
getUnsavedPageCountMax()
Get the maximum number of unsaved pages. |
|
int |
getWriteDelay()
|
|
boolean |
hasMap(java.lang.String name)
Check whether a given map exists. |
|
boolean |
hasUnsavedChanges()
Check whether there are any unsaved changes. |
|
long |
incrementVersion()
Increment the current version, without committing the changes. |
|
boolean |
isClosed()
|
|
static MVStore |
open(java.lang.String fileName)
Open a store in exclusive mode. |
|
|
openMap(java.lang.String name)
Open a map with the default settings. |
|
|
openMap(java.lang.String name,
MVMap.MapBuilder<M,K,V> builder)
Open a map with the given builder. |
|
void |
rollbackTo(long version)
Revert to the beginning of the given version. |
|
void |
setCacheSize(int mb)
Set the read cache size in MB. |
|
void |
setRetainVersion(long retainVersion)
Which version to retain in memory. |
|
void |
setRetentionTime(int ms)
How long to retain old, persisted chunks, in milliseconds. |
|
void |
setReuseSpace(boolean reuseSpace)
Whether empty space in the file should be re-used. |
|
void |
setStoreVersion(int version)
Update the store version. |
|
void |
setWriteDelay(int millis)
Set the maximum delay in milliseconds to store committed changes (for file-based stores). |
|
long |
store()
Commit all changes and persist them to disk. |
|
void |
sync()
Force all changes to be written to the storage. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final boolean ASSERT
| Method Detail |
|---|
public static MVStore open(java.lang.String fileName)
fileName - the file name (null for in-memory)
public <K,V> MVMap<K,V> openMap(java.lang.String name)
K - the key typeV - the value typename - the name of the map
public <M extends MVMap<K,V>,K,V> M openMap(java.lang.String name,
MVMap.MapBuilder<M,K,V> builder)
K - the key typeV - the value typename - the name of the mapbuilder - the map builder
public MVMap<java.lang.String,java.lang.String> getMetaMap()
It contains the following entries:
name.{name} = {mapId}
map.{mapId} = {map metadata}
root.{mapId} = {root position}
chunk.{chunkId} = {chunk metadata}
public boolean hasMap(java.lang.String name)
name - the map name
public void close()
It is not allowed to concurrently call close and store.
public void closeImmediately()
public long incrementVersion()
public long commit()
Unless the write delay is set to 0, this method does not write to the file. Instead, data is written after the delay, manually by calling the store method, when the write buffer is full, or when closing the store.
public long store()
One store operation may run at any time.
public boolean hasUnsavedChanges()
public boolean compactMoveChunks()
public void sync()
public boolean compact(int fillRate)
Only data of open maps can be moved. For maps that are not open, the old chunk is still referenced. Therefore, it is recommended to open all maps before calling this method.
fillRate - the minimum percentage of live entries
public int getPageSplitSize()
public boolean getReuseSpace()
public void setReuseSpace(boolean reuseSpace)
This setting is specially useful for online backup. To create an online backup, disable this setting, then copy the file (starting at the beginning of the file). In this case, concurrent backup and write operations are possible (obviously the backup process needs to be faster than the write operations).
reuseSpace - the new valuepublic int getRetentionTime()
public void setRetentionTime(int ms)
The default value is 45000 (45 seconds) when using the default file
store. It is assumed that a file system and hard disk will flush all
write buffers within this time. Using a lower value might be dangerous,
unless the file system and hard disk flush the buffers earlier. To
manually flush the buffers, use
MVStore.getFile().force(true), however please note that
according to various tests this does not always work as expected
depending on the operating system and hardware.
This setting is not persisted.
ms - how many milliseconds to retain old chunks (0 to overwrite them
as early as possible)public void setRetainVersion(long retainVersion)
retainVersion - the oldest version to retainpublic long getRetainVersion()
public int getUnsavedPageCount()
public int getUnsavedPageCountMax()
public int getStoreVersion()
public void setStoreVersion(int version)
version - the new store versionpublic void rollbackTo(long version)
version - the version to revert topublic long getCurrentVersion()
public long getCommittedVersion()
public FileStore getFileStore()
public java.util.Map<java.lang.String,java.lang.String> getStoreHeader()
public void setCacheSize(int mb)
mb - the cache size in MB.public boolean isClosed()
public void setWriteDelay(int millis)
The default is 1000, meaning committed changes are stored after at most one second.
When the value is set to -1, committed changes are only written when calling the store method. When the value is set to 0, committed changes are immediately written on a commit, but please note this decreases performance and does still not guarantee the disk will actually write the data.
millis - the maximum delaypublic int getWriteDelay()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||