-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Sample implementation | ||
|
||
Files: | ||
* `generial`: post, get, count, delete | ||
* `post`: post | ||
|
||
1) create virtual environment `virtual ./.venv` | ||
2) activate it ` . ./venv/bin/activate` | ||
3) install dependencies `pip install Rocket-Store` | ||
4) run test `python test.py` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
""" | ||
█▀ █▄█ █▀▀ █░█ █▀▀ █░█ | ||
▄█ ░█░ █▄▄ █▀█ ██▄ ▀▄▀ | ||
Author: <Anton Sychev> (anton at sychev dot xyz) | ||
sample.py (c) 2023 | ||
Created: 2023-12-01 01:02:01 | ||
Desc: sample create instance of RocketStore | ||
Docs: documentation | ||
""" | ||
|
||
from Rocketstore import Rocketstore | ||
|
||
rs = Rocketstore(**{"data_storage_area": "./test", | ||
"data_format": Rocketstore._FORMAT_JSON}) | ||
|
||
rs.post("cars", "Mercedes_Benz_GT_R", {"owner": "Lisa Simpson"}) | ||
|
||
print("GET: ", rs.get("cars", ""), "\n-----\n") | ||
# GET: {'count': 1, 'key': ['Mercedes_Benz_GT_R'], 'result': [{'owner': 'Lisa Simpson'}]} | ||
|
||
rs.post("cars", "BMW_740li", { | ||
"owner": "Greg Onslow"}, Rocketstore._ADD_AUTO_INC) | ||
rs.post("cars", "BMW_740li", {"owner": "Sam Wise"}, Rocketstore._ADD_AUTO_INC) | ||
rs.post("cars", "BMW_740li", {"owner": "Bill Bo"}, Rocketstore._ADD_AUTO_INC) | ||
# tienen que haber un BMW_740li | ||
|
||
print("GET ALL CARS: ", rs.get("cars", "*"), "\n-----\n") | ||
''' | ||
Get all records: | ||
{ | ||
count: 2, | ||
key: [ 'Mercedes_Benz_GT_R', 'BMW_740li' ], | ||
result: [ { owner: 'Lisa Simpson' }, { owner: 'Bill Bo' } ] | ||
} | ||
''' | ||
|
||
|
||
dataset = { | ||
"Gregs_BMW_740li": {"owner": "Greg Onslow"}, | ||
"Lisas_Mercedes_Benz_GT_R": {"owner": "Lisa Simpson"}, | ||
"Bills_BMW_740li": {"owner": "Bill Bo"}, | ||
} | ||
|
||
for i in dataset: | ||
rs.post("cars", i, dataset[i]) | ||
|
||
print("GET BMW's: ", rs.get("cars", "*BMW*"), "\n-----\n") | ||
''' | ||
Get BMW's: | ||
{ | ||
count: 3, | ||
key: [ 'BMW_740li', 'Gregs_BMW_740li', 'Bills_BMW_740li' ], | ||
result: [ | ||
{ owner: 'Bill Bo' }, | ||
{ owner: 'Greg Onslow' }, | ||
{ owner: 'Bill Bo' } | ||
] | ||
} | ||
''' | ||
|
||
|
||
print("Get list ordered by alphabetically descending keys: ", | ||
rs.get("cars", "", Rocketstore._ORDER_DESC), "\n-----\n") | ||
''' | ||
Get list ordered by alphabetically descending keys: | ||
{ | ||
count: 5, | ||
key: [ | ||
'Mercedes_Benz_GT_R', | ||
'BMW_740li', | ||
'Gregs_BMW_740li', | ||
'Lisas_Mercedes_Benz_GT_R', | ||
'Bills_BMW_740li' | ||
], | ||
result: [ | ||
{ owner: 'Lisa Simpson' }, | ||
{ owner: 'Bill Bo' }, | ||
{ owner: 'Greg Onslow' }, | ||
{ owner: 'Lisa Simpson' }, | ||
{ owner: 'Bill Bo' } | ||
] | ||
} | ||
''' | ||
|
||
r = rs.delete("cars", "*Mercedes*") | ||
print("Delete all Mercedes's: ", r, "\n-----\n") | ||
'''' | ||
Delete all Mercedes's: | ||
{ count: 2 } | ||
''' | ||
|
||
print("Return all cars: ", rs.get("cars", "*"), "\n-----\n") | ||
''' | ||
{ | ||
count: 3, | ||
key: [ 'BMW_740li', 'Gregs_BMW_740li', 'Bills_BMW_740li' ], | ||
result: [ | ||
{ owner: 'Bill Bo' }, | ||
{ owner: 'Greg Onslow' }, | ||
{ owner: 'Bill Bo' } | ||
] | ||
} | ||
''' | ||
|
||
|
||
print("Delete all records: ", rs.delete(), "\n-----\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from Rocketstore import Rocketstore | ||
|
||
rs = Rocketstore(**{"data_storage_area": "./test"}) | ||
|
||
print(rs) | ||
print("test Constants:", rs._ADD_AUTO_INC) | ||
print("test Constants: ", Rocketstore._ADD_AUTO_INC) | ||
|
||
dataInput = { | ||
"content": "hello asfalsdfsalfaslflasl", | ||
"embeddings": [0.2, 0.31231312, 0.111], | ||
} | ||
|
||
|
||
out = rs.post("glOtc6EzYQTZEt0J18cU1f4Ycdz1H8WWTDVkBQTp1Gv2BWgb", | ||
"memories", dataInput) | ||
|
||
print(out) | ||
|
||
|
||
out = rs.post("glOtc6EzYQTZEt0J18cU1f4Ycdz1H8WWTDVkBQTp1Gv2BWgb", | ||
"memories", dataInput, rs._ADD_AUTO_INC) | ||
|
||
print(out) | ||
|
||
out = rs.post("glOtc6EzYQTZEt0J18cU1f4Ycdz1H8WWTDVkBQTp1Gv2BWgb", | ||
"memories", dataInput, Rocketstore._ADD_AUTO_INC) | ||
|
||
print(out) |