Ghee/example.sh
2023-08-10 18:10:22 -07:00

34 lines
No EOL
929 B
Bash

#!/bin/sh
# Generates example dataset and does some stuff
if [ ! -d "example" ]; then
mkdir example
fi
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
# Index the dataset by ID
ghee idx -v -k id ./people ./people:id
# Index the dataset by state and ID
ghee idx -v -k state -k id ./people ./people:state:id
# Get the name of everybody from California
ghee get -w state=CA -f name ./people
# Get the name of everybody from California, taking advantage of the state index
# This will avoid traversing irrelevant portions of the index
ghee get -w state=CA -f name ./people:state:id
cd ..