Extract functions

This commit is contained in:
Josh Hansen 2023-09-27 16:12:06 -07:00
parent c76f88bd43
commit a50f90b280
2 changed files with 77 additions and 67 deletions

View file

@ -22,65 +22,96 @@ cd example
set -x
# Create a personnel dataset with three people
# 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
main() {
# Create a personnel dataset with three people
# 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
# Tell Ghee what key the data is indexed by
$GHEE init -k name ./people
# Tell Ghee what key the data is indexed by
$GHEE init -k name ./people
# Index the dataset by ID
$GHEE idx -v -k id ./people ./people:id
# Index the dataset by 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
# Index the dataset by state and ID, placing the index in the default path
$GHEE idx -v -k state -k id ./people
# Add more people to the table and its indices
$GHEE ins -v ./people < ../people.json
# Add more people to the table and its indices
$GHEE ins -v ./people < ../people.json
# Get all of ./people
$GHEE get -a ./people
# Get all of ./people
$GHEE get -a ./people
# # Get all of ./people without sorting in the walk of the folder hierarchy
# ghee get -a --nosort ./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
# Get the name of everybody from California; include all subpaths (don't ignore indices)
$GHEE get -a -w state=CA -f name ./people
# Remove Sofia
$GHEE del -v ./people -w name=Sofia
# Equivalently: ghee del -v ./people Sofia
# Remove 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
# Equivalently: ghee del -v ./people -w id=3
# Equivalently: ghee del -v ./people Lilly
# Remove Lilly from the :id index and all related indices
$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
# Equivalently: ghee del -v ./people -w state=CA -w id=0
# Equivalently: ghee del -v ./people Wulfrum
# Remove Wulfrum from the :state:id index and all related indices
$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
# 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
# Create a table directly
$GHEE create -v ./direct -k blah
# Create a table directly
$GHEE create -v ./direct -k blah
# Create people2 in one go using `create'
$GHEE create -v ./people2 -k id < ../people.json
# Create people2 in one go using `create'
$GHEE create -v ./people2 -k id < ../people.json
$GHEE status ./people2
$GHEE status ./people2
mkdir ./empty
$GHEE status ./empty
mkdir ./empty
$GHEE status ./empty
}
btrfs() {
$GHEE status .
$GHEE create -v -k toppings ./pizza
$GHEE status ./pizza
$GHEE touch ./pizza/olive
$GHEE status ./pizza
$GHEE commit -m "Add olive pizza" ./pizza
$GHEE status ./pizza
$GHEE touch ./pizza/pepperoni
echo "Olives are good on pizza" > ./pizza/olive
$GHEE set -s yumminess=5 ./pizza/olive
$GHEE status ./pizza
$GHEE commit -m "Add pepperoni; add details to olive" ./pizza
$GHEE status ./pizza
}
main
# --- BTRFS ---
dd if=/dev/zero of=./ghee-btrfs.img bs=1024 count=114000
@ -92,31 +123,8 @@ cd ./btrfs
sudo chown $OWNER:$OWNER .
$GHEE status .
btrfs
$GHEE create -v -k toppings ./pizza
$GHEE status ./pizza
$GHEE touch ./pizza/olive
$GHEE status ./pizza
$GHEE commit -m "Add olive pizza" ./pizza
$GHEE status ./pizza
$GHEE touch ./pizza/pepperoni
echo "Olives are good on pizza" > ./pizza/olive
$GHEE set -s yumminess=5 ./pizza/olive
$GHEE status ./pizza
$GHEE commit -m "Add pepperoni; add details to olive" ./pizza
$GHEE status ./pizza
cd ..

View file

@ -1,3 +1,4 @@
+ main
+ mkdir people
+ touch ./people/Sandeep ./people/Sofia ./people/Wulfrum
+ /home/josh/Projects/Ghee/target/debug/ghee set -s name=Sandeep -s id=2 -s state=CA ./people/Sandeep
@ -112,6 +113,7 @@ Devices:
+ sudo mount -o loop ./ghee-btrfs.img ./btrfs
+ cd ./btrfs
+ sudo chown josh:josh .
+ btrfs
+ /home/josh/Projects/Ghee/target/debug/ghee status .
No table found
+ /home/josh/Projects/Ghee/target/debug/ghee create -v -k toppings ./pizza