Пример #1
0
void VerifyHandler::checkAlloc(logrec_t& r)
{
    auto lsn = r.lsn();
    PageID pid = *((PageID*) (r.data_ssx()));
    if (r.type() == logrec_t::t_alloc_page) {
        if (allocatedPages.find(pid) != allocatedPages.end()) {
            std::cout << "on " << lsn
                << " alloc_page of pid " << pid
                << " which is already allocated" << std::endl;
            w_assert0(false);
        }
        allocatedPages.insert(pid);
    }
    else if (r.type() == logrec_t::t_dealloc_page) {
        if (allocatedPages.find(pid) == allocatedPages.end()) {
            std::cout << "on " << lsn
                << " dealloc_page of pid " << pid
                << " which is not allocated" << std::endl;
            w_assert0(false);
        }
        allocatedPages.erase(pid);
    }
    else {
        std::cout << "on " << lsn
            << " update on alloc pid " << r.pid()
            << " but invalid logrec type " << r.type_str()
            << std::endl;
        w_assert0(false);
    }
}