00001
00008 #ifndef LEAFPAGE_H
00009 #define LEAFPAGE_H
00010 #include"keypage.h"
00011
00012 struct memp_t
00013 {
00014 ploff_t off;
00015 uint16_t len;
00016 octet_t chksum;
00017 };
00018
00019 struct blobptr_t
00020 {
00021 off_t goff;
00022 };
00023
00028 struct content_t
00029 {
00030 union
00031 {
00032 memp_t memp;
00033 blobptr_t blobptr;
00034 };
00035 octet_t is_blob;
00036 };
00037
00041 struct Record_t
00042 {
00043 memp_t key;
00044 content_t content;
00045 };
00046
00047 #include"common_page.h"
00048
00053 struct LeafPage : KeyPage
00054 {
00055 ploff_t last;
00056 Record_t records[1];
00057 static LeafPage *init(char *m);
00058
00059 ploff_t endoftable()
00060 { return offsetof(LeafPage,records)+anz*sizeof(Record_t);
00061 }
00062 };
00063
00067 class LeafPageAccess : public KeyPageAccess
00068 {
00069 public:
00070 LeafPageAccess():KeyPageAccess() {}
00071 LeafPageAccess(CommonPage *base)
00072 :KeyPageAccess(base) {}
00073 virtual Page_type_t pagetype();
00077 void init()
00078 {
00079 LeafPage::init((char *)begin());
00080 }
00081 void init(CommonPage *base)
00082 {
00083 RAMS::Mseg::setto((char *)base,PAGESIZE);
00084 init();
00085 }
00086 size_t space();
00087
00092 int insert(const octet_t *key,size_t keylen,const octet_t *cont,size_t clen);
00093 virtual int splitt(CommonPage *neu1,CommonPage *neu2);
00094
00095
00096 protected:
00101 int insertstr(memp_t& memp,const octet_t *str,size_t len);
00102 LeafPage *page() { return (LeafPage *)begin(); }
00103 public:
00104 int keycmp(int i,const octet_t *other,size_t olen);
00105 mempl_t key(int i);
00106
00107 mempl_t content(int i)
00108 {
00109 mempl_t ret;
00110 ret.l = page()->records[i].content.memp.len;
00111 ret.ptr = (octet_t *)begin()+page()->records[i].content.memp.off;
00112 return ret;
00113 }
00114 };
00115 #endif
00116
00117
00118
00119
00120
00121