org.h2.mvstore

## Class SingleFileStore

- java.lang.Object
- - org.h2.mvstore.FileStore<org.h2.mvstore.SFChunk>
  - - org.h2.mvstore.RandomAccessStore
    - - org.h2.mvstore.SingleFileStore

    public class SingleFileStore
    extends RandomAccessStore

The default storage mechanism of the MVStore. This implementation persists data to a file. The file store is responsible to persist data and for free space management.

### Nested Class Summary

### Nested classes/interfaces inherited from class org.h2.mvstore.FileStore

`FileStore.PageSerializationManager`

### Field Summary

### Fields inherited from class org.h2.mvstore.RandomAccessStore

`freeSpace`

### 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 and Description
`SingleFileStore(java.util.Map<java.lang.String,java.lang.Object> config)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `backup(java.util.zip.ZipOutputStream out)`
`void` `close()` Close this store.
`static java.lang.String` `correctFileName(java.lang.String f)` Fix the file name, replacing backslash with slash.
`protected long` `getAfterLastBlock_()`
`int` `getMovePriority(int block)` Calculates relative "priority" for chunk to be moved.
`SingleFileStore` `open(java.lang.String fileName, boolean readOnly)`
`void` `open(java.lang.String fileName, boolean readOnly, char[] encryptionKey)` Try to open the file.
`java.nio.ByteBuffer` `readFully(org.h2.mvstore.SFChunk chunk, long pos, int len)` Read data from the store.
`void` `sync()` Flush all changes.
`java.lang.String` `toString()`
`void` `truncate(long size)` Truncate the file.
`protected void` `writeFully(org.h2.mvstore.SFChunk chunk, long pos, java.nio.ByteBuffer src)` Write to the file.

### Methods inherited from class org.h2.mvstore.RandomAccessStore

`adjustStoreToLastChunk, allocateChunkSpace, clear, compactMoveChunks, compactStore, createChunk, createChunk, createChunk, doHousekeeping, free, freeChunkSpace, getFillRate, getRewriteCandidates, initializeStoreHeader, isSpaceReused, markUsed, readStoreHeader, setReuseSpace, shouldSaveNow, shrinkStoreIfPossible, validateFileLength, writeChunk, writeCleanShutdownMark`

### Methods inherited from class org.h2.mvstore.FileStore

`accountForRemovedPage, bind, 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, getRootPos, getStoreHeader, getTocCacheHitRatio, getWriteBuffer, getWriteCount, hasChangesSince, hasPersistentData, init, initializeCommonHeaderAttributes, isIdle, isKnownVersion, isReadOnly, isRegularMap, lastChunkVersion, populateInfo, processCommonHeaderAttributes, readChunkFooter, readChunkHeaderAndFooter, readChunkHeaderOptionally, readChunkHeaderOptionally, readFully, registerDeadChunk, releaseWriteBuffer, rewriteChunks, rollbackTo, saveChunkMetadataChanges, setAutoCommitDelay, setCacheSize, setLastChunk, setRetentionTime, setSize, size, start, stop, store, writeCleanShutdown`

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

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

### Constructor Detail

#### SingleFileStore

    public SingleFileStore(java.util.Map<java.lang.String,java.lang.Object> config)

### Method Detail

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

#### readFully

    public java.nio.ByteBuffer readFully(org.h2.mvstore.SFChunk chunk,
                                         long pos,
                                         int len)

Description copied from class: `FileStore`
Read data from the store.

Specified by:
  `readFully` in class `FileStore<org.h2.mvstore.SFChunk>`
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

#### writeFully

    protected void writeFully(org.h2.mvstore.SFChunk chunk,
                              long pos,
                              java.nio.ByteBuffer src)

Description copied from class: `FileStore`
Write to the file.

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

#### open

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

Try to open the file.

Specified by:
  `open` in class `FileStore<org.h2.mvstore.SFChunk>`
Parameters:
  `fileName` - the file name
  `readOnly` - whether the file should only be opened in read-only mode, even if the file is writable
  `encryptionKey` - the encryption key, or null if encryption is not

#### open

    public SingleFileStore open(java.lang.String fileName,
                                boolean readOnly)

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

#### close

    public void close()

Close this store.

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

#### sync

    public void sync()

Flush all changes.

Overrides:
  `sync` in class `FileStore<org.h2.mvstore.SFChunk>`

#### truncate

    public void truncate(long size)

Truncate the file.

Specified by:
  `truncate` in class `RandomAccessStore`
Parameters:
  `size` - the new file size

#### getMovePriority

    public int getMovePriority(int block)

Calculates relative "priority" for chunk to be moved.

Overrides:
  `getMovePriority` in class `RandomAccessStore`
Parameters:
  `block` - where chunk starts
Returns:
  priority, bigger number indicate that chunk need to be moved sooner

#### getAfterLastBlock_

    protected long getAfterLastBlock_()

Overrides:
  `getAfterLastBlock_` in class `RandomAccessStore`

#### backup

    public void backup(java.util.zip.ZipOutputStream out)
                throws java.io.IOException

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

#### correctFileName

    public static java.lang.String correctFileName(java.lang.String f)

Fix the file name, replacing backslash with slash.

Parameters:
  `f` - the file name
Returns:
  the corrected file name