paleolimbot commented on code in PR #1751:
URL: https://github.com/apache/sedona/pull/1751#discussion_r1924483894
##########
spark/common/src/main/java/org/apache/sedona/core/spatialRDD/SpatialRDD.java:
##########
@@ -326,6 +327,25 @@ public void remove() {
true);
}
+ public JavaPairRDD<Integer, T> spatialPartitioningWithIds(GridType gridType,
int numPartitions)
+ throws Exception {
+ calc_partitioner(gridType, numPartitions);
+ return spatialPartitioningWithIds(partitioner);
+ }
+
+ public JavaPairRDD<Integer, T> spatialPartitioningWithIds(final
SpatialPartitioner partitioner) {
+ this.partitioner = partitioner;
+ return this.rawSpatialRDD
+ .flatMapToPair(
+ new PairFlatMapFunction<T, Integer, T>() {
+ @Override
+ public Iterator<Tuple2<Integer, T>> call(T spatialObject) throws
Exception {
+ return partitioner.placeObject(spatialObject);
+ }
+ })
+ .partitionBy(partitioner);
+ }
+
Review Comment:
This is probably not needed (the changes in the `Adapter` to preserve the
partitioning of `spatialPartitionedRDD` into the output data frame should
eliminate the need to keep any identifier alongside the partition).
##########
spark/common/src/main/scala/org/apache/sedona/sql/utils/Adapter.scala:
##########
@@ -162,10 +162,14 @@ object Adapter {
spatialRDD: SpatialRDD[T],
schema: StructType,
sparkSession: SparkSession): DataFrame = {
- val rdd = spatialRDD.rawSpatialRDD.rdd.map[Row](geom => {
- val stringRow = extractUserData(geom)
- castRowToSchema(stringRow = stringRow, schema = schema)
- })
+ val rdd = spatialRDD.rawSpatialRDD.rdd.mapPartitions(
Review Comment:
(But moved to a different overload since most of the time this will
introduce duplicates)
```suggestion
val rdd = spatialRDD.spatialPartitionedRDD.rdd.mapPartitions(
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]