Code Monkey home page Code Monkey logo

wooridb's Introduction

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.


If you want me to continue improving this project: Patreon link

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 is 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.
  • Able to handle very large numbers when using the P suffix.
    • Ex: 98347883122138743294728345738925783257325789353593473247832493483478935673.9347324783249348347893567393473247832493483478935673P.
  • Configuration is done via environment variables.
  • Authentication and Authorization via session token
  • Conditional Update
  • Some 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-8. To execute the docker container run:

  • docker run -p 1438:1438 naomijubs/wooridb:beta-8 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-8 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-8 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 is via --feature 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

Milestone to stable-ish version

Current Benchmarks

2,3 GHz Intel Core i9 8-Core 32 GB 2667 MHz DDR4

  • create_entity time: [4.7008 ms 4.7367 ms 4.7725 ms]
  • insert_entity time: [12.647 ms 12.977 ms 13.308 ms]
  • update_set_entity time: [14.896 ms 15.087 ms 15.309 ms]
  • update_content_entity time: [14.871 ms 15.070 ms 15.307 ms]
  • delete_entity time: [5.3966 ms 5.4423 ms 5.4908 ms] - Filtered 400s
  • evict_entity_id time: [15.534 ms 15.623 ms 15.721 ms] - Filtered 400s
  • evict_entity time: [12.318 ms 12.416 ms 12.540 ms] - Filtered 400s
  • select_all 20 entities time: [6.3402 ms 6.4743 ms 6.6356 ms]
  • select_all 10 entities time: [5.8318 ms 5.9682 ms 6.1340 ms]
  • select_all 1 entity time: [5.1030 ms 5.1379 ms 5.1738 ms]
  • history_10_registries_for_entity time: [5.4936 ms 5.5328 ms 5.5725 ms]
  • history_20_registries_for_entity time: [6.0676 ms 6.1049 ms 6.1429 ms]

WQL

2,3 GHz Intel Core i9 8-Core 32 GB 2667 MHz DDR4

  • create_entity time: [433.57 ns 435.00 ns 436.38 ns]
  • inser_entity time: [1.6349 us 1.6406 us 1.6463 us]
  • select_all time: [429.79 ns 431.05 ns 432.14 ns]
  • select_args time: [655.40 ns 657.53 ns 659.71 ns]

File approximated size

For ~10000 entries in a day, the file size will be 2.5 GB for registries (and for cached values - this may become an issue soon). After compression it can be reduced to 10% of this.

artillery.io

2,3 GHz Intel Core i9 8-Core 32 GB 2667 MHz DDR4

Insert

Config file:

config:
  target: "http://localhost:1438"
  phases:
    - duration: 100
      arrivalRate: 10
  defaults:
    headers:
      Content-Type: "application/wql"
scenarios:
  - flow:
      - post:
          url: "/wql/tx"
          body: "INSERT {name: \"name\", last_name: \"last name\", age: 20, blood: 'O'} INTO person"

Select

Contains 1000 registries of {name: \"name\", last_name: \"last name\", age: 20, blood: 'O'}.

Config file:

config:
  target: "http://localhost:1438"
  phases:
    - duration: 100
      arrivalRate: 10
  defaults:
    headers:
      Content-Type: "application/wql"
scenarios:
  - flow:
      - post:
          url: "/wql/query"
          body: "SELECT * FROM person"

wooridb's People

Contributors

dependabot[bot] avatar evaporei avatar mattheusv avatar naomijub avatar thiagokokada avatar vrmiguel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

wooridb's Issues

CHECK in wrong endpoint

Currently CHECK is being supported by /wql/tx endpoint when it should be supported by /wql/query

Edn support

Via feature EDN

  • Request (entity-history)
  • Response
  • --features edn

Precise Floats

as the book Database Internals: A Deep Dive Into How Distributed Data Systems Work suggests, dealing with precise floats is the database responsibility. If the user sends a precise amount for that float, you shouldn't trunc/round it.

Data Encryption

  • Define which data to encrypt.

  • Prevent user of reading encrypted data .

  • Allow user to check if data send to encrypted key is correct. CHECK {key: value,} FROM my_entity ID <uuid>.

  • Encryption configs from Config.toml -> Converted to Issue 34
    bcrypt seems the best rusty solution.

Tests in parallel

A possible option is to create a different data folder for each test (using a hash or datetime) so that no test affect the other one. Maybe on the beginning of the test script the data folder should be deleted, or at the end.

Remove \n from COUNT

(
 response: "{\n \"0195ebb0-6a03-4025-8cea-9660597847d9\": {\n  \"name\": String(\"Julia\"),\n  \"blood\": String(\"O\"),\n  \"age\": Integer(33),\n  \"lastname\": String(\"Naomi\"),\n },\n \"01c5b875-6169-4bb3-b072-846b4678d1ce\": {\n  \"blood\": String(\"O\"),\n  \"age\": Integer(33),\n  \"lastname\": String(\"Naomi\"),\n  \"name\": String(\"Julia\"),\n },\n \"01f7e8a7-e473-4dbe-b3c7-de9e3443d42e\": {\n  \"blood\": String(\"O\"),\n  \"name\": String(\"Julia\"),\n  \"age\": Integer(33),\n  \"lastname\": String(\"Naomi\"),\n },\n...}",
count: 1000,
)

Allow ORDER, GROUP and DEDUP for SELECT IDS IN

 if let Some(Algebra::Dedup(_)) = functions.get("DEDUP") {
        return Err(Error::FeatureNotImplemented(
            String::from("DEDUP"),
            String::from("SELECT WITH IDS"),
        ));
    }
    if let Some(Algebra::Dedup(_)) = functions.get("GROUP") {
        return Err(Error::FeatureNotImplemented(
            String::from("GROUP BY"),
            String::from("SELECT WITH IDS"),
        ));
    }
    if let Some(Algebra::Dedup(_)) = functions.get("ORDER") {
        return Err(Error::FeatureNotImplemented(
            String::from("ORDER BY"),
            String::from("SELECT WITH IDS"),
        ));
    }

Count

Algebric function

Crash Recovery

Whenever the system crashes it should be possible to read the last logs and recover system state.
Including reading possible ztsd files

Max connections

env variable to configure max connections
default should be 1000.

Very Large Numbers (larger than i128/f64)

Some languages like Clojure allow the user to write numbers as large as the available memory. This may not. be the case for WooriDB but it is a feature to keep in mind.

Store <information>.log in S3

Instead of saving registries only in-memory, save them at S3, which would delete old files instead of compressing them.

Json Support

Via feature json

  • Request
  • Response
  • --features json

Docs

Improve system documentation.

  • README
  • Book
    • Queries
    • Errors
    • TODOs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.