This file is a small documentation for files that provided by tellydb. Specified file names are default file names. They can be changed from configuration file. Configuration file is changeable via command argument.
It consists of file headers, authorization part and data lines.
file headers + authorization part + databases
File headers have 10 bytes size and is as follows:
0x1810 + server age (8-byte)
In this file, a structure named string length specifier for strings is defined as follows:
A string length is maximum
2^30-1and represented by 30 bit (6-bit + 3-byte).
A string length specifier is minimum 1 byte, maximum 4 byte. First two bits of first byte represents additional byte count.
For example, construction of string length using0b(10|100010) 0x07 0x09data is as follows:A: 0b(10|100010)
B: 0x07 = 0b00000111
C: 0x09 = 0b00001001Value of two bits before
|is0b10or2. This shows that existence of additional two bytes (B and C).
The six bits after|and additional bytes represents string length as reversed.
C + B + (Bits after | in A)or0b00001001_00000111_100010is147938.
Authorization part consists of passwords and their permissions and as follows:
password count byte count (1-byte, n) + password count (n-byte) + passwords
A password is as follows:
derived password (48-byte) + password permissions (1-byte)
For permissions, look at AUTH.md.
It consists of database names and their data lines.
key-value pair count (8-byte) + string length specifier + database name + data lines
A data line is as follows:
string length specifier + data key + data type + data value- Data key is a string.
Data value scheme is defined as:
Note
All content of data value that stores a number (list size, byte count, number etc.) is little-endian.
- For
TELLY_NULL (0x00)type, data value is nothing and the line consists ofdata key + 0x1D + TELLY_NULL. - For
TELLY_INT (0x01)type, data value isspecifier byte + number.
Note
All bits are used in specifier byte, the leftest bit represents the sign:
0 represents positive.
1 represents negative.
Other bits of specifier byte represent byte count of the number. For example:
0b11010000 represents a negative number that represented by 80 bytes.
Numbers are saved in Big-Endian format.
- For
TELLY_DOUBLE (0x02)type, data value isspecifier byte + point indicator byte + number.
Note
All bits are used in specifier byte, the leftest bit represents the sign:
0 represents positive.
1 represents negative.
Other bits of specifier byte represent byte count of the number. For example:
0b11010000 represents a negative number that represented by 80 bytes.
All bits are used in point indicator byte, the leftest bit represents that whether point is exist or not, it bit is for zeroed double values.
Other bits indicate posiiton of point in double value.
Numbers are saved in Big-Endian format.
-
For
TELLY_STR (0x03)type, data value isstring length specifier + string data. -
For
TELLY_BOOL (0x04)type, data value is0x00or0x01. -
For
TELLY_HASHTABLE (0x05)type, data value ishash table allocated size (n) + hash table element 1 + hash table element 2 ... hash table element n + 0x17.
Important
The hash table allocated size is a 4-byte value. For example, 32 is represented as 0x20 0x00 0x00 0x00.
A hash table element is element type + string length specifier + element key + element value.
Element values are data values, so their rules are same as data value rules.
Additionally, type of a hash table element should be TELLY_NULL, TELLY_INT, TELLY_DOUBLE, TELLY_STR or TELLY_BOOL.
- For
TELLY_LIST (0x06)type, data value islist size (n) + list element 1 + list element 2 ... list element n.
Important
The list size is a 4-byte value. For example, 32 is represented as 0x20 0x00 0x00 0x00.
A list element is element type + element value and element values are data values, so their rules are same as data value rules.
Additionally, type of a list element should be TELLY_NULL, TELLY_INT, TELLY_DOUBLE, TELLY_STR or TELLY_BOOL.
It consists of lines that are comments and values. A comment line is as follows:
#any text, no need a blank character after # character.
A value line is as follows:
KEY=VALUE
Maximum key length and maximum value length is 48.