Taewoo Kim | d185e8ea | 2016-02-02 21:17:00 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 26 | drop dataverse test if exists; |
| 27 | create dataverse test; |
| 28 | use dataverse test; |
| 29 | |
| 30 | create 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 | |
| 39 | create 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 | |
| 50 | create dataset TweetMessages(TweetMessageType) |
| 51 | primary key tweetid; |
| 52 | |
| 53 | create index twmSndLocIx on TweetMessages(sender-location) type rtree; |
| 54 | create index msgCountAIx on TweetMessages(countA) type btree; |
| 55 | create index msgCountBIx on TweetMessages(countB) type btree; |
| 56 | create index msgTextIx on TweetMessages(message-text) type keyword; |
| 57 | |
| 58 | write output to asterix_nc1:"rttest/index-join_rtree-spatial-self-intersect-point.adm"; |
| 59 | |
| 60 | for $t1 in dataset('TweetMessages') |
| 61 | for $t2 in dataset('TweetMessages') |
| 62 | let $n := create-circle($t1.sender-location, 0.5) |
| 63 | where spatial-intersect($t2.sender-location, $n) |
| 64 | order by $t2.tweetid |
| 65 | return {"tweetid2":$t2.tweetid, "loc2":$t2.sender-location}; |
| 66 | |