96 lines
2.4 KiB
Plaintext
96 lines
2.4 KiB
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
function print_help () {
|
||
|
echo "Usage: $0 [OPTION]"
|
||
|
echo "Optional arguments:"
|
||
|
echo -e " -h|--help -> Prints help."
|
||
|
echo -e " --scale-factor Positive_Integer -> Defines the dataset size."
|
||
|
echo -e " --transform-dataset -> Run just transform dataset (SNB -> Neo4j CSV)."
|
||
|
echo -e " --load-dataset -> Just load dataset into Neo4j."
|
||
|
echo -e " --run -> Just run Neo4j."
|
||
|
}
|
||
|
|
||
|
set -e
|
||
|
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||
|
|
||
|
# Read the arguments.
|
||
|
scale_factor=1
|
||
|
run_all=true
|
||
|
transform_dataset=false
|
||
|
load_dataset=false
|
||
|
run_neo=false
|
||
|
while [[ $# -gt 0 ]]
|
||
|
do
|
||
|
case $1 in
|
||
|
-h|--help)
|
||
|
print_help
|
||
|
exit 1
|
||
|
;;
|
||
|
--scale-factor)
|
||
|
scale_factor=$2
|
||
|
shift
|
||
|
;;
|
||
|
--transform-dataset)
|
||
|
run_all=false
|
||
|
transform_dataset=true
|
||
|
;;
|
||
|
--load-dataset)
|
||
|
run_all=false
|
||
|
load_dataset=true
|
||
|
;;
|
||
|
--run)
|
||
|
run_all=false
|
||
|
run_neo=true
|
||
|
;;
|
||
|
*)
|
||
|
# unknown option
|
||
|
;;
|
||
|
esac
|
||
|
shift # past argument or value
|
||
|
done
|
||
|
|
||
|
dataset_folder=${script_dir}/neo4j_csv_dataset_scale_${scale_factor}
|
||
|
|
||
|
# Transform the dataset into files on disk.
|
||
|
if [[ ${run_all} = true ]] || [[ ${transform_dataset} = true ]] ; then
|
||
|
cd ${dataset_folder}
|
||
|
chmod +x import.sh
|
||
|
NEO4J_HOME=/usr/share/neo4j ./import.sh
|
||
|
fi
|
||
|
|
||
|
# Load the dataset into Neo4j.
|
||
|
if [[ ${run_all} = true ]] || [[ ${load_dataset} = true ]] ; then
|
||
|
neo4j_data=${script_dir}/neo4j_home/data
|
||
|
neo4j_graphdb=${neo4j_data}/databases/graph.db
|
||
|
mkdir -p ${neo4j_graphdb}
|
||
|
rm -rf ${neo4j_graphdb}/*
|
||
|
cp -r ${dataset_folder}/graph.db/* ${neo4j_graphdb}/
|
||
|
fi
|
||
|
|
||
|
# Run Neo4j.
|
||
|
if [[ ${run_all} = true ]] || [[ ${run_neo} = true ]] ; then
|
||
|
NEO4J_HOME=${script_dir}/neo4j_home NEO4J_CONF=${script_dir}/neo4j_config /usr/share/neo4j/bin/neo4j console 2>&1 &
|
||
|
neo_pid=$!
|
||
|
sleep 5
|
||
|
|
||
|
# Create indexes.
|
||
|
cd ${script_dir}
|
||
|
if [ ! -d "ve3" ]; then
|
||
|
virtualenv -p python3 ve3 || command_fail "Virtualenv setup failed."
|
||
|
source ve3/bin/activate
|
||
|
pip install -r ${script_dir}/requirements_3.txt
|
||
|
fi
|
||
|
source ve3/bin/activate
|
||
|
python index_creation.py ${script_dir}/ldbc-snb-impls/snb-interactive-neo4j/scripts/indexCreation.neo4j
|
||
|
|
||
|
# On Ctrl-C stop Neo4j.
|
||
|
trap ctrl_c INT
|
||
|
function ctrl_c() {
|
||
|
kill -9 ${neo_pid}
|
||
|
exit 0
|
||
|
}
|
||
|
while true; do
|
||
|
sleep 1
|
||
|
done
|
||
|
fi
|