All Downloads are FREE. Search and download functionalities are using the official Maven repository.

geotrellis.spark.io.avro.AvroRecordCodec.scala Maven / Gradle / Ivy

Go to download

GeoTrellis is an open source geographic data processing engine for high performance applications.

The newest version!
package geotrellis.spark.io.avro

import org.apache.avro.generic._
import org.apache.avro._
import scala.annotation.implicitNotFound
import scala.reflect.ClassTag

@implicitNotFound("Cannot find AvroRecordCodec for ${T}. Try to import geotrellis.spark.io.avro.codecs.Implicits._")
abstract class AvroRecordCodec[T: ClassTag] extends AvroCodec[T, GenericRecord] {
  def schema: Schema
  def encode(thing: T, rec: GenericRecord)
  def decode(rec: GenericRecord): T

  def encode(thing: T): GenericRecord = {
    val rec = new GenericData.Record(schema)
    encode(thing, rec)
    rec
  }

  def supported[O](other: O): Boolean = {
    implicitly[ClassTag[T]].unapply(other).isDefined
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy