Package org.h2.mvstore
Class AppendOnlyMultiFileStore
- java.lang.Object
-
- org.h2.mvstore.FileStore<org.h2.mvstore.MFChunk>
-
- org.h2.mvstore.AppendOnlyMultiFileStore
-
public final class AppendOnlyMultiFileStore extends FileStore<org.h2.mvstore.MFChunk>
Class AppendOnlyMultiFileStore.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.h2.mvstore.FileStore
FileStore.PageSerializationManager
-
-
Field Summary
-
Fields inherited from class org.h2.mvstore.FileStore
lastChunk, META_ID_KEY, PIPE_LENGTH, readBytes, readCount, recoveryMode, saveChunkLock, storeHeader, writeBytes, writeCount
-
-
Constructor Summary
Constructors Constructor Description AppendOnlyMultiFileStore(java.util.Map<java.lang.String,java.lang.Object> config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadjustStoreToLastChunk()Make persistent changes after lastChunk was resetprotected voidallocateChunkSpace(org.h2.mvstore.MFChunk chunk, WriteBuffer buff)Allocate logical space and assign position of the buffer within the store.voidbackup(java.util.zip.ZipOutputStream out)voidclose()Close this store.protected voidcompactStore(int thresholdFillRate, long maxCompactTime, int maxWriteSize, MVStore mvStore)Compact store file, that is, compact blocks that have a low fill rate, and move chunks next to each other.protected org.h2.mvstore.MFChunkcreateChunk(int newChunkId)org.h2.mvstore.MFChunkcreateChunk(java.lang.String s)Build a Chunk from the given string.protected org.h2.mvstore.MFChunkcreateChunk(java.util.Map<java.lang.String,java.lang.String> map)protected voiddoHousekeeping(MVStore mvStore)protected voidfreeChunkSpace(java.lang.Iterable<org.h2.mvstore.MFChunk> chunks)Mark the space occupied by specified chunks as free.intgetFillRate()protected voidinitializeStoreHeader(long time)voidmarkUsed(long pos, int length)Mark the space as in use.AppendOnlyMultiFileStoreopen(java.lang.String fileName, boolean readOnly)voidopen(java.lang.String fileName, boolean readOnly, char[] encryptionKey)java.nio.ByteBufferreadFully(org.h2.mvstore.MFChunk chunk, long pos, int len)Read data from the store.protected voidreadStoreHeader(boolean recoveryMode)booleanshouldSaveNow(int unsavedMemory, int autoCommitMemory)Decision about autocommit is delegated to storeprotected voidshrinkStoreIfPossible(int minPercent)Shrink store if possible, and if at least a given percentage can be saved.protected booleanvalidateFileLength(java.lang.String msg)protected voidwriteChunk(org.h2.mvstore.MFChunk chunk, WriteBuffer buff)Write buffer associated with chunk into store at chunk's allocated positionprotected voidwriteCleanShutdownMark()Performs final preparation before store is closed normallyprotected voidwriteFully(org.h2.mvstore.MFChunk chunk, long pos, java.nio.ByteBuffer src)Write to the file.-
Methods inherited from class org.h2.mvstore.FileStore
accountForRemovedPage, bind, clear, compact, compactStore, deregisterMapRoot, discoverChunk, dropUnusedChunks, executeFileStoreOperation, findLastChunkWithCompleteValidChunkSet, getAutoCommitDelay, getAutoCompactFillRate, getCacheHitRatio, getCacheSize, getCacheSizeUsed, getChunks, getChunksFillRate, getChunksFromLayoutMap, getCreationTime, getDefaultRetentionTime, getFileName, getLayoutMap, getMaxPageSize, getMetaMapId, getMvStore, getReadBytes, getReadCount, getRetentionTime, getRewriteCandidates, getRootPos, getStoreHeader, getTocCacheHitRatio, getWriteBuffer, getWriteCount, hasChangesSince, hasPersistentData, init, initializeCommonHeaderAttributes, isIdle, isKnownVersion, isReadOnly, isRegularMap, isSpaceReused, lastChunkVersion, populateInfo, processCommonHeaderAttributes, readChunkFooter, readChunkHeaderAndFooter, readChunkHeaderOptionally, readChunkHeaderOptionally, readFully, registerDeadChunk, releaseWriteBuffer, rewriteChunks, rollbackTo, saveChunkMetadataChanges, setAutoCommitDelay, setCacheSize, setLastChunk, setRetentionTime, setReuseSpace, setSize, size, start, stop, store, submitOrRun, sync, writeCleanShutdown
-
-
-
-
Method Detail
-
createChunk
protected final org.h2.mvstore.MFChunk createChunk(int newChunkId)
- Specified by:
createChunkin classFileStore<org.h2.mvstore.MFChunk>
-
createChunk
public org.h2.mvstore.MFChunk createChunk(java.lang.String s)
Description copied from class:FileStoreBuild a Chunk from the given string.- Specified by:
createChunkin classFileStore<org.h2.mvstore.MFChunk>- Parameters:
s- the string- Returns:
- the Chunk created
-
createChunk
protected org.h2.mvstore.MFChunk createChunk(java.util.Map<java.lang.String,java.lang.String> map)
- Specified by:
createChunkin classFileStore<org.h2.mvstore.MFChunk>
-
shouldSaveNow
public boolean shouldSaveNow(int unsavedMemory, int autoCommitMemory)Description copied from class:FileStoreDecision about autocommit is delegated to store- Specified by:
shouldSaveNowin classFileStore<org.h2.mvstore.MFChunk>- Parameters:
unsavedMemory- amount of unsaved memory, so farautoCommitMemory- configured limit on amount of unsaved memory- Returns:
- true if commit should happen now
-
open
public void open(java.lang.String fileName, boolean readOnly, char[] encryptionKey)
-
open
public AppendOnlyMultiFileStore open(java.lang.String fileName, boolean readOnly)
-
close
public void close()
Close this store.
-
writeFully
protected void writeFully(org.h2.mvstore.MFChunk chunk, long pos, java.nio.ByteBuffer src)Description copied from class:FileStoreWrite to the file.- Specified by:
writeFullyin classFileStore<org.h2.mvstore.MFChunk>- Parameters:
chunk- to writepos- the write positionsrc- the source buffer
-
readFully
public java.nio.ByteBuffer readFully(org.h2.mvstore.MFChunk chunk, long pos, int len)Description copied from class:FileStoreRead data from the store.
-
initializeStoreHeader
protected void initializeStoreHeader(long time)
- Specified by:
initializeStoreHeaderin classFileStore<org.h2.mvstore.MFChunk>
-
readStoreHeader
protected void readStoreHeader(boolean recoveryMode)
- Specified by:
readStoreHeaderin classFileStore<org.h2.mvstore.MFChunk>
-
allocateChunkSpace
protected void allocateChunkSpace(org.h2.mvstore.MFChunk chunk, WriteBuffer buff)Description copied from class:FileStoreAllocate logical space and assign position of the buffer within the store.- Specified by:
allocateChunkSpacein classFileStore<org.h2.mvstore.MFChunk>- Parameters:
chunk- to allocate space forbuff- to allocate space for
-
writeChunk
protected void writeChunk(org.h2.mvstore.MFChunk chunk, WriteBuffer buff)Description copied from class:FileStoreWrite buffer associated with chunk into store at chunk's allocated position- Specified by:
writeChunkin classFileStore<org.h2.mvstore.MFChunk>- Parameters:
chunk- chunk to writebuff- to write
-
writeCleanShutdownMark
protected void writeCleanShutdownMark()
Description copied from class:FileStorePerforms final preparation before store is closed normally- Specified by:
writeCleanShutdownMarkin classFileStore<org.h2.mvstore.MFChunk>
-
adjustStoreToLastChunk
protected void adjustStoreToLastChunk()
Description copied from class:FileStoreMake persistent changes after lastChunk was reset- Specified by:
adjustStoreToLastChunkin classFileStore<org.h2.mvstore.MFChunk>
-
compactStore
protected void compactStore(int thresholdFillRate, long maxCompactTime, int maxWriteSize, MVStore mvStore)Description copied from class:FileStoreCompact store file, that is, compact blocks that have a low fill rate, and move chunks next to each other. This will typically shrink the file. Changes are flushed to the file, and old chunks are overwritten.- Specified by:
compactStorein classFileStore<org.h2.mvstore.MFChunk>- Parameters:
thresholdFillRate- do not compact if store fill rate above this value (0-100)maxCompactTime- the maximum time in milliseconds to compactmaxWriteSize- the maximum amount of data to be written as part of this callmvStore- that owns this FileStore
-
doHousekeeping
protected void doHousekeeping(MVStore mvStore) throws java.lang.InterruptedException
- Specified by:
doHousekeepingin classFileStore<org.h2.mvstore.MFChunk>- Throws:
java.lang.InterruptedException
-
getFillRate
public int getFillRate()
- Specified by:
getFillRatein classFileStore<org.h2.mvstore.MFChunk>
-
shrinkStoreIfPossible
protected void shrinkStoreIfPossible(int minPercent)
Description copied from class:FileStoreShrink store if possible, and if at least a given percentage can be saved.- Specified by:
shrinkStoreIfPossiblein classFileStore<org.h2.mvstore.MFChunk>- Parameters:
minPercent- the minimum percentage to save
-
markUsed
public void markUsed(long pos, int length)Description copied from class:FileStoreMark the space as in use.
-
freeChunkSpace
protected void freeChunkSpace(java.lang.Iterable<org.h2.mvstore.MFChunk> chunks)
Description copied from class:FileStoreMark the space occupied by specified chunks as free.- Specified by:
freeChunkSpacein classFileStore<org.h2.mvstore.MFChunk>- Parameters:
chunks- chunks to be processed
-
validateFileLength
protected boolean validateFileLength(java.lang.String msg)
- Specified by:
validateFileLengthin classFileStore<org.h2.mvstore.MFChunk>
-
-