Class/Object

org.coursera.naptime.courier

StringKeyCodec

Related Docs: object StringKeyCodec | package courier

Permalink

class StringKeyCodec extends DataCodec

Intended for Legacy support only!

This should only be used where compatibility with StringKeyFormat is required, for all other uses, please see the more flexible InlineStringCodec.

Provides an codec for Pegasus data that is compatible with StringKeyFormat.

While this codec encodes data in the same format as StringKeyFormat, it is designed to be used with Courier, not with Play JSON Formats.

Limitations: - The pegasus bytes type is not supported, consider base64 encoding to a string instead - The pegasus union type is not supported, please migrate to InlineStringCodec if needed - The pegasus map type is not supported, please migrate to InlineStringCodec if needed - Records containing optional fields are not allowed

This codec is "schema aided", meaning that the correct Pegasus schema is required to serialize or deserialize data, even to the raw DataMap and DataList types. This is because the order and names of record fields, defined in the schema, must be used by the codec to correctly serialize/deserialize to StringKeyFormat tuples.

The important type relations are:

StringKeyFormat type | Pegasus raw type | Pegasus schema type | Scala type ---------------------|------------------|---------------------|---------------------------------- Tuple | DataMap | record | case class <TypeName> Seq | DataList | array | <ItemName>Array extends IndexedSeq[T]

The "Tuple" encoding --------------------

- Example: [email protected] - JSON Equivalent: { "email": "[email protected]", "message": "Greetings", "recipient": "John"} - Reserved chars: !~ - Escape char: !

StringKeyFormat tuples are positionally ordered. The order of the tuple values must match the order of fields in a pegasus record. E.g. the pegasus record:

{
  "name": "...",
  "type": "record",
  "fields": [
    { "name": "message", "type": "..." },
    { "name": "recipient", "type": "..." },
    { "name": "email", "type": "..." }
  ]
}

Would be required for the above tuple example.

An empty string is parsed to a tuple of size 1 containing a single empty string.

The "Seq" encoding ------------------

- Example: one~two~three - JSON Equivalent: [ "one", "two", "three" ] - Reserved chars: !, - Escape char: !

An empty string is parsed to an empty Seq.

Linear Supertypes
DataCodec, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. StringKeyCodec
  2. DataCodec
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Instance Constructors

  1. new StringKeyCodec(schema: DataSchema, prefix: Option[String] = None)

    Permalink

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 bytesToList(bytes: Array[Byte]): DataList

    Permalink
    Definition Classes
    StringKeyCodec → DataCodec
  6. def bytesToMap(bytes: Array[Byte]): DataMap

    Permalink
    Definition Classes
    StringKeyCodec → DataCodec
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  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 listToBytes(dataList: DataList): Array[Byte]

    Permalink
    Definition Classes
    StringKeyCodec → DataCodec
  15. def mapToBytes(dataMap: DataMap): Array[Byte]

    Permalink
    Definition Classes
    StringKeyCodec → DataCodec
  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. def readList(inputStream: InputStream): DataList

    Permalink
    Definition Classes
    StringKeyCodec → DataCodec
  20. def readMap(inputStream: InputStream): DataMap

    Permalink
    Definition Classes
    StringKeyCodec → DataCodec
  21. final def synchronized[T0](arg0: ⇒ T0): T0

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

    Permalink
    Definition Classes
    AnyRef → Any
  23. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. def writeList(dataList: DataList, outputStream: OutputStream): Unit

    Permalink
    Definition Classes
    StringKeyCodec → DataCodec
  27. def writeMap(dataMap: DataMap, outputStream: OutputStream): Unit

    Permalink
    Definition Classes
    StringKeyCodec → DataCodec

Inherited from DataCodec

Inherited from AnyRef

Inherited from Any

Ungrouped