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
|
|
|
************************************************************************/
|
|
|
|
|
2009-07-20 17:42:43 +00:00
|
|
|
static inline int16_t* stasis_page_slotted_freespace_ptr(Page * p) { return stasis_page_int16_ptr_from_end((p), 1); }
|
|
|
|
static inline int16_t* stasis_page_slotted_numslots_ptr(Page * p) { return stasis_page_int16_ptr_from_end(p, 2); }
|
|
|
|
static inline int16_t* stasis_page_slotted_freelist_ptr(Page * p) { return stasis_page_int16_ptr_from_end(p, 3); }
|
|
|
|
static inline int16_t* stasis_page_slotted_slot_ptr(Page * p, slotid_t n) { return stasis_page_int16_ptr_from_end(p, (2*(n))+4); }
|
|
|
|
static inline int16_t* stasis_page_slotted_slot_length_ptr(Page * p, slotid_t n) { return stasis_page_int16_ptr_from_end((p), (2*(n))+5); }
|
|
|
|
static inline byte* stasis_page_slotted_record_ptr(Page * p, slotid_t n) { return stasis_page_byte_ptr_from_start((p), *stasis_page_slotted_slot_ptr((p), (n))); }
|
2004-07-30 01:28:39 +00:00
|
|
|
|
2009-07-20 17:42:43 +00:00
|
|
|
static inline const int16_t* stasis_page_slotted_freespace_cptr(const Page * p) { return stasis_page_slotted_freespace_ptr((Page*)p); }
|
|
|
|
static inline const int16_t* stasis_page_slotted_numslots_cptr(const Page * p) { return stasis_page_slotted_numslots_ptr((Page*)p); }
|
|
|
|
static inline const int16_t* stasis_page_slotted_freelist_cptr(const Page * p) { return stasis_page_slotted_freelist_ptr((Page*)p); }
|
|
|
|
static inline const int16_t* stasis_page_slotted_slot_cptr(const Page * p, slotid_t n) { return stasis_page_slotted_slot_ptr((Page*)p, n); }
|
|
|
|
static inline const int16_t* stasis_page_slotted_slot_length_cptr(const Page * p, slotid_t n) { return stasis_page_slotted_slot_length_ptr((Page*)p, n); }
|
|
|
|
static inline const byte* stasis_page_slotted_record_cptr(const Page * p, slotid_t n) { return stasis_page_slotted_record_ptr((Page*)p, n); }
|
2006-07-22 00:05:40 +00:00
|
|
|
|
2009-07-20 17:42:43 +00:00
|
|
|
void stasis_page_slotted_init();
|
|
|
|
void stasis_page_slotted_deinit();
|
|
|
|
page_impl stasis_page_slotted_impl();
|
|
|
|
page_impl stasis_page_boundary_tag_impl();
|