Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mochi-boot-camp
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
0
Merge Requests
0
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
sds
mochi-boot-camp
Commits
49f4e07d
Commit
49f4e07d
authored
Sep 25, 2019
by
Rob Latham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a c++ solution for sdskeyval
parent
1c662f48
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
sessions/s4-components/sdskv/solution/words-cc.cc
sessions/s4-components/sdskv/solution/words-cc.cc
+55
-0
No files found.
sessions/s4-components/sdskv/solution/words-cc.cc
0 → 100644
View file @
49f4e07d
#include <assert.h>
#include <sdskv-client.hpp>
#include <iostream>
#include <vector>
#include <string>
int
main
(
int
argc
,
char
**
argv
)
{
int
ret
;
if
(
argc
!=
3
)
{
fprintf
(
stderr
,
"Usage: %s <server address> <dictionary>
\n
"
,
argv
[
0
]);
exit
(
0
);
}
/* we are going to use margo/mercury to communicate */
margo_instance_id
mid
=
margo_init
(
"na+sm"
,
MARGO_CLIENT_MODE
,
0
,
0
);
assert
(
mid
);
/* fire up the 'sdskv' client library to prepare to find a server */
sdskv
::
client
keyval_client
(
mid
);
/* resolve a mercury address to a 'handle' to the provider on a specific address */
hg_addr_t
server
;
margo_addr_lookup
(
mid
,
argv
[
1
],
&
server
);
sdskv
::
provider_handle
handle
=
sdskv
::
provider_handle
(
keyval_client
,
server
,
1
);
sdskv
::
database
DB
=
keyval_client
.
open
(
handle
,
"test-db"
);
#define MAX_WORD 256
char
buffer
[
MAX_WORD
];
size_t
buflen
;
FILE
*
dict
=
fopen
(
argv
[
2
],
"r"
);
std
::
vector
<
std
::
string
>
empty
;
while
(
fgets
(
buffer
,
MAX_WORD
,
dict
)
!=
NULL
)
{
std
::
string
key
(
buffer
);
DB
.
put
(
key
,
empty
);
}
std
::
string
start_key
;
std
::
vector
<
std
::
string
>
output
(
25
);
DB
.
list_keys
(
start_key
,
output
);
for
(
auto
x
:
output
)
std
::
cout
<<
"key: "
<<
x
;
/* shut down (every) provider at given address and clean up resources */
keyval_client
.
shutdown
(
server
);
margo_addr_free
(
mid
,
server
);
margo_finalize
(
mid
);
return
0
;
}
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