• Stars
    star
    387
  • Rank 110,971 (Top 3 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 3 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A strongly-typed document database that runs on any transactional key-value store.

RefineDB

Build status

A strongly-typed document database that runs on any transactional key-value store.

Currently supported backends are:

  • FoundationDB for distributed deployment.
  • SQLite for single-machine deployment.
  • A simple in-memory key-value store for the web playground.

Try RefineDB on the Web Playground!

Warning: Not ready for production.

Motivation

Databases should be more scalable than popular SQL databases, more structured than popular NoSQL databases, and support stronger static type checking than any of the current databases. So I decided to build RefineDB as "the kind of database that I want to use myself".

RefineDB will be used as the database service of rusty-workers.

Architecture

Architecture

Getting started

Examples are a TODO but rdb-analyzer's tests and rdb-server (which uses RefineDB itself to store metadata) should give some basic insight on how the system works.

Schemas and the type system

In RefineDB, schemas are defined with types. For example, a part of a schema for a simple blog would look like:

type SiteConfig {
  site_name: string,
  registration_open: int64,
}

type BlogPost {
  @primary
  id: string,
  author_email: string,
  author_name: string,
  title: string,
  content: string,
  access_time: AccessTime,
}

type AccessTime {
  create_time: int64,
  update_time: int64,
}

export SiteConfig site_config;
export set<BlogPost> posts;

The primitive types are:

  • int64: 64-bit signed integer.
  • double: IEEE 754 double-precision floating point number.
  • string: UTF-8 string.
  • bytes: Byte array.
  • set<T>: A set with element type T.

Sum types are nice to have too, but I haven't implemented it yet.

Queries: the TreeWalker VM and RefineAsm

Queries in RefineDB are encoded as data flow graphs, and query execution is graph reduction.

The TreeWalker VM is a massively concurrent data flow virtual machine for running the queries, but I haven't written documentation on its internals.

RefineAsm is the textual representation of the query graph, with some syntactic sugar to make writing it easier.

An example RefineAsm script for adding a post to the above blog schema:

type PostMap = map {
  id: string,
  author_email: string,
  author_name: string,
  title: string,
  content: string,
  access_time: map {
    create_time: int64,
    update_time: int64,
  },
};
export graph add_post(root: schema, post: PostMap) {
  s_insert root.posts $ call(build_post) [post];
}
graph build_post(post: PostMap): BlogPost {
  return build_table(BlogPost)
    $ m_insert(access_time) (build_table(AccessTime) post.access_time) post;
}

Storage plan and schema migration

A storage plan is how a schema maps to entries in the key-value store. By separating schemas and storage plans, RefineDB's schemas are just "views" of the underlying keyspace and schema changes are fast.

During a migration, added fields are automatically assigned new storage keys, and removed fields will not be auto-deleted from the storage. This allows multiple schema versions to co-exist, enables the client to choose which schema version to use, and prevents unintended data deletion.

Storage design doc

License

MIT

More Repositories

1

blueboat

All-in-one, multi-tenant serverless JavaScript runtime.
Rust
1,917
star
2

mvsqlite

Distributed, MVCC SQLite that runs on FoundationDB.
Rust
1,399
star
3

IceCore

Application container built for WebAssembly
Rust
111
star
4

wasm-core

Portable WebAssembly implementation intended to run everywhere
Rust
81
star
5

dlock

Distributed-Lock-as-a-Service implemented on Cloudflare Durable Objects.
TypeScript
63
star
6

rust-coroutines

Stackful coroutine library for Rust that "just works"
C
49
star
7

Violet

Superscalar RISC-V processor written in Clash.
Haskell
34
star
8

v8-serde

[WIP] Pure-JavaScript implementation of the V8 value serializer
TypeScript
32
star
9

vmesh

VMesh is a decentralized Layer 3 mesh router and protocol designed for open network interconnection.
Go
30
star
10

AlphaBoard

An HTML5 web app for teaching
JavaScript
25
star
11

hexagon-e

The HexagonE VM
Rust
24
star
12

sqlite-cache

SQLite-based on-disk cache for Rust.
Rust
23
star
13

FlatRv

A cross-platform RISC-V interpreter that implements the RV32IMA instruction set.
Rust
19
star
14

MagiCore

An out-of-order processor that supports multiple instruction sets.
Scala
18
star
15

ice-node

Node bindings for the Ice Web Framework
C++
16
star
16

AlphaTrans

An extremely fast accelerator for block transfer in unstable networks
C++
13
star
17

notion-fetch

A Cloudflare Workers service that fetches and renders Notion pages as HTML, Markdown, or JSON.
TypeScript
13
star
18

minichat

Distributed real-time chat demo on Blueboat in 15 lines of JavaScript
JavaScript
10
star
19

unproxy

Map TCP services behind an HTTP(S) proxy to local ports.
Rust
10
star
20

rm-protection-c

rm-protection implemented in C
C
10
star
21

caddy-watch

Watch for interesting patterns in Caddy logs and send a Telegram notification.
Go
9
star
22

pbft-rs

Practical Byzantine Fault Tolerance implemented in Rust.
Rust
8
star
23

bsync

Incremental, multi-version remote backup tool for block devices.
Rust
8
star
24

b6t

Minimal containerized Blueboat suitable for self-hosting.
Shell
8
star
25

lambda-box

λ-box 是一个运行在 Blueboat 上的匿名提问箱 app.
TypeScript
8
star
26

mvps

Log-structured, transactional virtual block device backed by S3
Rust
8
star
27

kvm-sandbox

Sandbox for trustless execution, implemented with KVM.
C++
7
star
28

wstunnel

IP over WebSocket.
Rust
7
star
29

edp

An implementation of the Erlang Distribution Protocol in Rust.
Rust
7
star
30

ssci

Server Side Code Integrity
Rust
7
star
31

avalanche-demo

Demos of how the Avalanche family consensus protocols (Slush, Snowflake, Snowball and Avalanche) work.
TypeScript
6
star
32

supernova

A control plane for the Nebula overlay networking system.
TypeScript
6
star
33

liquid-layout

A layout engine that solves UI constraints using the Z3 prover.
Rust
6
star
34

fdb2kafka

Ship consistent logs from FoundationDB to Kafka.
Go
6
star
35

bsdloader

Minimal (~103KB) x86_64 FreeBSD UEFI loader
Rust
6
star
36

blog

Source code for my personal site.
TypeScript
6
star
37

metamachine

Experimental CPU with software-defined instruction set.
VHDL
5
star
38

FlatMk-v0

The FlatMk Microkernel.
Rust
5
star
39

NextHDL

symbolic evaluation == circuit synthesis
Rust
5
star
40

smr

Multi-process scheduler for managed runtimes.
Rust
5
star
41

hexagon

Rust
5
star
42

elfpromote

A small utility for modifying ELF shared library loading order.
Rust
5
star
43

gkv

Geo-replicated eventually-consistent KV store
Scala
5
star
44

jslinux-wstunnel

JSLinux (https://bellard.org/jslinux/) ported to use wstunnel (https://github.com/losfair/wstunnel) for networking.
JavaScript
5
star
45

lazyproxy

A TCP proxy that is so lazy that shuts down itself after a period of inactivity.
Rust
5
star
46

luax

A Lua 5.3 implementation in Rust (work in progress)
Rust
4
star
47

tsotest

Test Total Store Ordering status on your CPU.
Rust
4
star
48

bbcp

Multi-user control plane service for Blueboat.
TypeScript
4
star
49

blueboat-mds

Blueboat Metadata Service is a distributed metadata manager for Blueboat.
JavaScript
4
star
50

fediblog

Personal site (v2)
TypeScript
4
star
51

liblightning

High-performance general-purpose stackful coroutine library
Rust
4
star
52

violet-cosim

Cosimulator for the Violet core: https://github.com/losfair/Violet
Rust
4
star
53

bbcli

Command line tool for deploying and managing apps on Blueboat.
Rust
4
star
54

blueboat-examples

Example apps running on Blueboat.
JavaScript
4
star
55

rCore-SoC-2020

Code and documentation for rCore "OS Tutorial Summer of Code 2020".
Rust
4
star
56

mips

Single-cycle and pipelined MIPS CPUs written for learning purpose. Written in 12 hours.
Verilog
4
star
57

boat

[WIP] CLI for MagicBoat.
Rust
3
star
58

cloudkernel

Distributed usermode hypervisor for modern workloads.
C++
3
star
59

bluesched

Blueboat cluster scheduler.
Elixir
3
star
60

ops

My collection of scripts for operating services, databases and systems.
Shell
3
star
61

hgw

A "secure enclave" I run at home
Go
3
star
62

gluon

[WIP] Launch selfhosted apps in one click with mvSQLite and Fly.io
TypeScript
3
star
63

awesome-blueboat

A curated collection of web apps on the Blueboat engine.
3
star
64

jftp

Just Forward The Port
Rust
3
star
65

OxygenMark

C++
3
star
66

particles-rs

Particles effects implemented in Rust and running on the WebAssembly platform
Rust
3
star
67

node-multithread

Multithread for Node.js
C++
3
star
68

rekor-evm

Sigstore Rekor log rollup to EVMs
Rust
2
star
69

Presenter.js

Present your slides easily, with remote control.
JavaScript
2
star
70

morf

MoRF is a mutually-authenticated, encrypted communication protocol over lossy packet links with small MTUs
Rust
2
star
71

notion-blueboat

Notion website on Blueboat.
2
star
72

caddy-log-kafka

A Caddy log writer that writes logs to Kafka.
Go
2
star
73

tunnelme

A selfhosted tunnel service.
Haskell
2
star
74

mips-x

Another MIPS32 CPU. My course design for Computer Organization @ NUAA, 2020 Spring.
Verilog
2
star
75

bfjit-osr

Brainfuck JIT for demonstrating On-Stack Replacement technology.
Rust
2
star
76

naptd

Rust
2
star
77

caddy-log-to-mysql

Import Caddy logs to MySQL for analysis.
Rust
2
star
78

pl0-jit

JIT compiler targeting x86-64 for PL/0. Homework.
Rust
2
star
79

DeepDark

Process manager for Linux servers
C++
2
star
80

rvjit-aa64

RISC-V static binary translator targeting AArch64.
Rust
2
star
81

acquire

Digital remake of the "Acquire" board game
Gleam
2
star
82

blueanalytics

Self-hosted web analytics for Caddy + Blueboat.
TypeScript
1
star
83

TextSharing

Text Sharing
1
star
84

retls

Re-encrypt TLS connection with a different certificate
Rust
1
star
85

CloudEdu

A light web app for education.
JavaScript
1
star
86

bdtts-go

Unofficial Baidu TTS API for Golang
Go
1
star
87

SharpIce

C# web framework based on Ice Core
C#
1
star
88

OxygenMark-PageEngine

OxygenMark PageEngine
JavaScript
1
star
89

html2md

A fork of https://gitlab.com/Kanedias/html2md .
Rust
1
star
90

wavebpf-hw

Haskell
1
star
91

orange-rs

Hardware support crate for OrangeSoC.
Rust
1
star
92

FutureCore-Terminal

Terminal control & VM for FutureCore
C
1
star
93

pyice_base

C++
1
star
94

losfair

1
star
95

magicore-aas

MagiCore as a Service (https://github.com/losfair/MagiCore)
Rust
1
star
96

dockerfiles

My collection of dockerfiles.
Dockerfile
1
star
97

virtual-dom-rs

Rust
1
star
98

blurry

[WIP] Toy GPT frontend written in Haskell that runs on Deno
1
star
99

UniMessTunnel

Go
1
star