The treedb Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The treedb Reference Manual

This is the treedb Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 06:02:10 2022 GMT+0.

Table of Contents


1 Introduction

treedb

treedb is a simple in-memory database for hierarchical keys. This means, your keys are structured like a path in a file system or a system registry.

Features

Planned features

Installation

treedb comes with an ASDF system, so it can be loaded via ASDF or as a local project via quicklisp.

Usage

treedb lives in the package treedb.

Here are some examples:

;;create a new instance
(defparameter *db* (treedb:make-alist-treedb))

;;set values:
(setf (treedb:node *db* :a :1) "Hello" ; /:a/:1 <- "Hello"
      (treedb:node *db* :a :2) :world  ; /:a/:2 <- :world
      (treedb:node *db* :b) 1          ; /:b <- 1
      (treedb:node *db* :c) '((1 . 2) (3 . 4))) ; /:c <- '((1 . 2) (3 . 4))

;;get values
(treedb:node *db* :a :1) ; => "Hello"

;;delete nodes
(treedb:del-node *db* :b)

;;list keys
(treedb:children *db*) ; => (:A :C)
(treedb:children *db* :a) ; => (:|1| :|2|)

;;take a subtree
(treedb:subtree *db* :a) ; => subtree from :a

;;convert to alists or json (via cl-json)
(treedb:to-alist (treedb:subtree *db* :a))
  ; => ((:1 . "Hello") (:2 . :world))
(treedb:to-json (treedb:subtree *db* :a))
  ; => "{\"2\":\"world\",\"1\":\"Hello\"}"

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 treedb

A hierarchical key-value-database

Author

Christoph Finkensiep <chfin@freenet.de>

License

MIT

Dependency

cl-json (system).

Source

treedb.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 treedb/treedb.asd

Source

treedb.asd.

Parent Component

treedb (system).

ASDF Systems

treedb.


3.1.2 treedb/package.lisp

Source

treedb.asd.

Parent Component

treedb (system).

Packages

treedb.


Previous: , Up: Lisp   [Contents][Index]

3.1.3 treedb/treedb.lisp

Dependency

package.lisp (file).

Source

treedb.asd.

Parent Component

treedb (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 treedb

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Macros

Macro: node-or (db default &rest keys)

=> the value at ‘/k/e/y/s or ‘default‘
Returns the value at ‘keys or, if it is not found, ‘default‘.

Package

treedb.

Source

treedb.lisp.


5.1.2 Ordinary functions

Function: make-alist-treedb ()

Returns an empty tree of type ‘<alist-treedb>‘.

Package

treedb.

Source

treedb.lisp.


5.1.3 Generic functions

Generic Function: children (db &rest keys)

=> children of node ‘/k/e/y/s‘
Returns a list of keys, which are the children of the given node.

Package

treedb.

Source

treedb.lisp.

Methods
Method: children ((db <alist-treedb>) &rest keys)
Generic Function: del-node (db &rest keys)

=> the deleted value
Deletes the value at ‘/k/e/y/s‘.

Package

treedb.

Source

treedb.lisp.

Methods
Method: del-node ((db <alist-treedb>) &rest keys)
Generic Function: leaf-p (db &rest keys)

=> ‘t‘ or ‘nil‘
Tests, if ‘/k/e/y/s‘ is a leaf in ‘db‘.

Package

treedb.

Source

treedb.lisp.

Methods
Method: leaf-p ((db <alist-treedb>) &rest keys)
Generic Function: node (db &rest keys)

=> (the value at ‘/k/e/y/s‘, ‘t‘ / ‘nil‘) Returns the value of a leaf node as the first and ‘t‘ or ‘nil‘ as the second value, depending on if the node was found or not. Can be used with ‘setf‘.

Package

treedb.

Source

treedb.lisp.

Methods
Method: node ((db <alist-treedb>) &rest keys)
Generic Function: (setf node) (db &rest keys)

=> ‘val‘
Sets the value at ‘/k/e/y/s‘ to ‘val‘.

Package

treedb.

Source

treedb.lisp.

Methods
Method: (setf node) ((db <alist-treedb>) &rest keys)
Generic Function: node-p (db &rest keys)

=> ‘t‘ or ‘nil‘
Tests, if ‘/k/e/y/s‘ is a node in ‘db‘.

Package

treedb.

Source

treedb.lisp.

Methods
Method: node-p ((db <alist-treedb>) &rest keys)
Generic Function: subtree (db &rest keys)

=> subtree at ‘/k/e/y/s‘
Returns a new tree object with the contents of the subtree. The new object has the same type as ‘db‘.

Package

treedb.

Source

treedb.lisp.

Methods
Method: subtree ((db <alist-treedb>) &rest keys)
Generic Function: to-alist (db)

=> a nested alist
Returns the tree in alist form

Package

treedb.

Source

treedb.lisp.

Methods
Method: to-alist ((db <alist-treedb>))
Generic Function: to-json (db &optional stream)

=> a json string or ‘nil‘
Serializes the tree into json objects.
If ‘stream‘ is supplied, the json object is written to the corresponding stream. Otherwise it is returned as a string.

Package

treedb.

Source

treedb.lisp.

Methods
Method: to-json ((db <alist-treedb>) &optional stream)

5.1.4 Conditions

Condition: node-no-leaf-error

Signaled, if a given node is not a leaf.

Package

treedb.

Source

treedb.lisp.

Direct superclasses

error.

Condition: node-not-found-error

Signaled, if a node to delete was not found in the tree.

Package

treedb.

Source

treedb.lisp.

Direct superclasses

error.


5.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.1 Ordinary functions

Function: subtree-p (sub)
Package

treedb.

Source

treedb.lisp.

Function: to-key (src)
Package

treedb.

Source

treedb.lisp.

Function: to-keys (keys)
Package

treedb.

Source

treedb.lisp.

Function: value-p (sub)
Package

treedb.

Source

treedb.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.2 Generic functions

Generic Reader: root (object)
Package

treedb.

Methods
Reader Method: root ((<alist-treedb> <alist-treedb>))

automatically generated reader method

Source

treedb.lisp.

Target Slot

root.

Generic Writer: (setf root) (object)
Package

treedb.

Methods
Writer Method: (setf root) ((<alist-treedb> <alist-treedb>))

automatically generated writer method

Source

treedb.lisp.

Target Slot

root.


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.3 Conditions

Condition: malformed-tree-error

Signaled, if an internal error occurs. Probably means, you found a bug.

Package

treedb.

Source

treedb.lisp.

Direct superclasses

error.


Previous: , Up: Internals   [Contents][Index]

5.2.4 Classes

Class: <alist-treedb>
Package

treedb.

Source

treedb.lisp.

Direct methods
Direct slots
Slot: root
Type

list

Initform

(list :tree)

Initargs

:root

Readers

root.

Writers

(setf root).


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
C   D   F   G   L   M   N   R   S   T   V  
Index Entry  Section

(
(setf node): Public generic functions
(setf node): Public generic functions
(setf root): Private generic functions
(setf root): Private generic functions

C
children: Public generic functions
children: Public generic functions

D
del-node: Public generic functions
del-node: Public generic functions

F
Function, make-alist-treedb: Public ordinary functions
Function, subtree-p: Private ordinary functions
Function, to-key: Private ordinary functions
Function, to-keys: Private ordinary functions
Function, value-p: Private ordinary functions

G
Generic Function, (setf node): Public generic functions
Generic Function, (setf root): Private generic functions
Generic Function, children: Public generic functions
Generic Function, del-node: Public generic functions
Generic Function, leaf-p: Public generic functions
Generic Function, node: Public generic functions
Generic Function, node-p: Public generic functions
Generic Function, root: Private generic functions
Generic Function, subtree: Public generic functions
Generic Function, to-alist: Public generic functions
Generic Function, to-json: Public generic functions

L
leaf-p: Public generic functions
leaf-p: Public generic functions

M
Macro, node-or: Public macros
make-alist-treedb: Public ordinary functions
Method, (setf node): Public generic functions
Method, (setf root): Private generic functions
Method, children: Public generic functions
Method, del-node: Public generic functions
Method, leaf-p: Public generic functions
Method, node: Public generic functions
Method, node-p: Public generic functions
Method, root: Private generic functions
Method, subtree: Public generic functions
Method, to-alist: Public generic functions
Method, to-json: Public generic functions

N
node: Public generic functions
node: Public generic functions
node-or: Public macros
node-p: Public generic functions
node-p: Public generic functions

R
root: Private generic functions
root: Private generic functions

S
subtree: Public generic functions
subtree: Public generic functions
subtree-p: Private ordinary functions

T
to-alist: Public generic functions
to-alist: Public generic functions
to-json: Public generic functions
to-json: Public generic functions
to-key: Private ordinary functions
to-keys: Private ordinary functions

V
value-p: Private ordinary functions

Jump to:   (  
C   D   F   G   L   M   N   R   S   T   V  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   R   S  
Index Entry  Section

R
root: Private classes

S
Slot, root: Private classes

Jump to:   R   S