2004-07-31 00:27:55 +00:00
|
|
|
/************************************************************************
|
|
|
|
* @file implementation of variable-sized slotted pages
|
|
|
|
|
|
|
|
STRUCTURE OF A PAGE
|
|
|
|
<pre>
|
|
|
|
+-----------------------------------------+-----------------------+----+
|
|
|
|
| DATA SECTION +--------->| RID: (PAGE, 0) | |
|
|
|
|
| +-----------------+ | +-----------------------+ |
|
|
|
|
| +-->| RID: (PAGE, 1) | | |
|
|
|
|
| | +-----------------+ | |
|
|
|
|
| | | |
|
|
|
|
| ----------------+ | +------------------------------+
|
|
|
|
| | | +--->| RID: (PAGE, n) |
|
|
|
|
| | | | +------------------------------+
|
|
|
|
|======================================================================|
|
|
|
|
| ^ FREE SPACE | | | |
|
|
|
|
| | | | | |
|
|
|
|
| +-------------------|-------|---|--------------------+ |
|
|
|
|
| | | | | |
|
|
|
|
| +-------------|-------|---+ | |
|
|
|
|
| | | | | |
|
|
|
|
| +---|---+-----+---|---+---|---+--------------+-----|------+-------+
|
|
|
|
| | slotn | ... | slot1 | slot0 | num of slots | free space | *** |
|
|
|
|
+----+-------+-----+-------+-------+--------------+------------+-------+
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
*** = @see page.h for information on this field.
|
|
|
|
|
|
|
|
NOTE:
|
|
|
|
- slots are zero indexed.
|
|
|
|
- slots are of implemented as (offset, length)
|
|
|
|
|
2007-10-02 00:18:33 +00:00
|
|
|
Slotted page layout:
|
2004-07-31 00:27:55 +00:00
|
|
|
|
|
|
|
END:
|
2007-10-02 00:18:33 +00:00
|
|
|
lsn (4 bytes)
|
2004-07-31 00:27:55 +00:00
|
|
|
type (2 bytes)
|
|
|
|
free space (2 bytes)
|
|
|
|
num of slots (2 bytes)
|
|
|
|
freelist head(2 bytes)
|
|
|
|
slot 0 (4 bytes)
|
|
|
|
slot 1 (4 bytes)
|
|
|
|
...
|
|
|
|
slot n (4 bytes)
|
|
|
|
...
|
|
|
|
unused
|
|
|
|
...
|
|
|
|
record n (x bytes)
|
|
|
|
...
|
|
|
|
record 0 (y bytes)
|
|
|
|
record 1 (z bytes)
|
|
|
|
|
|
|
|
START
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
|
2006-06-13 22:46:11 +00:00
|
|
|
@todo slotted.c Should know that specific record types (like blobs) exist,
|
2007-10-02 00:18:33 +00:00
|
|
|
(but should not hardcode information about these types) This
|
|
|
|
has been handled, except in slottedPostRalloc...
|
2006-06-13 22:46:11 +00:00
|
|
|
|
2004-07-31 00:27:55 +00:00
|
|
|
************************************************************************/
|
|
|
|
|
2006-03-20 23:11:46 +00:00
|
|
|
#define SLOTTED_PAGE_OVERHEAD_PER_RECORD (2 * sizeof(short))
|
|
|
|
#define SLOTTED_PAGE_HEADER_OVERHEAD (3 * sizeof(short))
|
2004-07-30 01:28:39 +00:00
|
|
|
|
2006-07-22 00:01:42 +00:00
|
|
|
//#define SLOTTED_PAGE_CHECK_FOR_OVERLAP 1
|
2006-07-22 00:05:40 +00:00
|
|
|
//#define SLOTTED_PAGE_SKIP_SANITY_CHECKS 1
|
|
|
|
|
|
|
|
#ifdef LONG_TEST
|
|
|
|
#define SLOTTED_PAGE_CHECK_FOR_OVERLAP 1
|
|
|
|
#endif
|
2006-07-22 00:01:42 +00:00
|
|
|
|
2007-10-02 00:18:33 +00:00
|
|
|
/**
|
|
|
|
@todo rename and rewrite slotted.h macros as static inline functions.
|
|
|
|
*/
|
|
|
|
#define freespace_ptr(page) stasis_page_int16_ptr_from_end((page), 1)
|
|
|
|
#define numslots_ptr(page) stasis_page_int16_ptr_from_end((page), 2)
|
|
|
|
#define freelist_ptr(page) stasis_page_int16_ptr_from_end((page), 3)
|
|
|
|
#define slot_ptr(page, n) stasis_page_int16_ptr_from_end((page), (2*(n))+4)
|
|
|
|
#define slot_length_ptr(page, n) stasis_page_int16_ptr_from_end((page), (2*(n))+5)
|
|
|
|
#define record_ptr(page, n) stasis_page_byte_ptr_from_start((page), \
|
|
|
|
*slot_ptr((page), (n)))
|
|
|
|
|
|
|
|
#define freespace_cptr(page) stasis_page_int16_cptr_from_end((page), 1)
|
|
|
|
#define numslots_cptr(page) stasis_page_int16_cptr_from_end((page), 2)
|
|
|
|
#define freelist_cptr(page) stasis_page_int16_cptr_from_end((page), 3)
|
|
|
|
#define slot_cptr(page, n) stasis_page_int16_cptr_from_end((page), (2*(n))+4)
|
|
|
|
#define slot_length_cptr(page, n) stasis_page_int16_cptr_from_end((page), (2*(n))+5)
|
|
|
|
#define record_cptr(page, n) stasis_page_byte_cptr_from_start((page), \
|
|
|
|
*slot_cptr((page), (n)))
|
2004-07-30 01:28:39 +00:00
|
|
|
|
2004-08-17 01:46:17 +00:00
|
|
|
void slottedPageInit();
|
2007-06-07 21:53:09 +00:00
|
|
|
void slottedPageDeinit();
|
|
|
|
page_impl slottedImpl();
|
|
|
|
page_impl boundaryTagImpl();
|