3DB
A networked database with a focus on vectorization built with Justine
Tunney's cosmopolitan libc.
BUILDING
% etc/cosmo.sh # setup toolchain
% etc/ninja.k>build.ninja # generate build system
% ninja -j6 # build
% ninja -j6 test # run tests
BENCHMARKS
ec8dbb3 | select 300,000 rows, 16 columns in 400ms.
| select 300,000 rows, 1 column in 300ms.
CODEBASE REFERENCE
=======================================================================
| path | description
=----------------%-----------------------------------------------------
| inc/u.h | "Univeral" header. The "prelude".
| inc/A.h | A::A<X>: static width, memcpy-able vectors.
| inc/Q.h | Q::Q: bytecode VM stack object type.
| inc/T.h | T::T: an RC&COW database table object.
| inc/Asm.h | Asm::Asm: a serializable virtual machine object.
| inc/cmd.h | High-level C++ database command API.
| inc/bc.h | VM bytecode types, objects, and functions.
| inc/sse.h | SIMD SSE types and functions.
| inc/mem.h | Memory management functions.
| inc/net.h | Networking types and functions.
| inc/net/*.h | Send specific objects over the network.
| inc/db.h | Values and functions for managing the in-memory DB.
| inc/fs.h | Filesystem helpers.
| inc/str.h | Interned string table and other misc str functions.
| inc/var.h | var_t: variable name SSE representation.
| inc/ini.h | .ini config file parser.
=----------------%-----------------------------------------------------
| lib/bytes.cc | Object serialization into raw buffers of bytes.
| lib/Asm_exe.cc | Execute code inside an Asm::Asm.
| lib/Cmd_exe.cc | Execute Cmd::Cmd commands.
| lib/fmt/*.cc | Format objects into strings that you can print out.
| lib/net/*.cc | Send objects over the network.
=======================================================================
RUNNING THE SERVER
1. Make a config file cfg.ini (see example run/cfg.ini)
2. zip -r o/3db/3db.com cfg.ini
3. o/3db/3db.com
EXECUTING COMMANDS IN C++
An example client program is included in this project under 3i (3
interpreter). You can use this template to create your own query
programs.
A query is constructed through chains of methods. Note that these
methods may throw runtime exceptions or cause undefined behavior if
malformed.
=======================================================================
| CREATE
=======================================================================
Create commands create entries in the database to be initialized later.
/* create a table */
auto cmd = Cmd::Cmd(Cmd::CREATE, "example.com:2222")
.entry("table0")
.type(Db::Tab)
.columns({
std::tuple{"int", T::TInt},
std::tuple{"CHR", T::TCHR},
std::tuple{"DBL", T::TDBL}
});
=======================================================================
| INSERT
=======================================================================
Insert commands insert columns into tables in the database. This comm-
and only works on tables.
/* insert some stuff */
auto cmd = Cmd::Cmd(Cmd::INSERT, "example.com:2222")
.entry("table0")
.row(22)
.columns({
Q::Q(1),
Q::Q(A::A<Chr>{'a', 'b', 'c'}),
Q::Q(A::A<f64>{1.2, 3.4, 5.6})
});
=======================================================================
| SELECT
=======================================================================
Select commands select columns from tables entries. This command only
works on tables.
/* select a couple columns */
auto cmd = Cmd::Cmd(Cmd::SELECT, 0)
.entry("table1")
.columns(A::A{"ints", "strs"});
LICENSE
(c) Skylar Alexandra Bleed, MPL/2.0.