Use cargo run in example.sh

This commit is contained in:
Josh Hansen 2023-09-17 15:01:00 -07:00
parent 1e3a27259a
commit c0cbff8180
2 changed files with 31 additions and 30 deletions

View file

@ -1,6 +1,7 @@
#!/bin/sh
# Generates example dataset and does some stuff
GHEE="cargo run --quiet --"
if [ ! -d "example" ]; then
mkdir example
@ -14,54 +15,54 @@ set -x
# The name, ID, and state of residence are known for each person
mkdir people
touch ./people/Sandeep ./people/Sofia ./people/Wulfrum
ghee set -s name=Sandeep -s id=2 -s state=CA ./people/Sandeep
ghee set -s name=Sofia -s id=1 -s state=WA ./people/Sofia
ghee set -s name=Wulfrum -s id=0 -s state=CA ./people/Wulfrum
$GHEE set -s name=Sandeep -s id=2 -s state=CA ./people/Sandeep
$GHEE set -s name=Sofia -s id=1 -s state=WA ./people/Sofia
$GHEE set -s name=Wulfrum -s id=0 -s state=CA ./people/Wulfrum
# Tell Ghee what key the data is indexed by
ghee init -k name ./people
$GHEE init -k name ./people
# Index the dataset by ID
ghee idx -v -k id ./people ./people:id
$GHEE idx -v -k id ./people ./people:id
# Index the dataset by state and ID, placing the index in the default path
ghee idx -v -k state -k id ./people
$GHEE idx -v -k state -k id ./people
# Add more people to the table and its indices
ghee ins -v ./people < ../people.json
$GHEE ins -v ./people < ../people.json
# Get all of ./people
ghee get -a ./people
$GHEE get -a ./people
# # Get all of ./people without sorting in the walk of the folder hierarchy
# ghee get -a --nosort ./people
# Get the name of everybody from California; include all subpaths (don't ignore indices)
ghee get -a -w state=CA -f name ./people
$GHEE get -a -w state=CA -f name ./people
# Remove Sofia
ghee del -v ./people -w name=Sofia
$GHEE del -v ./people -w name=Sofia
# Equivalently: ghee del -v ./people Sofia
# Remove Lilly from the :id index and all related indices
ghee del -v ./people:id 3
$GHEE del -v ./people:id 3
# Equivalently: ghee del -v ./people -w id=3
# Equivalently: ghee del -v ./people Lilly
# Remove Wulfrum from the :state:id index and all related indices
ghee del -v ./people/:state:id CA 0
$GHEE del -v ./people/:state:id CA 0
# Equivalently: ghee del -v ./people -w state=CA -w id=0
# Equivalently: ghee del -v ./people Wulfrum
# Get the name of everybody from California still remaining,
# taking advantage of the state index
# This will avoid traversing irrelevant portions of the index
ghee get -a -w state=CA -f name ./people/:state:id
$GHEE get -a -w state=CA -f name ./people/:state:id
# Create a table directly
ghee create -v ./direct -k blah
$GHEE create -v ./direct -k blah
# Create people2 in one go using `create'
ghee create -v ./people2 -k id < ../people.json
$GHEE create -v ./people2 -k id < ../people.json
cd ..

View file

@ -1,18 +1,18 @@
+ mkdir people
+ touch ./people/Sandeep ./people/Sofia ./people/Wulfrum
+ ghee set -s name=Sandeep -s id=2 -s state=CA ./people/Sandeep
+ ghee set -s name=Sofia -s id=1 -s state=WA ./people/Sofia
+ ghee set -s name=Wulfrum -s id=0 -s state=CA ./people/Wulfrum
+ ghee init -k name ./people
+ ghee idx -v -k id ./people ./people:id
+ cargo run --quiet -- set -s name=Sandeep -s id=2 -s state=CA ./people/Sandeep
+ cargo run --quiet -- set -s name=Sofia -s id=1 -s state=WA ./people/Sofia
+ cargo run --quiet -- set -s name=Wulfrum -s id=0 -s state=CA ./people/Wulfrum
+ cargo run --quiet -- init -k name ./people
+ cargo run --quiet -- idx -v -k id ./people ./people:id
./people/Sandeep -> ./people:id/2
./people/Sofia -> ./people:id/1
./people/Wulfrum -> ./people:id/0
+ ghee idx -v -k state -k id ./people
+ cargo run --quiet -- idx -v -k state -k id ./people
./people/Sandeep -> ./people/:state:id/CA/2
./people/Sofia -> ./people/:state:id/WA/1
./people/Wulfrum -> ./people/:state:id/CA/0
+ ghee ins -v ./people
+ cargo run --quiet -- ins -v ./people
Initialized ./people/Janella
Linked ./people:id/3 -> ./people/Janella
Linked ./people/:state:id/FL/3 -> ./people/Janella
@ -22,7 +22,7 @@ Linked ./people/:state:id/NM/4 -> ./people/Lilly
Initialized ./people/Darrel
Linked ./people:id/5 -> ./people/Darrel
Linked ./people/:state:id/MI/5 -> ./people/Darrel
+ ghee get -a ./people
+ cargo run --quiet -- get -a ./people
user.ghee.tableinfo {"key":"name","indices":{"id":"./people:id","name":"./people","state,id":"./people/:state:id"}}
./people/Darrel user.id 5
./people/Darrel user.name Darrel
@ -42,24 +42,24 @@ Linked ./people/:state:id/MI/5 -> ./people/Darrel
./people/Wulfrum user.id 0
./people/Wulfrum user.name Wulfrum
./people/Wulfrum user.state CA
+ ghee get -a -w state=CA -f name ./people
+ cargo run --quiet -- get -a -w state=CA -f name ./people
./people/Wulfrum user.name Wulfrum
./people/Sandeep user.name Sandeep
+ ghee del -v ./people -w name=Sofia
+ cargo run --quiet -- del -v ./people -w name=Sofia
Removed ./people:id/1
Removed ./people/Sofia
Removed ./people/:state:id/WA/1
+ ghee del -v ./people:id 3
+ cargo run --quiet -- del -v ./people:id 3
Removed ./people:id/3
Removed ./people/Janella
+ ghee del -v ./people/:state:id CA 0
+ cargo run --quiet -- del -v ./people/:state:id CA 0
Removed ./people/Wulfrum
Removed ./people/:state:id/CA/0
+ ghee get -a -w state=CA -f name ./people/:state:id
+ cargo run --quiet -- get -a -w state=CA -f name ./people/:state:id
./people/:state:id/CA/2 user.name Sandeep
+ ghee create -v ./direct -k blah
+ cargo run --quiet -- create -v ./direct -k blah
Initialized table ./direct with key: user.blah
+ ghee create -v ./people2 -k id
+ cargo run --quiet -- create -v ./people2 -k id
Initialized table ./people2 with key: user.id
Initialized ./people2/3
Initialized ./people2/4