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
36d9f66d
Commit
36d9f66d
authored
Nov 20, 2021
by
Kamal Khodabhai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update server.cpp
parent
e9e6839e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
3 deletions
+32
-3
server.cpp
server.cpp
+32
-3
No files found.
server.cpp
View file @
36d9f66d
...
...
@@ -58,12 +58,41 @@ void getConfig() {
int
getHash
(
string
key
)
{
int
hash
=
0
;
for
(
auto
c
:
key
)
{
hash
=
(
hash
+
c
)
%
mod
;
int
len
=
key
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
hash
=
hash
+
((
hash
)
<<
5
)
+
key
[
i
]
+
(
key
[
i
]
<<
7
);
}
return
hash
;
return
(((
hash
)
^
(
hash
>>
16
))
&
0xffff
)
%
mod
;
}
// int getHash(string key){
// unsigned char obuf[41];
// char finalHash[41];
// string keyHash = "";
// int i;
// /* convert string to an unsigned char array because SHA1 takes unsigned char array as parameter */
// unsigned char unsigned_key[key.length()+1];
// for(i=0;i<key.length();i++){
// unsigned_key[i] = key[i];
// }
// unsigned_key[i] = '\0';
// SHA1(unsigned_key,sizeof(unsigned_key),obuf);
// for (i = 0; i < M/8; i++) {
// sprintf(finalHash,"%d",obuf[i]);
// keyHash += finalHash;
// }
// int hash = stoll(keyHash) % mod;
// return hash;
// }
class
CallData
{
public:
CallData
(
KeyValueServices
::
AsyncService
*
service
,
ServerCompletionQueue
*
cq
,
RequestType
reqType
)
:
service
(
service
),
cq
(
cq
),
getResponder
(
&
context
),
putResponder
(
&
context
),
delResponder
(
&
context
),
status
(
CREATE
),
reqType
(
reqType
)
{
...
...
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