#! /bin/bash

echo Generating dataset
../Generator -ds 1000 -sl 100 > d
awk '{if ($2 != 2) print $0}' < d > data
awk '{if ($2 == 2 && $3 >= 100) print $0}' < d > queries
rm -rf d

echo Creating new TPR-Tree
../TPRTreeLoad data tree 20

echo Querying TPR-Tree
../TPRTreeQuery queries tree > res
cat data queries > .t

echo Running exhaustive search
../Exhaustive .t > res2

echo Comparing results
sort -n res > a
sort -n res2 > b
if diff a b
then
echo "Same results with exhaustive search. Everything seems fine."
echo Results: `wc -l a`
rm -rf a b res res2 .t tree.*
else
echo "PROBLEM! We got different results from exhaustive search!"
fi
