Top Description Fields Constructors Methods
org.h2.mvstore

public final Class AppendOnlyMultiFileStore

extends FileStore<MFChunk>
Class Inheritance
Annotations
@SuppressWarnings:unused
Imports
org.h2.mvstore.cache.FilePathCache, org.h2.store.fs.FilePath, org.h2.store.fs.encrypt.FileEncrypt, .FilePathEncrypt, java.io.IOException, java.nio.ByteBuffer, java.nio.channels.FileChannel, .FileLock, .OverlappingFileLockException, java.util.HashMap, .Map, java.util.function.Function, java.util.zip.ZipOutputStream

Class AppendOnlyMultiFileStore.
Author
Andrei Tokar

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>
private long
creationTime

Hides org.h2.mvstore.FileStore.creationTime.

The time the store was created, in milliseconds since 1970.
private FileChannel
fileChannel

The current file.

private final FileChannel[]
fileChannels

All files currently used by this store.

private int
fileCount

Current number of files in use

private FileLock
fileLock

The file lock.

private final int
maxFileCount

Limit for the number of files used by this store

private FileChannel
originalFileChannel

The encrypted file (if encryption is used).

private int
Inherited from org.h2.mvstore.FileStore:
BLOCK_SIZEchunksHDR_BLOCKHDR_BLOCK_SIZEHDR_CHUNKHDR_CLEANHDR_CREATEDHDR_FLETCHERHDR_FORMATHDR_FORMAT_READHDR_HHDR_VERSIONlastChunkMETA_ID_KEYmvStorePIPE_LENGTHreadBytesreadCountrecoveryModesaveChunkLockstoreHeaderwriteByteswriteCount

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
adjustStoreToLastChunk()

Implements abstract org.h2.mvstore.FileStore.adjustStoreToLastChunk.

Make persistent changes after lastChunk was reset

protected void
allocateChunkSpace(MFChunk
to allocate space for
chunk
,
WriteBuffer
to allocate space for
buff
)

Implements abstract org.h2.mvstore.FileStore.allocateChunkSpace.

Allocate logical space and assign position of the buffer within the store.

public void
public void
close()

Overrides org.h2.mvstore.FileStore.close.

Close this store.

protected void
compactStore(int
do not compact if store fill rate above this value (0-100)
thresholdFillRate
,
long
the maximum time in milliseconds to compact
maxCompactTime
,
int
the maximum amount of data to be written as part of this call
maxWriteSize
,
MVStore
that owns this FileStore
mvStore
)

Implements abstract org.h2.mvstore.FileStore.compactStore.

Compact store file, that is, compact blocks that have a low fill rate, and move chunks next to each other.

protected final MFChunk
createChunk(int newChunkId)

Implements abstract org.h2.mvstore.FileStore.createChunk.

public MFChunk
createChunk(String
the string
s
)

Implements abstract org.h2.mvstore.FileStore.createChunk.

Build a Chunk from the given string.

protected MFChunk
protected void
protected void
freeChunkSpace(Iterable<MFChunk>
chunks to be processed
chunks
)

Implements abstract org.h2.mvstore.FileStore.freeChunkSpace.

Mark the space occupied by specified chunks as free.

public int
protected void
public void
markUsed(long
the position in bytes
pos
,
int
the number of bytes
length
)

Implements abstract org.h2.mvstore.FileStore.markUsed.

Mark the space as in use.

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

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

public AppendOnlyMultiFileStore
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(MFChunk
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.

protected void
readStoreHeader(boolean recoveryMode)

Implements abstract org.h2.mvstore.FileStore.readStoreHeader.

public boolean
shouldSaveNow(int
amount of unsaved memory, so far
unsavedMemory
,
int
configured limit on amount of unsaved memory
autoCommitMemory
)

Implements abstract org.h2.mvstore.FileStore.shouldSaveNow.

Decision about autocommit is delegated to store

protected void
shrinkStoreIfPossible(int
the minimum percentage to save
minPercent
)

Implements abstract org.h2.mvstore.FileStore.shrinkStoreIfPossible.

Shrink store if possible, and if at least a given percentage can be saved.

protected boolean
protected void
writeChunk(MFChunk
chunk to write
chunk
,
WriteBuffer
to write
buff
)

Implements abstract org.h2.mvstore.FileStore.writeChunk.

Write buffer associated with chunk into store at chunk's allocated position

protected void
writeCleanShutdownMark()

Implements abstract org.h2.mvstore.FileStore.writeCleanShutdownMark.

Performs final preparation before store is closed normally

protected void
writeFully(MFChunk
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.FileStore:
accountForRemovedPagebindcachePagecacheToCclearcompactcompactStorederegisterMapRootdiscoverChunkdropUnusedChunksexecuteFileStoreOperationfindLastChunkWithCompleteValidChunkSetgetAutoCommitDelaygetAutoCompactFillRategetCacheHitRatiogetCacheSizegetCacheSizeUsedgetChunksgetChunksFillRategetChunksFromLayoutMapgetCreationTimegetDefaultRetentionTimegetFileNamegetLayoutMapgetMaxPageSizegetMetaMapIdgetMvStoregetReadBytesgetReadCountgetRetentionTimegetRewritableChunksFillRategetRewriteCandidatesgetRootPosgetStoreHeadergetTocCacheHitRatiogetWriteBuffergetWriteCounthasChangesSincehasPersistentDatainitinitializeCommonHeaderAttributesisBackgroundThreadisIdleisKnownVersionisReadOnlyisRegularMapisSpaceReusedlastChunkVersionpopulateInfoprocessCommonHeaderAttributesreadChunkFooterreadChunkHeaderAndFooterreadChunkHeaderOptionallyreadChunkHeaderOptionallyreadFullyreadPageregisterDeadChunkreleaseWriteBufferrewriteChunksrollbackTosaveChunkMetadataChangessetAutoCommitDelaysetCacheSizesetLastChunksetRetentionTimesetReuseSpacesetSizesizestartstopstorestoreItsyncwriteCleanShutdownwriteInBackground

Field Detail

configback to summary
private final Map<String, Object> config
creationTimeback to summary
private long creationTime

Hides org.h2.mvstore.FileStore.creationTime.

The time the store was created, in milliseconds since 1970.

fileChannelback to summary
private FileChannel fileChannel

The current file. This is writable channel in append mode

fileChannelsback to summary
private final FileChannel[] fileChannels

All files currently used by this store. This includes current one at first position. Previous files are opened in read-only mode. Logical length of this array is defined by fileCount.

Annotations
@SuppressWarnings:MismatchedReadAndWriteOfArray
fileCountback to summary
private int fileCount

Current number of files in use

fileLockback to summary
private FileLock fileLock

The file lock.

maxFileCountback to summary
private final int maxFileCount

Limit for the number of files used by this store

Annotations
@SuppressWarnings:FieldCanBeLocal
originalFileChannelback to summary
private FileChannel originalFileChannel

The encrypted file (if encryption is used).

volumeIdback to summary
private int volumeId

Constructor Detail

AppendOnlyMultiFileStoreback to summary
public AppendOnlyMultiFileStore(Map<String, Object> config)

Method Detail

adjustStoreToLastChunkback to summary
protected void adjustStoreToLastChunk()

Implements abstract org.h2.mvstore.FileStore.adjustStoreToLastChunk.

Doc from org.h2.mvstore.FileStore.adjustStoreToLastChunk.

Make persistent changes after lastChunk was reset

Annotations
@Override
allocateChunkSpaceback to summary
protected void allocateChunkSpace(MFChunk chunk, WriteBuffer buff)

Implements abstract org.h2.mvstore.FileStore.allocateChunkSpace.

Doc from org.h2.mvstore.FileStore.allocateChunkSpace.

Allocate logical space and assign position of the buffer within the store.

Parameters
chunk:MFChunk

to allocate space for

buff:WriteBuffer

to allocate space for

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

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

Annotations
@Override
closeback to summary
public void close()

Overrides org.h2.mvstore.FileStore.close.

Close this store.

Annotations
@Override
compactStoreback to summary
protected void compactStore(int thresholdFillRate, long maxCompactTime, int maxWriteSize, MVStore mvStore)

Implements abstract org.h2.mvstore.FileStore.compactStore.

Doc from org.h2.mvstore.FileStore.compactStore.

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.

Parameters
thresholdFillRate:int

do not compact if store fill rate above this value (0-100)

maxCompactTime:long

the maximum time in milliseconds to compact

maxWriteSize:int

the maximum amount of data to be written as part of this call

mvStore:MVStore

that owns this FileStore

Annotations
@Override
createChunkback to summary
protected final MFChunk createChunk(int newChunkId)

Implements abstract org.h2.mvstore.FileStore.createChunk.

Annotations
@Override
createChunkback to summary
public MFChunk createChunk(String s)

Implements abstract org.h2.mvstore.FileStore.createChunk.

Doc from org.h2.mvstore.FileStore.createChunk.

Build a Chunk from the given string.

Parameters
s:String

the string

Returns:MFChunk

the Chunk created

Annotations
@Override
createChunkback to summary
protected MFChunk createChunk(Map<String, String> map)

Implements abstract org.h2.mvstore.FileStore.createChunk.

Annotations
@Override
doHousekeepingback to summary
protected void doHousekeeping(MVStore mvStore) throws InterruptedException

Implements abstract org.h2.mvstore.FileStore.doHousekeeping.

Annotations
@Override
freeChunkSpaceback to summary
protected void freeChunkSpace(Iterable<MFChunk> chunks)

Implements abstract org.h2.mvstore.FileStore.freeChunkSpace.

Doc from org.h2.mvstore.FileStore.freeChunkSpace.

Mark the space occupied by specified chunks as free.

Parameters
chunks:Iterable<MFChunk>

chunks to be processed

Annotations
@Override
getFillRateback to summary
public int getFillRate()

Implements abstract org.h2.mvstore.FileStore.getFillRate.

Annotations
@Override
initializeStoreHeaderback to summary
protected void initializeStoreHeader(long time)

Implements abstract org.h2.mvstore.FileStore.initializeStoreHeader.

Annotations
@Override
markUsedback to summary
public void markUsed(long pos, int length)

Implements abstract org.h2.mvstore.FileStore.markUsed.

Doc from org.h2.mvstore.FileStore.markUsed.

Mark the space as in use.

Parameters
pos:long

the position in bytes

length:int

the number of bytes

Annotations
@Override
openback to summary
public void open(String fileName, boolean readOnly, char[] encryptionKey)

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

Annotations
@Override
openback to summary
public AppendOnlyMultiFileStore 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(MFChunk 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:MFChunk

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
readStoreHeaderback to summary
protected void readStoreHeader(boolean recoveryMode)

Implements abstract org.h2.mvstore.FileStore.readStoreHeader.

Annotations
@Override
shouldSaveNowback to summary
public boolean shouldSaveNow(int unsavedMemory, int autoCommitMemory)

Implements abstract org.h2.mvstore.FileStore.shouldSaveNow.

Doc from org.h2.mvstore.FileStore.shouldSaveNow.

Decision about autocommit is delegated to store

Parameters
unsavedMemory:int

amount of unsaved memory, so far

autoCommitMemory:int

configured limit on amount of unsaved memory

Returns:boolean

true if commit should happen now

Annotations
@Override
shrinkStoreIfPossibleback to summary
protected void shrinkStoreIfPossible(int minPercent)

Implements abstract org.h2.mvstore.FileStore.shrinkStoreIfPossible.

Doc from org.h2.mvstore.FileStore.shrinkStoreIfPossible.

Shrink store if possible, and if at least a given percentage can be saved.

Parameters
minPercent:int

the minimum percentage to save

Annotations
@Override
validateFileLengthback to summary
protected boolean validateFileLength(String msg)

Implements abstract org.h2.mvstore.FileStore.validateFileLength.

Annotations
@Override
writeChunkback to summary
protected void writeChunk(MFChunk chunk, WriteBuffer buff)

Implements abstract org.h2.mvstore.FileStore.writeChunk.

Doc from org.h2.mvstore.FileStore.writeChunk.

Write buffer associated with chunk into store at chunk's allocated position

Parameters
chunk:MFChunk

chunk to write

buff:WriteBuffer

to write

Annotations
@Override
writeCleanShutdownMarkback to summary
protected void writeCleanShutdownMark()

Implements abstract org.h2.mvstore.FileStore.writeCleanShutdownMark.

Doc from org.h2.mvstore.FileStore.writeCleanShutdownMark.

Performs final preparation before store is closed normally

Annotations
@Override
writeFullyback to summary
protected void writeFully(MFChunk 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:MFChunk

to write

pos:long

the write position

src:ByteBuffer

the source buffer

Annotations
@Override