Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <k2hash/k2hash.h>
- #include <k2hash/k2hshm.h>
- #include <sstream>
- using namespace std;
- int main() {
- K2HShm k;
- cout << k.GetSystemPageSize() << endl;
- bool isCppCreated = k.Create("/tmp/testcpp.k2h");
- cout << (isCppCreated ? "already ..." : "now created!") << endl;
- k.Attach("/tmp/testcpp.k2h", false);
- k.Set("tako", "僕は磯に住むタコだよ🐙");
- k.Set("ika", "僕は磯に住むイカだよくコ:彡");
- cout << k.GetSystemPageSize() << endl;
- cout << k.GetK2hashFilePath() << endl;
- cout << k.Get("tako") << endl;
- cout << (k.Get("tako") ? "GET" : "NOT GET") << endl;
- ifstream ifs("yubin.csv");
- string s, out;
- while (getline(ifs, s)) {
- stringstream ss(s);
- vector<string> vs;
- while (getline(ss, out, ','))
- vs.push_back(out);
- const char *key = &vs[0][0];
- const char *val = &vs[1][0];
- k.Set(key, val);
- }
- cout << k.Get("\"4100004\"") << endl;
- k.Detach();
- cout << (k.Get("tako") ? "GET" : "NOT GET") << endl;
- }
Add Comment
Please, Sign In to add comment