3.1. File Format

3.1.1. Global File structure

Range

Name

Content

Synchronization

0…

Head

version + checkpoint

Shared lock when reading the checkpoint.

Exclusive lock when writing the checkpoint,

and during journal construction.

41…

Body

immutable journal

Never modified, never locked:

can be safely read without any synchronization.

checkpoint…

Tail

current transaction

Exclusive lock when writing the transaction,

and during journal construction.

3.1.3. Compact number format

Log entries use a compact number format for string length, record id, table id, and field id. This format allows very large values, but still takes very little space for small values.

Bytes of compact numbers are stored with the most significant bytes first. The number of extra bytes is stored in the 3 high-order bits of the first byte. Numbers between 0 and 31 included are stored as one byte. At most 61 bits can be stored.

Here are some examples

Number

Compact representation

0

00

1

01

2

02

31

1f

32

20 20

33

20 21

256

21 00

8191

3f ff

8192

40 20 00

3.1.4. Log Entry

See joedb/journal/Readonly_Journal.cpp.