chiark / gitweb /
much work on hash tables etc.
[chiark-tcl.git] / cdb / cdb.tct
1 Table *cdbtoplevel TopLevel_Command
2         cdb
3                 subcmd  enum(Cdb/_SubCommand, "cdb subcommand")
4                 ...     obj
5         cdb-wr
6                 subcmd  enum(Cdbwr/_SubCommand, "cdb-wr subcommand")
7                 ...     obj
8
9 Table cdb Cdb_SubCommand
10         open
11                 path    string
12                 =>      iddata(&cdbtcl_databases)
13         lookup
14                 db      iddata(&cdbtcl_databases)
15                 key     obj
16                 =>      obj
17         lookup-hb
18                 db      iddata(&cdbtcl_databases)
19                 key     hb
20                 =>      hb
21         close
22                 db      iddata(&cdbtcl_databases)
23
24 Table cdbwr Cdbwr_SubCommand
25         create-empty 0
26                 pathb   string
27                 # files:
28                 #       <pathb>.main
29                 #       <pathb>.lock
30                 #       <pathb>.cdb
31                 #       <pathb>.log
32                 #       <pathb>.tmp (might be new .main or new .cdb)
33                 # invariants:
34                 #       .lock is an empty file
35                 #         which is locked with fcntl by open
36                 #       .main is a cdb native text file
37                 #         and always exists
38                 #       .cdb is a cdb database containing data
39                 #         equivalent to and at least as recent as .main
40                 #         (maybe not identical, because .cdb may
41                 #         have been updated with data from .log but
42                 #         .main not yet); if .log does not exist then
43                 #         they are identical)
44                 #       .cdb may not exist; in which case it is to
45                 #         be treated as if it existed and was empty
46                 #         but this is maximally early (so main must
47                 #         exist and be empty since .main is never
48                 #         newer than .cdb)
49                 #       if .log exists, it is a cdb native
50                 #         text file _without the trailing newline_;
51                 #         its contents override values from .main or .cdb
52                 #       if .main.tmp or .cdb.tmp exists it is irrelevant
53                 # zero length values mean record is deleted (in .log only;
54                 #  forbidden elsewhere)
55                 # while db is open:
56                 #       .lock is locked
57                 #       .log and open hash table contain same info
58         open 0
59                 pathb   string
60                 on_info obj
61                 =>      iddata(&cdbtcl_rwdatabases)
62         open-okjunk RWSCF_OKJUNK
63                 pathb   string
64                 on_info obj
65                 =>      iddata(&cdbtcl_rwdatabases)
66                 # on_info <event> <xinfo>...:
67                 # on_info open-clean <statistics-info-string>
68                 # on_info open-dirty-start <statistics-info-string>
69                 # on_info open-dirty-junk <problem-info-string>
70                 # on_info open-dirty-done <statistics-info-string>
71                 # on_info compact-start <statistics-info-string>
72                 # on_info compact-done <statistics-info-string>
73                 # on_info close <statistics-info-string>
74         lookup 0
75                 db      iddata(&cdbtcl_rwdatabases)
76                 key     obj
77                 ?def    obj
78                 =>      obj
79         lookup-hb 0
80                 db      iddata(&cdbtcl_rwdatabases)
81                 key     hb
82                 ?def    hb
83                 =>      hb
84         update 0
85                 db      iddata(&cdbtcl_rwdatabases)
86                 key     obj
87                 value   obj
88         update-hb 0
89                 db      iddata(&cdbtcl_rwdatabases)
90                 key     hb
91                 value   hb
92         compact-force 0
93                 db      iddata(&cdbtcl_rwdatabases)
94         compact-check 0
95                 db      iddata(&cdbtcl_rwdatabases)
96         compact-onupdate 0 # this is the default
97                 db      iddata(&cdbtcl_rwdatabases)
98         compact-explicit 0
99                 db      iddata(&cdbtcl_rwdatabases)
100         close 0
101                 db      iddata(&cdbtcl_rwdatabases)
102
103 EntryExtra Cdbwr_SubCommand
104         unsigned flags;