blob: 53399e1dc959d827456f83fd8b43dbcce5d032c8 [file] [log] [blame]
Steven Glenn Jacobs8b53ce52017-11-14 10:21:43 -08001/*
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 an advanced channel for index usage
21 * Expected Res : Success
22 * Date : Oct 2017
23 */
24
25drop dataverse channels5 if exists;
26create dataverse channels5;
27use channels5;
28
29create type UserLocation as closed {
30 recordId: uuid,
31 location: circle,
32 userName: string,
33 timeStamp: datetime
34};
35
36create type EmergencyReport as closed {
37 reportId: uuid,
38 Etype: string,
39 location: circle,
40 timeStamp: datetime
41};
42
43create type EmergencyShelter as closed {
44 shelterName: string,
45 location: circle
46};
47
48create dataset UserLocations(UserLocation)
49primary key recordId autogenerated;
50
51create dataset EmergencyReports(EmergencyReport)
52primary key reportId autogenerated;
53
54create index locTimes on UserLocations(timeStamp);
55create index repTimes on EmergencyReports(timeStamp);
56
57create function RecentEmergenciesNearUser(userName) {
58 (
59 SELECT r AS report
60 FROM
61 (select value r from EmergencyReports r where r.timeStamp > current_datetime() - day_time_duration("PT10S")) r,
62 (select value r from UserLocations l where l.timeStamp > current_datetime() - day_time_duration("PT10S")) l
63 where l.userName = userName
64 and spatial_intersect(r.location,l.location)
65 )
66};
67
68write output to nc1:"rttest/channel-advanced.sqlpp";
69
70create repetitive channel EmergencyChannel using RecentEmergenciesNearUser@1 period duration("PT10S");