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(Map<String,Object> config)`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`adjustStoreToLastChunk()`
Make persistent changes after lastChunk was reset
`protected void`
`allocateChunkSpace(org.h2.mvstore.MFChunk chunk, WriteBuffer buff)`
Allocate logical space and assign position of the buffer within the store.
`void`
`backup(ZipOutputStream out)`
`void`
`close()`
Close this store.
`protected void`
`compactStore(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 final org.h2.mvstore.MFChunk`
`createChunk(int newChunkId)`
`org.h2.mvstore.MFChunk`
`createChunk(String s)`
Build a Chunk from the given string.
`protected org.h2.mvstore.MFChunk`
`createChunk(Map<String,String> map)`
`protected void`
`doHousekeeping(MVStore mvStore)`
`protected void`
`freeChunkSpace(Iterable<org.h2.mvstore.MFChunk> chunks)`
Mark the space occupied by specified chunks as free.
`int`
`getFillRate()`
`protected void`
`initializeStoreHeader(long time)`
`void`
`markUsed(long pos, int length)`
Mark the space as in use.
`AppendOnlyMultiFileStore`
`open(String fileName, boolean readOnly)`
`void`
`open(String fileName, boolean readOnly, char[] encryptionKey)`
`ByteBuffer`
`readFully(org.h2.mvstore.MFChunk chunk, long pos, int len)`
Read data from the store.
`protected void`
`readStoreHeader(boolean recoveryMode)`
`boolean`
`shouldSaveNow(int unsavedMemory, int autoCommitMemory)`
Decision about autocommit is delegated to store
`protected void`
`shrinkStoreIfPossible(int minPercent)`
Shrink store if possible, and if at least a given percentage can be saved.
`protected boolean`
`validateFileLength(String msg)`
`protected void`
`writeChunk(org.h2.mvstore.MFChunk chunk, WriteBuffer buff)`
Write buffer associated with chunk into store at chunk's allocated position
`protected void`
`writeCleanShutdownMark()`
Performs final preparation before store is closed normally
`protected void`
`writeFully(org.h2.mvstore.MFChunk chunk, long pos, 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, sync, writeCleanShutdown`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### AppendOnlyMultiFileStore

public AppendOnlyMultiFileStore(Map<String,Object> config)

## Method Details

### createChunk

protected final org.h2.mvstore.MFChunk createChunk(int newChunkId)

Specified by:
  `createChunk` in class `FileStore<org.h2.mvstore.MFChunk>`

### createChunk

public org.h2.mvstore.MFChunk createChunk(String s)
Description copied from class: `FileStore`
Build a Chunk from the given string.

Specified by:
  `createChunk` in class `FileStore<org.h2.mvstore.MFChunk>`
Parameters:
  `s` - the string
Returns:
  the Chunk created

### createChunk

protected org.h2.mvstore.MFChunk createChunk(Map<String,String> map)

Specified by:
  `createChunk` in class `FileStore<org.h2.mvstore.MFChunk>`

### shouldSaveNow

public boolean shouldSaveNow(int unsavedMemory, int autoCommitMemory)
Description copied from class: `FileStore`
Decision about autocommit is delegated to store

Specified by:
  `shouldSaveNow` in class `FileStore<org.h2.mvstore.MFChunk>`
Parameters:
  `unsavedMemory` - amount of unsaved memory, so far
  `autoCommitMemory` - configured limit on amount of unsaved memory
Returns:
  true if commit should happen now

### open

public void open(String fileName, boolean readOnly, char[] encryptionKey)

Specified by:
  `open` in class `FileStore<org.h2.mvstore.MFChunk>`

### open

public AppendOnlyMultiFileStore open(String fileName, boolean readOnly)

Specified by:
  `open` in class `FileStore<org.h2.mvstore.MFChunk>`

### close

public void close()
Close this store.

Overrides:
  `close` in class `FileStore<org.h2.mvstore.MFChunk>`

### writeFully

protected void writeFully(org.h2.mvstore.MFChunk chunk, long pos, ByteBuffer src)
Description copied from class: `FileStore`
Write to the file.

Specified by:
  `writeFully` in class `FileStore<org.h2.mvstore.MFChunk>`
Parameters:
  `chunk` - to write
  `pos` - the write position
  `src` - the source buffer

### readFully

public ByteBuffer readFully(org.h2.mvstore.MFChunk chunk, long pos, int len)
Description copied from class: `FileStore`
Read data from the store.

Specified by:
  `readFully` in class `FileStore<org.h2.mvstore.MFChunk>`
Parameters:
  `chunk` - that owns data to be read
  `pos` - the read "position"
  `len` - the number of bytes to read
Returns:
  the byte buffer with data requested

### initializeStoreHeader

protected void initializeStoreHeader(long time)

Specified by:
  `initializeStoreHeader` in class `FileStore<org.h2.mvstore.MFChunk>`

### readStoreHeader

protected void readStoreHeader(boolean recoveryMode)

Specified by:
  `readStoreHeader` in class `FileStore<org.h2.mvstore.MFChunk>`

### allocateChunkSpace

protected void allocateChunkSpace(org.h2.mvstore.MFChunk chunk, WriteBuffer buff)
Description copied from class: `FileStore`
Allocate logical space and assign position of the buffer within the store.

Specified by:
  `allocateChunkSpace` in class `FileStore<org.h2.mvstore.MFChunk>`
Parameters:
  `chunk` - to allocate space for
  `buff` - to allocate space for

### writeChunk

protected void writeChunk(org.h2.mvstore.MFChunk chunk, WriteBuffer buff)
Description copied from class: `FileStore`
Write buffer associated with chunk into store at chunk's allocated position

Specified by:
  `writeChunk` in class `FileStore<org.h2.mvstore.MFChunk>`
Parameters:
  `chunk` - chunk to write
  `buff` - to write

### writeCleanShutdownMark

protected void writeCleanShutdownMark()
Description copied from class: `FileStore`
Performs final preparation before store is closed normally

Specified by:
  `writeCleanShutdownMark` in class `FileStore<org.h2.mvstore.MFChunk>`

### adjustStoreToLastChunk

protected void adjustStoreToLastChunk()
Description copied from class: `FileStore`
Make persistent changes after lastChunk was reset

Specified by:
  `adjustStoreToLastChunk` in class `FileStore<org.h2.mvstore.MFChunk>`

### compactStore

protected void compactStore(int thresholdFillRate, long maxCompactTime, int maxWriteSize, MVStore mvStore)
Description copied from class: `FileStore`
Compact 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:
  `compactStore` in class `FileStore<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 compact
  `maxWriteSize` - the maximum amount of data to be written as part of this call
  `mvStore` - that owns this FileStore

### doHousekeeping

protected void doHousekeeping(MVStore mvStore) throws InterruptedException

Specified by:
  `doHousekeeping` in class `FileStore<org.h2.mvstore.MFChunk>`
Throws:
  `InterruptedException`

### getFillRate

public int getFillRate()

Specified by:
  `getFillRate` in class `FileStore<org.h2.mvstore.MFChunk>`

### shrinkStoreIfPossible

protected void shrinkStoreIfPossible(int minPercent)
Description copied from class: `FileStore`
Shrink store if possible, and if at least a given percentage can be saved.

Specified by:
  `shrinkStoreIfPossible` in class `FileStore<org.h2.mvstore.MFChunk>`
Parameters:
  `minPercent` - the minimum percentage to save

### markUsed

public void markUsed(long pos, int length)
Description copied from class: `FileStore`
Mark the space as in use.

Specified by:
  `markUsed` in class `FileStore<org.h2.mvstore.MFChunk>`
Parameters:
  `pos` - the position in bytes
  `length` - the number of bytes

### freeChunkSpace

protected void freeChunkSpace(Iterable<org.h2.mvstore.MFChunk> chunks)
Description copied from class: `FileStore`
Mark the space occupied by specified chunks as free.

Specified by:
  `freeChunkSpace` in class `FileStore<org.h2.mvstore.MFChunk>`
Parameters:
  `chunks` - chunks to be processed

### validateFileLength

protected boolean validateFileLength(String msg)

Specified by:
  `validateFileLength` in class `FileStore<org.h2.mvstore.MFChunk>`

### backup

public void backup(ZipOutputStream out) throws IOException

Specified by:
  `backup` in class `FileStore<org.h2.mvstore.MFChunk>`
Throws:
  `IOException`