Guanli Liu created SEDONA-502:
---------------------------------
Summary: 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
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)