Skip to content

Commit 6fc8dae

Browse files
Merge pull request #201 from JakeRoggenbuck/demo-project
Demo project
2 parents bca80b6 + 4ea3ff3 commit 6fc8dae

File tree

6 files changed

+154
-0
lines changed

6 files changed

+154
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ The src (`./src`) directory is where the Rust code goes. This gets called by the
124124
`system.rs` - all the functions and structs related to getting information from the system machine
125125
`database.rs` - the database struct and the related functions
126126

127+
## Demo Project
128+
129+
In the demo project, we made an API that uses our database to store grades. Here we are sending a PUT and then doing a GET.
130+
131+
![image](https://github.com/user-attachments/assets/f06156d7-c31b-4afb-ba7e-e5156deedac7)
132+
127133
## Testing
128134

129135
### Rust testing

demo-project/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
3+
# Auto-generated by autoignore:
4+
# --------------- #
5+
../ECS165
6+
../src/regres.md
7+
../testM3.py
8+
# ----------------#

demo-project/main.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from fastapi import FastAPI
2+
from lstore.db import Database
3+
from lstore.query import Query
4+
from pydantic import BaseModel
5+
from fastapi.responses import JSONResponse
6+
7+
8+
app = FastAPI()
9+
db = Database()
10+
scores_table = db.create_table('Scores', 5, 0)
11+
query = Query(scores_table)
12+
13+
14+
class Scores(BaseModel):
15+
student_id: int
16+
score_1: int
17+
score_2: int
18+
score_3: int
19+
score_4: int
20+
21+
22+
"""
23+
Here is how you can access a score
24+
25+
```sh
26+
curl "http://127.0.0.1:8000/values/1"
27+
```
28+
"""
29+
@app.get("/values/{value_id}")
30+
def read_value(value_id: int):
31+
res = query.select(value_id, 0, [1] * 5)
32+
33+
if len(res) > 0:
34+
val = res[0]
35+
36+
if val is not None:
37+
return JSONResponse(content=val.columns)
38+
39+
return JSONResponse(content={})
40+
41+
42+
"""
43+
Here is how you can add data using curl.
44+
45+
```sh
46+
curl -X PUT "http://127.0.0.1:8000/values"
47+
-H "Content-Type: application/json"
48+
-d '{
49+
"student_id": 100200300,
50+
"score_1": 94,
51+
"score_2": 91,
52+
"score_3": 98,
53+
"score_4": 94
54+
}'
55+
```
56+
"""
57+
@app.put("/values")
58+
def update_item(values: Scores):
59+
ret = query.insert(
60+
values.student_id,
61+
values.score_1,
62+
values.score_2,
63+
values.score_3,
64+
values.score_4,
65+
)
66+
67+
return JSONResponse(content=ret)

demo-project/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
../target/wheels/lstore-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
2+
fastapi
3+
uvicorn
4+
black

demo-project/running.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uvicorn main:app

regress.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
src (sum-tests) λ cargo bench -- sum
2+
Compiling either v1.13.0
3+
Compiling crossbeam-utils v0.8.21
4+
Compiling itertools v0.10.5
5+
Compiling crossbeam-epoch v0.9.18
6+
Compiling crossbeam-deque v0.8.6
7+
Compiling rayon-core v1.12.1
8+
Compiling rayon v1.10.0
9+
Compiling criterion-plot v0.5.0
10+
Compiling criterion v0.4.0
11+
Compiling redoxql v0.1.0 (/home/jake/Repos/redoxql)
12+
Finished `bench` profile [optimized + debuginfo] target(s) in 1m 19s
13+
Running unittests src/lib.rs (/home/jake/Repos/redoxql/target/release/deps/redoxql-bd4aee3918e78c09)
14+
15+
running 2 tests
16+
test table::tests::large_sum_test ... ignored
17+
test table::tests::sum_test ... ignored
18+
19+
test result: ok. 0 passed; 0 failed; 2 ignored; 0 measured; 43 filtered out; finished in 0.00s
20+
21+
Running benches/merge_benchmarks.rs (/home/jake/Repos/redoxql/target/release/deps/merge_benchmarks-9a5f75221ac36d28)
22+
Gnuplot not found, using plotters backend
23+
Running benches/page_benchmarks.rs (/home/jake/Repos/redoxql/target/release/deps/page_benchmarks-23f697d7bf81e8e7)
24+
Gnuplot not found, using plotters backend
25+
Running benches/page_dir_benchmarks.rs (/home/jake/Repos/redoxql/target/release/deps/page_dir_benchmarks-a5a0b831cdac0359)
26+
Gnuplot not found, using plotters backend
27+
Running benches/query_benchmarks.rs (/home/jake/Repos/redoxql/target/release/deps/query_benchmarks-2d8c6c38b30cda52)
28+
Gnuplot not found, using plotters backend
29+
sum operation/sum 10 records
30+
time: [34.739 µs 34.908 µs 35.093 µs]
31+
change: [+2366.9% +2398.9% +2434.7%] (p = 0.00 < 0.05)
32+
Performance has regressed.
33+
Found 8 outliers among 100 measurements (8.00%)
34+
1 (1.00%) low severe
35+
4 (4.00%) high mild
36+
3 (3.00%) high severe
37+
sum operation/sum 100 records
38+
time: [97.079 µs 98.910 µs 101.18 µs]
39+
change: [+495.20% +502.97% +511.99%] (p = 0.00 < 0.05)
40+
Performance has regressed.
41+
Found 10 outliers among 100 measurements (10.00%)
42+
6 (6.00%) high mild
43+
4 (4.00%) high severe
44+
sum operation/sum 1000 records
45+
time: [479.19 µs 480.36 µs 481.51 µs]
46+
change: [+166.07% +166.90% +167.77%] (p = 0.00 < 0.05)
47+
Performance has regressed.
48+
Found 1 outliers among 100 measurements (1.00%)
49+
1 (1.00%) low mild
50+
sum operation/sum 10000 records
51+
time: [3.5710 ms 3.5928 ms 3.6174 ms]
52+
change: [+75.521% +76.708% +78.180%] (p = 0.00 < 0.05)
53+
Performance has regressed.
54+
Found 10 outliers among 100 measurements (10.00%)
55+
2 (2.00%) high mild
56+
8 (8.00%) high severe
57+
Benchmarking sum operation/sum 100000 records: Warming up for 3.0000 s
58+
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 8.7s, or reduce sample count to 50.
59+
sum operation/sum 100000 records
60+
time: [53.093 ms 53.273 ms 53.463 ms]
61+
change: [+31.530% +32.465% +33.422%] (p = 0.00 < 0.05)
62+
Performance has regressed.
63+
Found 9 outliers among 100 measurements (9.00%)
64+
8 (8.00%) high mild
65+
1 (1.00%) high severe
66+
67+
(arg: 1) ^C
68+
src (sum-tests) λ

0 commit comments

Comments
 (0)