Liking cljdoc? Tell your friends :D

xitdb.db


*return-history?*clj

source

append-context!clj

(append-context! history slot fn)

Appends a new history context and calls fn with a write cursor. Returns the history count after the append; the new entry is at (dec count).

Appends a new history context and calls `fn` with a write cursor.
Returns the history count after the append; the new entry is at `(dec count)`.
sourceraw docstring

compactclj

(compact xdb target)

Compacts the latest value of xdb into a new database at target. target can be :memory or the name of a file that does not exist. Returns an open XITDBDatabase containing at most one history entry. The source database is unchanged.

Holds the source's write lock for the whole copy, so swap! and reset! on xdb block until compaction finishes. Must not be called from inside a swap! or reset! on xdb; doing so throws IllegalStateException.

Compacts the latest value of `xdb` into a new database at `target`.
`target` can be `:memory` or the name of a file that does not exist.
Returns an open XITDBDatabase containing at most one history entry. The source
database is unchanged.

Holds the source's write lock for the whole copy, so `swap!` and `reset!` on
`xdb` block until compaction finishes. Must not be called from inside a
`swap!` or `reset!` on `xdb`; doing so throws IllegalStateException.
sourceraw docstring

db-historyclj

(db-history db)
source

db-modeclj

(db-mode xdb)

Returns the mode of xdb, :clojure or :compat (see xit-db), as recorded in its header.

Returns the mode of `xdb`, `:clojure` or `:compat` (see `xit-db`), as recorded
in its header.
sourceraw docstring

deref-atclj

(deref-at xdb index)

Returns the version of the data at the specified index.

Returns the version of the data at the specified index.
sourceraw docstring

freeze!clj

(freeze! x)

Prevents all data written in the current transaction from being mutated by any remaining changes. Throws if called outside of a transaction. Returns a read-only version of the given writeable data structure.

Prevents all data written in the current transaction from
being mutated by any remaining changes. Throws if called
outside of a transaction. Returns a read-only version of the
given writeable data structure.
sourceraw docstring

history-indexcljdeprecated

source

lock-fileclj

(lock-file db)

Locks the file of db, if it has one. Returns the lock, or nil.

Locks the file of `db`, if it has one. Returns the lock, or nil.
sourceraw docstring

materializeclj

source

open-databaseclj

(open-database filename open-mode)
(open-database filename open-mode mode)

Opens database filename. If filename is :memory, returns a memory based db. open-mode can be r or rw. mode is nil (the default), :clojure or :compat, see xit-db. It picks the header ID of a new file, clj1 unless it is :compat. An existing file keeps its own ID, since the engine ignores the hasher's ID for it, and a non-nil mode is checked against that ID.

Opens database `filename`.
If `filename` is `:memory`, returns a memory based db.
open-mode can be `r` or `rw`.
mode is nil (the default), `:clojure` or `:compat`, see `xit-db`. It picks the
header ID of a new file, clj1 unless it is `:compat`. An existing file keeps its
own ID, since the engine ignores the hasher's ID for it, and a non-nil mode is
checked against that ID.
sourceraw docstring

read-historyclj

(read-history db)

Returns the read only transaction history array.

Returns the read only transaction history array.
sourceraw docstring

v->slot!clj

(v->slot! cursor v)

Converts a value to a slot which can be written to a cursor. XITDB* types are written by reference (structural sharing) when they belong to the same database as cursor; values from another database are refused. All other types are converted by conversion/v->slot!.

Converts a value to a slot which can be written to a cursor.
XITDB* types are written by reference (structural sharing) when they belong
to the same database as `cursor`; values from another database are refused.
All other types are converted by `conversion/v->slot!`.
sourceraw docstring

xdb-cursorclj

(xdb-cursor xdb keypath)
source

xit-dbclj

(xit-db filename)
(xit-db filename {:keys [mode]})

Returns a new XITDBDatabase which can be used to query and transact data. filename can be :memory or the name of a file on the filesystem. If the file does not exist, it will be created. The returned database handle can be used from multiple threads, and so can the values read from it. Reads can run in parallel, transactions (eg. swap!) will only allow one writer at a time.

An existing file opens in the mode its header records (see db-mode):

  • Clojure mode uses the Clojure key encoding, which supports all key types. Files xitdb-clj creates are in this mode unless asked otherwise, with header ID clj1.
  • Compat mode shares files with other languages, and every file whose header is not clj1 is in it. A string key hashes as its raw UTF-8 bytes; writing any other key or set member throws IllegalArgumentException, reading one finds nothing and removing one does nothing. Native maps and sets are written plain rather than counted, so other languages can read them with their plain hash map and set types, and count on them walks the collection.

opts takes :mode, :clojure or :compat, which throws IllegalArgumentException for any other value. It picks the mode of a new file, and a new compat file gets header ID sha1. An existing file in the other mode is rejected without being modified, for callers that rely on one mode.

Files written by xitdb-clj 0.5.0 and earlier have header ID 0, like Java files, but are rejected in every mode because they use an older file format, so they never open in compat mode, where their lookups would miss and writes would create duplicates. They must be migrated (see the README).

Returns a new XITDBDatabase which can be used to query and transact data.
`filename` can be `:memory` or the name of a file on the filesystem.
If the file does not exist, it will be created.
The returned database handle can be used from multiple threads, and so can the
values read from it. Reads can run in parallel, transactions (eg. `swap!`) will
only allow one writer at a time.

An existing file opens in the mode its header records (see `db-mode`):
- Clojure mode uses the Clojure key encoding, which supports all key types.
  Files xitdb-clj creates are in this mode unless asked otherwise, with header
  ID clj1.
- Compat mode shares files with other languages, and every file whose header
  is not clj1 is in it. A string key hashes as its raw UTF-8 bytes; writing any
  other key or set member throws IllegalArgumentException, reading one finds
  nothing and removing one does nothing. Native maps and sets are written plain
  rather than counted, so other languages can read them with their plain hash
  map and set types, and `count` on them walks the collection.

`opts` takes `:mode`, `:clojure` or `:compat`, which throws
IllegalArgumentException for any other value. It picks the mode of a new file,
and a new compat file gets header ID sha1. An existing file in the other mode
is rejected without being modified, for callers that rely on one mode.

Files written by xitdb-clj 0.5.0 and earlier have header ID 0, like Java files,
but are rejected in every mode because they use an older file format, so they
never open in compat mode, where their lookups would miss and writes would
create duplicates. They must be migrated (see the README).
sourceraw docstring

xitdb-reset!clj

(xitdb-reset! history new-value)

Sets the value of the database to new-value. Returns the new history count.

Sets the value of the database to `new-value`.
Returns the new history count.
sourceraw docstring

xitdb-swap!clj

(xitdb-swap! db base-keypath f & args)

Starts a new transaction and calls f with the value at base-keypath. If base-keypath is nil, will use the root cursor. f will receive a XITDBWrite* type with the value at base-keypath and args. Actions on the XITDBWrite* type (like assoc) will mutate it. Return value of f is written at base-keypath (or root) cursor. Returns the new history count.

Starts a new transaction and calls `f` with the value at `base-keypath`.
If `base-keypath` is nil, will use the root cursor.
`f` will receive a XITDBWrite* type with the value at `base-keypath` and `args`.
Actions on the XITDBWrite* type (like `assoc`) will mutate it.
Return value of `f` is written at `base-keypath` (or root) cursor.
Returns the new history count.
sourceraw docstring

xitdb-swap-with-lock!clj

(xitdb-swap-with-lock! xitdb base-keypath f & args)

Performs the 'swap!' operation while locking db.lock. Returns the new value of the database. If the binding *return-history?* is true, returns [history-count value-before value-after], where the written version is (deref-at xitdb (dec history-count)). If keypath is not empty, the result of f will be written to the db at keypath rather than db root. Similarly, if keypath is not empty, the returned value will be the value at keypath.

Performs the 'swap!' operation while locking `db.lock`.
Returns the new value of the database.
If the binding `*return-history?*` is true, returns
`[history-count value-before value-after]`, where the written version is
`(deref-at xitdb (dec history-count))`.
If `keypath` is not empty, the result of `f` will be written to the db at `keypath` rather
than db root.
Similarly, if `keypath` is not empty, the returned value will be the value at `keypath`.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close