Last active
March 16, 2018 15:52
-
-
Save quiye/c11fc81a0832420abc112c2952b73711 to your computer and use it in GitHub Desktop.
k2hash_sample.cpp https://github.com/yahoojapan/k2hash/wiki/Developer_jpn#-k2hshmクラス
This file contains 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<iostream> | |
#include<fstream> | |
#include<sstream> | |
#include <k2hash/k2hash.h> | |
#include <k2hash/k2hshm.h> | |
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
https://qiita.com/monhan/items/443b2bf8d9ff094215dc