#ifndef _ROSE_COMPRESSION_PSTAR_IMPL_H__ #define _ROSE_COMPRESSION_PSTAR_IMPL_H__ // Copyright 2007 Google Inc. All Rights Reserved. // Author: sears@google.com (Rusty Sears) #include #include #include "pstar.h" #include "for.h" namespace rose { /** Appends a value to a page managed by pstar. For now, most of the "real work" is handled by the compression algorithm. This function simply checks the return value from the plugin. If the value should be stored as an exception, then it is prepended to the list of exceptions at end of the page. The compressed data is kept at the beginning of the page. */ template slot_index_t Pstar::append(int xid, const TYPE dat) { slot_index_t ret = plug_.append(xid, dat, freespace_ptr(), p_->memAddr, &free_bytes_); return free_bytes_ >= 0 ? ret : NOSPACE; } // The rest of this file interfaces with Stasis ------------------------- /** Implementation of the Stasis pageLoaded() callback. @see stasis/page.h */ template static void pStarLoaded(Page * p) { p->LSN = *stasis_page_lsn_ptr(p); p->impl = new Pstar(p); } /** Implementation of the Stasis pageFlushed() callback. */ template static void pStarFlushed(Page * p) { *stasis_page_lsn_ptr(p) = p->LSN; } template static void pStarCleanup(Page * p) { delete (Pstar*)p->impl; } /** Basic page_impl for pstar @see stasis/page.h */ static const page_impl pstar_impl = { -1, 0, // pStarRead, 0, // pStarWrite, 0, // pStarReadDone, 0, // pStarWriteDone, 0, // pStarGetType, 0, // pStarSetType, 0, // pStarGetLength, 0, // pStarFirst, 0, // pStarNext, 0, // pStarIsBlockSupported, 0, // pStarBlockFirst, 0, // pStarBlockNext, 0, // pStarBlockDone, 0, // pStarFreespace, 0, // pStarCompact, 0, // pStarPreRalloc, 0, // pStarPostRalloc, 0, // pStarFree, 0, // dereference_identity, 0, // pStarLoaded, 0, // pStarFlushed 0, // pStarCleanup }; /** Be sure to call "registerPageType(Pstar<...>::impl())" once for each template instantiation that Stasis might encounter, even if a particular binary might not use that instantiation. This must be done before calling Tinit(). @see registerPageType() from Stasis. */ template page_impl Pstar::impl() { page_impl ret = pstar_impl; ret.page_type = plugin_id,COMPRESSOR,TYPE>(); ret.pageLoaded = pStarLoaded; ret.pageFlushed = pStarFlushed; ret.pageCleanup = pStarCleanup; return ret; } } // namespace rose #endif // _ROSE_COMPRESSION_PSTAR_IMPL_H__