#include #include #include #include #include using namespace std; using namespace apache::thrift; using namespace apache::thrift::protocol; using namespace apache::thrift::transport; int main(int argc, char **argv) { boost::shared_ptr socket(new TSocket("localhost", 9090)); boost::shared_ptr transport(new TFramedTransport(socket)); boost::shared_ptr protocol(new TBinaryProtocol(transport)); sherpa::PersistentStoreClient client(protocol); transport->open(); socket->setNoDelay(true); sherpa::BinaryResponse getResponse; sherpa::RecordListResponse scanResponse; cout << client.addDatabase("michi") << endl;; cout << client.insert("michi", "k1", "v1") << endl; cout << client.insert("michi", "k1", "v1") << endl; cout << client.insert("michi", "k11", "v11") << endl; client.get(getResponse, "michi", "k1"); cout << getResponse.responseCode << endl; cout << getResponse.value << endl; client.scan(scanResponse, "michi", sherpa::ScanOrder::Ascending, "", true, "", true, 100, 100); std::vector::iterator itr; for (itr = scanResponse.records.begin(); itr != scanResponse.records.end(); itr++) { cout << itr->key << " " << itr->value << endl; } client.scan(scanResponse, "michi", sherpa::ScanOrder::Descending, "", true, "", true, 100, 100); for (itr = scanResponse.records.begin(); itr != scanResponse.records.end(); itr++) { cout << itr->key << " " << itr->value << endl; } cout << client.remove("michi", "k1") << endl; client.get(getResponse, "michi", "k1"); cout << getResponse.responseCode << endl; transport->close(); return 0; }