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.
  • 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