Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CS744 DECS-PA4-KEYVALUE-SERVER
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kamal Khodabhai
CS744 DECS-PA4-KEYVALUE-SERVER
Commits
e140c269
Commit
e140c269
authored
Nov 21, 2021
by
Mayank Manoj
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'vishal' into 'master'
Vishal See merge request
!4
parents
36cd6757
c95cb611
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
LFU.h
LFU.h
+17
-6
LRU.h
LRU.h
+3
-3
No files found.
LFU.h
View file @
e140c269
...
@@ -334,8 +334,7 @@ public:
...
@@ -334,8 +334,7 @@ public:
{
{
return
(((
int
)
s
.
at
(
0
))
<<
8
)
+
((
int
)
s
.
at
(
1
));
return
(((
int
)
s
.
at
(
0
))
<<
8
)
+
((
int
)
s
.
at
(
1
));
}
}
string
getKeyValuePairs
(
int
newId
,
int
id
)
string
getKeyValuePairs
(
int
id
)
{
{
unordered_map
<
string
,
string
>
flush
;
unordered_map
<
string
,
string
>
flush
;
string
keyValPairs
=
""
;
string
keyValPairs
=
""
;
...
@@ -354,7 +353,7 @@ public:
...
@@ -354,7 +353,7 @@ public:
{
{
fileName
.
erase
(
n
-
4
);
fileName
.
erase
(
n
-
4
);
fileName
=
fileName
.
substr
(
2
);
fileName
=
fileName
.
substr
(
2
);
if
(
hash
(
fileName
)
<=
id
)
if
(
hash
(
fileName
)
<=
newId
||
hash
(
fileName
)
>
id
)
{
{
ifstream
fin
;
ifstream
fin
;
fin
.
open
(
fName
);
fin
.
open
(
fName
);
...
@@ -384,9 +383,21 @@ public:
...
@@ -384,9 +383,21 @@ public:
closedir
(
dirFile
);
closedir
(
dirFile
);
}
}
for
(
int
i
=
0
;
i
<=
curr_pos
;
i
++
)
vector
<
string
>
toBeDeleted
;
if
(
hash
(
cacheHeap
[
i
]
->
key
)
<=
id
)
flush
[
cacheHeap
[
i
]
->
key
]
=
cacheHeap
[
i
]
->
value
;
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
;
unordered_map
<
string
,
string
>::
iterator
itr
;
for
(
itr
=
flush
.
begin
();
itr
!=
flush
.
end
();
itr
++
)
for
(
itr
=
flush
.
begin
();
itr
!=
flush
.
end
();
itr
++
)
...
...
LRU.h
View file @
e140c269
...
@@ -263,7 +263,7 @@ public:
...
@@ -263,7 +263,7 @@ public:
}
}
// key1;key2;key3;;value1;value2;value3;
// key1;key2;key3;;value1;value2;value3;
string
getKeyValuePairs
(
int
id
)
string
getKeyValuePairs
(
int
newId
,
int
id
)
{
{
unordered_map
<
string
,
string
>
flush
;
unordered_map
<
string
,
string
>
flush
;
string
keyValPairs
=
""
;
string
keyValPairs
=
""
;
...
@@ -282,7 +282,7 @@ public:
...
@@ -282,7 +282,7 @@ public:
{
{
fileName
.
erase
(
n
-
4
);
fileName
.
erase
(
n
-
4
);
fileName
=
fileName
.
substr
(
2
);
fileName
=
fileName
.
substr
(
2
);
if
(
hash
(
fileName
)
<=
id
)
if
(
hash
(
fileName
)
<=
newId
&&
hash
(
fileName
)
>
id
)
{
{
ifstream
fin
;
ifstream
fin
;
fin
.
open
(
fName
);
fin
.
open
(
fName
);
...
@@ -315,7 +315,7 @@ public:
...
@@ -315,7 +315,7 @@ public:
Node
*
temp
=
head
->
next
;
Node
*
temp
=
head
->
next
;
while
(
temp
->
next
)
while
(
temp
->
next
)
{
{
if
(
hash
(
temp
->
key
)
<=
id
)
if
(
hash
(
temp
->
key
)
<=
newId
&&
hash
(
temp
->
key
)
>
id
)
{
{
flush
[
temp
->
key
]
=
temp
->
payload
;
flush
[
temp
->
key
]
=
temp
->
payload
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment