diff --git a/benchmarks/roseTable.cpp b/benchmarks/roseTable.cpp index b9fe283..7654954 100644 --- a/benchmarks/roseTable.cpp +++ b/benchmarks/roseTable.cpp @@ -20,19 +20,20 @@ int main(int argc, char **argv) { typedef rose::StaticTuple tup; using rose::For; using rose::Rle; + using rose::Nop; int ret; // multicolumn is deprecated; want static dispatch! rose::plugin_id_t * plugins = (rose::plugin_id_t*)malloc(10 * sizeof(rose::plugin_id_t)); plugins[0] = rose::plugin_id, Rle, typ0>(); - plugins[1] = rose::plugin_id, Rle, typ1>(); + plugins[1] = rose::plugin_id, Nop, typ1>(); // rle plugins[2] = rose::plugin_id, For, typ2>(); plugins[3] = rose::plugin_id, Rle, typ3>(); - plugins[4] = rose::plugin_id, Rle, typ4>(); + plugins[4] = rose::plugin_id, Nop, typ4>(); // rle plugins[5] = rose::plugin_id, Rle, typ5>(); plugins[6] = rose::plugin_id, For, typ6>(); - plugins[7] = rose::plugin_id, For, typ7>(); + plugins[7] = rose::plugin_id, Nop, typ7>(); // for plugins[8] = rose::plugin_id, For, typ8>(); plugins[9] = rose::plugin_id, Rle, typ9>(); diff --git a/src/stasis/page/compression/compression.h b/src/stasis/page/compression/compression.h index 4519d83..71f1c0a 100644 --- a/src/stasis/page/compression/compression.h +++ b/src/stasis/page/compression/compression.h @@ -60,11 +60,11 @@ inline plugin_id_t plugin_id() { // assert(sizeof(TYPE) <= 8 && type_idx[sizeof(TYPE)] >= 0); - // XXX first '2' hardcodes the number of COMPRESSOR implementations... + // XXX '3' hardcodes the number of COMPRESSOR implementations... plugin_id_t ret = USER_DEFINED_PAGE(0) // II S C - + idx_count * 2 * 2 * PAGEFORMAT::PAGE_FORMAT_ID + + idx_count * 2 * 3 * PAGEFORMAT::PAGE_FORMAT_ID + idx_count * 2 * COMPRESSOR::PLUGIN_ID + idx_count * (is_signed < 0) + type_idx[sizeof(TYPE)]; diff --git a/src/stasis/page/compression/nop.h b/src/stasis/page/compression/nop.h new file mode 100644 index 0000000..9188df8 --- /dev/null +++ b/src/stasis/page/compression/nop.h @@ -0,0 +1,103 @@ +#ifndef _ROSE_COMPRESSION_NOP_H__ +#define _ROSE_COMPRESSION_NOP_H__ + +#undef try +#undef catch +#undef end + +#include + +/** + @file A 'no-op' compression implementation + + This file implements a COMPRESSOR plugin that stores data in + uncompressed form. +*/ + +#include + +#include "pstar.h" + +namespace rose { + + template class Nop { + public: + typedef TYPE TYP; + + static const int PLUGIN_ID = 2; + inline void offset(TYPE o) {} + inline size_t max_overrun() { return 0; } + inline slot_index_t append(int xid, const TYPE dat, byte_off_t * except, + byte * exceptions, int *free_bytes) { + if(*free_bytes >= (int)sizeof(TYPE)) { + slot_index_t ret = *numentries_ptr(); + ((TYPE*)(numentries_ptr()+1))[ret] = dat; + (*free_bytes)-=sizeof(TYPE); + (*numentries_ptr())++; + return ret; + } else { + return NOSPACE; + } + } + inline TYPE *recordRead(int xid, slot_index_t slot, byte *exceptions, + TYPE *buf) { + if(slot < *numentries_ptr()) { + *buf = ((TYPE*)(numentries_ptr()+1))[slot]; + return buf; + } else { + return 0; + } + } + inline std::pair* + recordFind(int xid, slot_index_t start, slot_index_t stop, + byte *exceptions, TYPE value, + std::pair& scratch) { + slot_index_t i; + std::pair*ret = 0; + TYPE *rec = 0; + for(i = start; i< stop; i++) { + TYPE t; + rec = recordRead(xid,i,0,&t); + if(*rec == value) { + scratch.first = i; + scratch.second = stop; + ret = &scratch; + i++; + break; + } + } + for(;i(mem_); + } + void * mem_; + }; + +} +#endif diff --git a/src/stasis/page/compression/pluginDispatcher.h b/src/stasis/page/compression/pluginDispatcher.h index a0a0b17..f0ab413 100644 --- a/src/stasis/page/compression/pluginDispatcher.h +++ b/src/stasis/page/compression/pluginDispatcher.h @@ -45,7 +45,8 @@ class PluginDispatcher{ public: #define dispatchSwitch(col,cases,...) \ - static const int base = USER_DEFINED_PAGE(0) + 2 * 2 * 4;\ + static const int base = USER_DEFINED_PAGE(0) + 3 * 2 * 4;\ + /*printf("page = %d pluginid = %d base = %d\n", USER_DEFINED_PAGE(0), plugin_ids_[col], base); fflush(stdout);*/ \ switch(plugin_ids_[col]-base) { \ cases(0, For, col,uint8_t, __VA_ARGS__); \ cases(1, For,col,uint16_t,__VA_ARGS__); \ @@ -63,6 +64,14 @@ class PluginDispatcher{ cases(13,Rle, col,int16_t, __VA_ARGS__); \ cases(14,Rle, col,int32_t, __VA_ARGS__); \ cases(15,Rle, col,int64_t, __VA_ARGS__); \ + cases(16,Nop, col,uint8_t, __VA_ARGS__); \ + cases(17,Nop,col,uint16_t,__VA_ARGS__); \ + cases(18,Nop,col,uint32_t,__VA_ARGS__); \ + cases(19,Nop,col,uint64_t,__VA_ARGS__); \ + cases(20,Nop, col,int8_t, __VA_ARGS__); \ + cases(21,Nop, col,int16_t, __VA_ARGS__); \ + cases(22,Nop, col,int32_t, __VA_ARGS__); \ + cases(23,Nop, col,int64_t, __VA_ARGS__); \ default: abort(); \ }; diff --git a/src/stasis/page/compression/tuple.h b/src/stasis/page/compression/tuple.h index 50a0756..da22762 100644 --- a/src/stasis/page/compression/tuple.h +++ b/src/stasis/page/compression/tuple.h @@ -15,6 +15,7 @@ #include "compression.h" #include "for.h" #include "rle.h" +#include "nop.h" #include "string.h" namespace rose {