cbt:基于Apache CouchDB btree的多层MVCC仅日志附加数据库库

  • D4_850575
    了解作者
  • 57.6KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 04:04
    上传日期
#cbt 基于Apache CouchDB btree的多层MVCC仅日志附加数据库库。 与couchdb相比的变化 可插拔存储后端 使用CRC32而非MD5检查数据完整性 重新编写了文件init部分以使其更健壮 消除了对外部配置的需要。 提供正确的默认值并使用erlang环境。 文档和规格 一些语法上的改进。 建造 1.安装钢筋 要构建cbt,您需要在PATH安装rebar。 钢筋在Github上可用: 按照进行安装。 2.建立 获取源代码: $ git clone https://bitbucket.org/refugeio/cbt.git 生成源代码,运行make命令。 它将获取任何需要的依赖项。 $ cd /<PATH>/cbt $ make 注意:要使用snappy或lz4压缩方法,您需要安装以下依赖项: snappy : : lz4 : : 并启动您安
cbt-master.zip
  • cbt-master
  • NOTICE
    396B
  • test
  • cbt_btree_ramfile_tests.erl
    18.1KB
  • cbt_ramfile_tests.erl
    6.1KB
  • cbt_ets_btree_copy_tests.erl
    3.8KB
  • cbt_ets_tests.erl
    18KB
  • cbt_btree_copy_tests.erl
    3.6KB
  • cbt_tests.hrl
    1.3KB
  • cbt_btree_tests.erl
    18.1KB
  • cbt_stream_tests.erl
    3.3KB
  • cbt_file_tests.erl
    8.8KB
  • rebar.config
    721B
  • include
  • cbt.hrl
    1.4KB
  • LICENSE
    11.1KB
  • src
  • cbt_btree.erl
    32.5KB
  • cbt_backend.erl
    1.3KB
  • cbt.app.src
    208B
  • cbt_ramfile.erl
    10.5KB
  • cbt_btree_copy.erl
    8.3KB
  • cbt_compress.erl
    3.5KB
  • cbt_ets.erl
    3.3KB
  • cbt_file.erl
    21.8KB
  • cbt_stream.erl
    11.3KB
  • cbt_util.erl
    5.5KB
  • doc
  • overview.edoc
    4.4KB
  • .gitignore
    154B
  • Makefile
    977B
  • README.md
    5.2KB
  • rebar_dev.config
    1.3KB
内容介绍
#cbt multi-layer MVCC log append-only database library based on the Apache CouchDB btree. ## Changes compared to couchdb - Pluggable Storage backends - use CRC32 to check data integrity instead of MD5 - rewrote the file init part to make it more robust - removed the need of an external config. Provides correct default and use erlang environment. - documentation and specs - some syntax improvements. ## build ### 1. install rebar To build cbt you need to install rebar in your `PATH`. Rebar is available on Github: https://github.com/rebar/rebar Follow the [README](https://github.com/rebar/rebar/blob/master/README.md) to install it. ### 2. build Fetch the source code: $ git clone https://bitbucket.org/refugeio/cbt.git Build the source, run the `make` command. It will fetch any needed dependencies. $ cd /<PATH_TO>/cbt $ make > **Note:** To use snappy or lz4 compression methods you need to install the > following dependencies: > - `snappy`: https://github.com/fdmanana/snappy-erlang-nif > - ` lz4`: https://github.com/krestenkrab/erlang-lz4 > > And launch your application installed in the library path. ### 3. test CBT Run the following command line: $ make test ### 3. Build the doc $ make doc and open the `index.html` file in the doc folder. Or read it [online](http://cbt.cowdb.org). ## Example of usage with the file backend Example of usage: Store a {Key Value} pair in a btree: 1> {ok, Fd} = cbt_file:open("test.db", [create_if_missing]). {ok,<0.35.0>} 2> {ok, Btree} = cbt_btree:open(nil, Fd). {ok,{btree,<0.35.0>,nil,undefined,undefined,undefined,nil, snappy,1279}} 3> 3> {ok, Btree2} = cbt_btree:add(Btree, [{a, 1}]). {ok,{btree,<0.35.0>, {0,[],32}, undefined,undefined,undefined,nil,snappy,1279}} 4> Root = cbt_btree:get_state(Btree2). {0,[],32} 5> Header = {1, Root}. {1,{0,[],32}} 6> cbt_file:write_header(Fd, Header). ok What we did here is to open a file, create a btree inside and add a key value. Until we write the header, the database value is not changed. Now open the database in a new process and read the btree using the last header: 7> {ok, Fd1} = cbt_file:open("test.db"). {ok,<0.44.0>} 8> 8> {ok, Header1} = cbt_file:read_header(Fd1). {ok,{1,{0,[],32}}} 9> Header1 == Header 9> . true 10> {_, ReaderRoot} = Header1. {1,{0,[],32}} 11> {ok, SnapshotBtree} = cbt_btree:open(ReaderRoot, Fd1). {ok,{btree,<0.44.0>, {0,[],32}, undefined,undefined,undefined,nil,snappy,1279}} 12> cbt_btree:lookup(SnapshotBtree, [a]). [{ok,{a,1}}] You can check that the database value is not change until we store the header: 13> {ok, Btree4} = cbt_btree:add(Btree2, [{a, 1}, {b, 2}]). {ok,{btree,<0.35.0>, {4160,[],39}, undefined,undefined,undefined,nil,snappy,1279}} 14> cbt_btree:lookup(Btree4, [a, b]). [{ok,{a,1}},{ok,{b,2}}] 15> Root2 = cbt_btree:get_state(Btree4). {4160,[],39} 16> Header2 = {1, Root2}. {1,{4160,[],39}} 17> cbt_file:write_header(Fd, Header2). ok 18> cbt_btree:lookup(SnapshotBtree, [a, b]). [{ok,{a,1}},not_found] ## ETS backend Find here a simple usage of the ETS backend of cbt allowing you to store one database in an ETS. 1> cbt_ets:new(test). test 2> {ok, Bt} = cbt_ets:open_btree(test, test). {ok,{btree,test,cbt_ets,nil,identity,identity, #Fun<cbt_btree.1.30772535>,nil,none,1279,2558}} 3> {ok, Bt2} = cbt_btree:add(Bt, [{a, 1}]). {ok,{btree,test,cbt_ets, {1,[],28}, identity,identity,#Fun<cbt_btree.1.30772535>,nil,none,1279, 2558}} 4> cbt_ets:update_btree(test, test, Bt2). true 5> {ok, SnapshotBtree} = cbt_ets:open_btree(test, test). {ok,{btree,test,cbt_ets, {1,[],28}, identity,identity,#Fun<cbt_btree.1.30772535>,nil,none,1279, 2558}} 6> cbt_btree:lookup(SnapshotBtree, [a]). [{ok,{a,1}}] 7> {ok, Bt3} = cbt_btree:add(Bt2, [{b, 2}]). {ok,{btree,test,cbt_ets, {2,[],36}, identity,identity,#Fun<cbt_btree.1.30772535>,nil,none,1279, 2558}} 8> cbt_ets:update_btree(test, test, Bt3). true 9> cbt_btree:lookup(SnapshotBtree, [a, b]). [{ok,{a,1}},not_found] 10> {ok, SnapshotBtree2} = cbt_ets:open_btree(test, test). {ok,{btree,test,cbt_ets, {2,[],36}, identity,identity,#Fun<cbt_btree.1.30772535>,nil,none,1279, 2558}} 11> cbt_btree:lookup(SnapshotBtree2, [a, b]). [{ok,{a,1}},{ok,{b,2}}]i ## Custom storage backend CBT provides you 2 different backends by default: - `cbt_file`: Backend to store data in a file - `cbt_ets`: Backend to store data in ETS. But can use a custom backends to store the btree data if you need it. For example if you want to store the btree in a custom file backend when you want to change the data types or when you want to store the BTREE over a Key/Value store. To do it just pass the backend module to the btree and give it the Reference (atom or pid) that have been created when initializing the backend. Have a look in the `cbt_ets' module for more informations.
评论
    相关推荐
    • github-中介
      github-中介
    • apache-jena
      apache-jena-3.1.0.zip
    • Java加速器:使用Apache Maven,Docker和GitHub软件包的GitHub Actions for Java
      6. Apache Maven:构建自动化工具 持续交付 1. Packer: Cloud Image创建者 2. Ansible:配置管理 3. Terraform:基础架构即代码 贡献准则 各种形式的贡献值得赞赏 :thumbs_up: 在阅读贡献准则。 行为守则 阅读准则...
    • ghmac:GitHub for Mac 食谱
      安装 GitHub Mac。 要求 OS X 和 GitHub 帐户(用于使用该应用程序)。 属性 有关默认值,请参阅attributes/default.rb 。 node['ghmac']['url'] - 检索 zip 文件的 URL。 node['ghmac']['checksum'] - zip 文件的...
    • setup-apache-flex-action:Github Action来设置Apache Flex SDK
      Github Action来设置Apache Flex SDK 此操作将下载 ,将bin文件夹添加到PATH ,并设置FLEX_HOME环境变量。 输入项 flex-version (可选) Apache Flex SDK的版本。 此值必须包括主要,次要和修订版本,例如4.16.1 ...
    • apacheds-github-interceptor:一个 ApacheDS 拦截器,将 LDAP 成员更改同步到 githu
      ApacheDS GitHub 拦截器 一个 ApacheDS 拦截器,它将 LDAP 成员资格更改同步到 GitHub 组织。 CI状态: 安装 在 Java 8 上使用 Eclipse 4.5 和 Maven M2E 构建。安装了这个之后,导入项目并使用 maven (pom.xml -> ...
    • Apache Zeppelin Github Viewer-crx插件
      Github Viewer for Apache Zeppelin 安装该文件以按预期的方式在Github中查看Apache Zeppelin笔记本。 请在此处创建任何问题:https://github.com/rishabhbhardwaj/zeppelin-github-viewer/issues欢迎您为改善此问题...
    • Abhiapache.github.io
      Abhiapache.github.io
    • b.github.com
      (现在托管在GitHub上)。 使用生成静态网站。 执照 所有原始文本内容均根据。 所有代码均根据,复制如下: 版权所有2008-2015 Benjamin Black 根据Apache许可版本2.0(“许可”)许可; 除非遵守许可,否则您...
    • github-users
      github-users