Commit cb03611b authored by Giorgio Azzinnaro's avatar Giorgio Azzinnaro

putting in rocksdb working

parent 0c0325c8
logo.png

95.4 KB | W: | H:

logo.png

267 KB | W: | H:

logo.png
logo.png
logo.png
logo.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -37,9 +37,11 @@ service Db {
}
message GetReq {
string key = 1; // TODO How about getting multiple objects at one
}
message GetResp {
google.protobuf.Any message = 1;
}
message PutReq {
......@@ -47,9 +49,11 @@ message PutReq {
}
message PutResp {
string key = 1; // TODO Maybe should be repeated for all stored keys?
}
message DelReq {
string key = 1;
}
message DelResp {
......
......@@ -26,7 +26,7 @@ profanedb::server::Server::Server()
boost::filesystem::path("/home/giorgio/Documents/ProfaneDB/src")
),
profanedb::storage::Config::RocksDB(
rocksdb::Options(),
Server::RocksDBOptions(),
"/tmp/profanedb"
)
)
......@@ -34,6 +34,14 @@ profanedb::server::Server::Server()
{
}
rocksdb::Options profanedb::server::Server::RocksDBOptions()
{
rocksdb::Options options;
options.create_if_missing = true;
return options;
}
profanedb::server::Server::~Server()
{
server->Shutdown();
......
......@@ -23,6 +23,8 @@
#include <grpc++/grpc++.h>
#include <grpc/support/log.h>
#include <rocksdb/db.h>
#include <profanedb/storage/db.h>
#include <profanedb/storage/config.h>
......@@ -42,6 +44,7 @@ public:
void Run();
private:
static rocksdb::Options RocksDBOptions();
profanedb::storage::Config config;
void HandleRpcs();
......
......@@ -54,3 +54,13 @@ profanedb::storage::Config::RocksDB::RocksDB(rocksdb::Options options, std::stri
, name(name)
{
}
const rocksdb::Options profanedb::storage::Config::RocksDB::GetOptions() const
{
return this->options;
}
const std::string profanedb::storage::Config::RocksDB::GetName() const
{
return this->name;
}
......@@ -52,6 +52,9 @@ public:
public:
RocksDB(rocksdb::Options options, std::string name);
const rocksdb::Options GetOptions() const;
const std::string GetName() const;
private:
rocksdb::Options options;
std::string name;
......
......@@ -24,11 +24,15 @@ profanedb::storage::Db::Db(profanedb::storage::Config config)
, parser(config.GetProfaneConfig())
, normalizer(parser)
{
// rocksdb::DB::Open(config.GetRocksConfig(), name, &db);
rocksdb::DB::Open(
config.GetRocksConfig().GetOptions(),
config.GetRocksConfig().GetName(),
&db);
}
profanedb::storage::Db::~Db()
{
delete this->db;
}
profanedb::protobuf::GetResp profanedb::storage::Db::Get(const profanedb::protobuf::GetReq & request)
......@@ -41,7 +45,7 @@ profanedb::protobuf::PutResp profanedb::storage::Db::Put(const profanedb::protob
for (auto const & obj: map) {
std::cout << obj.first << ":" << std::endl << obj.second.DebugString() << std::endl;
// db->Put(rocksdb::WriteOptions(), obj.first, obj.second.SerializeAsString());
db->Put(rocksdb::WriteOptions(), obj.first, obj.second.SerializeAsString());
}
return *profanedb::protobuf::PutResp().New();
......
......@@ -49,7 +49,7 @@ private:
Parser parser;
Normalizer normalizer;
std::unique_ptr<rocksdb::DB> db;
rocksdb::DB * db;
};
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment