Trait

com.spotify.scio.coders

CoderGrammar

Related Doc: package coders

Permalink

sealed trait CoderGrammar extends AnyRef

Coder Grammar is used to explicitly specify Coder derivation for types used in pipelines.

The CoderGrammar can be used as follows: - To find the Coder being implicitly derived by Scio. (Debugging)

def c: Coder[MyType] = Coder[MyType]

- To generate an implicit instance to be in scope for type T, use Coder.gen

implicit def coderT: Coder[T] = Coder.gen[T]

Note: Implicit Coders for all parameters of the constructor of type T should be in scope for Coder.gen to be able to derive the Coder.

- To define a Coder of custom type, where the type can be mapped to some other type for which a Coder is known, use Coder.xmap

- To explicitly use kryo Coder use Coder.kryo

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CoderGrammar
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def beam[T](beam: org.apache.beam.sdk.coders.Coder[T]): Coder[T]

    Permalink

    Create a ScioCoder from a Beam Coder

  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def disjunction[T, Id](typeName: String, coder: Map[Id, Coder[T]])(id: (T) ⇒ Id)(implicit arg0: Coder[Id]): Coder[T]

    Permalink
  8. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  12. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  13. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  14. def kryo[T](implicit ct: ClassTag[T]): Coder[T]

    Permalink

    Create an instance of Kryo Coder for a given Type.

    Create an instance of Kryo Coder for a given Type.

    Eg: A kryo Coder for org.joda.time.Interval would look like:

    implicit def jiKryo: Coder[Interval] = Coder.kryo[Interval]
  15. def kv[K, V](koder: Coder[K], voder: Coder[V]): Coder[KV[K, V]]

    Permalink
  16. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  20. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  21. def transform[A, B](c: Coder[A])(f: (org.apache.beam.sdk.coders.Coder[A]) ⇒ Coder[B]): Coder[B]

    Permalink
  22. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. def xmap[A, B](c: Coder[A])(f: (A) ⇒ B, t: (B) ⇒ A): Coder[B]

    Permalink

    Given a Coder[A], create a Coder[B] by defining two functions A => B and B => A.

    Given a Coder[A], create a Coder[B] by defining two functions A => B and B => A. The Coder[A] can be resolved implicitly by calling Coder[A]

    Eg: Coder for org.joda.time.Interval can be defined by having the following implicit in scope. Without this implicit in scope Coder derivation falls back to Kryo.

    implicit def jiCoder: Coder[Interval] =
      Coder.xmap(Coder[(Long, Long)])(t => new Interval(t._1, t._2),
         i => (i.getStartMillis, i.getEndMillis))

    In the above example we implicitly derive Coder[(Long, Long)] and we define two functions, one to convert a tuple (Long, Long) to Interval, and a second one to convert an Interval to a tuple of (Long, Long)

Inherited from AnyRef

Inherited from Any

Ungrouped