chiark / gitweb /
much work on hash tables etc.
[chiark-tcl.git] / cdb / cdb.tct
index fca6ecbcab0e6ddb2605ddcd5a46e8ecadf6a67d..0999af9d94018820df2bc43cd76f78836ddde89e 100644 (file)
@@ -22,7 +22,7 @@ Table cdb Cdb_SubCommand
                db      iddata(&cdbtcl_databases)
 
 Table cdbwr Cdbwr_SubCommand
-       create-empty -1
+       create-empty 0
                pathb   string
                # files:
                #       <pathb>.main
@@ -35,29 +35,51 @@ Table cdbwr Cdbwr_SubCommand
                #         which is locked with fcntl by open
                #       .main is a cdb native text file
                #         and always exists
-               #       if .tmp exists it is irrelevant
-               #       if .cdb exists it is a cdb database
-               #         containing exactly the same as .main
+               #       .cdb is a cdb database containing data
+               #         equivalent to and at least as recent as .main
+               #         (maybe not identical, because .cdb may
+               #         have been updated with data from .log but
+               #         .main not yet); if .log does not exist then
+               #         they are identical)
+               #       .cdb may not exist; in which case it is to
+               #         be treated as if it existed and was empty
+               #         but this is maximally early (so main must
+               #         exist and be empty since .main is never
+               #         newer than .cdb)
                #       if .log exists, it is a cdb native
                #         text file _without the trailing newline_;
                #         its contents override values from .main or .cdb
-       open -1
+               #       if .main.tmp or .cdb.tmp exists it is irrelevant
+               # zero length values mean record is deleted (in .log only;
+               #  forbidden elsewhere)
+               # while db is open:
+               #       .lock is locked
+               #       .log and open hash table contain same info
+       open 0
+               pathb   string
+               on_info obj
+               =>      iddata(&cdbtcl_rwdatabases)
+       open-okjunk RWSCF_OKJUNK
                pathb   string
                on_info obj
                =>      iddata(&cdbtcl_rwdatabases)
                # on_info <event> <xinfo>...:
                # on_info open-clean <statistics-info-string>
-               # on_info open-dirty <statistics-info-string>
+               # on_info open-dirty-start <statistics-info-string>
+               # on_info open-dirty-junk <problem-info-string>
+               # on_info open-dirty-done <statistics-info-string>
                # on_info compact-start <statistics-info-string>
-               # on_info compact-end <statistics-info-string>
+               # on_info compact-done <statistics-info-string>
                # on_info close <statistics-info-string>
-       lookup 1
+       lookup 0
                db      iddata(&cdbtcl_rwdatabases)
                key     obj
+               ?def    obj
                =>      obj
-       lookup-hb 1
+       lookup-hb 0
                db      iddata(&cdbtcl_rwdatabases)
                key     hb
+               ?def    hb
                =>      hb
        update 0
                db      iddata(&cdbtcl_rwdatabases)
@@ -67,18 +89,16 @@ Table cdbwr Cdbwr_SubCommand
                db      iddata(&cdbtcl_rwdatabases)
                key     hb
                value   hb
-       update-quick 1
+       compact-force 0
                db      iddata(&cdbtcl_rwdatabases)
-               key     obj
-               value   obj
-       update-quick-hb 1
+       compact-check 0
                db      iddata(&cdbtcl_rwdatabases)
-               key     hb
-               value   hb
-       close 0
+       compact-onupdate 0 # this is the default
                db      iddata(&cdbtcl_rwdatabases)
-       close-quick 1
+       compact-explicit 0
+               db      iddata(&cdbtcl_rwdatabases)
+       close 0
                db      iddata(&cdbtcl_rwdatabases)
 
 EntryExtra Cdbwr_SubCommand
-       int quick;
+       unsigned flags;