[jira] [Commented] (CALCITE-1861) Spatial Indexes

2020-03-09 Thread Julian Hyde (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17055343#comment-17055343
 ] 

Julian Hyde commented on CALCITE-1861:
--

{quote}How to integrate it in Calcite? 
{quote}
Do you mean how do we enable spatial rules when people make a vanilla 
connection to Calcite via JDBC? We don't necessarily want that. Let's do it for 
this branch, and revisit before we merge to master.

Modify {{RelOptRules.registerDefaultRules}} and register the spatial rules and 
I think you will get the desired effect.

Add a section to the end of {{spatial.iq}} to test rewrites, and use the 
{{!plan}} command to check that they have worked. (If that section grows too 
large, break out a new file {{spatial_index.iq}}.)

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>  Components: spatial
>Reporter: Atri Sharma
>Priority: Major
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2020-03-08 Thread Tao Yang (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17054652#comment-17054652
 ] 

Tao Yang commented on CALCITE-1861:
---

Hi [~julianhyde], in RelOptRulesTest.java the SpatialRules are setup in 
function 'spatial' for the test. How to integrate it in Calcite? Is there 
another similar rule integrated as an example? 

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>  Components: spatial
>Reporter: Atri Sharma
>Priority: Major
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2020-02-18 Thread Julian Hyde (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17039430#comment-17039430
 ] 

Julian Hyde commented on CALCITE-1861:
--

Thanks for digging up the changes I made to {{spatial.md}}; I had forgotten 
about that! [~txy2539], the table definition [~mmior] refers to is this:
{code:java}
CREATE TABLE Restaurants (
   VARCHAR(20) cuisine,
   INT x NOT NULL,
   INT y NOT NULL,
   INT h  NOT NULL DERIVED (ST_Hilbert(x, y)))
 SORT KEY (h);
{code}
The {{DERIVED}} keyword is crucial. It means that the column is always computed 
(and therefore the planner can rely on the value of the column always being the 
hilbert index).

The {{SORT KEY}} declaration is quite important. The rewrite will still work 
without it, but if the table is not known to be sorted, the system will have to 
do a full scan. The physical organization of the table depends on which system 
you are targeting. IIRC, Calcite tables don't support {{SORT KEY}} so this is 
basically pseudo-syntax.

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>  Components: spatial
>Reporter: Atri Sharma
>Priority: Major
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2020-02-18 Thread Michael Mior (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17039419#comment-17039419
 ] 

Michael Mior commented on CALCITE-1861:
---

I should also add that if you look in {{site/_docs/spatial.md}}, [~julianhyde] 
added a section that gives an example of what such a table definition might 
look like.

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>  Components: spatial
>Reporter: Atri Sharma
>Priority: Major
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2020-02-18 Thread Michael Mior (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17039408#comment-17039408
 ] 

Michael Mior commented on CALCITE-1861:
---

[~txy2539] Right now, this is a predicate that is explicitly mentioned in the 
query. That is, the rule matches a condition on the query that looks like 
`hilbertColumn = hilbert(latitude, longitude)`. For testing, you can start with 
just creating a table populated with the appropriate values. That is, you would 
have the columns `latitude`, `longitude`, and `hilbertColumn` where the last 
column contains the pre-computed position on the Hilbert curve.

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>  Components: spatial
>Reporter: Atri Sharma
>Priority: Major
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2020-02-17 Thread Tao Yang (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17038707#comment-17038707
 ] 

Tao Yang commented on CALCITE-1861:
---

[~julianhyde] Hi Julian, I found that the Hilbert curve function and the 
function that transfers region to index on Hilbert curve index have been 
implemented by using 'com.google.uzaygezen.core.CompactHilbertCurve' and 
related packages.  

Spatial Rules that optimize the ST_Within is also implemented. 

But in LogicalProject, there is a HILBERT=[$4], meaning we need to select from 
a column that has the index on the curve. Is this HILBERT column maintained in 
the memory or in the database? How does Apache Calcite generate and maintain 
this column( might be a B+tree)? 

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>  Components: spatial
>Reporter: Atri Sharma
>Priority: Major
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2020-01-16 Thread Julian Hyde (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17016774#comment-17016774
 ] 

Julian Hyde commented on CALCITE-1861:
--

[~txy2539], I have now rebased my 
[1861-spatial|https://github.com/julianhyde/calcite/commits/1861-spatial] 
branch. There are a few test failures, but the build basically works. Review 
the last 16 or so commits on that branch, and see which files I have been 
changing. I apologize that the branch is a mixture of things - in addition to 
spatial, I'm trying to make table-valued functions work more reliably, and a 
few commits that fix up after rebasing.

In particular, look at changes I made to spatial.iq and RelOptRulesTest.xml. 
These are both test files, and they give a clue as to what I was doing in the 
rest of the code.

An easy way to start might be to implement one or two geospatial SQL functions. 
Lots of them are listed in spatial.iq with '# Not implemented' comments. What 
[~mmior] did in [17cd76af7|https://github.com/apache/calcite/commit/17cd76af7], 
 CALCITE-2031, is a good template to follow.

Much more advanced is to use algebraic transforms to implement particular 
spatial queries efficiently. The testSpatialXxx methods in RelOptRulesTest are 
examples.

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>  Components: spatial
>Reporter: Atri Sharma
>Priority: Major
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2020-01-15 Thread Tao Yang (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17016389#comment-17016389
 ] 

Tao Yang commented on CALCITE-1861:
---

Hi, I am Tao Yang, a student of Michael Mior. I am interested in implement this 
function as part of my academic project. Thanks for sharing all the related 
information. 

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>  Components: spatial
>Reporter: Atri Sharma
>Priority: Major
>  Labels: gsoc2018
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2020-01-15 Thread Julian Hyde (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17016385#comment-17016385
 ] 

Julian Hyde commented on CALCITE-1861:
--

[~mmior], I got a lot of it working in my branch 
https://github.com/julianhyde/calcite/commits/1861-spatial. I don't recall why 
I didn't mark it 'complete' and merge to master. Let me rebase that branch onto 
latest master.

I recall that I got certain cases working (e.g. a column based on space-filling 
curve, that allows points-near-a-constant-point and points-in-a-constant-region 
queries to work), and others I did not complete (e.g. a table that contains 
tiles, to allow regions-that-overlap-regions queries to work).

Please ask your student to post comments to this case; we can collaborate here.


> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>  Components: spatial
>Reporter: Atri Sharma
>Priority: Major
>  Labels: gsoc2018
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2020-01-15 Thread Michael Mior (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17016354#comment-17016354
 ] 

Michael Mior commented on CALCITE-1861:
---

[~julianhyde] I have a student working with me this semester who is hoping to 
take a first pass at implementing this. In terms of getting some ideas on where 
to start implementing, I'm assuming the existing lattice code is a good 
starting point. Do you have any other suggestions?

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>  Components: spatial
>Reporter: Atri Sharma
>Priority: Major
>  Labels: gsoc2018
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2018-03-13 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16397959#comment-16397959
 ] 

Julian Hyde commented on CALCITE-1861:
--

Related work in Druid: https://github.com/druid-io/druid/issues/5482

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>  Components: spatial
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>Priority: Major
>  Labels: gsoc2018
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2017-08-25 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16141946#comment-16141946
 ] 

Julian Hyde commented on CALCITE-1861:
--

[~stefano.bortoli], I logged CALCITE-1968 to support a GEOMETRY data type and 
the OpenGIS functions. Spatial index support will use those functions. The 
initial goal is to accelerate a query that finds all points within a given 
distance of a given point:

{code}
SELECT *, ST_Distance(ST_MakePoint(r.x, r.y), ST_MakePoint(100, 250))
FROM Restaurant AS r
WHERE ST_Distance(ST_MakePoint(r.x, r.y), ST_MakePoint(100, 250)) < 10
{code}

I need help on this. This work will not get completed if I am the sole resource.

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2017-08-25 Thread Stefano Bortoli (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16141803#comment-16141803
 ] 

Stefano Bortoli commented on CALCITE-1861:
--

Hi [~julianhyde], what is the plan for this feature? I see that the branch is 
quite active. 

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2017-07-06 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16077211#comment-16077211
 ] 

Julian Hyde commented on CALCITE-1861:
--

Ah, HilbertCurve2D looks perfect. I've been thinking about how to generate 
ranges on the Hilbert curve from a shape (rectangle or circle) and I realized 
it wasn't going to be trivial.

To answer your earlier questions about Calcite. It is the top half of a 
database, the brains without the brawn. So, it doesn't have any data structures 
(e.g. b-tree indexes) or algorithms (e.g. hash join) but it works in terms of 
relational algebra. It translates a SQL query into logical relational algebra, 
and then optimizes it to physical relational algebra of the target system. 
Sometimes that means generating a query to send to a particular back-end system 
such as Solr/Lucene, HBase, Druid.

Rewriting spatial queries to Hilbert curves is a good fit for Calcite because 
it is a logical rewrite; it doesn't require any particular data structure to 
make it work. But we do need the logic to transform (x, y) regions into Hilbert 
curve ranges, because that happens at query planning time.

Spatial support would also mean adding a core set of spatial data types and 
functions to our SQL dialect. Systems that use Calcite as their SQL front-end 
would need to implement those functions.

Most of the functions are not interesting from a query optimization standpoint 
- they process one row at a time - so we'd pass them straight through to the 
back end. But the "WHERE distance(point(x, y), point(x2, y2)) < constant" case 
is interesting,  because to be handled efficiently the query needs to be 
transformed to use an index.

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2017-07-05 Thread David Smiley (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16075958#comment-16075958
 ] 

David Smiley commented on CALCITE-1861:
---

Yes; my mention of LocationTech's SF Curve library should have indicated it 
includes Uzaygezen: 
https://github.com/locationtech/sfcurve/blob/master/hilbert/src/main/scala/org/locationtech/sfcurve/hilbert/HilbertCurve2D.scala

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2017-07-04 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16073196#comment-16073196
 ] 

Julian Hyde commented on CALCITE-1861:
--

Another possible library: Google's 
[uzaygezen|https://github.com/aioaneid/uzaygezen project] maps between 
multi-dimensional points and Hilbert curves and is Apache licensed.

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2017-06-30 Thread David Smiley (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16070578#comment-16070578
 ] 

David Smiley commented on CALCITE-1861:
---

Hi.  Is Lucene/Solr related; that is might you use either for this?  I'm not 
very familiar with Calcite other than that it contains an SQL parser module 
used by Solr.

If we're just talking about computing spatial relationships (intersects, 
contains, within, ...) between shapes where one of those shapes could be a 
polygon, then you have some options:
* JTS (with Spatial4j maybe).  JTS has historically been LGPL licensed but it's 
undergoing transition to LocationTech (part of the Eclipse Foundation) where it 
is relicensed with a BSD style license.  You can find the code there with this 
license on GitHub.  It is going through IP review process still (I monitor 
this).  It has yet to be officially released (thus published to Maven central 
etc.) under this new more permissive license.
* ESRI's Geometry API: https://github.com/Esri/geometry-api-java   ASL.  Isn't 
used a lot for whatever reason; maybe because it's relatively new whereas JTS 
is the gold standard.

If you only need to compute relationships with a polygon and a rectangle, then 
Lucene has internal code for this that you could copy. 
https://github.com/o19s/lucene-solr/blob/7be69c60387a99df8a7caaed18725d00568104f5/lucene/core/src/java/org/apache/lucene/geo/Polygon2D.java#L39-L39

If you wish to do spatial indexing on top of another store that doesn't 
necessarily have 1st class spatial support, I recommend investigating and 
participating in a new LocationTech project called SFCurve: 
https://www.locationtech.org/proposals/sfcurve  
https://github.com/locationtech/sfcurve   I've been monitoring this.  GeoWave's 
indexing code is being contributed right now.

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2017-06-30 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16070546#comment-16070546
 ] 

Julian Hyde commented on CALCITE-1861:
--

[~dsmiley], I see you're involved with both Lucene/SOLR and Spatial4j. Can you 
tell us what's going on with that project? Can we accomplish what we need to 
(to support common GIS functions via SQL) without having to pull in JTS (which 
is LGPL licensed, and therefore a no-go for us).

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2017-06-30 Thread Atri Sharma (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16070540#comment-16070540
 ] 

Atri Sharma commented on CALCITE-1861:
--

Spatial4j looks pretty good to me, I think we should use it

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2017-06-30 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16070532#comment-16070532
 ] 

Julian Hyde commented on CALCITE-1861:
--

If we need a library with geospatial functions, what are the options? 
[GeoTools|http://www.geotools.org/] is the most popular in but it is LGPL so we 
can't use it. 
[Spatial4j|https://www.locationtech.org/projects/technology.spatial4j] is 
Apache licensed, hasn't had a release in a while, but otherwise looks good.

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2017-06-30 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16070512#comment-16070512
 ] 

Julian Hyde commented on CALCITE-1861:
--

Yes. Use a simple table {{t (id, x, y, h)}} with a constraint that {{h = 
toHilbert(x, y)}}, and transform a query {{select * from t where x between 3 
and 5 and y between 0 and 1}} into something like {{select * from t where h 
between ... and ... or h between ... and ...}}.

The rule will be similar to DateRangeRules, added in CALCITE-1334, in how it 
maps between columns that are connected using a check constraint.

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2017-06-30 Thread Atri Sharma (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16070493#comment-16070493
 ] 

Atri Sharma commented on CALCITE-1861:
--

[~julianhyde] Should I start by using the library functions you added to 
implement n dimension reduction to 1, and then using it in  a dummy rule?

Does that seem like a reasonable starting point?

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2017-06-30 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16070482#comment-16070482
 ] 

Julian Hyde commented on CALCITE-1861:
--

[Towards a Painless Index for Spatial Objects, Zhang et al 
2014|http://dl.acm.org/citation.cfm?id=2629333] describes the approach: reduce 
n-dimensions to one using a space-filling curve, then store the column in a 
table. Calcite does not need to know about any specialized data structures like 
R-trees, and in fact if the table is sorted or range-partitioned on that column 
(as would be typical in HBase) then things should be just fine.

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1861) Spatial Indexes

2017-06-30 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16070472#comment-16070472
 ] 

Julian Hyde commented on CALCITE-1861:
--

In https://github.com/julianhyde/calcite/tree/1861-spatial I have added some 
library functions for mapping between co-ordinates and position on the Hilbert 
curve, based on http://ratml.org/misc/hilbert_curve.pdf. See also 
https://github.com/galtay/hilbert_curve.

> Spatial Indexes
> ---
>
> Key: CALCITE-1861
> URL: https://issues.apache.org/jira/browse/CALCITE-1861
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Atri Sharma
>Assignee: Julian Hyde
>
> Many Calcite users, like Phoenix and Flink can benefit from support of 
> Spatial indexes.
> See:
> http://revenant.ca/www/postgis/workshop/indexing.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)