RocksStorageNode

From OpenCog

The RocksStorageNode is a StorageNode that can save/restore Atoms to a RocksDB database. It uses exactly the same API as all the other StorageNodes; see StorageNode for details.

The RocksStorageNode is a single-user node. Only one process at a time can open and work with the 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.

Implementation

The source code for this node is located here: https://github.com/opencog/atomspace-rocks/

See also