Documentation of 'org.mapdb.StoreHeap' Java class
StoreHeap
org.mapdb

Class StoreHeap

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, Engine


    public class StoreHeap
    extends Store
    Store which keeps all instances on heap. It does not use serialization.
    • Constructor Detail

      • StoreHeap

        public StoreHeap(boolean txDisabled,
                         int lockScale,
                         int lockingStrategy,
                         boolean snapshotEnable)
    • Method Detail

      • update

        public <A> void update(long recid,
                               A value,
                               Serializer<A> serializer)
        Description copied from interface: Engine

        Update existing record with new value.

        Recid must be a number returned by 'put' method. Behaviour for invalid recid (random number or already deleted record) is not defined, typically it throws 'EndOfFileException', but it may also corrupt store.

        Specified by:
        update in interface Engine
        Overrides:
        update in class Store
        Parameters:
        recid - (record identifier) under which record was persisted.
        value - new record value to be stored
        serializer - used to serialize record into binary form
      • compareAndSwap

        public <A> boolean compareAndSwap(long recid,
                                          A expectedOldValue,
                                          A newValue,
                                          Serializer<A> serializer)
        Description copied from interface: Engine

        Updates existing record in atomic (Compare And Swap) manner. Value is modified only if old value matches expected value. There are three ways to match values, MapDB may use any of them:

        1. Equality check oldValue==expectedOldValue when old value is found in instance cache
        2. Deserializing oldValue using serializer and checking oldValue.equals(expectedOldValue)
        3. Serializing expectedOldValue using serializer and comparing binary array with already serialized oldValue

        Recid must be a number returned by 'put' method. Behaviour for invalid recid (random number or already deleted record) is not defined, typically it throws 'EndOfFileException', but it may also corrupt store.

        Specified by:
        compareAndSwap in interface Engine
        Overrides:
        compareAndSwap in class Store
        Parameters:
        recid - (record identifier) under which record was persisted.
        expectedOldValue - old value to be compared with existing record
        newValue - to be written if values are matching
        serializer - used to serialize record into binary form
        Returns:
        true if values matched and newValue was written
      • getCurrSize

        public long getCurrSize()
        Specified by:
        getCurrSize in class Store
      • getFreeSize

        public long getFreeSize()
        Specified by:
        getFreeSize in class Store
      • fileLoad

        public boolean fileLoad()
        Description copied from class: Store

        If underlying storage is memory-mapped-file, this method will try to load and precache all file data into disk cache. Most likely it will call MappedByteBuffer.load(), but could also read content of entire file etc This method will not pin data into memory, they might be removed at any time.

        Specified by:
        fileLoad in class Store
        Returns:
        true if this method did something, false if underlying storage does not support loading, or is already in-memory
      • backup

        public void backup(java.io.OutputStream out,
                           boolean incremental)
        Specified by:
        backup in class Store
      • backupRestore

        public void backupRestore(java.io.InputStream[] in)
        Specified by:
        backupRestore in class Store
      • preallocate

        public long preallocate()
        Description copied from interface: Engine
        Preallocates recid for not yet created record. It does not insert any data into it.
        Returns:
        new recid
      • put

        public <A> long put(A value,
                            Serializer<A> serializer)
        Description copied from interface: Engine
        Insert new record.
        Parameters:
        value - records to be added
        serializer - used to convert record into/from binary form
        Returns:
        recid (record identifier) under which record is stored.
      • close

        public void close()
        Description copied from interface: Engine

        Close store/cache. This method must be called before JVM exits to flush all caches and prevent store corruption. Also it releases resources used by MapDB (disk, memory..).

        Engine can no longer be used after this method was called. If Engine is used after closing, it may throw any exception including NullPointerException

        There is an configuration option DBMaker.Maker.closeOnJvmShutdown() which uses shutdown hook to automatically close Engine when JVM shutdowns.

      • commit

        public void commit()
        Description copied from interface: Engine
        Makes all changes made since the previous commit/rollback permanent. In transactional mode (on by default) it means creating journal file and replaying it to storage. In other modes it may flush disk caches or do nothing at all (check your config options)
      • rollback

        public void rollback()
                      throws java.lang.UnsupportedOperationException
        Description copied from interface: Engine
        Undoes all changes made in the current transaction. If transactions are disabled it throws UnsupportedOperationException.
        Throws:
        java.lang.UnsupportedOperationException - if transactions are disabled
      • canRollback

        public boolean canRollback()
        Returns:
        true if engine supports rollback
      • snapshot

        public Engine snapshot()
                        throws java.lang.UnsupportedOperationException
        Description copied from interface: Engine
        Returns read-only snapshot of data in Engine.
        Throws:
        java.lang.UnsupportedOperationException - if snapshots are not supported/enabled
      • compact

        public void compact()

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.