Commit 89265d67 authored by Vishal Saha's avatar Vishal Saha

modified logic for key sharing

parent 503288eb
......@@ -334,7 +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 = "";
......@@ -353,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);
......@@ -387,7 +387,7 @@ public:
for (int i = 0; i <= curr_pos; i++)
{
if (hash(cacheHeap[i]->key) <= id)
if (hash(cacheHeap[i]->key) <= newId || hash(cacheHeap[i]->key) > id)
{
toBeDeleted.push_back(cacheHeap[i]->key);
flush[cacheHeap[i]->key] = cacheHeap[i]->value;
......
......@@ -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