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

geotrellis.spark.testkit.package.scala Maven / Gradle / Ivy

Go to download

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

There is a newer version: 0.10.3
Show newest version
package geotrellis.spark

package object testkit {
  implicit class TestJavaSerialization[T](val t: T) {
    def serializeAndDeserialize(): T = {
      import java.io.ByteArrayInputStream
      import java.io.ByteArrayOutputStream
      import java.io.DataInputStream
      import java.io.DataOutputStream
      import java.io.ObjectInputStream
      import java.io.ObjectOutputStream

      val baos = new ByteArrayOutputStream()
      val oos = new ObjectOutputStream(baos)
      oos.writeObject(t)
      oos.close()

      val b = baos.toByteArray()
      val bais = new ByteArrayInputStream(b)
      val ois = new ObjectInputStream(bais)

      val actual = ois.readObject().asInstanceOf[T]
      ois.close()
      actual
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy