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

  • 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