summaryrefslogtreecommitdiff
path: root/src/hdb/README
diff options
context:
space:
mode:
Diffstat (limited to 'src/hdb/README')
-rw-r--r--src/hdb/README154
1 files changed, 154 insertions, 0 deletions
diff --git a/src/hdb/README b/src/hdb/README
new file mode 100644
index 0000000..0db7269
--- /dev/null
+++ b/src/hdb/README
@@ -0,0 +1,154 @@
1/*************************************************************************
2 *
3 * HTCd - Copyright (C) 1998-2006 Henrik Rydberg
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20HDB/1.2 FILE FORMAT SPECIFICATION Sat Feb 24 18:38:25 MET 2001
21
22MT AND MP SAFE
23
24One single format utilizing memory maps, and which is designed to
25work safely between processes and within a multi-threading process.
26To accomplish this, there are two types of locking mechanisms -
27one inter-process lock in the file header, and one MT lock implemented
28the usual way.
29
30The format is robust within each thread, except for changes in the
31table structure, which generates fatal error_t errors.
32
33The format includes a finite (32) number of tables, which should not
34be a real problem. Besides, a possible change is to move the frame
35pointer to a position inside, so that additional header could be
36added if needed.
37
38FILEFORMAT in HDB/1.2
39
40BYTES 1.2 NAME DESCRIPTION
4132 IDENT Identification header
424 LOCK Inter-process lock
434 MINOR Minor modification state number
444 MAJOR Major modification state number
454 FATAL Fatal modification state number
464 FILESIZE Size of file
474 FILETOP Size of used part
484 TABLES Number of table name strings
494 INDEX Which column is the order column.
5032 COMPNAME Comparison name
5132*32 TABLENAMES Table names
524 FRAME Start of record data
53* RECORDS Record list
54 4 mem amount of memory for this record
55 4 caps the capacity of this record - 0 means deleted
56 mem-8 data The data follows
570 ZEROS The rest of the file is padded with zeros.
58
59The records are always staying where they land; a minor change means
60a change in-place, a major change means a change leading to an index
61update, which could be a deletion, an insertion. Those are updated at
62will, and not seen until wanted. A fatal change is a change in the
63table structure, i.e., an insertion or deletion of a table. Also a
64table name change counts as fatal. The filesize used to be (earlier
65versions) a state needing attention as well, but not anymore.
66
67--
68
69HDB/1.11 FILE FORMAT SPECIFICATION Mon Jan 29 03:51:41 MET 2001
70
71STATIC/DYNAMIC mapping
72
73The header field determines whether the mapping is dynamic or static,
74i.e., static mapping creates a shared mmap and edits the records
75directly, whereas the dynamic mapping creates a private map and
76stores the changes on save only.
77
78The format changed quite a lot after all...
79
80FILEFORMAT in HDB/1.11
81
82BYTES 1.11 NAME DESCRIPTION
8332 IDENT Identification header
844 MODNUM Modification number
854 LOCK Soft lock
864 FILESIZE Size of file
874 FILETOP Size of used part
884 FIXED Whether fixed mapping or not
894 TABLES Number of table name strings
904 INDEX Which column is the order column.
9132 COMPNAME Comparison name
924 RECORDS Number of records in file.
93 tables
94 4,* name table name
95 4,* defaults default string
96 4 caps default sizes
97 [4],* records TABLES[RECORDS]
98
99Size info [4] always refers to the stringref-size, but the number of
100bytes actually written is as follows: for fixed maps, it is tabs[].caps,
101and for dynamic maps, it is capsize(), which is defined as (n=stringref-size)
102(4+n)&~3.
103
104--
105
106HDB/1.10 FILE FORMAT SPECIFICATION Thu Jan 25 00:42:49 MET 2001
107
108The HDB/1.0 format has been used widely in the software
109for our group (MST) during the last three years of so.
110The HDB/1.1 file format is binary compatible with 1.0,
111and merely consists of a formalization, along with a
112change in the internal manipulation scheme and a new
113hdb editor.
114
115FILE FORMAT IN 1.0 and 1.1
116
117BYTES 1.0/1.1 NAME DESCRIPTION
11832/variable HEAD Identification header.
119 Used to be exactly 32 bytes,
120 but see no point in that.
1214 TABLES Number of table name strings
122 4 dim bytes in string
123 * data string data
1244 DEFAULTS Number of default strings
125 4 dim bytes in string
126 * data string data
1274 ORDERBY Which column is the order column.
1284 dim Number of bytes in compname.
129* data string data
1304 RECORDS Number of records in file.
131 4 tables
132 4 dim
133 * data
1340/variable FOOTER File ends. Simple Footer.
135
136ADDITIONAL CHANGES BETWEEN 1.0 and 1.1
137
138The major difference - and the rationale for 1.1 - is
139the possiblity to edit files directly, as in mmap.
140To be able to do this, there is a need to force a minimum
141size to each field. This is done by padding the data
142with trailing zeros. This is ok since only string data
143is stored in the fields, and never binary data. Just think
144of it; if it was binary data, it would not be replaced
145by something the same size anyways, so thats forbidden
146in the direct-editing mode. It makes no difference to
147the normal operation.
148
149The default sizes for new fields are taken from the defaults
150table, which again is completely compatible. The only
151difference is that the zeros are stored as well, and hence
152cannot be defined just by the default string, but need an editor
153that specifies the sizes.
154