Skip to content

Commit

Permalink
Merge pull request #1719 from lossyrob/refactor/TileRDDMethods
Browse files Browse the repository at this point in the history
Moved TileRDDMethods to private in geotrellis.spark.mapalgebra.local
  • Loading branch information
echeipesh authored Oct 28, 2016
2 parents 934bdcf + 7752991 commit f1c58f9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package geotrellis.spark.mapalgebra.local

import scala.reflect.ClassTag
import geotrellis.raster.Tile
import geotrellis.util.MethodExtensions
import org.apache.spark.rdd.RDD

/** Trait that defines a Methods class as an RDD[(K, Tile)] MethodsExtensions
* having a ClassTag for K. This trait is used in the local mapalgebra case
* because we have traits that stack onto the eventual implicit Methods class
* for local operations. This breaks from the usual pattern of
* marking a Methods trait as an abstract class if it needs context bounds like
* ClassTag.
*/
private[local] trait TileRDDMethods[K] extends MethodExtensions[RDD[(K, Tile)]] {
implicit val keyClassTag: ClassTag[K]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package geotrellis.spark.mapalgebra.zonal
import geotrellis.raster.mapalgebra.zonal._
import geotrellis.raster.histogram._
import geotrellis.raster._

import geotrellis.spark._
import geotrellis.spark.mapalgebra._
import geotrellis.util.MethodExtensions

import org.apache.spark.Partitioner
import org.apache.spark.rdd._

trait ZonalTileRDDMethods[K] extends TileRDDMethods[K] {
import scala.reflect.ClassTag

abstract class ZonalTileRDDMethods[K: ClassTag] extends MethodExtensions[RDD[(K, Tile)]] {
def zonalHistogram(zonesTileRdd: RDD[(K, Tile)], partitioner: Option[Partitioner] = None): Map[Int, Histogram[Int]] =
Zonal.histogram(self, zonesTileRdd, partitioner)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package geotrellis.spark.summary

import geotrellis.raster._
import geotrellis.raster.histogram._
import geotrellis.spark.mapalgebra._
import geotrellis.util.MethodExtensions

trait StatsTileCollectionMethods[K] extends TileCollectionMethods[K] {
trait StatsTileCollectionMethods[K] extends MethodExtensions[Seq[(K, Tile)]] {

def averageByKey(): Seq[(K, Tile)] =
self.groupBy(_._1).mapValues { seq => seq.map(_._2).reduce(_ + _) / seq.size } toSeq
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import geotrellis.raster.histogram._
import geotrellis.raster.mapalgebra.local._
import geotrellis.raster.summary._
import geotrellis.spark._
import geotrellis.spark.mapalgebra._
import geotrellis.util.MethodExtensions

import org.apache.spark.Partitioner
import org.apache.spark.rdd.RDD
import org.apache.spark.SparkContext._

import scala.reflect.ClassTag

trait StatsTileRDDMethods[K] extends TileRDDMethods[K] {
abstract class StatsTileRDDMethods[K: ClassTag] extends MethodExtensions[RDD[(K, Tile)]] {

def averageByKey(partitioner: Option[Partitioner] = None): RDD[(K, Tile)] = {
val createCombiner = (tile: Tile) => tile -> 1
Expand Down

0 comments on commit f1c58f9

Please sign in to comment.