PerPageCopy(PerPageCopy const& that) { store_ = that.store_; pagenos_ = that.pagenos_; for (std::size_t pageno : pagenos_) store_->ref_page(pageno); }
// Copy and move ChunkedData(ChunkedData const& that) { store_ = that.store_; pagenos_ = that.pagenos_; for (std::size_t pageno : pagenos_) store_->ref_page(pageno); }
PerPageCopy& operator=(PerPageCopy const& that) { this->clear(); store_ = that.store_; pagenos_ = that.pagenos_; for (std::size_t pageno : pagenos_) store_->ref_page(pageno); return *this; }
ChunkedData& operator=(ChunkedData const& that) { this->clear(); store_ = that.store_; pagenos_ = that.pagenos_; for (std::size_t pageno : pagenos_) store_->ref_page(pageno); return *this; }
const void* page(std::size_t i) const { return store_->get_page(pagenos_[i]); }
void clear() { for (std::size_t pageno : pagenos_) store_->unref_page(pageno); pagenos_.clear(); }
void testPageStore(PageStore& uut) { CPPUNIT_ASSERT_EQUAL(0, uut.getPageCount()); int pageSize = uut.getPageSize(); boost::shared_ptr<Page> p = uut.createPage(); CPPUNIT_ASSERT_EQUAL(pageSize, p->getDataSize()); populatePage(p); verifyPage(p); _ids.push_back(p->getId()); for (int i = 1; i < 100; i++) { CPPUNIT_ASSERT_EQUAL(i, uut.getPageCount()); p = uut.createPage(); populatePage(p); _ids.push_back(i); } CPPUNIT_ASSERT_EQUAL(100, uut.getPageCount()); for (int i = 0; i < 100; i++) { p = uut.getPage(_ids[i]); verifyPage(p); } uut.save(); for (int i = 0; i < 100; i++) { p = uut.getPage(_ids[i]); verifyPage(p); } uut.flush(); for (int i = 0; i < 100; i++) { p = uut.getPage(_ids[i]); verifyPage(p); } }