Ticket #2067: reproduce.sh

File reproduce.sh, 2.6 KB (added by Dimitar Misev, 6 years ago)
Line 
1#!/bin/bash
2
3COLL=test_induced_condenser
4TYPE=GreySetWithNullvalues
5RASQL='rasql --user rasadmin --passwd rasadmin'
6
7query()
8{
9 $RASQL -q "$1" --out string 2> /dev/null | grep Result | sed 's/Result object 1: //' | tr -d '{' | tr -d '}'
10}
11
12# cleanup
13$RASQL -q "drop collection $COLL" > /dev/null 2>&1
14$RASQL -q "drop type $TYPE" > /dev/null 2>&1
15
16# setup collection
17$RASQL -q "create type $TYPE as set (GreyCube null values [10])" --quiet
18$RASQL -q "create collection $COLL $TYPE" --quiet
19
20# insert first slice
21$RASQL -q "insert into $COLL values marray i in [0, 0:0, 5:9] values 1c" --quiet
22# make first half of first slice null values
23$RASQL -q "update $COLL as c set c assign marray i in [0:0, 0:0, 0:4] values 10c" --quiet
24
25# insert second slice, doesn't intersect the first slice
26$RASQL -q "update $COLL as c set c assign marray i in [1:1, 0:0, 10:19] values 2c" --quiet
27
28echo
29echo "N = NULL = 10"
30echo
31echo "-------------------------------------------------------"
32echo "case 1 - area [0:0, 0:9]:"
33echo " slice 1: [N,N,N,N,N,1,1,1,1,1]"
34echo " slice 2: [ , , , , , , , , , ],2,2,2,2,2,2,2,2,2,2"
35echo
36
37echo -n "max of slice 1 and 2: "
38query "select encode(c[0, 0:0, 0:9] max c[1, 0:0, 0:9], \"csv\") from $COLL as c"
39echo -n "min of slice 1 and 2: "
40query "select encode(c[0, 0:0, 0:9] min c[1, 0:0, 0:9], \"csv\") from $COLL as c"
41echo -n " + of slice 1 and 2: "
42query "select encode(c[0, 0:0, 0:9] + c[1, 0:0, 0:9], \"csv\") from $COLL as c"
43echo
44
45# update second slice, to overlap the first slice
46$RASQL -q "update $COLL as c set c assign marray i in [1:1, 0:0, 3:7] values 3c" --quiet
47
48echo "-------------------------------------------------------"
49echo "case 2 - area [0:0, 0:9]:"
50echo " slice 1: [N,N,N,N,N,1,1,1,1,1]"
51echo " slice 2: [ , , ,3,3,3,3,3, , ],2,2,2,2,2,2,2,2,2,2"
52echo
53
54echo -n "max of slice 1 and 2: "
55query "select encode(c[0, 0:0, 0:9] max c[1, 0:0, 0:9], \"csv\") from $COLL as c"
56echo -n "min of slice 1 and 2: "
57query "select encode(c[0, 0:0, 0:9] min c[1, 0:0, 0:9], \"csv\") from $COLL as c"
58echo -n " + of slice 1 and 2: "
59query "select encode(c[0, 0:0, 0:9] + c[1, 0:0, 0:9], \"csv\") from $COLL as c"
60echo
61
62echo "-------------------------------------------------------"
63echo "case 3 - area [0:0, 2:11]:"
64echo " slice 1: N,N,[N,N,N,1,1,1,1,1, , ]"
65echo " slice 2: , ,[ ,3,3,3,3,3, , ,2,2],2,2,2,2,2,2,2,2"
66echo
67
68echo -n "max of slice 1 and 2: "
69query "select encode(c[0, 0:0, 2:11] max c[1, 0:0, 2:11], \"csv\") from $COLL as c"
70echo -n "min of slice 1 and 2: "
71query "select encode(c[0, 0:0, 2:11] min c[1, 0:0, 2:11], \"csv\") from $COLL as c"
72echo -n " + of slice 1 and 2: "
73query "select encode(c[0, 0:0, 2:11] + c[1, 0:0, 2:11], \"csv\") from $COLL as c"
74echo