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

## Method Summary

Modifier and Type
Method
Description
`void`
`backup(ZipOutputStream out)`
`void`
`close()`
Close this store.
`static String`
`correctFileName(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(String fileName, boolean readOnly)`
`void`
`open(String fileName, boolean readOnly, char[] encryptionKey)`
Try to open the file.
`ByteBuffer`
`readFully(org.h2.mvstore.SFChunk chunk, long pos, int len)`
Read data from the store.
`void`
`sync()`
Flush all changes.
`String`
`toString()`
`void`
`truncate(long size)`
Truncate the file.
`protected void`
`writeFully(org.h2.mvstore.SFChunk chunk, long pos, 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 Details

### SingleFileStore

public SingleFileStore(Map<String,Object> config)

## Method Details

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### readFully

public 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, 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(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(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(ZipOutputStream out) throws IOException

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

### correctFileName

public static String correctFileName(String f)
Fix the file name, replacing backslash with slash.

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