[ 
https://issues.apache.org/jira/browse/SEDONA-502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17842541#comment-17842541
 ] 

Jia Yu commented on SEDONA-502:
-------------------------------

[~guanli] This is an expected behavior.

 

RangeQuery and KNNQuery are only supposed to be run on rawRDD or indexedRawRDD.

 

SpatialPartitioning will introduce duplicates in the result and is only 
supposed to be used by JoinQuery. JoinQuery has a deduplicate process.

> SpatialRDD's indexedRDD is not available in RangeQuery and KNNQuery
> -------------------------------------------------------------------
>
>                 Key: SEDONA-502
>                 URL: https://issues.apache.org/jira/browse/SEDONA-502
>             Project: Apache Sedona
>          Issue Type: Bug
>            Reporter: Guanli Liu
>            Priority: Major
>
> I encountered a problem while executing queries. I loaded a set of point 
> data, followed by partitioning and building an index on each partition. 
> However, when I performed range queries and KNN queries, errors occurred. 
> After inspecting the source code, I found that the reason was the 
> indexedRawRDD and indexedRDD.
>  
> When creating indexes on all partitions of a SpatialRDD object:
>  
> {code:java}
> // create quadtree partition
> point_rdd.spatialPartitioning(GridType.QUADTREE)
> // create rtree index
> point_rdd.buildIndex(IndexType.RTREE, True) {code}
>  
>  
> The following error message is shown:
>  
> {code:java}
> org.apache.sedona.core.spatialOperator.RangeQuery.SpatialRangeQuery.
> : java.lang.Exception: [RangeQuery][SpatialRangeQuery] Index doesn't exist. 
> Please build index on rawSpatialRDD 
> ...{code}
>  
>  
> The reason is when building an index on each partition of a SpatialRDD 
> object, indexedRDD should be used instead of indexedRawRDD (which is null). 
> indexedRawRDD can be used when building an index on rawSpatialRDD.
>  
> {code:java}
> // From Line 61 at org.apache.sedona.core.spatialOperator.RangeQuery.java
> if (useIndex == true) {
>     if (spatialRDD.indexedRawRDD == null) {
>         throw new Exception("[RangeQuery][SpatialRangeQuery] Index doesn't 
> exist. Please build index on rawSpatialRDD.");
>     }
>     return spatialRDD.indexedRawRDD.mapPartitions(new 
> RangeFilterUsingIndex(queryGeometry, spatialPredicate));
> }{code}
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to