WooriDB

Overview

WooriDB

USER GUIDE

WooriDB is a general purpose (EXPERIMENTAL) time serial database, which means it contains all entities registries indexed by DateTime. It is schemaless, key-value storage and uses its own query syntax that is similar to SparQL and Crux's Datalog.

Some other features are:

  • Hashing keys content with ENCRYPT keyword.
  • Hashed values are filtered out and can only be checked with CHECK keyword.
  • Ron schemas for input and output.
    • JSON to be supported via feature.
    • EDN to be supported via feature.
  • Entities are indexed by entity_name (Entity Tree), DateTime (Time Serial) and Uuid (Entity ID). Entity format is a HashMap where keys are strings and values are supported Types.
  • Stores persistent data locally.
    • S3 as a backend is to be developed.
    • Postgres as a backend is to be developed.
    • DynamoDB as a backend is to be developed.
  • Able to handle very large numbers when using the P suffix.
    • Ex: 98347883122138743294728345738925783257325789353593473247832493483478935673.9347324783249348347893567393473247832493483478935673P.
  • Configuration is done via environment variables.
    • Non sensitive configurations are done with Config.toml.
    • CORS
  • Authentication and Authorization via session token
    • Creating and removing ADMINs/new users.
  • Conditional Update
  • Possible Relation Algebra
  • Entity history

Woori means our and although I developed this DB initially alone, it is in my culture to call everything that is done for our community and by our community ours.

This project is hugely inspired by:

Installation

To run WooriDB it is necessary to have Rust installed in the machine. There are two ways to do this:

  1. Go to rustup.rs and copy the command there, for unix it is curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh.
  2. Clone WooriDB and execute make setup.

Executing WooriDB

  • Release mode performance: make release in project root for performance optimization.
  • Release mode size: make run in project root for size optimization.
  • Debug mode: make debug in project root.

Docker

you can find the latest docker image at naomijub/wooridb. The current most stable tag is beta-2. To execute the docker container run:

  • docker run -p 1438:1438 naomijubs/wooridb:beta-2 debug for debug mode.
  • docker run -p 1438:1438 -e AUTH_HASHING_COST=8 -e ADMIN=your-admin-id -e ADMIN_PASSWORD=your-admin-pswd naomijubs/wooridb:beta-2 run for size optimization.
  • docker run -p 1438:1438 -e AUTH_HASHING_COST=8 -e ADMIN=your-admin-id -e ADMIN_PASSWORD=your-admin-pswd naomijubs/wooridb:beta-2 release for performance optimization.
  • All -e/--env can be replaced by a --env-file path/to/your/.env. Your .envfile should contain the following fields:
HASHING_COST=16
PORT=1438
AUTH_HASHING_COST=8
ADMIN=your-admin-id
ADMIN_PASSWORD=your-admin-pswd

Usage

  • Responses are in RON format. Support for JSON and EDN will be done later by using features.
  • For now only persistent local memory is used. Support for S3, Postgres and DynamoDB will also be done later by using features.
  • Precise floats or numbers larger than f64::MAX/i128::MAX can be defined with an UPPERCASE P at the end.
    • Note: This type cannot be updated with UPDATE CONTENT.
    • Ex.: INSERT {a: 98347883122138743294728345738925783257325789353593473247832493483478935673.9347324783249348347893567393473247832493483478935673P, } INTO my_entity.
  • BLOB will not be supported. Check out To BLOB or Not To BLOB: Large Object Storage in a Database or a Filesystem.
  • To configure hashing cost and port some environment variables are required:
HASHING_COST=16
PORT=1438

TODOS

Current Benchmarks

MacBook Pro, 2.2 GHz Intel Core i7, 16 GB 2400 MHz DDR4

  • create_entity time: [15.269 ms 15.332 ms 15.396 ms]
  • insert_entity time: [27.438 ms 28.177 ms 28.958 ms]
  • update_set_entity time: [24.110 ms 24.857 ms 25.695 ms]
  • update_content_entity time: [25.076 ms 25.819 ms 26.584 ms]
  • delete_entity time: [41.999 ms 42.719 ms 43.492 ms] - Filtered 400s
  • evict_entity_id time: [41.387 ms 42.029 ms 42.731 ms] - Filtered 400s
  • evict_entity time: [31.582 ms 31.805 ms 32.039 ms] - Filtered 400s
Comments
  • json

    json

    Hi, I am writing a client library for wooridb. It would be great to be able to use vanilla serde_json::from_str. The custom DateTime seems to require me to implement my own deserialiser. Or am I missing something? Still trying to get my head around serde etc.

    opened by sc13-bioinf 5
  • Update README.md

    Update README.md

    This PR focuses on improving the legibility of the README, alongside minor typo and grammar fixes.

    Notes:

    • I assumed that Woori refers to a Korean word. If I'm wrong, please let me know.
    • I didn't yet go over the several SELECT request descriptions but probably will later on.
    opened by vrmiguel 4
  • proof of concept

    proof of concept

    pure json response

    So this is not for merging, just a proof of concept. It's only implemented for SELECT * right now. Bincode doesn't support tagged enums. The Types enum needed to be mirrored to allow separate serde annotations for transfer vs internal serialisation (See https://github.com/serde-rs/serde/issues/1310). There is probably some redundant stuff in my experiments to make Response support the new TypesSelfDescribed enum.

    I tried (note that Internal tagging does not allow the enum variants with values): #[serde(tag = "type", content = "value")] pub enum TypesSelfDescribing {

    "tx_time":{"type":"DateTime","value":"2022-08-21T12:06:35.595025264Z"}, "last_name":{"type":"String","value":"Rabbit"}

    #[serde(untagged)] pub enum TypesSelfDescribing {

    "tx_time":"2022-08-21T12:06:35.595025264Z", "last_name":"Rabbit"

    //with no serde annotation: pub enum TypesSelfDescribing { "tx_time":{"DateTime":"2022-08-21T12:06:35.595025264Z"}, "last_name":{"String":"Rabbit"}

    So for that last format I guess no tag means that bincode would be ok and therefore no mirroring, but I guess the its no longer possible to round trip. Maybe all that was needed was to replace:

    https://github.com/naomijub/wooridb/blob/646997e36dee18e54614271b9829e695de704888/woori-db/src/schemas/query.rs#L496

    with the serde_json::from_str

    opened by sc13-bioinf 1
  • Improve where performance for algebric functions

    Improve where performance for algebric functions

    One possible solution is to cache in memory the current state so we avoid IO `BTreeMap<Uuid, (DataRegister, HashMap<String, Types>)>' for example

    opened by naomijub 1
  • Count keys different than all

    Count keys different than all

    Currently when we want to count it counts all elements, but the user may want to count only a specific key.

    Currently it is possible to count a by using SELECT #{key_to_count,} FROM key WHERE {...} COUNT instead of SELECT * FROM key WHERE {...} COUNT. However, it may be better to use SELECT * FROM key WHERE {...} COUNT #{key_to_count,}

    enhancement help wanted good first issue question Possible Feature 
    opened by naomijub 0
Releases(0.1.9)
  • 0.1.9(Jul 1, 2022)

    • [x] updates dependencies

    To use this release

    GET at https://github.com/naomijub/wooridb/archive/0.1.9.tar.gz / $ tar -zxvf 0.1.9.tar.gz $ cd woori-0.1.9 $ make release # or make debug

    Optimized for size:

    GET at https://github.com/naomijub/wooridb/archive/0.1.9.tar.gz / $ tar -zxvf 0.1.9.tar.gz $ cd woori-0.1.9 $ make run

    To support json:

    GET at https://github.com/naomijub/wooridb/archive/0.1.9.tar.gz / $ tar -zxvf 0.1.9.tar.gz $ cd woori-0.1.9 $ make json

    To support entity history:

    GET at https://github.com/naomijub/wooridb/archive/0.1.9.tar.gz / $ tar -zxvf 0.1.9.tar.gz $ cd woori-0.1.9 $ make history

    Source code(tar.gz)
    Source code(zip)
  • 0.1.8(Apr 23, 2021)

    • [x] Reduce cache file size.

    To use this release

    GET at https://github.com/naomijub/wooridb/archive/0.1.8.tar.gz / $ tar -zxvf 0.1.8.tar.gz $ cd woori-0.1.8 $ make release # or make debug

    Optimized for size:

    GET at https://github.com/naomijub/wooridb/archive/0.1.8.tar.gz / $ tar -zxvf 0.1.8.tar.gz $ cd woori-0.1.8 $ make run

    To support json:

    GET at https://github.com/naomijub/wooridb/archive/0.1.8.tar.gz / $ tar -zxvf 0.1.8.tar.gz $ cd woori-0.1.8 $ make json

    To support entity history:

    GET at https://github.com/naomijub/wooridb/archive/0.1.8.tar.gz / $ tar -zxvf 0.1.8.tar.gz $ cd woori-0.1.8 $ make history

    Source code(tar.gz)
    Source code(zip)
  • 0.1.7(Apr 2, 2021)

    • [x] Join
    • [x] Improve updates performance
    • [x] Improve where performance

    To use this release

    GET at https://github.com/naomijub/wooridb/archive/0.1.7.tar.gz / $ tar -zxvf 0.1.7.tar.gz $ cd woori-0.1.7 $ make release # or make debug

    Optimized for size:

    GET at https://github.com/naomijub/wooridb/archive/0.1.7.tar.gz / $ tar -zxvf 0.1.7.tar.gz $ cd woori-0.1.7 $ make run

    To support json:

    GET at https://github.com/naomijub/wooridb/archive/0.1.7.tar.gz / $ tar -zxvf 0.1.7.tar.gz $ cd woori-0.1.7 $ make json

    To support entity history:

    GET at https://github.com/naomijub/wooridb/archive/0.1.7.tar.gz / $ tar -zxvf 0.1.7.tar.gz $ cd woori-0.1.7 $ make history

    Source code(tar.gz)
    Source code(zip)
  • 0.1.6(Mar 27, 2021)

    • [x] Union
    • [x] Intersect
    • [x] Difference
    • [x] zstd decompression

    To use this release

    GET at https://github.com/naomijub/wooridb/archive/0.1.6.tar.gz / $ tar -zxvf 0.1.6.tar.gz $ cd woori-0.1.6 $ make release # or make debug

    Optimized for size:

    GET at https://github.com/naomijub/wooridb/archive/0.1.6.tar.gz / $ tar -zxvf 0.1.6.tar.gz $ cd woori-0.1.6 $ make run

    To support json:

    GET at https://github.com/naomijub/wooridb/archive/0.1.6.tar.gz / $ tar -zxvf 0.1.6.tar.gz $ cd woori-0.1.6 $ make json

    To support entity history:

    GET at https://github.com/naomijub/wooridb/archive/0.1.6.tar.gz / $ tar -zxvf 0.1.6.tar.gz $ cd woori-0.1.6 $ make history

    Source code(tar.gz)
    Source code(zip)
  • 0.1.5(Mar 25, 2021)

    • [x] Json feature
    • [x] Entity history feature
    • [x] tx_time for every response

    To use this release

    GET at https://github.com/naomijub/wooridb/archive/0.1.5.tar.gz / $ tar -zxvf 0.1.5.tar.gz $ cd woori-0.1.5 $ make release # or make debug

    Optimized for size:

    GET at https://github.com/naomijub/wooridb/archive/0.1.5.tar.gz / $ tar -zxvf 0.1.5.tar.gz $ cd woori-0.1.5 $ make run

    To support json:

    GET at https://github.com/naomijub/wooridb/archive/0.1.5.tar.gz / $ tar -zxvf 0.1.5.tar.gz $ cd woori-0.1.5 $ make json

    To support entity history:

    GET at https://github.com/naomijub/wooridb/archive/0.1.5.tar.gz / $ tar -zxvf 0.1.5.tar.gz $ cd woori-0.1.5 $ make history

    Source code(tar.gz)
    Source code(zip)
  • 0.1.4(Mar 14, 2021)

    • [x] Dedups None and Types::Nil
    • [x] Improves error response codes

    To use this release

    GET at https://github.com/naomijub/wooridb/archive/0.1.4.tar.gz / $ tar -zxvf 0.1.4.tar.gz $ cd woori-0.1.4 $ make release # or make debug

    Optimized for size:

    GET at https://github.com/naomijub/wooridb/archive/0.1.4.tar.gz / $ tar -zxvf 0.1.4.tar.gz $ cd woori-0.1.4 $ make run

    Source code(tar.gz)
    Source code(zip)
  • 0.1.3(Mar 13, 2021)

    Contains relation algebra and aux functions:

    • DEDUP
    • ORDER BR
    • GROUP BY
    • LIMIT
    • OFFSET
    • COUNT

    To use this release

    GET at  https://github.com/naomijub/wooridb/archive/0.1.3.tar.gz /
    $ tar -zxvf 0.1.3.tar.gz
    $ cd woori-0.1.3
    $ make release # or make debug
    

    Optimized for size:

    GET at  https://github.com/naomijub/wooridb/archive/0.1.3.tar.gz /
    $ tar -zxvf 0.1.3.tar.gz
    $ cd woori-0.1.3
    $ make run
    
    Source code(tar.gz)
    Source code(zip)
  • 0.1.2(Mar 2, 2021)

    Contains entity history endpoint

    To use this release

    GET at  https://github.com/naomijub/wooridb/archive/0.1.2.tar.gz /
    $ tar -zxvf 0.1.2.tar.gz
    $ cd woori-0.1.2
    $ make release # or make debug
    

    Optimized for size:

    GET at  https://github.com/naomijub/wooridb/archive/0.1.2.tar.gz /
    $ tar -zxvf 0.1.2.tar.gz
    $ cd woori-0.1.2
    $ make run
    
    Source code(tar.gz)
    Source code(zip)
  • 0.1.1(Feb 26, 2021)

    To use this release

    GET at  https://github.com/naomijub/wooridb/archive/0.1.1.tar.gz /
    $ tar -zxvf 0.1.1.tar.gz
    $ cd woori-0.1.1
    $ make release # or make debug
    

    Optimized for size:

    GET at  https://github.com/naomijub/wooridb/archive/0.1.1.tar.gz /
    $ tar -zxvf 0.1.1.tar.gz
    $ cd woori-0.1.1
    $ make run
    
    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Feb 21, 2021)

    To use this release

    GET at  https://github.com/naomijub/wooridb/archive/0.1.0.tar.gz /
    $ tar -zxvf 0.1.0.tar.gz
    $ cd woori-0.1.0
    $ make run # or make debug
    

    Run requires extra environment variables

    Source code(tar.gz)
    Source code(zip)
Owner
Julia Naomi
Rust, Games, Kotlin, Elixir
Julia Naomi