lwhay / asterixdb

Automatically exported from code.google.com/p/asterixdb
0 stars 0 forks source link

Spatial-distance should be able to pick up index #831

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
DDL:
drop dataverse twitter if exists;
create dataverse twitter;

use dataverse twitter;

create type TwitterUserType as open {
    screen-name: string,
    lang: string,
    friends-count: int32,
    statuses-count: int32,
    name: string,
    followers-count: int32
}

create type TweetMessageType as closed {
    tweetid: int64,
    user: TwitterUserType,
    sender-location: point,
    send-time: datetime,
    referred-topics: {{ string }},
    message-text: string,
    countA: int32,
    countB: int32
}

create dataset TweetMessages(TweetMessageType)
primary key tweetid;

create index locationIdx on TweetMessages(sender-location) type rtree;

load dataset TweetMessages using 
localfs(("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="a
dm"));

for $tweet in dataset TweetMessages
let $circle := circle("50,50 20")
where spatial-intersect($tweet.sender-location,$circle) 
return $tweet;

for $tweet in dataset TweetMessages
where spatial-distance($tweet.sender-location,point("50,50")) < 20
return $tweet;

The first query picks up the index. The second equivalent query doesn't. 

Original issue reported on code.google.com by sjaco...@ucr.edu on 3 Dec 2014 at 8:40

GoogleCodeExporter commented 9 years ago
Current rewrite rules in RTreeAccessMethod.java class doesn't consider 
spatial-distance an optimizable function for Rtree index. We need to fix this. 

Original comment by kiss...@gmail.com on 3 Dec 2014 at 10:12

GoogleCodeExporter commented 9 years ago
Agreed.  It could probably just rewrite the latter form into the former form 
(with the center of the circle being the location in hand).

Original comment by dtab...@gmail.com on 3 Dec 2014 at 11:26

GoogleCodeExporter commented 9 years ago
Just changing the label of this since it seems more like a defect/bug than 
anything else. 

Original comment by ima...@uci.edu on 3 Dec 2014 at 11:33

GoogleCodeExporter commented 9 years ago

Original comment by sjaco...@ucr.edu on 15 Dec 2014 at 6:54