Kimahriman commented on a change in pull request #515: URL: https://github.com/apache/incubator-sedona/pull/515#discussion_r598305765
########## 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: Also, if you index the map side I believe that would require loading all geometries per partition into memory at once, limiting the scalability and requiring a certain amount of executor memory based on your data. But indexing the broadcast side let's the map side be fully lazy and iterative, optimizing memory usage. -- 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]
