void load_(vector<uint32_t>& indexes) { uint32_t idx = indexes.front(); indexes.erase(indexes.begin()); NodeType* n = nodes[idx].pNode_ ; nodes[idx] = _cache_node_(n); for (uint32_t i=0; i<n->getSize(); i++) { if (n->getDiskAddr(i)==(uint64_t)-1) continue; if (n->getDiskAddr(i)%2==0) continue; NodeType* t = new NodeType(f_); t->load(n->getDiskAddr(i)); nodes[count_] = _cache_node_(t); indexes.push_back(count_); n->setMemAddr(i, count_); count_++; if (count_>=CACHE_SIZE) { indexes.clear(); return; } } }
/*! *Load bucket of specific disk address into memory. **/ nodePtr getNodeByMemAddr(uint32_t& memAddr, uint64_t diskAddr) { if (diskAddr%2==1) return nodePtr(); if (memAddr>=count_ && memAddr!=(uint32_t)-1&&count_!=0) return nodePtr(); if (memAddr!=(uint32_t)-1) { NodeType* t = nodes[memAddr].pNode_; if (t->getDiskAddr()==diskAddr) { return nodePtr(nodes[memAddr], memAddr); } } uint32_t i = findInCache(diskAddr); if (i != (uint32_t)-1) { memAddr = i; return nodePtr(nodes[i], memAddr); } if (count_<CACHE_SIZE) { NodeType* t = new NodeType(f_); t->load(diskAddr); nodes[count_] = _cache_node_(t); memAddr = count_; count_++; return nodePtr(nodes[memAddr], memAddr); } //cout<< "getNodeByMemAddr()\n"; memAddr = findSwitchOut(); //cout<<"\nswitch out-: "<<memAddr<<endl; kickOutNodes(memAddr); NodeType* t = new NodeType(f_); t->load(diskAddr); nodes[memAddr] = _cache_node_(t); return nodePtr(nodes[memAddr], memAddr); }