1 | #!/bin/bash
|
---|
2 |
|
---|
3 | COLL=test_induced_condenser
|
---|
4 | TYPE=GreySetWithNullvalues
|
---|
5 | RASQL='rasql --user rasadmin --passwd rasadmin'
|
---|
6 |
|
---|
7 | query()
|
---|
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 |
|
---|
28 | echo
|
---|
29 | echo "N = NULL = 10"
|
---|
30 | echo
|
---|
31 | echo "-------------------------------------------------------"
|
---|
32 | echo "case 1 - area [0:0, 0:9]:"
|
---|
33 | echo " slice 1: [N,N,N,N,N,1,1,1,1,1]"
|
---|
34 | echo " slice 2: [ , , , , , , , , , ],2,2,2,2,2,2,2,2,2,2"
|
---|
35 | echo
|
---|
36 |
|
---|
37 | echo -n "max of slice 1 and 2: "
|
---|
38 | query "select encode(c[0, 0:0, 0:9] max c[1, 0:0, 0:9], \"csv\") from $COLL as c"
|
---|
39 | echo -n "min of slice 1 and 2: "
|
---|
40 | query "select encode(c[0, 0:0, 0:9] min c[1, 0:0, 0:9], \"csv\") from $COLL as c"
|
---|
41 | echo -n " + of slice 1 and 2: "
|
---|
42 | query "select encode(c[0, 0:0, 0:9] + c[1, 0:0, 0:9], \"csv\") from $COLL as c"
|
---|
43 | echo
|
---|
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 |
|
---|
48 | echo "-------------------------------------------------------"
|
---|
49 | echo "case 2 - area [0:0, 0:9]:"
|
---|
50 | echo " slice 1: [N,N,N,N,N,1,1,1,1,1]"
|
---|
51 | echo " slice 2: [ , , ,3,3,3,3,3, , ],2,2,2,2,2,2,2,2,2,2"
|
---|
52 | echo
|
---|
53 |
|
---|
54 | echo -n "max of slice 1 and 2: "
|
---|
55 | query "select encode(c[0, 0:0, 0:9] max c[1, 0:0, 0:9], \"csv\") from $COLL as c"
|
---|
56 | echo -n "min of slice 1 and 2: "
|
---|
57 | query "select encode(c[0, 0:0, 0:9] min c[1, 0:0, 0:9], \"csv\") from $COLL as c"
|
---|
58 | echo -n " + of slice 1 and 2: "
|
---|
59 | query "select encode(c[0, 0:0, 0:9] + c[1, 0:0, 0:9], \"csv\") from $COLL as c"
|
---|
60 | echo
|
---|
61 |
|
---|
62 | echo "-------------------------------------------------------"
|
---|
63 | echo "case 3 - area [0:0, 2:11]:"
|
---|
64 | echo " slice 1: N,N,[N,N,N,1,1,1,1,1, , ]"
|
---|
65 | echo " slice 2: , ,[ ,3,3,3,3,3, , ,2,2],2,2,2,2,2,2,2,2"
|
---|
66 | echo
|
---|
67 |
|
---|
68 | echo -n "max of slice 1 and 2: "
|
---|
69 | query "select encode(c[0, 0:0, 2:11] max c[1, 0:0, 2:11], \"csv\") from $COLL as c"
|
---|
70 | echo -n "min of slice 1 and 2: "
|
---|
71 | query "select encode(c[0, 0:0, 2:11] min c[1, 0:0, 2:11], \"csv\") from $COLL as c"
|
---|
72 | echo -n " + of slice 1 and 2: "
|
---|
73 | query "select encode(c[0, 0:0, 2:11] + c[1, 0:0, 2:11], \"csv\") from $COLL as c"
|
---|
74 | echo
|
---|