The treedb Reference Manual

Table of Contents

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

The treedb Reference Manual

This is the treedb Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Tue Feb 20 09:26:06 2018 GMT+0.


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

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\"}"

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

2 Systems

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


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

2.1 treedb

Author

Christoph Finkensiep <chfin@freenet.de>

License

MIT

Description

A hierarchical key-value-database

Dependency

cl-json

Source

treedb.asd (file)

Components

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

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 files   [Contents][Index]

3.1.1 treedb.asd

Location

treedb.asd

Systems

treedb (system)


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

3.1.2 treedb/package.lisp

Parent

treedb (system)

Location

package.lisp

Packages

treedb


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

3.1.3 treedb/treedb.lisp

Dependency

package.lisp (file)

Parent

treedb (system)

Location

treedb.lisp

Exported Definitions
Internal Definitions

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

4 Packages

Packages are listed by definition order.


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

4.1 treedb

Source

package.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

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

5 Definitions

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


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

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

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 (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: make-alist-treedb ()

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

Package

treedb

Source

treedb.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

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 (file)

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 (file)

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 (file)

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 (file)

Writer

(setf node) (generic function)

Methods
Method: node (DB <alist-treedb>) &rest KEYS
Generic Function: (setf node) VAL DB &rest KEYS

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

Package

treedb

Source

treedb.lisp (file)

Reader

node (generic function)

Methods
Method: (setf node) VAL (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 (file)

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 (file)

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 (file)

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 (file)

Methods
Method: to-json (DB <alist-treedb>) &optional STREAM

Previous: , Up: Exported definitions   [Contents][Index]

5.1.4 Conditions

Condition: node-no-leaf-error ()

Signaled, if a given node is not a leaf.

Package

treedb

Source

treedb.lisp (file)

Direct superclasses

error (condition)

Condition: node-not-found-error ()

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

Package

treedb

Source

treedb.lisp (file)

Direct superclasses

error (condition)


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

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Functions

Function: subtree-p SUB
Package

treedb

Source

treedb.lisp (file)

Function: to-key SRC
Package

treedb

Source

treedb.lisp (file)

Function: to-keys KEYS
Package

treedb

Source

treedb.lisp (file)

Function: value-p SUB
Package

treedb

Source

treedb.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Generic functions

Generic Function: root OBJECT
Generic Function: (setf root) NEW-VALUE OBJECT
Package

treedb

Methods
Method: root (<ALIST-TREEDB> <alist-treedb>)

automatically generated reader method

Source

treedb.lisp (file)

Method: (setf root) NEW-VALUE (<ALIST-TREEDB> <alist-treedb>)

automatically generated writer method

Source

treedb.lisp (file)


Next: , Previous: , Up: Internal definitions   [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 (file)

Direct superclasses

error (condition)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.4 Classes

Class: <alist-treedb> ()
Package

treedb

Source

treedb.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: root
Type

list

Initargs

:root

Initform

(list :tree)

Readers

root (generic function)

Writers

(setf root) (generic function)


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

Appendix A Indexes


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

A.1 Concepts

Jump to:   F   L   T  
Index Entry  Section

F
File, Lisp, treedb.asd: The treedb<dot>asd file
File, Lisp, treedb/package.lisp: The treedb/package<dot>lisp file
File, Lisp, treedb/treedb.lisp: The treedb/treedb<dot>lisp file

L
Lisp File, treedb.asd: The treedb<dot>asd file
Lisp File, treedb/package.lisp: The treedb/package<dot>lisp file
Lisp File, treedb/treedb.lisp: The treedb/treedb<dot>lisp file

T
treedb.asd: The treedb<dot>asd file
treedb/package.lisp: The treedb/package<dot>lisp file
treedb/treedb.lisp: The treedb/treedb<dot>lisp file

Jump to:   F   L   T  

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): Exported generic functions
(setf node): Exported generic functions
(setf root): Internal generic functions
(setf root): Internal generic functions

C
children: Exported generic functions
children: Exported generic functions

D
del-node: Exported generic functions
del-node: Exported generic functions

F
Function, make-alist-treedb: Exported functions
Function, subtree-p: Internal functions
Function, to-key: Internal functions
Function, to-keys: Internal functions
Function, value-p: Internal functions

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

L
leaf-p: Exported generic functions
leaf-p: Exported generic functions

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

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

R
root: Internal generic functions
root: Internal generic functions

S
subtree: Exported generic functions
subtree: Exported generic functions
subtree-p: Internal functions

T
to-alist: Exported generic functions
to-alist: Exported generic functions
to-json: Exported generic functions
to-json: Exported generic functions
to-key: Internal functions
to-keys: Internal functions

V
value-p: Internal 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: Internal classes

S
Slot, root: Internal classes

Jump to:   R   S  

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

A.4 Data types

Jump to:   <  
C   M   N   P   S   T  
Index Entry  Section

<
<alist-treedb>: Internal classes

C
Class, <alist-treedb>: Internal classes
Condition, malformed-tree-error: Internal conditions
Condition, node-no-leaf-error: Exported conditions
Condition, node-not-found-error: Exported conditions

M
malformed-tree-error: Internal conditions

N
node-no-leaf-error: Exported conditions
node-not-found-error: Exported conditions

P
Package, treedb: The treedb package

S
System, treedb: The treedb system

T
treedb: The treedb system
treedb: The treedb package

Jump to:   <  
C   M   N   P   S   T