#ifndef _ROSE_COMPRESSION_PAGELAYOUT_H__ #define _ROSE_COMPRESSION_PAGELAYOUT_H__ #include "compression.h" // for plugin_id namespace rose { // XXX need to be able to de-init this stuff. static int cmp_num = 1; static int init_num = 1; template class SingleColumnTypePageLayout { public: typedef FORMAT FMT; static inline void initPageLayout() { stasis_page_impl_register(FMT::impl()); // XXX these should register template instantiations of worker // threads that are statically compiled to deal with the tree // we're instantiating. lsmTreeRegisterComparator(cmp_num, FMT::TUP::cmp); lsmTreeRegisterPageInitializer (init_num, (lsm_page_initializer_t)initPage); my_cmp_num = cmp_num; cmp_num++; my_init_num = init_num; init_num++; } static inline FORMAT * initPage(Page *p, const typename FORMAT::TUP * t) { const column_number_t column_count = t->column_count(); plugin_id_t pluginid = plugin_id(); plugin_id_t * plugins = (plugin_id_t*)malloc(column_count * sizeof(plugin_id_t)); for(column_number_t c = 0; c < column_count; c++) { plugins[c] = pluginid; } FORMAT * f = new FORMAT(-1,p,column_count,plugins); for(column_number_t c = 0; c < column_count; c++) { COMPRESSOR* com = (COMPRESSOR*) f->compressor(c); typename COMPRESSOR::TYP val = *(typename COMPRESSOR::TYP*)(t->get(c)); com->offset(val); } free(plugins); return f; } static inline int cmp_id() { return my_cmp_num; } static inline int init_id() { return my_init_num; } private: static int my_cmp_num; static int my_init_num; }; template int SingleColumnTypePageLayout::my_cmp_num = -1; template int SingleColumnTypePageLayout::my_init_num = -1; template recordid TlsmTableAlloc(); //// --- multicolumn static page layout template class MultiColumnTypePageLayout { public: typedef FORMAT FMT; static inline void initPageLayout() { stasis_page_impl_register(FMT::impl()); // XXX these should register template instantiations of worker // threads that are statically compiled to deal with the tree // we're instantiating. lsmTreeRegisterComparator(cmp_num, FMT::TUP::cmp); lsmTreeRegisterPageInitializer (init_num, (lsm_page_initializer_t)initPage); my_cmp_num = cmp_num; cmp_num++; my_init_num = init_num; init_num++; } static inline FORMAT * initPage(Page *p, const typename FORMAT::TUP * t) { plugin_id_t plugins[N]; if(0 < N) plugins[0] = plugin_id(); if(1 < N) plugins[1] = plugin_id(); if(2 < N) plugins[2] = plugin_id(); if(3 < N) plugins[3] = plugin_id(); if(4 < N) plugins[4] = plugin_id(); if(5 < N) plugins[5] = plugin_id(); if(6 < N) plugins[6] = plugin_id(); if(7 < N) plugins[7] = plugin_id(); if(8 < N) plugins[8] = plugin_id(); if(9 < N) plugins[9] = plugin_id(); FORMAT * f = new FORMAT(-1,p); if(0 < N) f->compressor0()->offset(*t->get0()); if(1 < N) f->compressor1()->offset(*t->get1()); if(2 < N) f->compressor2()->offset(*t->get2()); if(3 < N) f->compressor3()->offset(*t->get3()); if(4 < N) f->compressor4()->offset(*t->get4()); if(5 < N) f->compressor5()->offset(*t->get5()); if(6 < N) f->compressor6()->offset(*t->get6()); if(7 < N) f->compressor7()->offset(*t->get7()); if(8 < N) f->compressor8()->offset(*t->get8()); if(9 < N) f->compressor9()->offset(*t->get9()); return f; } static inline int cmp_id() { return my_cmp_num; } static inline int init_id() { return my_init_num; } private: static int my_cmp_num; static int my_init_num; }; template int MultiColumnTypePageLayout::my_cmp_num = -1; template int MultiColumnTypePageLayout::my_init_num = -1; template recordid TlsmTableAlloc(); } #endif // _ROSE_COMPRESSION_PAGELAYOUT_H__