/* ** 2011-08-14 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** PAGE FORMAT: ** ** The maximum page size is 65536 bytes. ** ** Since all records are equal to or larger than 2 bytes in size, and ** some space within the page is consumed by the page footer, there must ** be less than 2^15 records on each page. ** ** Each page ends with a footer that describes the pages contents. This ** footer serves as similar purpose to the page header in an SQLite database. ** A footer is used instead of a header because it makes it easier to ** populate a new page based on a sorted list of key/value pairs. ** ** The footer consists of the following values (starting at the end of ** the page and continuing backwards towards the start). All values are ** stored as unsigned big-endian integers. ** ** * Number of records on page (2 bytes). ** * Flags field (2 bytes). ** * Left-hand pointer value (8 bytes). ** * The starting offset of each record (2 bytes per record). ** ** Records may span pages. Unless it happens to be an exact fit, the part ** of the final record that starts on page X that does not fit on page X ** is stored at the start of page (X+1). This means there may be pages where ** (N==0). And on most pages the first record that starts on the page will ** not start at byte offset 0. For example: ** ** aaaaa bbbbb ccc