#!/bin/bash

r='rasql --user rasadmin --passwd rasadmin'

if [ ! -f test.bin ]; then
  # generate 1.4GB data
  head -c 1408000000 /dev/urandom > test.bin
fi

$r -q 'create type ushort11 as (att0 ushort,att1 ushort,att2 ushort,att3 ushort,att4 ushort,att5 ushort,att6 ushort,att7 ushort,att8 ushort,att9 ushort,att10 ushort)' > /dev/null
$r -q 'create type B_MDD_ushort11_3 as ushort11 mdarray [ d0,d1,d2 ]' > /dev/null
$r -q 'create type B_SET_ushort11_3 as set (B_MDD_ushort11_3)' > /dev/null

$r -q 'drop collection test' > /dev/null
$r -q 'create collection test B_SET_ushort11_3' > /dev/null
$r -q 'INSERT INTO test VALUES $1 TILING REGULAR [0:0,0:499,0:499] TILE SIZE 5500000' -f test.bin --mdddomain [0:0,0:7999,0:7999] --mddtype B_MDD_ushort11_3 > /dev/null
