Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ The src (`./src`) directory is where the Rust code goes. This gets called by the
`system.rs` - all the functions and structs related to getting information from the system machine
`database.rs` - the database struct and the related functions

## Demo Project

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.

![image](https://github.com/user-attachments/assets/f06156d7-c31b-4afb-ba7e-e5156deedac7)

## Testing

### Rust testing
Expand Down
8 changes: 8 additions & 0 deletions demo-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


# Auto-generated by autoignore:
# --------------- #
../ECS165
../src/regres.md
../testM3.py
# ----------------#
67 changes: 67 additions & 0 deletions demo-project/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from fastapi import FastAPI
from lstore.db import Database
from lstore.query import Query
from pydantic import BaseModel
from fastapi.responses import JSONResponse


app = FastAPI()
db = Database()
scores_table = db.create_table('Scores', 5, 0)
query = Query(scores_table)


class Scores(BaseModel):
student_id: int
score_1: int
score_2: int
score_3: int
score_4: int


"""
Here is how you can access a score

```sh
curl "http://127.0.0.1:8000/values/1"
```
"""
@app.get("/values/{value_id}")
def read_value(value_id: int):
res = query.select(value_id, 0, [1] * 5)

if len(res) > 0:
val = res[0]

if val is not None:
return JSONResponse(content=val.columns)

return JSONResponse(content={})


"""
Here is how you can add data using curl.

```sh
curl -X PUT "http://127.0.0.1:8000/values"
-H "Content-Type: application/json"
-d '{
"student_id": 100200300,
"score_1": 94,
"score_2": 91,
"score_3": 98,
"score_4": 94
}'
```
"""
@app.put("/values")
def update_item(values: Scores):
ret = query.insert(
values.student_id,
values.score_1,
values.score_2,
values.score_3,
values.score_4,
)

return JSONResponse(content=ret)
4 changes: 4 additions & 0 deletions demo-project/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
../target/wheels/lstore-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
fastapi
uvicorn
black
1 change: 1 addition & 0 deletions demo-project/running.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uvicorn main:app
68 changes: 68 additions & 0 deletions regress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
src (sum-tests) λ cargo bench -- sum
Compiling either v1.13.0
Compiling crossbeam-utils v0.8.21
Compiling itertools v0.10.5
Compiling crossbeam-epoch v0.9.18
Compiling crossbeam-deque v0.8.6
Compiling rayon-core v1.12.1
Compiling rayon v1.10.0
Compiling criterion-plot v0.5.0
Compiling criterion v0.4.0
Compiling redoxql v0.1.0 (/home/jake/Repos/redoxql)
Finished `bench` profile [optimized + debuginfo] target(s) in 1m 19s
Running unittests src/lib.rs (/home/jake/Repos/redoxql/target/release/deps/redoxql-bd4aee3918e78c09)

running 2 tests
test table::tests::large_sum_test ... ignored
test table::tests::sum_test ... ignored

test result: ok. 0 passed; 0 failed; 2 ignored; 0 measured; 43 filtered out; finished in 0.00s

Running benches/merge_benchmarks.rs (/home/jake/Repos/redoxql/target/release/deps/merge_benchmarks-9a5f75221ac36d28)
Gnuplot not found, using plotters backend
Running benches/page_benchmarks.rs (/home/jake/Repos/redoxql/target/release/deps/page_benchmarks-23f697d7bf81e8e7)
Gnuplot not found, using plotters backend
Running benches/page_dir_benchmarks.rs (/home/jake/Repos/redoxql/target/release/deps/page_dir_benchmarks-a5a0b831cdac0359)
Gnuplot not found, using plotters backend
Running benches/query_benchmarks.rs (/home/jake/Repos/redoxql/target/release/deps/query_benchmarks-2d8c6c38b30cda52)
Gnuplot not found, using plotters backend
sum operation/sum 10 records
time: [34.739 µs 34.908 µs 35.093 µs]
change: [+2366.9% +2398.9% +2434.7%] (p = 0.00 < 0.05)
Performance has regressed.
Found 8 outliers among 100 measurements (8.00%)
1 (1.00%) low severe
4 (4.00%) high mild
3 (3.00%) high severe
sum operation/sum 100 records
time: [97.079 µs 98.910 µs 101.18 µs]
change: [+495.20% +502.97% +511.99%] (p = 0.00 < 0.05)
Performance has regressed.
Found 10 outliers among 100 measurements (10.00%)
6 (6.00%) high mild
4 (4.00%) high severe
sum operation/sum 1000 records
time: [479.19 µs 480.36 µs 481.51 µs]
change: [+166.07% +166.90% +167.77%] (p = 0.00 < 0.05)
Performance has regressed.
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) low mild
sum operation/sum 10000 records
time: [3.5710 ms 3.5928 ms 3.6174 ms]
change: [+75.521% +76.708% +78.180%] (p = 0.00 < 0.05)
Performance has regressed.
Found 10 outliers among 100 measurements (10.00%)
2 (2.00%) high mild
8 (8.00%) high severe
Benchmarking sum operation/sum 100000 records: Warming up for 3.0000 s
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.
sum operation/sum 100000 records
time: [53.093 ms 53.273 ms 53.463 ms]
change: [+31.530% +32.465% +33.422%] (p = 0.00 < 0.05)
Performance has regressed.
Found 9 outliers among 100 measurements (9.00%)
8 (8.00%) high mild
1 (1.00%) high severe

(arg: 1) ^C
src (sum-tests) λ