Top Description Fields Constructors Methods
org.h2.mvstore

public Class SingleFileStore

extends RandomAccessStore
Class Inheritance
Imports
java.io.IOException, java.nio.ByteBuffer, java.nio.channels.FileChannel, .FileLock, .OverlappingFileLockException, java.util.Map, java.util.function.Function, java.util.zip.ZipEntry, .ZipOutputStream, org.h2.mvstore.cache.FilePathCache, org.h2.store.fs.FilePath, org.h2.store.fs.encrypt.FileEncrypt, .FilePathEncrypt, org.h2.util.IOUtils

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.

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>
private FileChannel
fileChannel

The file.

private FileLock
fileLock

The file lock.

private FileChannel
originalFileChannel

The encrypted file (if encryption is used).

Inherited from org.h2.mvstore.RandomAccessStore:
freeSpace

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
private static void
public void
close()

Overrides org.h2.mvstore.FileStore.close.

Close this store.

public static String

Returns:

the corrected file name
correctFileName
(String
the file name
f
)

Fix the file name, replacing backslash with slash.

protected long
public int

Returns:

priority, bigger number indicate that chunk need to be moved sooner
getMovePriority
(int
where chunk starts
block
)

Overrides org.h2.mvstore.RandomAccessStore.getMovePriority.

Calculates relative "priority" for chunk to be moved.

private FileLock
lockFileChannel(FileChannel fileChannel, boolean readOnly, String fileName)

public void
open(String
the file name
fileName
,
boolean
whether the file should only be opened in read-only mode, even if the file is writable
readOnly
,
char[]
the encryption key, or null if encryption is not
encryptionKey
)

Implements abstract org.h2.mvstore.FileStore.open.

Try to open the file.

public SingleFileStore
open(String fileName, boolean readOnly)

Implements abstract org.h2.mvstore.FileStore.open.

private void
open(String fileName, boolean readOnly, Function<FileChannel, FileChannel> encryptionTransformer)

public ByteBuffer
readFully(SFChunk
that owns data to be read
chunk
,
long
the read "position"
pos
,
int
the number of bytes to read
len
)

Implements abstract org.h2.mvstore.FileStore.readFully.

Read data from the store.

public void
sync()

Overrides org.h2.mvstore.FileStore.sync.

Flush all changes.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
truncate(long
the new file size
size
)

Implements abstract org.h2.mvstore.RandomAccessStore.truncate.

Truncate the file.

protected void
writeFully(SFChunk
to write
chunk
,
long
the write position
pos
,
ByteBuffer
the source buffer
src
)

Implements abstract org.h2.mvstore.FileStore.writeFully.

Write to the file.

Inherited from org.h2.mvstore.RandomAccessStore:
adjustStoreToLastChunkallocateChunkSpaceclearcompactMoveChunkscompactStorecreateChunkcreateChunkcreateChunkdoHousekeepingfreefreeChunkSpacegetFileLengthInUsegetFillRategetFirstFreegetRewriteCandidatesinitializeStoreHeaderisSpaceReusedmarkUsedreadStoreHeadersetReuseSpaceshouldSaveNowshrinkStoreIfPossiblevalidateFileLengthwriteChunkwriteCleanShutdownMark

Field Detail

configback to summary
private final Map<String, Object> config
fileChannelback to summary
private FileChannel fileChannel

The file.

fileLockback to summary
private FileLock fileLock

The file lock.

originalFileChannelback to summary
private FileChannel originalFileChannel

The encrypted file (if encryption is used).

Constructor Detail

SingleFileStoreback to summary
public SingleFileStore(Map<String, Object> config)

Method Detail

backupback to summary
public void backup(ZipOutputStream out) throws IOException

Implements abstract org.h2.mvstore.FileStore.backup.

Annotations
@Override
backupFileback to summary
private static void backupFile(ZipOutputStream out, String fileName, FileChannel in) throws IOException
closeback to summary
public void close()

Overrides org.h2.mvstore.FileStore.close.

Close this store.

Annotations
@Override
correctFileNameback to summary
public static String correctFileName(String f)

Fix the file name, replacing backslash with slash.

Parameters
f:String

the file name

Returns:String

the corrected file name

getAfterLastBlock_back to summary
protected long getAfterLastBlock_()

Overrides org.h2.mvstore.RandomAccessStore.getAfterLastBlock_.

Annotations
@Override
getMovePriorityback to summary
public int getMovePriority(int block)

Overrides org.h2.mvstore.RandomAccessStore.getMovePriority.

Calculates relative "priority" for chunk to be moved.

Parameters
block:int

where chunk starts

Returns:int

priority, bigger number indicate that chunk need to be moved sooner

Annotations
@Override
lockFileChannelback to summary
private FileLock lockFileChannel(FileChannel fileChannel, boolean readOnly, String fileName) throws IOException
openback to summary
public void open(String fileName, boolean readOnly, char[] encryptionKey)

Implements abstract org.h2.mvstore.FileStore.open.

Try to open the file.

Parameters
fileName:String

the file name

readOnly:boolean

whether the file should only be opened in read-only mode, even if the file is writable

encryptionKey:char[]

the encryption key, or null if encryption is not

Annotations
@Override
openback to summary
public SingleFileStore open(String fileName, boolean readOnly)

Implements abstract org.h2.mvstore.FileStore.open.

Annotations
@Override
openback to summary
private void open(String fileName, boolean readOnly, Function<FileChannel, FileChannel> encryptionTransformer)
readFullyback to summary
public ByteBuffer readFully(SFChunk chunk, long pos, int len)

Implements abstract org.h2.mvstore.FileStore.readFully.

Doc from org.h2.mvstore.FileStore.readFully.

Read data from the store.

Parameters
chunk:SFChunk

that owns data to be read

pos:long

the read "position"

len:int

the number of bytes to read

Returns:ByteBuffer

the byte buffer with data requested

Annotations
@Override
syncback to summary
public void sync()

Overrides org.h2.mvstore.FileStore.sync.

Flush all changes.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
truncateback to summary
public void truncate(long size)

Implements abstract org.h2.mvstore.RandomAccessStore.truncate.

Truncate the file.

Parameters
size:long

the new file size

Annotations
@Override
@SuppressWarnings:ThreadPriorityCheck
writeFullyback to summary
protected void writeFully(SFChunk chunk, long pos, ByteBuffer src)

Implements abstract org.h2.mvstore.FileStore.writeFully.

Doc from org.h2.mvstore.FileStore.writeFully.

Write to the file.

Parameters
chunk:SFChunk

to write

pos:long

the write position

src:ByteBuffer

the source buffer

Annotations
@Override