blob: e20638b424f14dc4803520049cf7cb0d9590b3e3 [file] [log] [blame]
Steven Glenn Jacobs345b0f52018-04-12 13:19:50 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19/*
20 * Description : Check a push-based channel plan
21 * Expected Res : Success
22 * Date : Mar 2018
23 */
24
25drop dataverse channels7 if exists;
26create dataverse channels7;
27use channels7;
28
29create type UserLocation as {
30 location: circle,
31 userName: string,
32 timeStamp: datetime
33};
34
35
36create type UserLocationFeedType as {
37 location: circle,
38 userName: string
39};
40
41create type EmergencyReport as {
42 reportId: uuid,
43 Etype: string,
44 location: circle,
45 timeStamp: datetime
46};
47
48create type EmergencyReportFeedType as {
49 Etype: string,
50 location: circle
51};
52
53
54create type EmergencyShelter as {
55 shelterName: string,
56 location: point
57};
58
59create dataset UserLocations(UserLocation)
60primary key userName;
61create dataset Shelters(EmergencyShelter)
62primary key shelterName;
63create dataset Reports(EmergencyReport)
64primary key reportId autogenerated;
65
66create index location_time on UserLocations(timeStamp);
67create index u_location on UserLocations(location) type RTREE;
68create index s_location on Shelters(location) type RTREE;
69create index report_time on Reports(timeStamp);
70
71create function RecentEmergenciesNearUser(userName) {
72 (
73 select report, shelters from
74 ( select value r from Reports r where r.timeStamp >
75 current_datetime() - day_time_duration("PT10S"))report,
76 UserLocations u
77 let shelters = (select s.location from Shelters s where spatial_intersect(s.location,u.location))
78 where u.userName = userName
79 and spatial_intersect(report.location,u.location)
80 )
81};
82
83write output to nc1:"rttest/channel-push.sqlpp";
84
85create repetitive push channel EmergencyChannel using RecentEmergenciesNearUser@1 period duration("PT10S");