Class TemporaryDb

    • Method Detail

      • newInstance

        public static TemporaryDb newInstance()
        Creates a new empty TemporaryDb.
      • createSnapshot

        public Snapshot createSnapshot​(Cleaner cleaner)
        Description copied from interface: Database
        Creates a new snapshot of the database state.
        Specified by:
        createSnapshot in interface Database
        Parameters:
        cleaner - a cleaner to register the snapshot
        Returns:
        a new snapshot of the database state
      • createFork

        public Fork createFork​(Cleaner cleaner)
        Description copied from interface: Database
        Creates a new database fork.

        A fork allows to perform a transaction: a number of independent writes to a database, which then may be atomically applied to the database.

        Specified by:
        createFork in interface Database
        Parameters:
        cleaner - a cleaner to register the fork
        Returns:
        a new database fork
      • merge

        public void merge​(Fork fork)
        Applies the changes from the given fork to the database state. TemporaryDb can only merge forks that it created itself.

        Once this method completes, any indexes created with the fork and the fork itself are closed and cannot be used anymore. Any subsequent operations on these objects will result in IllegalStateException.

        Parameters:
        fork - a fork to get changes from
        Throws:
        RuntimeException - if the fork cannot be applied to the database state. The provided fork will be closed