RocksStorageNode
The RocksStorageNode and MonoStorageNode are StorageNodes that can save/restore Atoms to a RocksDB database. These both use exactly the same API as all the other StorageNodes; see StorageNode for details.
The MonoStorageNode is optimized for storing a single AtomSpace. The RocksStorageNode is capable of storing multiple AtomSpaces at once, possibly arranged in a complex DAG (directed acyclic graph) of inheritance.
Both are single-user nodes. Only one process at a time can open and work with a Rocks database. RocksDB lives on the local filesystem, it is not a networked database. This has several benefits suitable for most users:
- Its very fast, especially on SSD disks connected via PCIEv3.
- There is nothing to configure. You just specify a filepath, and everything else is automatic.
- Creating backups is super-easy: you just copy the entire RocksDB directory.
Users who want to have a networked, multi-user distributed AtomSpace are encouraged to use RocksStorageNode together with CogStorageNode to provide networking. Creating a true distributed AtomSpace with this infrastructure also requires having some policy agents that decide which atoms to move around, where to move/copy them to, and how often they need to be moved/copied. See the wiki page Networked AtomSpaces for basic definitions of networking terms, as they apply to AtomSpaces. A pre-pre-alpha project to implement some of these agents has been created here: https://github.com/opencog/atomspace-agents/ .
Example
Here's a very short example that opens a connection to a RocksDB database, and fetches all of the Values attached to a given Atom.
(define rsn (RocksStorageNode "rocks:///tmp/foo.rdb")) (cog-open rsn) (fetch-atom (Concept "bar") rsn) (cog-close rsn)
Complete, functional demos are provided in the github examples directory.
URL format
The URL format simply specifies a location in the file system:
- rocks:///some/path/to/database.rdb
Note that database.rdb is actually a directory: RocksDB uses a number of different files to do it's thing.
The MonoStorageNode uses a different URL. It can be accessed as
- (MonoStorageNode "monospace:///tmp/bar.rdb")
The storage formats for RocksStorageNode and MonoStorageNode are NOT compatible with one-another! In particular, the multi-space version cannot be opened with the monospace driver!
Implementation
The source code for this node is located here: https://github.com/opencog/atomspace-rocks/