@@ -307,7 +307,9 @@ object PointLuceneRDD extends Versionable
307307 similarity : String )
308308 (implicit docConverter : V => Document )
309309 : PointLuceneRDD [V ] = {
310- val partitions = elems.mapPartitions[AbstractPointLuceneRDDPartition [V ]](
310+ val partitions = elems
311+ .sortBy(item => item._1._1) // Sort by x-axis
312+ .mapPartitions[AbstractPointLuceneRDDPartition [V ]](
311313 iter => Iterator (PointLuceneRDDPartition [V ](iter, indexAnalyzer, queryAnalyzer)),
312314 preservesPartitioning = true )
313315 new PointLuceneRDD (partitions, indexAnalyzer, queryAnalyzer, similarity)
@@ -329,9 +331,11 @@ object PointLuceneRDD extends Versionable
329331 similarity : String )
330332 (implicit docConverter : V => Document )
331333 : PointLuceneRDD [V ] = {
332- val partitions = elems.rdd.mapPartitions[AbstractPointLuceneRDDPartition [V ]](
333- iter => Iterator (PointLuceneRDDPartition [V ](iter, indexAnalyzer, queryAnalyzer)),
334- preservesPartitioning = true )
334+ val partitions = elems.rdd
335+ .sortBy(item => item._1._1) // Sort by x-axis
336+ .mapPartitions[AbstractPointLuceneRDDPartition [V ]](
337+ iter => Iterator (PointLuceneRDDPartition [V ](iter, indexAnalyzer, queryAnalyzer)),
338+ preservesPartitioning = true )
335339 new PointLuceneRDD (partitions, indexAnalyzer, queryAnalyzer, similarity)
336340 }
337341
@@ -355,13 +359,13 @@ object PointLuceneRDD extends Versionable
355359 * val lucene = ShapeLuceneRDD(counties, "shape")
356360 *
357361 * }}
358- * @param df Input dataframe containing Shape as String field named "shapeField"
362+ * @param df Input DataFrame containing Shape as String field named "shapeField"
359363 * @param shapeField Name of DataFrame column that contains Shape as String, i.e., WKT
360- * @param shapeConv Implicit convertion for spatial / shape
364+ * @param shapeConv Implicit conversion for spatial / shape
361365 * @param docConverter Implicit conversion for Lucene Document
362366 * @return
363367 */
364- def apply (df : DataFrame ,
368+ def apply (df : DataFrame ,
365369 shapeField : String )
366370 (implicit shapeConv : String => PointType , docConverter : Row => Document )
367371 : PointLuceneRDD [Row ] = {
@@ -371,14 +375,15 @@ object PointLuceneRDD extends Versionable
371375 }
372376
373377
374- def apply (df : DataFrame ,
378+ def apply (df : DataFrame ,
375379 shapeField : String ,
376380 indexAnalyzer : String ,
377381 queryAnalyzer : String ,
378382 similarity : String )
379- (implicit shapeConv : String => PointType , docConverter : Row => Document )
383+ (implicit shapeConv : String => PointType , docConverter : Row => Document )
380384 : PointLuceneRDD [Row ] = {
381385 val partitions = df.rdd.map(row => (shapeConv(row.getString(row.fieldIndex(shapeField))), row))
386+ .sortBy(item => item._1._1) // Sort by x-axis
382387 .mapPartitions[AbstractPointLuceneRDDPartition [Row ]](
383388 iter => Iterator (PointLuceneRDDPartition [Row ](iter, indexAnalyzer, queryAnalyzer)),
384389 preservesPartitioning = true )
0 commit comments