Skip to content

Latest commit

 

History

History
73 lines (56 loc) · 2.85 KB

README.md

File metadata and controls

73 lines (56 loc) · 2.85 KB

Datahike RocksDB Backend

The goal of this backend is to support RocksDB. This implementation is a work in progress.

Configuration

Please read the Datahike configuration docs on how to configure your backend. Details about the backend configuration can be found in konserve-rocksdb.A sample configuration is create-database, connect and delete-database:

{:store {:backend :rocksdb :path "/tmp/datahike-rocksdb-playground"}}

Usage

Add to your Leiningen or Boot dependencies: Clojars Project

Run Datahike in your REPL

  (ns project.core
    (:require [datahike.api :as d]
              [datahike-rocksdb.core]))

  (def cfg {:store {:backend :rocksdb :path "/tmp/datahike-rocksdb-playground"}})

  ;; Create a database at this place, by default configuration we have a strict
  ;; schema validation and keep historical data
  (d/create-database cfg)

  (def conn (d/connect cfg))

  ;; The first transaction will be the schema we are using:
  (d/transact conn [{:db/ident :name
                     :db/valueType :db.type/string
                     :db/cardinality :db.cardinality/one }
                    {:db/ident :age
                     :db/valueType :db.type/long
                     :db/cardinality :db.cardinality/one }])

  ;; Let's add some data and wait for the transaction
  (d/transact conn [{:name  "Alice", :age   20 }
                    {:name  "Bob", :age   30 }
                    {:name  "Charlie", :age   40 }
                    {:age 15 }])

  ;; Search the data
  (d/q '[:find ?e ?n ?a
         :where
         [?e :name ?n]
         [?e :age ?a]]
    @conn)
  ;; => #{[3 "Alice" 20] [4 "Bob" 30] [5 "Charlie" 40]}

  ;; Clean up the database if it is not needed any more
  (d/delete-database cfg)

Run Tests

  bash -x ./bin/run-integration-tests

License

Copyright © 2023 lambdaforge UG (haftungsbeschränkt)

This program and the accompanying materials are made available under the terms of the Eclipse Public License 1.0.