Class Fork
java.lang.Object
com.exonum.binding.core.proxy.AbstractNativeProxy
com.exonum.binding.core.storage.database.View
com.exonum.binding.core.storage.database.Fork
public final class Fork extends View
A fork is a database view, allowing both read and write operations.
A fork represents the database state at the time it was created plus any changes to the database made using this fork.
A fork allows to perform a transaction: a number of independent writes to the database, which then may be atomically applied (i.e. committed) to the database and change the database state.
-
Field Summary
-
Method Summary
Modifier and Type Method Description void
createCheckpoint()
Creates in-memory checkpoint of the current state of this Fork.Cleaner
getCleaner()
Returns the cleaner of this view.static Fork
newInstance(long nativeHandle, boolean owningHandle, Cleaner cleaner)
Creates a new Fork proxy.static Fork
newInstance(long nativeHandle, Cleaner cleaner)
Creates a new owning Fork proxy.void
rollback()
Rollbacks changes to the latest checkpoint.Methods inherited from class com.exonum.binding.core.storage.database.View
canModify, findOpenIndex, getViewNativeHandle, registerIndex
Methods inherited from class com.exonum.binding.core.proxy.AbstractNativeProxy
getNativeHandle, isValidHandle
-
Method Details
-
newInstance
Creates a new owning Fork proxy.- Parameters:
nativeHandle
- a handle of the native Fork objectcleaner
- a cleaner to perform any operations
-
newInstance
Creates a new Fork proxy.- Parameters:
nativeHandle
- a handle of the native Fork objectowningHandle
- whether a proxy owns the corresponding native object and is responsible to clean it upcleaner
- a cleaner to destroy this fork and any dependent objects
-
getCleaner
Description copied from class:View
Returns the cleaner of this view. It is supposed to be used with collections and other objects depending on this view.- Specified by:
getCleaner
in classView
-
createCheckpoint
public void createCheckpoint()Creates in-memory checkpoint of the current state of this Fork. A checkpoint allows to restore the state of the Fork by reverting the changes made since the last checkpoint operation withrollback()
. The changes made before the last checkpoint cannot be reverted, because each new checkpoint replaces the previous: checkpoints are not stacked.Creating a checkpoint will invalidate all collections that were instantiated with this fork.
This operation is not intended to be used by services.
-
rollback
public void rollback()Rollbacks changes to the latest checkpoint. If no checkpoints were created, rollbacks all changes made by this fork. Rollback affects only changes made with this particular Fork instance.Rollback will invalidate all collections that were created with this fork.
This operation is not intended to be used by services.
-