blob: 816bfe6e39158007d1d0ebe94a09dbf4e48c0fc1 [file] [log] [blame]
Taewoo Kimd185e8ea2016-02-02 21:17:00 -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 : Self-joins on a dataset on the intersection of a point attribute.
21 * The dataset 'TweetMessages' has an RTree index, and we expect the
22 * join to be transformed into an indexed nested-loop join.
23 * Success : Yes
24 */
25
26drop dataverse test if exists;
27create dataverse test;
28use dataverse test;
29
30create type TwitterUserType as closed {
31 screen-name: string,
32 lang: string,
33 friends-count: int64,
34 statuses-count: int64,
35 name: string,
36 followers-count: int64
37}
38
39create type TweetMessageType as closed {
40 tweetid: int64,
41 user: TwitterUserType,
42 sender-location: point,
43 send-time: datetime,
44 referred-topics: {{ string }},
45 message-text: string,
46 countA: int64,
47 countB: int64
48}
49
50create dataset TweetMessages(TweetMessageType)
51primary key tweetid;
52
53create index twmSndLocIx on TweetMessages(sender-location) type rtree;
54create index msgCountAIx on TweetMessages(countA) type btree;
55create index msgCountBIx on TweetMessages(countB) type btree;
56create index msgTextIx on TweetMessages(message-text) type keyword;
57
58write output to asterix_nc1:"rttest/index-join_rtree-spatial-self-intersect-point.adm";
59
60for $t1 in dataset('TweetMessages')
61for $t2 in dataset('TweetMessages')
62let $n := create-circle($t1.sender-location, 0.5)
63where spatial-intersect($t2.sender-location, $n)
64order by $t2.tweetid
65return {"tweetid2":$t2.tweetid, "loc2":$t2.sender-location};
66