Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/lykia-rs/lykiadb into featu…
Browse files Browse the repository at this point in the history
…re/planner
  • Loading branch information
can-keklik committed Aug 10, 2024
2 parents 97a72a0 + f319479 commit 081b8e8
Show file tree
Hide file tree
Showing 84 changed files with 4,209 additions and 998 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver= "2"
members = ["lykiadb-server", "lykiadb-shell", "lykiadb-connect", "lykiadb-playground"]
members = ["lykiadb-server", "lykiadb-shell", "lykiadb-lang", "lykiadb-playground", "lykiadb-connect"]
edition = "2021"

[profile.release]
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ Lykia is a toy multi-model database basically written for educational purposes.

- [x] Core scripting language
- [x] A minimal standard library
- [x] Data manipulation language ("SELECT", "INSERT", "UPDATE", "DELETE")
- [x] DML/DDL SQL
- [x] Event loop, client-server communication
- [ ] Data definition language ("CREATE COLLECTION", etc.) (in progress)
- [x] Minimal playground app
- [ ] Query binding and planning (in progress)
- [ ] LSM storage engine (based on [mini-lsm](https://github.com/lykia-rs/mini-lsm)) (in progress)
- [ ] Bitcask storage engine
- [ ] MVCC for transaction management (based on [mini-lsm](https://github.com/lykia-rs/mini-lsm))
- [ ] B-Tree implementation for indexing
- [ ] Plan optimization
-----------------------------------------
- [ ] B-Tree implementation for indexing
- [ ] LSM storage engine (based on [mini-lsm](https://github.com/lykia-rs/mini-lsm))
- [ ] Basic replication with Raft

## Getting Started
Expand All @@ -47,15 +49,19 @@ To use Lykia, you can download the latest release from the GitHub releases page.
Run the server:

```shell
$ cargo run --release --bin lykiadb-lykiadb-server
$ cargo run --release --bin lykiadb-server
```
Run the client:
Run the shell:

```shell
$ cargo run --release --bin lykiadb-shell lykiadb-shell/examples/fib.ly
```
Run the playground:

Client transmits the fib.ly in an infinite loop.
```shell
$ cd lykiadb-playground
$ pnpm dev
```

## License
Lykia is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.
12 changes: 12 additions & 0 deletions lykiadb-lang/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
authors = ["Vedat Can Keklik <vcankeklik@gmail.com>"]
name = "lykiadb-lang"
version = "0.1.0"
edition = "2021"

[dependencies]
phf = { version = "0.11", default-features = false, features = ["macros"] }
rustc-hash = "1.1.0"
serde = { version = "1.0.188", features=["derive", "rc"] }
serde_json = "1.0.105"
assert-json-diff = "2.0.2"
167 changes: 157 additions & 10 deletions lykiadb-server/src/lang/ast/expr.rs → lykiadb-lang/src/ast/expr.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
use serde::{Deserialize, Serialize};
use std::sync::Arc;

use crate::lang::{
tokenizer::token::{Span, Spanned},
Identifier,
};
use crate::{Identifier, Span, Spanned};

use super::{
sql::{SqlDelete, SqlInsert, SqlSelect, SqlUpdate},
stmt::Stmt,
AstNode,
};

use crate::lang::Literal;
use crate::Literal;

#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(tag = "@type")]
Expand Down Expand Up @@ -39,24 +37,32 @@ pub enum Expr {
query: SqlSelect,
#[serde(skip)]
span: Span,
#[serde(skip)]
id: usize,
},
#[serde(rename = "Expr::Insert")]
Insert {
command: SqlInsert,
#[serde(skip)]
span: Span,
#[serde(skip)]
id: usize,
},
#[serde(rename = "Expr::Update")]
Update {
command: SqlUpdate,
#[serde(skip)]
span: Span,
#[serde(skip)]
id: usize,
},
#[serde(rename = "Expr::Delete")]
Delete {
command: SqlDelete,
#[serde(skip)]
span: Span,
#[serde(skip)]
id: usize,
},
#[serde(rename = "Expr::Variable")]
Variable {
Expand All @@ -71,13 +77,17 @@ pub enum Expr {
expr: Box<Expr>,
#[serde(skip)]
span: Span,
#[serde(skip)]
id: usize,
},
#[serde(rename = "Expr::Literal")]
Literal {
value: Literal,
raw: String,
#[serde(skip)]
span: Span,
#[serde(skip)]
id: usize,
},
#[serde(rename = "Expr::Function")]
Function {
Expand All @@ -86,6 +96,8 @@ pub enum Expr {
body: Arc<Vec<Stmt>>,
#[serde(skip)]
span: Span,
#[serde(skip)]
id: usize,
},
#[serde(rename = "Expr::Binary")]
Binary {
Expand All @@ -94,13 +106,17 @@ pub enum Expr {
right: Box<Expr>,
#[serde(skip)]
span: Span,
#[serde(skip)]
id: usize,
},
#[serde(rename = "Expr::Unary")]
Unary {
operation: Operation,
expr: Box<Expr>,
#[serde(skip)]
span: Span,
#[serde(skip)]
id: usize,
},
#[serde(rename = "Expr::Assignment")]
Assignment {
Expand All @@ -118,20 +134,26 @@ pub enum Expr {
right: Box<Expr>,
#[serde(skip)]
span: Span,
#[serde(skip)]
id: usize,
},
#[serde(rename = "Expr::Call")]
Call {
callee: Box<Expr>,
args: Vec<Expr>,
#[serde(skip)]
span: Span,
#[serde(skip)]
id: usize,
},
#[serde(rename = "Expr::Get")]
Get {
object: Box<Expr>,
name: Identifier,
#[serde(skip)]
span: Span,
#[serde(skip)]
id: usize,
},
#[serde(rename = "Expr::Set")]
Set {
Expand All @@ -140,43 +162,69 @@ pub enum Expr {
value: Box<Expr>,
#[serde(skip)]
span: Span,
#[serde(skip)]
id: usize,
},
}

impl Spanned for Expr {
fn get_span(&self) -> Span {
match self {
Expr::Select { query: _, span }
| Expr::Insert { command: _, span }
| Expr::Delete { command: _, span }
| Expr::Update { command: _, span }
Expr::Select {
query: _,
span,
id: _,
}
| Expr::Insert {
command: _,
span,
id: _,
}
| Expr::Delete {
command: _,
span,
id: _,
}
| Expr::Update {
command: _,
span,
id: _,
}
| Expr::Variable {
name: _,
span,
id: _,
}
| Expr::Grouping { expr: _, span }
| Expr::Grouping {
expr: _,
span,
id: _,
}
| Expr::Literal {
value: _,
raw: _,
span,
id: _,
}
| Expr::Function {
name: _,
parameters: _,
body: _,
span,
id: _,
}
| Expr::Binary {
left: _,
operation: _,
right: _,
span,
id: _,
}
| Expr::Unary {
operation: _,
expr: _,
span,
id: _,
}
| Expr::Assignment {
dst: _,
Expand All @@ -189,23 +237,122 @@ impl Spanned for Expr {
operation: _,
right: _,
span,
id: _,
}
| Expr::Call {
callee: _,
args: _,
span,
id: _,
}
| Expr::Get {
object: _,
name: _,
span,
id: _,
}
| Expr::Set {
object: _,
name: _,
value: _,
span,
id: _,
} => *span,
}
}
}

impl AstNode for Expr {
fn get_id(&self) -> usize {
match self {
Expr::Select {
query: _,
span: _,
id,
}
| Expr::Insert {
command: _,
span: _,
id,
}
| Expr::Delete {
command: _,
span: _,
id,
}
| Expr::Update {
command: _,
span: _,
id,
}
| Expr::Variable {
name: _,
span: _,
id,
}
| Expr::Grouping {
expr: _,
span: _,
id,
}
| Expr::Literal {
value: _,
raw: _,
span: _,
id,
}
| Expr::Function {
name: _,
parameters: _,
body: _,
span: _,
id,
}
| Expr::Binary {
left: _,
operation: _,
right: _,
span: _,
id,
}
| Expr::Unary {
operation: _,
expr: _,
span: _,
id,
}
| Expr::Assignment {
dst: _,
expr: _,
span: _,
id,
}
| Expr::Logical {
left: _,
operation: _,
right: _,
span: _,
id,
}
| Expr::Call {
callee: _,
args: _,
span: _,
id,
}
| Expr::Get {
object: _,
name: _,
span: _,
id,
}
| Expr::Set {
object: _,
name: _,
value: _,
span: _,
id,
} => *id,
}
}
}
Loading

0 comments on commit 081b8e8

Please sign in to comment.