Skip to content

Commit 58308b3

Browse files
docs: add initial documentation (#2)
* tutorial: draft docs * ci: build tutorial mdbook * tutorial: 01-01: write docs * tutorial: update summary * 01-01: write docs * 01-01: complete docs * docs: add build instructions in README * update summary * 00: add worldmap * ci: move rust-toolchain file
1 parent 3dcfab5 commit 58308b3

37 files changed

+739
-4
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@ on:
44
push:
55
branches:
66
- main
7-
paths:
8-
- 'code/**'
97
pull_request:
108
branches:
119
- main
12-
paths:
13-
- 'code/**'
1410

1511
env:
1612
CARGO_TERM_COLOR: always
@@ -43,3 +39,16 @@ jobs:
4339
with:
4440
command: test
4541
args: --manifest-path code/Cargo.toml --release --no-fail-fast --all-features
42+
43+
docs:
44+
runs-on: ubuntu-20.04
45+
steps:
46+
- uses: actions/checkout@v2
47+
- uses: actions-rs/toolchain@v1
48+
with:
49+
profile: minimal
50+
- name: Install mdbook
51+
run: cargo install mdbook mdbook-toc
52+
- name: Build docs
53+
working-directory: ./docs
54+
run: mdbook build

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,31 @@
33
[![CI](https://github.com/singularity-data/risinglight-tutorial/workflows/CI/badge.svg?branch=main)](https://github.com/singularity-data/risinglight-tutorial/actions)
44

55
Let's build an OLAP database from scratch!
6+
7+
## Building
8+
9+
The documentation is written in [mdBook][mdBook].
10+
11+
[mdBook]: https://github.com/rust-lang/mdBook
12+
13+
To install mdBook:
14+
15+
```sh
16+
cargo install mdbook mdbook-toc
17+
```
18+
19+
Build the documentation:
20+
21+
```sh
22+
cd docs
23+
mdbook build
24+
```
25+
26+
We provide complete codes for each task.
27+
28+
To build and test these codes:
29+
30+
```sh
31+
cd code
32+
cargo test
33+
```

code/01-01/src/test.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
// Add the following lines to your Cargo.toml file:
2+
//
3+
// ```toml
4+
// [dev-dependencies]
5+
// sqllogictest = "0.1"
6+
// test-case = "1.2"
7+
// ```
8+
19
use std::path::Path;
210

311
use test_case::test_case;

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
book
2+
.DS_Store

docs/book.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[book]
2+
authors = ["Runji Wang"]
3+
language = "cn"
4+
multilingual = false
5+
src = "src"
6+
title = "RisingLight Tutorial"
7+
8+
[preprocessor.toc]
9+
command = "mdbook-toc"
10+
renderer = ["html"]

docs/src/00-lets-build-a-database.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# RisingLight Tutorial
2+
3+
RisingLight 是一个 Rust 语言编写的单机分析型(OLAP)数据库系统。
4+
5+
在这个教程中,我们将会带领大家从零开始,一步一步地实现自己的数据库!
6+
从一个最简单的 SQL 解析器开始,逐步实现查询引擎、存储引擎、优化器和事务,最终能够运行工业级的 TPC-H 基准测试。
7+
8+
除了标准教科书上的内容以外,你还可以体验到业界最前沿的流式计算引擎 lol。
9+
10+
## 为何要做这个教程
11+
12+
TODO
13+
14+
## RisingLight 世界地图
15+
16+
![](img/worldmap.svg)
17+
18+
<!--
19+
可以画成类似 DDIA 的样子
20+
-->
21+
22+
## 如何学习本教程
23+
24+
正如你所见,整个 RisingLight 是一个广阔的开放世界!
25+
在这里你可以按照自己的兴趣,选择任意一种可行的路径来完成这个数据库的开发。
26+
当然如果你喜欢按部就班的节奏,我们也提供一条推荐的主线路径供大家参考。
27+
28+
RisingLight 根据数据库中的不同方向,分成了若干小世界。它们整体上相对独立,但相互之间又有千丝万缕的关联。
29+
每个世界由很多小任务组成,在每个任务中我们会实现一个功能。而每个功能我们都会提供一系列的标准 SQL 语句作为测试,只要通过了全部测试就算完成了这个任务!
30+
31+
例如在第一个任务中,我们提供的测试语句是:
32+
33+
```sql
34+
SELECT 'Hello, world!'
35+
```
36+
37+
它的期望输出是:
38+
39+
```
40+
Hello, world!
41+
```
42+
43+
只要你的程序对于给定的输入,能够给出正确的输出,我们就认为你正确实现了这一功能。
44+
45+
这种方法叫做 **端到端测试(End-to-End Testing)**。你可以使用任何一种方法来通过测试,并且我们鼓励大家大开脑洞去尝试不同的实现方式。
46+
47+
当然,在没有任何提示的情况下独立完成整个系统的设计与实现是相当困难的,但这也是对能力提高非常有帮助的。
48+
我们欢迎对自己能力有信心的大佬们来挑战这个 **Hard 模式**,收获更多经验值!
49+
50+
对于其他同学来说,我们会带领大家完成系统的整体设计,提示一些关键的实现细节,并提供必要的框架代码,
51+
由同学们自行实现剩下的部分。这种是类似其它教程所采用的 **Normal 模式**
52+
53+
不过更为实际的情况是,在这个教程出来一段时间之后,社区中一定会涌现出大量的优秀作业供大家参考。
54+
考虑到这点,我们干脆直接公开每个任务的完整代码,官方提供《RisingLight 源码解析》。
55+
赶时间的朋友就不用亲自下场写代码了,直接来玩适合快速通关的 **Easy 模式** 吧。
56+
57+
以上三种模式,同学们可以根据自己的情况,选择适合自己的方式来完成每个任务。
58+
需要提醒大家的是,付出和收获往往是成正比的,我们鼓励大家在力所能及的范围内去做更有挑战性的尝试。
59+
60+
为了这种难度的区别,每个任务的文档会分为以下几个部分:
61+
62+
1. 背景知识:介绍完成任务所必须掌握的知识,提供参考资料
63+
2. 任务目标:描述任务需要完成的内容,需要通过的测试
64+
3. 整体设计:介绍代码框架和需要注意的细节
65+
4. 源码解析:详细介绍实现代码
66+
67+
如果你想挑战 Hard,那么看到 2 就可以开始动手了;如果你选择 Normal,那么还可以继续看完 3;而如果你是 Easy 玩家,那就看完全部文档吧!

0 commit comments

Comments
 (0)