public class MongoDBVBranch extends java.lang.Object implements VBranch
Implementation of VBranch
for MongoDB. Each
thread owns an index and a head of the branch/commit it has checked out.
This ensures isolation. If two threads try to create a commit with the
same head, the commit()
method will fail. The rule is: come first,
serve first.
Thread-safety: this class is thread-safe. Instances can be shared between threads, but each thread has its own index and head.
Constructor and Description |
---|
MongoDBVBranch(java.lang.String name,
long rootCid,
Tree tree,
MongoDBVDatabase db)
Constructs a new branch object (not the branch itself)
|
Modifier and Type | Method and Description |
---|---|
long |
commit()
Commit objects that have been added or changed in this branch
to the database
|
VCollection |
getCollection(java.lang.String name)
Gets or creates a database collection.
|
MongoDBVDatabase |
getDB() |
long |
getHead() |
Index |
getIndex() |
VLargeCollection |
getLargeCollection(java.lang.String name)
Gets or creates a database collection that can handle large
objects (BLOBs).
|
VLargeCollection |
getLargeCollection(java.lang.String name,
AccessStrategy accessStrategy)
Gets or creates a database collection that can handle large
objects (BLOBs) and uses a given access strategy.
|
java.util.Map<java.lang.String,java.lang.Object> |
getQueryObject() |
long |
getRootCid() |
void |
rollback()
Resets this branch (i.e. discards all changes made since
the branch has been checked out or since the last commit)
|
public MongoDBVBranch(java.lang.String name, long rootCid, Tree tree, MongoDBVDatabase db)
name
- the branch's name (may be null for unnamed branches)rootCid
- the CID of the branch's roottree
- the tree of commitsdb
- the database objectpublic java.util.Map<java.lang.String,java.lang.Object> getQueryObject()
public long getHead()
public VCollection getCollection(java.lang.String name)
VBranch
Gets or creates a database collection. Collections have no special meaning, they are just used to group objects.
The collection's state depends on the branch currently checkout out.
getCollection
in interface VBranch
name
- the collection's namepublic VLargeCollection getLargeCollection(java.lang.String name)
VBranch
getLargeCollection
in interface VBranch
name
- the collection's namepublic VLargeCollection getLargeCollection(java.lang.String name, AccessStrategy accessStrategy)
name
- the collection's nameaccessStrategy
- the strategy used to access large objectspublic Index getIndex()
public MongoDBVDatabase getDB()
public long getRootCid()
public long commit()
VBranch