-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #616 from jbouffard/improvement/partitioner
Partition Strategies and Preservation
- Loading branch information
Showing
21 changed files
with
724 additions
and
196 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
geopyspark-backend/geotrellis/src/main/scala/geopyspark/geotrellis/PartitionStrategy.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package geopyspark.geotrellis | ||
|
||
import org.apache.spark._ | ||
|
||
|
||
abstract class PartitionStrategy(numPartitions: Option[Int]) { | ||
def producePartitioner(partitions: Int): Option[Partitioner] | ||
} | ||
|
||
|
||
class HashPartitionStrategy(val numPartitions: Option[Int]) extends PartitionStrategy(numPartitions) { | ||
def producePartitioner(partitions: Int): Option[Partitioner] = | ||
numPartitions match { | ||
case None => Some(new HashPartitioner(partitions)) | ||
case Some(num) => Some(new HashPartitioner(num)) | ||
} | ||
} | ||
|
||
object HashPartitionStrategy { | ||
def apply(numPartitions: Integer): HashPartitionStrategy = | ||
numPartitions match { | ||
case i: Integer => new HashPartitionStrategy(Some(i.toInt)) | ||
case null => new HashPartitionStrategy(None) | ||
} | ||
} | ||
|
||
|
||
class SpatialPartitionStrategy(val numPartitions: Option[Int], val bits: Int) extends PartitionStrategy(numPartitions) { | ||
def producePartitioner(partitions: Int): Option[Partitioner] = | ||
numPartitions match { | ||
case None => Some(SpatialPartitioner(partitions, bits)) | ||
case Some(num) => Some(SpatialPartitioner(num, bits)) | ||
} | ||
} | ||
|
||
object SpatialPartitionStrategy { | ||
def apply(numPartitions: Integer, bits: Int): SpatialPartitionStrategy = | ||
numPartitions match { | ||
case i: Integer => new SpatialPartitionStrategy(Some(i.toInt), bits) | ||
case null => new SpatialPartitionStrategy(None, bits) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.