GithubHelp home page GithubHelp logo

jz's Introduction

WARNING: Experimental & just for fun

jz: Simple JSON database presented as a HTTP REST server

Goals:

  • Durability (HTTP response means the write has been persisted to disk)
  • Column schema (the most efficient index by datatype)
  • LMDB (zero copy and fast reads)
  • Minimise time-to-first-row (online aggregation)
  • GROUP BY CUBE support (pivot tables)
  • One big table (NoSQL)
  • SQL-like querying
  • Document tagging
  • Multi-tenancy

Inspired by the following papers:

How do I use this?

All examples below make use of the excellent httpie

Start the server

sudo ./jz/jz.py -z
pidfile is: /var/run/jz.pid
daemonizing...

Add index

Indices allow you to do range queries.

http -h --ignore-stdin POST 127.0.0.1:8888/index/ name=x datatype=uint64
http -h --ignore-stdin POST 127.0.0.1:8888/index/ name=y datatype=uint64
HTTP/1.1 200 OK
Content-Language: en-us
Content-Type: application/json
Content-Length: 2
Server: jz/0.1.0

HTTP/1.1 200 OK
Content-Language: en-us
Content-Type: application/json
Content-Length: 2
Server: jz/0.1.0

POST JSON document

Post a JSON document with dictionary containing a key "x" with value 10.

echo '{"x": 10}' | http -h POST 127.0.0.1:8888/
HTTP/1.1 200 OK
Content-Language: en-us
Content-Type: application/json
Content-Length: 2
Server: jz/0.1.0

GET JSON documents using JSON query

Retrieve a list of documents.

echo 'WHERE 0 < x' | http GET 127.0.0.1:8888/
[{"x": 10}
]

GET JSON documents using multiple clause JSON query

echo '{"x": 10}' | http POST 127.0.0.1:8888/
echo '{"x": 20, "y": 50}' | http POST 127.0.0.1:8888/
echo '{"x": 70, "y": 90}' | http POST 127.0.0.1:8888/
echo '{"x": 30, "y": 40}' | http POST 127.0.0.1:8888/
echo 'WHERE x > 25 AND 60 < y' | http -b GET 127.0.0.1:8888/
[{"x": 70, "y": 90}
]

Shutdown server

sudo cat /var/run/jz.pid | sudo xargs kill
echo Done!
Done!

Security

jz does not implement SSL/TLS. You will need to use a SSL terminator (eg. ngnix)

TODO

  • Add sargable iterators
  • Multi-vendor
  • GROUP BY

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.