Guest User

Untitled

a guest
Apr 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <k2hash/k2hash.h>
  4. #include <k2hash/k2hshm.h>
  5. #include <sstream>
  6. using namespace std;
  7.  
  8. int main() {
  9. K2HShm k;
  10. cout << k.GetSystemPageSize() << endl;
  11.  
  12. bool isCppCreated = k.Create("/tmp/testcpp.k2h");
  13. cout << (isCppCreated ? "already ..." : "now created!") << endl;
  14.  
  15. k.Attach("/tmp/testcpp.k2h", false);
  16. k.Set("tako", "僕は磯に住むタコだよ🐙");
  17. k.Set("ika", "僕は磯に住むイカだよくコ:彡");
  18. cout << k.GetSystemPageSize() << endl;
  19. cout << k.GetK2hashFilePath() << endl;
  20. cout << k.Get("tako") << endl;
  21. cout << (k.Get("tako") ? "GET" : "NOT GET") << endl;
  22.  
  23. ifstream ifs("yubin.csv");
  24. string s, out;
  25. while (getline(ifs, s)) {
  26. stringstream ss(s);
  27. vector<string> vs;
  28. while (getline(ss, out, ','))
  29. vs.push_back(out);
  30. const char *key = &vs[0][0];
  31. const char *val = &vs[1][0];
  32. k.Set(key, val);
  33. }
  34.  
  35. cout << k.Get("\"4100004\"") << endl;
  36.  
  37. k.Detach();
  38. cout << (k.Get("tako") ? "GET" : "NOT GET") << endl;
  39. }
Add Comment
Please, Sign In to add comment