Giter Site home page Giter Site logo

dborchard / tiny-db Goto Github PK

View Code? Open in Web Editor NEW
20.0 1.0 5.0 412 KB

Tiny Database: Query Engine, Storage Engine, Calcite, ANTLR

Home Page: https://medium.com/p/ca6d3f06e115

Java 51.29% ANTLR 48.71%
antlr4 calcite database query-engine storage-engine

tiny-db's Introduction

TinyDB

A tiny database that supports Btree Index, Planner and Parser.

Sample Queries

  • Without Index
create table T1 ( A int, B varchar(9) );
insert into T1 (A, B) values (1, 'Alice');
insert into T1 (A, B) values (2, 'Bob');
select A,B from T1;
select A,B from T1 where A=1;

Output

>
+---+-------+
| a | b     |
+---+-------+
| 1 | Alice |
| 2 | Bob   |
+---+-------+
>
+---+-------+
| a | b     |
+---+-------+
| 1 | Alice |
+---+-------+
  • With Index
create table T2 ( A int, B varchar(9) );
create index A_IDX on T2(A);
insert into T2 (A, B) values (1, 'Alice');
insert into T2 (A, B) values (2, 'Bob');
select A,B from T2;
select A,B from T2 where A=1;
>
+---+-------+
| a | b     |
+---+-------+
| 1 | Alice |
| 2 | Bob   |
+---+-------+

> index on a used
+---+-------+
| a | b     |
+---+-------+
| 1 | Alice |
+---+-------+

NOTE: Delete the tinydb data directory to start fresh.

Features

  • Frontend

  • Query Engine

    • Basic Query Engine (Supporting Projection, Selection etc)
    • Rule Based Planners (use BTree Index if available on that field)
    • Calcite backed Query Engine (Currently supports ScannableTable and not ModifiableTable)
    • Calcite Optimizer [Todo]
  • Index

    • Naive B+Tree Index
    • Library backed B+Tree Index (davidmoten bplustree library, Delete not supported by library)
  • Storage Engine

    • File Manager, Block, Page
  • CLI interface

TODO

  • Recovery Manager (WAL)
  • Transactions
  • Concurrency Manager
  • Buffer Manager

Notes

This work is a derived from SimpleDB

Current Limitations

  • Not implemented Primary Key, Unique Key etc.
  • If we create index after the data is inserted, there is some anomaly.
  • Currently only supports Varchar, int.

tiny-db's People

Stargazers

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

Watchers

 avatar

tiny-db's Issues

BplusTree Key's are not generic

In ConstantSerializer we are assuming Index as Integer. We need to modify that logic to be generic enough for Constant class.

public class ConstantSerializer implements Serializer<D_Constant> {

  @Override
  public D_Constant read(LargeByteBuffer bb) {
    int ival = bb.getInt();
    return new D_Constant(ival);
  }

UPDATE Table having invalid ANTLR Parser logic

There is an issue with the "where" condition for ANTLR Parser implementation.

tinysql> select A,B from T2;
+---+---------+
| A | B       |
+---+---------+
| 1 | 'Alice' |
| 2 | 'Bob'   |
+---+---------+

tinysql> update T2 SET A=1 where A=2;
1 row updated.
tinysql> select A,B from T2;
+---+---------+
| A | B       |
+---+---------+
| 1 | 'Alice' |
| 2 | 'Bob'   |
+---+---------+

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.