Created
April 11, 2018 22:09
-
-
Save quiye/abf75c6681cc62e402119c2217083f91 to your computer and use it in GitHub Desktop.
K2HASHの使用デモ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment