
geotrellis.spark.io.LayerWriter.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of geotrellis-spark_2.10 Show documentation
Show all versions of geotrellis-spark_2.10 Show documentation
GeoTrellis is an open source geographic data processing engine for high performance applications.
The newest version!
package geotrellis.spark.io
import geotrellis.spark._
import geotrellis.spark.io.avro._
import geotrellis.spark.io.index._
import geotrellis.spark.io.json._
import geotrellis.util._
import org.apache.spark.rdd._
import spray.json._
import scala.reflect.ClassTag
trait LayerWriter[ID] {
val attributeStore: AttributeStore
protected def _write[
K: AvroRecordCodec: JsonFormat: ClassTag,
V: AvroRecordCodec: ClassTag,
M: JsonFormat: GetComponent[?, Bounds[K]]
](id: ID, layer: RDD[(K, V)] with Metadata[M], keyIndex: KeyIndex[K]): Unit
def write[
K: AvroRecordCodec: JsonFormat: ClassTag,
V: AvroRecordCodec: ClassTag,
M: JsonFormat: GetComponent[?, Bounds[K]]
](id: ID, layer: RDD[(K, V)] with Metadata[M], keyIndex: KeyIndex[K]): Unit =
layer.metadata.getComponent[Bounds[K]] match {
case keyBounds: KeyBounds[K] =>
_write[K, V, M](id, layer, keyIndex)
case EmptyBounds =>
throw new EmptyBoundsError("Cannot write layer with empty bounds.")
}
def write[
K: AvroRecordCodec: JsonFormat: ClassTag,
V: AvroRecordCodec: ClassTag,
M: JsonFormat: GetComponent[?, Bounds[K]]
](id: ID, layer: RDD[(K, V)] with Metadata[M], keyIndexMethod: KeyIndexMethod[K]): Unit =
layer.metadata.getComponent[Bounds[K]] match {
case keyBounds: KeyBounds[K] =>
val keyIndex = keyIndexMethod.createIndex(keyBounds)
_write[K, V, M](id, layer, keyIndex)
case EmptyBounds =>
throw new EmptyBoundsError("Cannot write layer with empty bounds.")
}
def writer[
K: AvroRecordCodec: JsonFormat: ClassTag,
V: AvroRecordCodec: ClassTag,
M: JsonFormat: GetComponent[?, Bounds[K]]
](keyIndexMethod: KeyIndexMethod[K]): Writer[ID, RDD[(K, V)] with Metadata[M]] =
new Writer[ID, RDD[(K, V)] with Metadata[M]] {
def write(id: ID, layer: RDD[(K, V)] with Metadata[M]) =
LayerWriter.this.write[K, V, M](id, layer, keyIndexMethod)
}
def writer[
K: AvroRecordCodec: JsonFormat: ClassTag,
V: AvroRecordCodec: ClassTag,
M: JsonFormat: GetComponent[?, Bounds[K]]
](keyIndex: KeyIndex[K]): Writer[ID, RDD[(K, V)] with Metadata[M]] =
new Writer[ID, RDD[(K, V)] with Metadata[M]] {
def write(id: ID, layer: RDD[(K, V)] with Metadata[M]) =
LayerWriter.this.write[K, V, M](id, layer, keyIndex)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy