ProtobufOutputStreamOutput

fm.serializer.protobuf.ProtobufOutputStreamOutput
final class ProtobufOutputStreamOutput(var os: OutputStream) extends Output

Modified Protocol Buffers Output

The main difference between his and the stock Protocol Buffers Implementation is the handling of repeated fields. In this implementation:

  • We use ONLY packed repeated fields for collections (including non-numeric types)

The Stock Implementation:

  • Optionally uses packed repeated fields for numeric types

Attributes

Graph
Supertypes
trait Output
trait RawOutput
trait NestedOutput
trait FieldOutput
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def allowStringMap: Boolean
final def encodeZigZag32(n: Int): Int

Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers into values that can be efficiently encoded with varint. (Otherwise, negative values must be sign-extended to 64 bits to be varint encoded, thus always taking 10 bytes on the wire.)

Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers into values that can be efficiently encoded with varint. (Otherwise, negative values must be sign-extended to 64 bits to be varint encoded, thus always taking 10 bytes on the wire.)

Value parameters

n

A signed 32-bit integer.

Attributes

Returns

An unsigned 32-bit integer, stored in a signed int because Java has no explicit unsigned support.

final def encodeZigZag64(n: Long): Long

Encode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers into values that can be efficiently encoded with varint. (Otherwise, negative values must be sign-extended to 64 bits to be varint encoded, thus always taking 10 bytes on the wire.)

Encode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers into values that can be efficiently encoded with varint. (Otherwise, negative values must be sign-extended to 64 bits to be varint encoded, thus always taking 10 bytes on the wire.)

Value parameters

n

A signed 64-bit integer.

Attributes

Returns

An unsigned 64-bit integer, stored in a signed int because Java has no explicit unsigned support.

final def writeBoolNoTag(value: Boolean): Unit
final def writeBytesNoTag(value: Array[Byte]): Unit
final def writeDoubleNoTag(value: Double): Unit
final def writeFieldBigDecimal(number: Int, name: String, value: BigDecimal): Unit
final def writeFieldBigInteger(number: Int, name: String, value: BigInteger): Unit
final def writeFieldBool(number: Int, name: String, value: Boolean): Unit
final def writeFieldByteArray(number: Int, name: String, value: Array[Byte]): Unit
final def writeFieldCollection[T](number: Int, name: String, col: T)(f: (NestedOutput, T) => Unit): Unit
final def writeFieldDouble(number: Int, name: String, value: Double): Unit
final def writeFieldFixedInt(number: Int, name: String, value: Int): Unit
final def writeFieldFixedLong(number: Int, name: String, value: Long): Unit
final def writeFieldFloat(number: Int, name: String, value: Float): Unit
final def writeFieldInt(number: Int, name: String, value: Int): Unit
final def writeFieldLengthDelimitedObject[T](number: Int, name: String, obj: T)(f: (FieldOutput, T) => Unit): Unit
final def writeFieldLong(number: Int, name: String, value: Long): Unit
def writeFieldNull(number: Int, name: String): Unit
final def writeFieldObject[T](number: Int, name: String, obj: T)(f: (FieldOutput, T) => Unit): Unit
final def writeFieldSignedInt(number: Int, name: String, value: Int): Unit
final def writeFieldSignedLong(number: Int, name: String, value: Long): Unit
final def writeFieldString(number: Int, name: String, value: String): Unit
final def writeFieldUnsignedInt(number: Int, name: String, value: Int): Unit
final def writeFieldUnsignedLong(number: Int, name: String, value: Long): Unit
final def writeFixed32NoTag(value: Int): Unit
final def writeFixed64NoTag(value: Long): Unit
final def writeFloatNoTag(value: Float): Unit
final def writeInt32NoTag(value: Int): Unit
final def writeInt64NoTag(value: Long): Unit
final def writeLengthDelimited[T](obj: T)(f: (Output, T) => Unit): Unit
final def writeLengthDelimitedNull(): Unit

Note: This is a very inefficient way to encode null (it takes 10 bytes!!!) but it should be a very rare case since we have a separate encoding for null fields that will be used the majority of the time.

Note: This is a very inefficient way to encode null (it takes 10 bytes!!!) but it should be a very rare case since we have a separate encoding for null fields that will be used the majority of the time.

The only time this should get called is for null values within a collection or nested collection which is hopefully a rare case.

e.g. List("1","2",null,"4") or List(List("1","2"), List(null, null), List("5","6"))

Attributes

final def writeMessageNoTag[T](obj: T)(f: (Output, T) => Unit): Unit
final def writeNestedBigDecimal(value: BigDecimal): Unit
final def writeNestedBigInteger(value: BigInteger): Unit
final def writeNestedBool(value: Boolean): Unit
final def writeNestedByteArray(value: Array[Byte]): Unit
final def writeNestedCollection[T](col: T)(f: (NestedOutput, T) => Unit): Unit
final def writeNestedDouble(value: Double): Unit
final def writeNestedFixedInt(value: Int): Unit
final def writeNestedFixedLong(value: Long): Unit
final def writeNestedFloat(value: Float): Unit
final def writeNestedInt(value: Int): Unit
final def writeNestedLong(value: Long): Unit
final def writeNestedObject[T](obj: T)(f: (FieldOutput, T) => Unit): Unit
final def writeNestedSignedInt(value: Int): Unit
final def writeNestedSignedLong(value: Long): Unit
final def writeNestedString(value: String): Unit
final def writeNestedUnsignedInt(value: Int): Unit
final def writeNestedUnsignedLong(value: Long): Unit
final def writeRawBigDecimal(value: BigDecimal): Unit
final def writeRawBigEndian32(value: Int): Unit

Write a big-endian 32-bit integer.

Write a big-endian 32-bit integer.

Attributes

final def writeRawBigEndian64(value: Long): Unit

Write a big-endian 64-bit integer.

Write a big-endian 64-bit integer.

Attributes

final def writeRawBigInteger(value: BigInteger): Unit
final def writeRawBool(value: Boolean): Unit
final def writeRawByteArray(value: Array[Byte]): Unit
final def writeRawCollection[T](col: T)(f: (NestedOutput, T) => Unit): Unit

Write out a RAW collection. This method will wrap the collection in whatever leading/trailing "stuff" is needed (e.g. length prefixing, leading/trailing chars, etc...). The method that you pass in should use the Output instance to make repeated calls to a single write

Write out a RAW collection. This method will wrap the collection in whatever leading/trailing "stuff" is needed (e.g. length prefixing, leading/trailing chars, etc...). The method that you pass in should use the Output instance to make repeated calls to a single write

Attributes

final def writeRawDouble(value: Double): Unit
final def writeRawFixedInt(value: Int): Unit
final def writeRawFixedLong(value: Long): Unit
final def writeRawFloat(value: Float): Unit
final def writeRawInt(value: Int): Unit
final def writeRawLittleEndian32(value: Int): Unit

Write a little-endian 32-bit integer.

Write a little-endian 32-bit integer.

Attributes

final def writeRawLittleEndian64(value: Long): Unit

Write a little-endian 64-bit integer.

Write a little-endian 64-bit integer.

Attributes

final def writeRawLong(value: Long): Unit
final def writeRawObject[T](obj: T)(f: (FieldOutput, T) => Unit): Unit

For writing objects. Note: that the obj is passed in for null handling by the implementation. If the object is not null then the function f will be called so the caller can write out the fields

For writing objects. Note: that the obj is passed in for null handling by the implementation. If the object is not null then the function f will be called so the caller can write out the fields

Attributes

final def writeRawSignedInt(value: Int): Unit
final def writeRawSignedLong(value: Long): Unit
final def writeRawString(value: String): Unit
final def writeRawUnsignedInt(value: Int): Unit
final def writeRawUnsignedLong(value: Long): Unit
final def writeRawVarint32(value: Int): Unit

Encode and write a varint. value is treated as unsigned, so it won't be sign-extended if negative.

Encode and write a varint. value is treated as unsigned, so it won't be sign-extended if negative.

Attributes

final def writeRawVarint64(value: Long): Unit

Encode and write a varint.

Encode and write a varint.

Attributes

final def writeSInt32NoTag(value: Int): Unit
final def writeSInt64NoTag(value: Long): Unit
final def writeStringNoTag(value: String): Unit
final def writeTag(number: Int, wireType: Int): Unit

Encode and write a tag.

Encode and write a tag.

Attributes

final def writeUInt32NoTag(value: Int): Unit
final def writeUInt64NoTag(value: Long): Unit