Skip to content

Commit

Permalink
rename project to DoraDB
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangzhe authored and jiangzhe committed Nov 16, 2024
1 parent c77aab4 commit 4a53a6c
Show file tree
Hide file tree
Showing 177 changed files with 5,326 additions and 942 deletions.
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[workspace]
members = [
"xngin-datatype",
"xngin-catalog",
"xngin-sql",
"xngin-expr",
"xngin-compute",
"xngin-plan",
"xngin-protocol",
"xngin-storage",
"xngin-server",
"xngin-tpch-tests"
"doradb-datatype",
"doradb-catalog",
"doradb-sql",
"doradb-expr",
"doradb-compute",
"doradb-plan",
"doradb-protocol",
"doradb-storage",
"doradb-server",
"doradb-tpch-tests"
]
exclude = ["xngin-bench"]
exclude = ["doradb-bench"]
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# XNGIN
# EVODB

![build](https://github.com/jiangzhe/xngin/actions/workflows/build.yml/badge.svg)
![codecov](https://codecov.io/gh/jiangzhe/xngin/branch/main/graph/badge.svg?token=T3RMZE2998)
![build](https://github.com/jiangzhe/evodb/actions/workflows/build.yml/badge.svg)
![codecov](https://codecov.io/gh/jiangzhe/evodb/branch/main/graph/badge.svg?token=T3RMZE2998)

Xngin(pronounced "X Engine") is a personal project to build a SQL engine from scratch.

The project name is inspired by [Nginx](https://en.wikipedia.org/wiki/Nginx), which is a
very popular web server with high performance and ease to use.
doradb is a experimental project to memory-optimized disk-based database from scratch.

## Goal

1. Fast.
2. Easy to use.
3. Distributed.
Fast speed on both transactional and analytical processing.

## License

Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions xngin-bench/Cargo.toml → doradb-bench/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[package]
name = "xngin-bench"
name = "doradb-bench"
version = "0.1.0"
edition = "2021"
authors = ["jiangzhe <[email protected]>"]
license = "MIT OR Apache-2.0"
description = "Benchmarks of X-Engine"
keywords = ["database", "benchmark"]
categories = ["database"]
repository = "https://github.com/jiangzhe/xngin/xngin-bench/"
repository = "https://github.com/jiangzhe/doradb/doradb-bench/"

[dependencies]
xngin-datatype = {version = "0.1.0", path = "../xngin-datatype"}
xngin-compute = {version = "0.1.0", path = "../xngin-compute"}
xngin-storage = {version = "0.1.0", path = "../xngin-storage"}
doradb-datatype = {version = "0.1.0", path = "../doradb-datatype"}
doradb-compute = {version = "0.1.0", path = "../doradb-compute"}
doradb-storage = {version = "0.1.0", path = "../doradb-storage"}
criterion = {version = "0.3", features = ["html_reports"]}
rand = "0.8.3"
pprof = {version = "0.4", features = ["flamegraph", "criterion"]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rand::{thread_rng, Rng};
use xngin_storage::bitmap::Bitmap;
use doradb_storage::bitmap::Bitmap;

fn bench_count(c: &mut Criterion) {
const N1: usize = 10240;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use std::iter::FromIterator;
use xngin_storage::bitmap::Bitmap;
use doradb_storage::bitmap::Bitmap;

fn bench_extend(c: &mut Criterion) {
for log2_size in [12, 14] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use std::iter::FromIterator;
use xngin_storage::bitmap::Bitmap;
use doradb_storage::bitmap::Bitmap;

fn bench_intersect(c: &mut Criterion) {
for log2_size in [12, 14] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rand::{thread_rng, Rng};
use xngin_storage::bitmap::Bitmap;
use doradb_storage::bitmap::Bitmap;

fn bench_range_iter(c: &mut Criterion) {
const N: usize = 10240;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use std::iter::FromIterator;
use xngin_storage::bitmap::Bitmap;
use doradb_storage::bitmap::Bitmap;

fn bench_shift(c: &mut Criterion) {
for log2_size in [12, 14] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use criterion::{criterion_group, criterion_main, Criterion};
use xngin_compute::BinaryEval;
use xngin_compute::arith::{Impl, AddI32, AddI64};
use xngin_storage::attr::Attr;
use xngin_datatype::PreciseType;
use doradb_compute::BinaryEval;
use doradb_compute::arith::{Impl, AddI32, AddI64};
use doradb_storage::attr::Attr;
use doradb_datatype::PreciseType;

fn bench_codec(c: &mut Criterion) {
for log2_size in [12, 14] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rand::Rng;
use xngin_datatype::memcmp::MemCmpFormat;
use doradb_datatype::memcmp::MemCmpFormat;

fn bench_sort(c: &mut Criterion) {
let mut group = c.benchmark_group("memsort");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use criterion::{criterion_group, criterion_main, Criterion};
use pprof::criterion::{PProfProfiler, Output};
use xngin_compute::BinaryEval;
use xngin_compute::arith::{Impl, AddI32};
use xngin_storage::attr::Attr;
use xngin_datatype::PreciseType;
use doradb_compute::BinaryEval;
use doradb_compute::arith::{Impl, AddI32};
use doradb_storage::attr::Attr;
use doradb_datatype::PreciseType;

fn bench_add(c: &mut Criterion) {
let size = 4096;
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions xngin-catalog/Cargo.toml → doradb-catalog/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "xngin-catalog"
name = "doradb-catalog"
version = "0.1.0"
edition = "2021"
authors = ["jiangzhe <[email protected]>"]
license = "MIT OR Apache-2.0"
description = "Catalog of X-Engine"
keywords = ["database"]
categories = ["database"]
repository = "https://github.com/jiangzhe/xngin/xngin-catalog/"
repository = "https://github.com/jiangzhe/doradb/doradb-catalog/"

[dependencies]
xngin-datatype = { version = "0.1.0", path = "../xngin-datatype" }
doradb-datatype = { version = "0.1.0", path = "../doradb-datatype" }
semistr = "0.1"
bitflags = "1.3"
indexmap = "1.7"
Expand Down
File renamed without changes.
47 changes: 44 additions & 3 deletions xngin-catalog/src/lib.rs → doradb-catalog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ pub mod mem_impl;
use crate::error::Result;
use bitflags::bitflags;
use semistr::SemiStr;
use std::fmt;
use std::hash::Hash;
use std::marker::PhantomData;
use xngin_datatype::PreciseType;
use doradb_datatype::PreciseType;

/// Catalog maintains metadata of all database objects.
/// It could be shared between threads.
Expand Down Expand Up @@ -40,14 +41,22 @@ pub trait Catalog: Send + Sync {
fn exists_column(&self, table_id: &TableID, column_name: &str) -> bool;

fn find_column_by_name(&self, table_id: &TableID, column_name: &str) -> Option<Column>;

fn find_keys(&self, table_id: &TableID) -> Vec<Key>;
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ObjectID<T> {
id: u32,
_marker: PhantomData<T>,
}

impl<T> fmt::Debug for ObjectID<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ObjectID").field("id", &self.id).finish()
}
}

impl<T> ObjectID<T> {
/// Required to create object only within the catalog module.
pub(crate) fn new(id: u32) -> Self {
Expand Down Expand Up @@ -90,6 +99,11 @@ pub struct Table {
pub name: SemiStr,
}

pub enum Key {
PrimaryKey(Vec<Column>),
UniqueKey(Vec<Column>),
}

/// Table spec used in creating table
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TableSpec {
Expand All @@ -115,7 +129,7 @@ pub struct Column {
pub table_id: TableID,
pub name: SemiStr,
pub pty: PreciseType,
pub idx: u32,
pub idx: ColIndex,
pub attr: ColumnAttr,
}

Expand All @@ -138,6 +152,33 @@ impl ColumnSpec {
}
}

/// ColIndex wraps u32 to be the index of column in current table/subquery.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ColIndex(u32);

impl ColIndex {
#[inline]
pub fn value(&self) -> u32 {
self.0
}
}

impl From<u32> for ColIndex {
fn from(src: u32) -> Self {
ColIndex(src)
}
}

impl std::fmt::Display for ColIndex {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "c{}", self.0)
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct TblCol(pub TableID, pub ColIndex);

bitflags! {
pub struct ColumnAttr: u8 {
const PK = 0x01; // primary key
Expand Down
43 changes: 41 additions & 2 deletions xngin-catalog/src/mem_impl.rs → doradb-catalog/src/mem_impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use crate::error::{Error, Result};
use crate::{Catalog, Column, ColumnID, Schema, SchemaID, Table, TableID, TableSpec};
use crate::{
Catalog, ColIndex, Column, ColumnAttr, ColumnID, Key, Schema, SchemaID, Table, TableID,
TableSpec,
};
use indexmap::IndexMap;
use parking_lot::RwLock;
use semistr::SemiStr;
Expand Down Expand Up @@ -188,7 +191,7 @@ impl Catalog for MemCatalog {
name: c.name.clone(),
pty: c.pty,
attr: c.attr,
idx: i as u32,
idx: ColIndex::from(i as u32),
};
columns.push(column);
}
Expand Down Expand Up @@ -222,4 +225,40 @@ impl Catalog for MemCatalog {
}
}
}

#[inline]
fn find_keys(&self, table_id: &TableID) -> Vec<Key> {
let inner = self.inner.read();
if let Some(columns) = inner.table_columns.get(table_id).map(|twc| &twc.columns) {
let mut res = vec![];
let pk: Vec<Column> = columns
.iter()
.filter_map(|c| {
if c.attr.contains(ColumnAttr::PK) {
Some(c.clone())
} else {
None
}
})
.collect();
if !pk.is_empty() {
res.push(Key::PrimaryKey(pk));
}
let uk: Vec<Column> = columns
.iter()
.filter_map(|c| {
if c.attr.contains(ColumnAttr::UK) {
Some(c.clone())
} else {
None
}
})
.collect();
if !uk.is_empty() {
res.push(Key::UniqueKey(uk));
}
return res;
}
vec![]
}
}
12 changes: 6 additions & 6 deletions xngin-compute/Cargo.toml → doradb-compute/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[package]
name = "xngin-compute"
name = "doradb-compute"
version = "0.1.0"
edition = "2021"
authors = ["jiangzhe <[email protected]>"]
license = "MIT OR Apache-2.0"
description = "Computation module of X-Engine"
keywords = ["database", "vectorization"]
categories = ["database-implementations"]
repository = "https://github.com/jiangzhe/xngin/xngin-compute/"
repository = "https://github.com/jiangzhe/doradb/doradb-compute/"

[dependencies]
thiserror = "1.0"
libc = "0.2.101"
xngin-catalog = { version = "0.1.0", path = "../xngin-catalog" }
xngin-datatype = { version = "0.1.0", path = "../xngin-datatype" }
xngin-storage = { version = "0.1.0", path = "../xngin-storage" }
xngin-expr = { version = "0.1.0", path = "../xngin-expr" }
doradb-catalog = { version = "0.1.0", path = "../doradb-catalog" }
doradb-datatype = { version = "0.1.0", path = "../doradb-datatype" }
doradb-storage = { version = "0.1.0", path = "../doradb-storage" }
doradb-expr = { version = "0.1.0", path = "../doradb-expr" }
smallvec = {version = "1.8", features = ["union"]}

[dev-dependencies]
Expand Down
14 changes: 7 additions & 7 deletions xngin-compute/src/arith.rs → doradb-compute/src/arith.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::error::{Error, Result};
use crate::BinaryEval;
use xngin_datatype::PreciseType;
use xngin_storage::array::Array;
use xngin_storage::attr::Attr;
use xngin_storage::codec::{Codec, Single};
use xngin_storage::repr::ByteRepr;
use xngin_storage::sel::Sel;
use doradb_datatype::PreciseType;
use doradb_storage::array::Array;
use doradb_storage::attr::Attr;
use doradb_storage::codec::{Codec, Single};
use doradb_storage::repr::ByteRepr;
use doradb_storage::sel::Sel;

/// Kinds of arithmetic expression.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -279,7 +279,7 @@ impl_arith_eval_for_num!(AddI64, i64, i64, i64, +);
#[cfg(test)]
mod tests {
use super::*;
use xngin_storage::codec::Single;
use doradb_storage::codec::Single;

#[test]
fn test_vec_eval_4096() {
Expand Down
14 changes: 7 additions & 7 deletions xngin-compute/src/cmp.rs → doradb-compute/src/cmp.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::error::{Error, Result};
use crate::BinaryEval;
use xngin_datatype::PreciseType;
use xngin_expr::PredFuncKind;
use xngin_storage::attr::Attr;
use xngin_storage::bitmap::Bitmap;
use xngin_storage::codec::{Codec, Single};
use xngin_storage::repr::ByteRepr;
use xngin_storage::sel::Sel;
use doradb_datatype::PreciseType;
use doradb_expr::PredFuncKind;
use doradb_storage::attr::Attr;
use doradb_storage::bitmap::Bitmap;
use doradb_storage::codec::{Codec, Single};
use doradb_storage::repr::ByteRepr;
use doradb_storage::sel::Sel;

/// Kinds of comparison expression.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
Expand Down
Loading

0 comments on commit 4a53a6c

Please sign in to comment.