Apache Derby Disk Page Format

Apache Derby stores table and index data in Containers, which is a map to files in the seg0 directory of the database. Derby provides one to one mapping of containers with the files. Two containers can't map to a single file and 1 container can't map to multiple files. The actual data is put on the pages of the container.

The records are stored on the page and it is accessed by using "Slot" that represents the record order or it is accessed by the "ID" that identifies the records of the page. We can use the slot and id to access records.

A container has three types of Pages as mentioned below.

1. Header Page

It is a specialized version of the Alloc Page.

2. Data Pages

It is used to hold data.

3. Alloc Pages

It holds page allocation information. An Alloc page is a specialized version of the Data page.

The containers can be seen below.

containers derby

Data Page Format

A Data Page Format is divided into five parts which are mentioned below.

data format

Let us see each section of the Data Page in detail.

1. Format Id

The formatid is used to store the formatid of the page. It is a 4 bytes array. The probable values are RAW_STORE_STORED_PAGE or RAW_STORE_ALLOC_PAGE.

2. Page Header

The page header is a fixed size format that stores 56 bytes.

3. Records

This part of the Data Page format stores the actual records with each having a records header.

4. Slot Offset Table

The size of the slot offset table is greater than or less than 64K.

5. Checksum

It is 8 bytes of a java.util.zip.CRC32 checksum of the entire page contents.