For a conceptual overview of data versioning, branches, and epochs, see How Atoti manages data versioning on Atoti Hub.
What are epochs?
An epoch is created each time the database gets a new version:- In the datastore, when a transaction is committed.
- In DirectQuery, when the application is refreshed with
refresh()orrefresh(ChangeDescription).

How does epoch management work?
As long as an epoch is considered valid, all corresponding versions will be kept by their respective multi-versioned components. This automatically implies a memory cost (and the potential performance cost) of keeping multiple epochs and their associated versions. Epochs that are no longer needed can be released, meaning that the corresponding versions may be discarded and garbage collected. Released epochs are no longer accessible for queries.How is the epoch management policy configured?
The epoch manager and itsIEpochManagementPolicy are defined when building the application:
- In the datastore, call
StartBuilding.application().withEpochPolicy(policy). - In DirectQuery, call
Application.builder(connector).epochPolicy(policy).
KeepLastEpochPolicy.
This policy keeps only the latest epochs, based on their age, their number, or both.
It always keeps the head of every defined branch.
The default configuration of this epoch policy implies that old epochs may only be discarded when a new epoch is created
or when a garbage collection cycle is triggered by the JVM.
This can however be customized further:
KeepAllEpochPolicy can be used to retain all epochs for the entire lifetime of the application.
How are available epochs inspected?
Since the Epoch counter is incremented each time a transaction is committed, it may be hard to track which epochs are available on a running Atoti application. The epoch manager is responsible for applying theIEpochManagementPolicy on the application during its lifespan.
Release of old epochs is performed automatically according to the policy, or can be performed manually through the
Epoch Manager MBean (releasing epochs, dropping branches, listing existing branches).
The same operations are available programmatically via the IEpochManager interface.
The IDatabase and IVersionHistory interfaces provide methods to access the versions that are not released.
The getEpochsUsage operation, available in the Epoch Manager MBean, provides statistics about the versions held by
each multi-versioned component of the application as well as the released and discarded epochs.
How is a specific version queried?
EachIDatabaseVersion provides a getQueryRunner() method to execute queries on that version of the data.
Queries performed on this IQueryRunner interface will return data corresponding to facts as-of the corresponding
epoch.
The Epoch Dimension is available when performing MDX Queries and allows for complex cross-epoch
calculations.
What are branches?
For a conceptual overview of branches and What-If analysis, see How Atoti manages data versioning on Atoti Hub.
master branch only.
For more information, see Branching.
In practice every transaction is made on some branch, which is assumed to be “master” if unspecified.
A branch can therefore be represented by the set of the transactions done on it.
How do branches work in Atoti?
Atoti uses a Version History to link all the versions of the components using MVCC together. ThisIVersionHistory is always linear, even with multiple branches.
Branch information is held in the IHistoryNodes of the IVersionHistory, which is created temporally,
commit after commit:

-
Initially, there is only one branch, called
master. - When feeding data into a datastore, each transaction can be applied from any existing branch and committed on any other branch, creating a new one if needed.
- Once created, it is possible to continue committing data on a branch and update its head (the latest version of a branch).
- When performing a transaction, only the mentioned branch will be updated. If some data must be committed on multiple branches, a transaction must be performed on each of the impacted branches.
-
It is not possible to merge or rebase branches in Atoti. However, a branch can be fast-forwarded to another
branch’s head using
IDatabaseService.fastForward().
How is a branch created?
To create a branch, start a transaction withstartTransactionOnBranch or startTransactionFromBranch on the ITransactionManager.
The branch is created when the transaction is committed.
How is data queried on a branch?
It is possible to perform a query on any version of any branch as long as the specified Epoch is still valid. The query’s results will correspond to the data as it was at the specified epoch within its corresponding branch. For more information about the epoch policy, see the How is the epoch management policy configured? section.- The Database REST API supports branch-specific queries on the Database. The query returns data corresponding to the HEAD of the requested branch.
- The Epoch Dimension’s Branch/What-if level enables analysis of aggregated data across scenarios by changing the member of the Epoch Dimension queried by the MDX code.
How are branches listed and deleted?
In order to keep track of the existing branches on an Atoti application, the following methodIEpochManager.getBranches() is available and returns the names of the current valid branches. The application also
exposes an MBean named showBranches that will print various information about branches such as the first epoch of a
branch, the latest epoch of a branch and the epoch on which a branch was created.
When a branch is no longer necessary, it can be dropped to free the memory held by the versions corresponding to its
underlying epochs and their associated versions.
It is possible to delete a branch by calling IEpochManager.releaseBranch(String branchName), which is available as an
MBean named dropBranch.
Note that a branch can only be dropped if it does not contain the latest version. If the branch contains the latest
version, it will be dropped after the next commit.
Similarly, a branch will be effectively dropped if none of the related versions are being used.
What are the performance characteristics of branches?
Thanks to the linear design of branches in Atoti, using branches does not imply an additional memory usage cost. Moreover, there is no inherent cost incurred by the used branches count increase. However, the current design leads to the following caveat:Performing a commit on a branch B will have a time cost equal to the cost of this commit in a branch-less scenario PLUS the cost of reverting the state of the store from its current head to the head of the branch B. Unfortunately, this additional cost is uncorrelated to the commit itself, but depends not only on the operations that occur on the datastore, but also on the order on which they occurred.It is also worth mentioning that Indexed aggregate providers are multi-versioned components as well and therefore support branches. As a consequence, they contribute to the memory consumption of each branch by holding pre-aggregated data. Note that it is not the case for the Just-In-Time aggregates provider, as aggregates are computed on the fly.