-
Notifications
You must be signed in to change notification settings - Fork 4
Collaboration #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: nightly
Are you sure you want to change the base?
Collaboration #10
Changes from 41 commits
8335f11
69f6ade
d7bdcab
a34870a
841bf49
aaa23b0
a1bd933
622f46e
9512c74
613bdff
8ab6bb8
93f801d
63d3429
c370cef
1562973
5059fef
2ec0762
b5c3a2f
0cc33c6
507f79b
7b83294
8a59246
6b7be31
0d224b9
b4be4ae
1fbfaf5
197e3dc
fda371f
0d525a5
b893f60
280b26a
f6e924f
ba495a2
fff9bcb
aac4b78
041b486
1c9f9d1
05a3627
c2ff2d7
d4a1ad6
ff690a7
7faf26b
a7fc206
e74c533
c87ba16
76c0d6b
cc247ce
4a306f6
e6f1e4f
5733650
b51468a
f8cb26e
29daf04
bf9d65e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| *.csv | ||
| *.csv2 | ||
| .git |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| extras/model.go |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,78 @@ | ||
| # LambdaDB | ||
| In memory database that uses filters to get the data you need. | ||
| Lambda DB has a tiny codebase which does a lot | ||
| Lambda is not ment as a persistance storage or a replacement for a traditional | ||
| Database but as fast analytics engine cache representation engine. | ||
|
|
||
| Can be used for your needs by changing the models.go file to your needs. | ||
| powers: https://dego.vng.nl | ||
|
|
||
| ## Properties: | ||
|
|
||
| - Insanely fast API. 1ms respsonses | ||
| - Fast to setup. | ||
| - Easy to deploy. | ||
| - Easy to customize. | ||
| - Easy export data | ||
|
|
||
| - Implement custom authorized filters. | ||
|
|
||
| ## Indexes | ||
|
|
||
| - S2 geoindex for fast point lookup | ||
| - Bitarrays | ||
| - Mapping | ||
|
|
||
| - Your own special needs indexes! | ||
|
|
||
| ## Flow: | ||
|
|
||
| Generate a model and load your data. | ||
| The API is generated from your model. | ||
| Deploy. | ||
|
|
||
| Condition: Your dataset must fit in memory. | ||
|
|
||
| Can be used for your needs by changing the `models.go` file to your needs. | ||
| Creating and registering of the functionality that is needed. | ||
|
|
||
|
|
||
| ### Steps | ||
| You can start the database with only a csv. | ||
| Go over steps below, And see the result in your browser. | ||
|
|
||
| 1. place csv file, in dir extras. | ||
| 2. `python3 create_model.py > ../model.go` | ||
| 3. cd ../ | ||
| 4. go fmt | ||
| 2. `python3 create_model_.py` answer the questions. | ||
| 3. go fmt model.go | ||
| 4. mv model.go ../ | ||
| 5. go build | ||
| 6. ./lambda --help | ||
| 7. ./lambda --csv assets/items.csv or `python3 ingestion.py -b 1000` | ||
| 9. curl 127.0.0.1:8128/help/ | ||
| 10. browser 127.0.0.1:8128/ | ||
|
|
||
|
|
||
| 11. instructions curl 127.0.0.1:8128/help/ | python -m json.tool | ||
|
|
||
|
|
||
|
|
||
| ### Running | ||
|
|
||
| sudo docker-compose up --no-deps --build | ||
|
|
||
| promql {instance="lambdadb:8000"} | ||
|
|
||
| python3 extras/ingestion.py -f movies_subset.tsv -format tsv -dbhost 127.0.0.1:8000 | ||
| ======= | ||
|
|
||
| 1. instructions curl 127.0.0.1:8000/help/ | python -m json.tool | ||
|
|
||
| ### Questions | ||
|
|
||
|
|
||
|
|
||
| ### TODO | ||
|
|
||
| - load data directly from a database (periodic) | ||
| - document the `create_model.py` questions | ||
| - use a remote source for CSV | ||
| - use some compression faster to load than gzip | ||
| - generate swagger API | ||
| - Add more tests | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -x | ||
| set -e | ||
| set -u | ||
|
|
||
|
|
||
| curl -vvv \ | ||
| --data-urlencode 'geojson={ | ||
| "type": "Polygon", | ||
| "coordinates": [ | ||
| [ | ||
| [4.902321, 52.428306], | ||
| [4.90127, 52.427024], | ||
| [4.905281, 52.426069], | ||
| [4.906782, 52.426226], | ||
| [4.906418, 52.427469], | ||
| [4.902321, 52.428306] | ||
| ] | ||
| ] | ||
| }' \ | ||
| 'http://127.0.0.1:8000/list/?groupby=postcode&reduce=count' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this file is right now only relevant for one project it and not other projects, it can't be added. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well it s a first basic test that should be converted to a real test using real data. It took a long time to create like it is. Also serves as an example. so mark as NEEDS WORK or something. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -x | ||
| set -e | ||
| set -u | ||
|
|
||
| # should be cached. | ||
| curl -vv 'http://127.0.0.1:8000/list/?groupby=woning_type&reduce=count' | ||
|
|
||
| # should not be cached.(using bitmaps) | ||
| curl -vv 'http://127.0.0.1:8000/list/?match-wijkcode=WK036394&groupby=woning_type&reduce=count' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this file is right now only relevant for one project it and not other projects, it can't be added. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could add test dataset and convert them to proper tests. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "strconv" | ||
| ) | ||
|
|
||
| type registerCustomGroupByFunc map[string]func(*Item, ItemsGroupedBy) | ||
|
|
||
| var RegisterGroupByCustom registerCustomGroupByFunc | ||
|
|
||
| func init() { | ||
|
|
||
| RegisterGroupByCustom = make(registerCustomGroupByFunc) | ||
| RegisterGroupByCustom["gebruiksdoelen-mixed"] = GroupByGettersGebruiksdoelen | ||
|
|
||
| } | ||
|
|
||
| func reduceWEQ(items Items) map[string]string { | ||
| result := make(map[string]string) | ||
| weq := 0 | ||
| for i := range items { | ||
| _weq, err := strconv.ParseInt(items[i].Woningequivalent, 10, 64) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| weq += int(_weq) | ||
| } | ||
| result["woningenquivalent"] = strconv.Itoa(weq) | ||
| return result | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this file is right now only relevant for one project it and not other projects, it can't be added. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to to read!!!