196 Star 316 Fork 259

云溪数据库公司 / zb-kvs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

0. What is ZN-KVS

ZN-KVS is a RocksDB replacement with optimized tail latency, throughput etc.

  • zn-kvs is designed with memory as the main storage medium and disk as the auxiliary storage medium.
  • ZN-KVS uses Rocksdb's WAL and SST file format to generate the logic of asynchronous disk flush.
  • Support Rocksdb's external interface.

Notes

  • ZN-KVS was only tested and production ready under Linux platform
  • Language bindings except C/C++ are not fully tested yet.
  • Existing data can be migirated from ZN-KVS directly to RocksDB, but cannot direct migrate back to ZN-KVS.
  • ZN-KVS was forked from RocksDB v6.2.1.

Design Principle

  • Homogeneous data store adjacency in memroy.
  • KV data and index store separated.
  • Index is persistently in memory.
  • KV data store in memory as more as possible.
  • Flush thread asynchronous process new kv data.

Architecture Overview

architecture

More detail of architecture desgin is here.

1. Use ZN-KVS

Compilation

Compile project to static library, which can be integrated into yourown project.

Advanced options of compilation is here.

# Add some dependencies
sudo apt install libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev libgflags-dev git
sudo apt install build-essential  autoconf gcc  g++ ccache libncurses5-dev byacc cmake

# Create build directory
mkdir build
cd build

# Build with default
cmake ..
make -j4

Usage of ZN-KVS

ZN-KVS inherites exported interface from Rocsdb. So you can use ZN-KVS just like Rocksdb, except that adding one line code "options.pureMemTable = true".

Example code of Usage:

int main() {
  Options options = Options();
  options.env = Env::Default();
  options.pureMemTable = true;
  rocksdb::DB* db2 = nullptr;
  rocksdb::Status s = DB::Open(options, dbname_+"/db_test", &db2);
  WriteOptions writeOptions = WriteOptions();
  ASSERT_OK(db2->Put(writeOptions,"542", "v2"));
  ASSERT_OK(db2->Put(writeOptions,"444", "v1"));
  ASSERT_OK(db2->Put(writeOptions,"ps", "v3"));
  ASSERT_OK(db2->Put(writeOptions,"ps", "v4"));

  ASSERT_EQ("v1", OpenGet(db2,"444"));
  ASSERT_EQ("v2", OpenGet(db2,"542"));
  ASSERT_EQ("v4", OpenGet(db2,"ps"));
  db2->Close();
  delete db2;
}
std::string OpenGet(DB* db,const std::string& k) {
  ReadOptions options;

  std::string result;
  Status s = db->Get(options, k, &result);
  if (s.IsNotFound()) {
    result = "NOT_FOUND";
  } else if (!s.ok()) {
    result = s.ToString();
  }
  return result;
}

2. Performance Improvement

Benchmark

with only 1G data test, ZN-KVS can has At list 100% search performance improvement than Rocksdb.

architecture

3. Contributing

  • ZN-KVS uses Github issues and pull requests to manage features and bug fixes.
  • All PRs are welcome including code formating and refactoring.

4. License

  • Apache 2.0

5. Users

Please let us know if you are using ZN-KVS, thanks!

空文件

简介

ZNBase 是浪潮打造的一款分布式数据库产品,具备强一致、高可用分布式架构、分布式水平扩展、高性能、企业级安全等特性,自研的原生分布式存储引擎支持完整 ACID,支持 PostgreSQL 协议访问 展开 收起
C++ 等 6 种语言
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/ZNBase/zn-kvs.git
git@gitee.com:ZNBase/zn-kvs.git
ZNBase
zn-kvs
zb-kvs
develop

搜索帮助