Commit e140c269 authored by Mayank Manoj's avatar Mayank Manoj

Merge branch 'vishal' into 'master'

Vishal

See merge request !4
parents 36cd6757 c95cb611
......@@ -334,8 +334,7 @@ public:
{
return (((int)s.at(0)) << 8) + ((int)s.at(1));
}
string getKeyValuePairs(int id)
string getKeyValuePairs(int newId, int id)
{
unordered_map<string, string> flush;
string keyValPairs = "";
......@@ -354,7 +353,7 @@ public:
{
fileName.erase(n - 4);
fileName = fileName.substr(2);
if (hash(fileName) <= id)
if (hash(fileName) <= newId || hash(fileName) > id)
{
ifstream fin;
fin.open(fName);
......@@ -384,9 +383,21 @@ public:
closedir(dirFile);
}
for(int i=0;i<=curr_pos;i++)
if(hash(cacheHeap[i]->key)<=id)
flush[cacheHeap[i]->key]=cacheHeap[i]->value;
vector<string> toBeDeleted;
for (int i = 0; i <= curr_pos; i++)
{
if (hash(cacheHeap[i]->key) <= newId || hash(cacheHeap[i]->key) > id)
{
toBeDeleted.push_back(cacheHeap[i]->key);
flush[cacheHeap[i]->key] = cacheHeap[i]->value;
}
}
for (string key : toBeDeleted)
{
this->deleteNodeByKey(key);
}
unordered_map<string, string>::iterator itr;
for (itr = flush.begin(); itr != flush.end(); itr++)
......
......@@ -263,7 +263,7 @@ public:
}
// key1;key2;key3;;value1;value2;value3;
string getKeyValuePairs(int id)
string getKeyValuePairs(int newId, int id)
{
unordered_map<string, string> flush;
string keyValPairs = "";
......@@ -282,7 +282,7 @@ public:
{
fileName.erase(n - 4);
fileName = fileName.substr(2);
if (hash(fileName) <= id)
if (hash(fileName) <= newId && hash(fileName) > id)
{
ifstream fin;
fin.open(fName);
......@@ -315,7 +315,7 @@ public:
Node *temp = head->next;
while (temp->next)
{
if (hash(temp->key) <= id)
if (hash(temp->key) <= newId && hash(temp->key) > id)
{
flush[temp->key] = temp->payload;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment