Kimahriman commented on a change in pull request #515: URL: https://github.com/apache/incubator-sedona/pull/515#discussion_r598281857
########## File path: sql/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/SpatialIndexExec.scala ########## @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.spark.sql.sedona_sql.strategy.join + +import scala.collection.JavaConverters._ + +import org.apache.sedona.core.enums.IndexType +import org.apache.spark.broadcast.Broadcast +import org.apache.spark.internal.Logging +import org.apache.spark.rdd.RDD +import org.apache.spark.sql.catalyst.InternalRow +import org.apache.spark.sql.catalyst.expressions.{Attribute, BindReferences, Expression, UnsafeRow} +import org.apache.spark.sql.execution.{SparkPlan, UnaryExecNode} + + + +case class SpatialIndexExec(child: SparkPlan, + shape: Expression, + indexType: IndexType) + extends UnaryExecNode + with TraitJoinQueryBase + with Logging { + + override def output: Seq[Attribute] = child.output + + override protected def doExecute(): RDD[InternalRow] = { + throw new UnsupportedOperationException( + "SpatialIndex does not support the execute() code path.") + } + + override protected[sql] def doExecuteBroadcast[T](): Broadcast[T] = { + val boundShape = BindReferences.bindReference(shape, child.output) Review comment: Yeah I guess that's why I thought it made sense to build the index on the broadcast sided. For one, you only have to do it once and can reuse the same index on all partitions. But I guess that main question is (that I have no idea the answer to): is it faster to build an index on N geometries or query N geometries against an existing index? I assumed the second one, but haven't actually tried the first. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
