changelog shortlog graph tags branches changeset file revisions annotate raw help

Mercurial > demo / examples/db/xdb/proto.lisp

revision 41: 81b7333f27f8
     1.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2+++ b/examples/db/xdb/proto.lisp	Sun Jun 16 22:15:04 2024 -0400
     1.3@@ -0,0 +1,86 @@
     1.4+(in-package :xdb)
     1.5+
     1.6+(defgeneric initialize-doc-container (collection)
     1.7+  (:documentation
     1.8+   "Create the docs container and set the collection's docs to the container.
     1.9+If you specialize this then you have to specialize add-doc, store-doc,
    1.10+sort-collection, sort-collection-temporary and union-collection. "))
    1.11+
    1.12+(defgeneric map-docs (result-type function collection &rest more-collections)
    1.13+  (:documentation
    1.14+   "Applies the function accross all the documents in the collection"))
    1.15+
    1.16+(defgeneric duplicate-doc-p (doc test-doc)
    1.17+  (:method ((a t) (b t))))
    1.18+
    1.19+(defgeneric find-duplicate-doc (collection doc &key function)
    1.20+  (:documentation "Load collection from a file."))
    1.21+
    1.22+(defgeneric add-doc (collection doc &key duplicate-doc-p-func)
    1.23+  (:documentation "Add a document to the docs container."))
    1.24+
    1.25+(defgeneric store-doc (collection doc &key duplicate-doc-p-func)
    1.26+  (:documentation "Serialize the doc to file and add it to the collection."))
    1.27+
    1.28+(defgeneric serialize-doc (collection doc &key)
    1.29+  (:documentation "Serialize the doc to file."))
    1.30+
    1.31+(defgeneric serialize-docs (collection &key duplicate-doc-p-func)
    1.32+  (:documentation "Store all the docs in the collection on file and add it to the collection."))
    1.33+
    1.34+(defgeneric load-from-file (collection file)
    1.35+  (:documentation "Load collection from a file."))
    1.36+
    1.37+(defgeneric get-collection (db name)
    1.38+  (:documentation "Returns the collection by name."))
    1.39+
    1.40+(defgeneric add-collection (db name &key load-from-file-p)
    1.41+  (:documentation "Adds a collection to the db."))
    1.42+
    1.43+(defgeneric snapshot (collection)
    1.44+  (:documentation "Write out a snapshot."))
    1.45+
    1.46+(defgeneric load-db (db &key load-from-file-p)
    1.47+  (:documentation "Loads all the collections in a location."))
    1.48+
    1.49+(defgeneric get-docs (db collection-name &key return-type &allow-other-keys)
    1.50+  (:documentation "Returns the docs that belong to a collection."))
    1.51+
    1.52+(defgeneric get-doc (collection value  &key element test)
    1.53+  (:documentation "Returns the docs that belong to a collection."))
    1.54+
    1.55+(defgeneric get-doc-complex (test element value collection  &rest more-collections)
    1.56+  (:documentation "Returns the docs that belong to a collection."))
    1.57+
    1.58+(defgeneric get-doc-simple (element value collection  &rest more-collections)
    1.59+  (:documentation "Returns the docs that belong to a collection."))
    1.60+
    1.61+(defgeneric find-doc (collection &key test)
    1.62+  (:documentation "Returns the docs that belong to a collection."))
    1.63+
    1.64+(defgeneric find-doc-complex (test collection &rest more-collections)
    1.65+  (:documentation "Returns the first doc that matches the test."))
    1.66+
    1.67+(defgeneric find-docs (return-type test collection))
    1.68+
    1.69+(defgeneric union-collection (return-type collection &rest more-collections))
    1.70+
    1.71+(defgeneric sort-collection (collection &key return-sort sort-value-func sort-test-func)
    1.72+  (:documentation "This sorts the collection 'permanantly'."))
    1.73+
    1.74+(defgeneric sort-collection-temporary (collection &key sort-value-func sort-test-func)
    1.75+  (:documentation "This does not sort the actual collection but returns an array
    1.76+of sorted docs."))
    1.77+
    1.78+(defgeneric sum (collection &key function &allow-other-keys)
    1.79+  (:documentation "Applies the function to all the docs in the collection and returns the sum of
    1.80+the return values."))
    1.81+
    1.82+(defgeneric max-val (collection &key function element))
    1.83+
    1.84+;;; Document
    1.85+(defgeneric add (doc &key collection duplicate-doc-p-func)
    1.86+  (:documentation "Add a document to the docs container."))
    1.87+
    1.88+;;; Disk
    1.89+(defgeneric write-object (object stream))