Skip to content

Commit

Permalink
Merge pull request OpenAtomFoundation#230 from Tapeete/support_custom…
Browse files Browse the repository at this point in the history
…_compression

support multiple compression algorithm
  • Loading branch information
baotiao authored Jan 4, 2018
2 parents 0762f84 + 00fca3e commit 6bbef39
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/pika_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ PikaServer::PikaServer() :
option.max_open_files = g_pika_conf->max_cache_files();
option.max_bytes_for_level_multiplier = g_pika_conf->max_bytes_for_level_multiplier();
if (g_pika_conf->compression() == "none") {
option.compression = false;
option.compression = nemo::Options::CompressionType::kNoCompression;
} else if (g_pika_conf->compression() == "snappy") {
option.compression = nemo::Options::CompressionType::kSnappyCompression;
} else if (g_pika_conf->compression() == "zlib") {
option.compression = nemo::Options::CompressionType::kZlibCompression;
}

std::string db_path = g_pika_conf->db_path();
LOG(INFO) << "Prepare DB...";
db_ = std::shared_ptr<nemo::Nemo>(new nemo::Nemo(db_path, option));
Expand Down Expand Up @@ -396,7 +401,11 @@ bool PikaServer::ChangeDb(const std::string& new_path) {
option.max_open_files = g_pika_conf->max_cache_files();
option.max_bytes_for_level_multiplier = g_pika_conf->max_bytes_for_level_multiplier();
if (g_pika_conf->compression() == "none") {
option.compression = false;
option.compression = nemo::Options::CompressionType::kNoCompression;
} else if (g_pika_conf->compression() == "snappy") {
option.compression = nemo::Options::CompressionType::kSnappyCompression;
} else if (g_pika_conf->compression() == "zlib") {
option.compression = nemo::Options::CompressionType::kZlibCompression;
}
std::string db_path = g_pika_conf->db_path();
std::string tmp_path(db_path);
Expand Down Expand Up @@ -1482,8 +1491,13 @@ bool PikaServer::FlushAll() {
option.max_open_files = g_pika_conf->max_cache_files();
option.max_bytes_for_level_multiplier = g_pika_conf->max_bytes_for_level_multiplier();
if (g_pika_conf->compression() == "none") {
option.compression = false;
option.compression = nemo::Options::CompressionType::kNoCompression;
} else if (g_pika_conf->compression() == "snappy") {
option.compression = nemo::Options::CompressionType::kSnappyCompression;
} else if (g_pika_conf->compression() == "zlib") {
option.compression = nemo::Options::CompressionType::kZlibCompression;
}

LOG(INFO) << "Prepare open new db...";
db_ = std::shared_ptr<nemo::Nemo>(new nemo::Nemo(g_pika_conf->db_path(), option));
LOG(INFO) << "open new db success";
Expand Down

0 comments on commit 6bbef39

Please sign in to comment.