This package provides an implementation of the heap file organization for NanoDB. All heap files in nanodb are accessed by pages, as is the case with virtually all NanoDB files. Following is a description of the storage format for heap files:
Page 0 is the header page, containing the table's schema and statistics information. All other pages are data pages, storing tuples using a slotted-page structure in each page. Relevant classes are:
The header page has the following structural layout:
Offset in Page | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | unsigned byte | File type, set to {@link edu.caltech.nanodb.storage.DBFileType#HEAP_DATA_FILE}. (See the {@link edu.caltech.nanodb.storage.FileManagerImpl} for code that accesses and manipulates this value.) | 1 | unsigned byte | Encoded page size p, where the actual page size is 2p. (See the {@link edu.caltech.nanodb.storage.FileManagerImpl} for code that accesses and manipulates this value.) | 2 ({@link edu.caltech.nanodb.storage.heapfile.HeaderPage#OFFSET_SCHEMA_SIZE}) | unsigned short |
The number of bytes in the header page occupied by the table schema. This value should not be 0, although the API allows it to be. (See {@link edu.caltech.nanodb.storage.heapfile.HeaderPage#getSchemaSize} and {@link edu.caltech.nanodb.storage.heapfile.HeaderPage#setSchemaSize} for accessing and manipulating this value.) |
4 ({@link edu.caltech.nanodb.storage.heapfile.HeaderPage#OFFSET_STATS_SIZE}) | unsigned short |
The number of bytes in the header page occupied by table statistics. This value may be 0 if the table currently has no statistics. (See {@link edu.caltech.nanodb.storage.heapfile.HeaderPage#getStatsSize} and {@link edu.caltech.nanodb.storage.heapfile.HeaderPage#setStatsSize} for accessing and manipulating this value.) |
6 ({@link edu.caltech.nanodb.storage.heapfile.HeaderPage#OFFSET_SCHEMA_START}) | [table schema] | The schema of the table, as written by the {@link edu.caltech.nanodb.storage.SchemaWriter} helper class. | [after table schema] | [table statistics] | The table's statistics, as written by the {@link edu.caltech.nanodb.storage.StatsWriter} helper class. |