jigaoluo / cmu15-445 Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
代码里面直接把所有键值对缓存到内存中再重新插入,但是实验要求里面假设了哈希表非常大,无法直接放入内存中:
// 1. In-memory cache all key-value pair
std::vector<std::pair<KeyType, ValueType>> pair_cache;
// pair_cache.reserve()
assert(page_number == page_ids_cache.size());
for (size_t page_index = 0; page_index < page_number; page_index++) {
auto bpm_page = buffer_pool_manager_->FetchPage(page_ids_cache[page_index]);
bpm_page->RLatch();
auto block_page = reinterpret_cast<HashTableBlockPage<KeyType, ValueType, KeyComparator>*>(bpm_page->GetData());
for (slot_offset_t slot_offset = 0;
slot_offset < ((page_index == page_number - 1) ? BLOCK_ARRAY_SIZE_LAST_PAGE : BLOCK_ARRAY_SIZE_PRO_PAGE);
slot_offset++) {
if (block_page->IsReadable(slot_offset)) {
pair_cache.emplace_back(block_page->KeyAt(slot_offset), block_page->ValueAt(slot_offset));
block_page->Remove(slot_offset);
}
}
bpm_page->RUnlatch();
buffer_pool_manager_->UnpinPage(page_ids_cache[page_index], false);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.