Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Generated by Scrooge
* version: 20.4.1
* rev: 74d6bed636c90dc4b67e342ecd80033bad43e94d
* built at: 20200425-214521
*/
package com.twitter.finagle.thrift.thriftscala
import com.twitter.io.Buf
import com.twitter.scrooge.{
InvalidFieldsException,
LazyTProtocol,
StructBuilder,
StructBuilderFactory,
TFieldBlob,
ThriftStruct,
ThriftStructCodec3,
ThriftStructField,
ThriftStructFieldInfo,
ThriftStructMetaData,
ValidatingThriftStruct,
ValidatingThriftStructCodec3
}
import org.apache.thrift.protocol._
import org.apache.thrift.transport.TMemoryBuffer
import scala.collection.immutable.{Map => immutable$Map}
import scala.collection.mutable.Builder
import scala.reflect.{ClassTag, classTag}
/**
* An annotation is similar to a log statement. It includes a host field which
* allows these events to be attributed properly, and also aggregatable.
*/
object Annotation extends ValidatingThriftStructCodec3[Annotation] with StructBuilderFactory[Annotation] {
val NoPassthroughFields: immutable$Map[Short, TFieldBlob] = immutable$Map.empty[Short, TFieldBlob]
val Struct: TStruct = new TStruct("Annotation")
val TimestampField: TField = new TField("timestamp", TType.I64, 1)
val TimestampFieldManifest: Manifest[Long] = manifest[Long]
val ValueField: TField = new TField("value", TType.STRING, 2)
val ValueFieldManifest: Manifest[String] = manifest[String]
val HostField: TField = new TField("host", TType.STRUCT, 3)
val HostFieldManifest: Manifest[com.twitter.finagle.thrift.thriftscala.Endpoint] = manifest[com.twitter.finagle.thrift.thriftscala.Endpoint]
/**
* Field information in declaration order.
*/
lazy val fieldInfos: scala.List[ThriftStructFieldInfo] = scala.List[ThriftStructFieldInfo](
new ThriftStructFieldInfo(
TimestampField,
false,
false,
TimestampFieldManifest,
_root_.scala.None,
_root_.scala.None,
immutable$Map.empty[String, String],
immutable$Map.empty[String, String],
None
),
new ThriftStructFieldInfo(
ValueField,
false,
false,
ValueFieldManifest,
_root_.scala.None,
_root_.scala.None,
immutable$Map.empty[String, String],
immutable$Map.empty[String, String],
None
),
new ThriftStructFieldInfo(
HostField,
true,
false,
HostFieldManifest,
_root_.scala.None,
_root_.scala.None,
immutable$Map.empty[String, String],
immutable$Map.empty[String, String],
None
)
)
val structAnnotations: immutable$Map[String, String] =
immutable$Map.empty[String, String]
private val fieldTypes: IndexedSeq[ClassTag[_]] = IndexedSeq[ClassTag[_]](
classTag[Long].asInstanceOf[ClassTag[_]],
classTag[String].asInstanceOf[ClassTag[_]],
classTag[_root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint]].asInstanceOf[ClassTag[_]]
)
private[this] val structFields: Seq[ThriftStructField[Annotation]] = Seq[ThriftStructField[Annotation]](
new ThriftStructField[Annotation](
TimestampField,
_root_.scala.Some(TimestampFieldManifest),
classOf[Annotation]) {
def getValue[R](struct: Annotation): R = struct.timestamp.asInstanceOf[R]
},
new ThriftStructField[Annotation](
ValueField,
_root_.scala.Some(ValueFieldManifest),
classOf[Annotation]) {
def getValue[R](struct: Annotation): R = struct.value.asInstanceOf[R]
},
new ThriftStructField[Annotation](
HostField,
_root_.scala.Some(HostFieldManifest),
classOf[Annotation]) {
def getValue[R](struct: Annotation): R = struct.host.asInstanceOf[R]
}
)
override lazy val metaData: ThriftStructMetaData[Annotation] =
new ThriftStructMetaData(this, structFields, fieldInfos, Nil, structAnnotations)
/**
* Checks that all required fields are non-null.
*/
def validate(_item: Annotation): Unit = {
}
/**
* Checks that the struct is a valid as a new instance. If there are any missing required or
* construction required fields, return a non-empty list.
*/
def validateNewInstance(item: Annotation): scala.Seq[com.twitter.scrooge.validation.Issue] = {
val buf = scala.collection.mutable.ListBuffer.empty[com.twitter.scrooge.validation.Issue]
buf ++= validateField(item.timestamp)
buf ++= validateField(item.value)
buf ++= validateField(item.host)
buf.toList
}
def withoutPassthroughFields(original: Annotation): Annotation =
new Immutable(
timestamp = original.timestamp,
value = original.value,
host =
{
val field = original.host
field.map { field =>
com.twitter.finagle.thrift.thriftscala.Endpoint.withoutPassthroughFields(field)
}
}
)
def newBuilder(): StructBuilder[Annotation] = new AnnotationStructBuilder(_root_.scala.None, fieldTypes)
override def encode(_item: Annotation, _oproto: TProtocol): Unit = {
_item.write(_oproto)
}
private[this] def lazyDecode(_iprot: LazyTProtocol): Annotation = {
var timestamp: Long = 0L
var valueOffset: Int = -1
var host: Option[com.twitter.finagle.thrift.thriftscala.Endpoint] = None
var _passthroughFields: Builder[(Short, TFieldBlob), immutable$Map[Short, TFieldBlob]] = null
var _done = false
val _start_offset = _iprot.offset
_iprot.readStructBegin()
do {
val _field = _iprot.readFieldBegin()
val _fieldType = _field.`type`
if (_fieldType == TType.STOP) {
_done = true
} else {
_field.id match {
case 1 =>
if (_fieldType == TType.I64) {
timestamp = readTimestampValue(_iprot)
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'timestamp' (expected=%s, actual=%s).",
TType.I64,
_fieldType
)
}
case 2 =>
if (_fieldType == TType.STRING) {
valueOffset = _iprot.offsetSkipString()
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'value' (expected=%s, actual=%s).",
TType.STRING,
_fieldType
)
}
case 3 =>
if (_fieldType == TType.STRUCT) {
host = Some(readHostValue(_iprot))
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'host' (expected=%s, actual=%s).",
TType.STRUCT,
_fieldType
)
}
case _ =>
if (_passthroughFields eq null)
_passthroughFields = immutable$Map.newBuilder[Short, TFieldBlob]
_passthroughFields += _root_.scala.Tuple2(_field.id, TFieldBlob.read(_field, _iprot))
}
_iprot.readFieldEnd()
}
} while (!_done)
_iprot.readStructEnd()
new LazyImmutable(
_iprot,
_iprot.buffer,
_start_offset,
_iprot.offset,
timestamp,
valueOffset,
host,
if (_passthroughFields eq null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
override def decode(_iprot: TProtocol): Annotation = {
if (_iprot.isInstanceOf[LazyTProtocol]) {
lazyDecode(_iprot.asInstanceOf[LazyTProtocol])
} else {
eagerDecode(_iprot)
}
}
private[thriftscala] def eagerDecode(_iprot: TProtocol): Annotation = {
var timestamp: Long = 0L
var value: String = null
var host: _root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint] = _root_.scala.None
var _passthroughFields: Builder[(Short, TFieldBlob), immutable$Map[Short, TFieldBlob]] = null
var _done = false
_iprot.readStructBegin()
do {
val _field = _iprot.readFieldBegin()
val _fieldType = _field.`type`
if (_fieldType == TType.STOP) {
_done = true
} else {
_field.id match {
case 1 =>
if (_fieldType == TType.I64) {
timestamp = readTimestampValue(_iprot)
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'timestamp' (expected=%s, actual=%s).",
TType.I64,
_fieldType
)
}
case 2 =>
if (_fieldType == TType.STRING) {
value = readValueValue(_iprot)
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'value' (expected=%s, actual=%s).",
TType.STRING,
_fieldType
)
}
case 3 =>
if (_fieldType == TType.STRUCT) {
host = _root_.scala.Some(readHostValue(_iprot))
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'host' (expected=%s, actual=%s).",
TType.STRUCT,
_fieldType
)
}
case _ =>
if (_passthroughFields eq null)
_passthroughFields = immutable$Map.newBuilder[Short, TFieldBlob]
_passthroughFields += _root_.scala.Tuple2(_field.id, TFieldBlob.read(_field, _iprot))
}
_iprot.readFieldEnd()
}
} while (!_done)
_iprot.readStructEnd()
new Immutable(
timestamp,
value,
host,
if (_passthroughFields eq null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
def apply(
timestamp: Long,
value: String,
host: _root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint] = _root_.scala.None
): Annotation =
new Immutable(
timestamp,
value,
host
)
def unapply(_item: Annotation): _root_.scala.Option[_root_.scala.Tuple3[Long, String, Option[com.twitter.finagle.thrift.thriftscala.Endpoint]]] = _root_.scala.Some(_item.toTuple)
@inline private[thriftscala] def readTimestampValue(_iprot: TProtocol): Long = {
_iprot.readI64()
}
@inline private def writeTimestampField(timestamp_item: Long, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(TimestampField)
writeTimestampValue(timestamp_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeTimestampValue(timestamp_item: Long, _oprot: TProtocol): Unit = {
_oprot.writeI64(timestamp_item)
}
@inline private[thriftscala] def readValueValue(_iprot: TProtocol): String = {
_iprot.readString()
}
@inline private def writeValueField(value_item: String, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(ValueField)
writeValueValue(value_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeValueValue(value_item: String, _oprot: TProtocol): Unit = {
_oprot.writeString(value_item)
}
@inline private[thriftscala] def readHostValue(_iprot: TProtocol): com.twitter.finagle.thrift.thriftscala.Endpoint = {
com.twitter.finagle.thrift.thriftscala.Endpoint.decode(_iprot)
}
@inline private def writeHostField(host_item: com.twitter.finagle.thrift.thriftscala.Endpoint, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(HostField)
writeHostValue(host_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeHostValue(host_item: com.twitter.finagle.thrift.thriftscala.Endpoint, _oprot: TProtocol): Unit = {
host_item.write(_oprot)
}
object Immutable extends ThriftStructCodec3[Annotation] {
override def encode(_item: Annotation, _oproto: TProtocol): Unit = { _item.write(_oproto) }
override def decode(_iprot: TProtocol): Annotation = Annotation.decode(_iprot)
override lazy val metaData: ThriftStructMetaData[Annotation] = Annotation.metaData
}
/**
* The default read-only implementation of Annotation. You typically should not need to
* directly reference this class; instead, use the Annotation.apply method to construct
* new instances.
*/
class Immutable(
val timestamp: Long,
val value: String,
val host: _root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint],
override val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends Annotation {
def this(
timestamp: Long,
value: String,
host: _root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint] = _root_.scala.None
) = this(
timestamp,
value,
host,
immutable$Map.empty[Short, TFieldBlob]
)
}
/**
* This is another Immutable, this however keeps strings as lazy values that are lazily decoded from the backing
* array byte on read.
*/
private[this] class LazyImmutable(
_proto: LazyTProtocol,
_buf: Array[Byte],
_start_offset: Int,
_end_offset: Int,
val timestamp: Long,
valueOffset: Int,
val host: _root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint],
override val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends Annotation {
override def write(_oprot: TProtocol): Unit = {
if (_oprot.isInstanceOf[LazyTProtocol]) {
_oprot.asInstanceOf[LazyTProtocol].writeRaw(_buf, _start_offset, _end_offset - _start_offset)
} else {
super.write(_oprot)
}
}
lazy val value: String =
if (valueOffset == -1)
null
else {
_proto.decodeString(_buf, valueOffset)
}
/**
* Override the super hash code to make it a lazy val rather than def.
*
* Calculating the hash code can be expensive, caching it where possible
* can provide significant performance wins. (Key in a hash map for instance)
* Usually not safe since the normal constructor will accept a mutable map or
* set as an arg
* Here however we control how the class is generated from serialized data.
* With the class private and the contract that we throw away our mutable references
* having the hash code lazy here is safe.
*/
override lazy val hashCode: Int = super.hashCode
}
/**
* This Proxy trait allows you to extend the Annotation trait with additional state or
* behavior and implement the read-only methods from Annotation using an underlying
* instance.
*/
trait Proxy extends Annotation {
protected def _underlying_Annotation: Annotation
override def timestamp: Long = _underlying_Annotation.timestamp
override def value: String = _underlying_Annotation.value
override def host: _root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint] = _underlying_Annotation.host
override def _passthroughFields: immutable$Map[Short, TFieldBlob] = _underlying_Annotation._passthroughFields
}
}
/**
* Prefer the companion object's [[com.twitter.finagle.thrift.thriftscala.Annotation.apply]]
* for construction if you don't need to specify passthrough fields.
*/
trait Annotation
extends ThriftStruct
with _root_.scala.Product3[Long, String, Option[com.twitter.finagle.thrift.thriftscala.Endpoint]]
with ValidatingThriftStruct[Annotation]
with java.io.Serializable
{
import Annotation._
def timestamp: Long
def value: String
/**
* Always the host that recorded the event. By specifying the host you allow
* rollup of all events (such as client requests to a service) by IP address.
*/
def host: _root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint]
def _passthroughFields: immutable$Map[Short, TFieldBlob] = immutable$Map.empty
def _1: Long = timestamp
def _2: String = value
def _3: _root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint] = host
def toTuple: _root_.scala.Tuple3[Long, String, Option[com.twitter.finagle.thrift.thriftscala.Endpoint]] =
_root_.scala.Tuple3[Long, String, Option[com.twitter.finagle.thrift.thriftscala.Endpoint]](
timestamp,
value,
host
)
/**
* Gets a field value encoded as a binary blob using TCompactProtocol. If the specified field
* is present in the passthrough map, that value is returned. Otherwise, if the specified field
* is known and not optional and set to None, then the field is serialized and returned.
*/
def getFieldBlob(_fieldId: Short): _root_.scala.Option[TFieldBlob] = {
val passedthroughValue = _passthroughFields.get(_fieldId)
if (passedthroughValue.isDefined) {
passedthroughValue
} else {
val _buff = new TMemoryBuffer(32)
val _oprot = new TCompactProtocol(_buff)
val _fieldOpt: _root_.scala.Option[TField] = _fieldId match {
case 1 =>
writeTimestampValue(timestamp, _oprot)
_root_.scala.Some(Annotation.TimestampField)
case 2 =>
if (value ne null) {
writeValueValue(value, _oprot)
_root_.scala.Some(Annotation.ValueField)
} else {
_root_.scala.None
}
case 3 =>
if (host.isDefined) {
writeHostValue(host.get, _oprot)
_root_.scala.Some(Annotation.HostField)
} else {
_root_.scala.None
}
case _ => _root_.scala.None
}
if (_fieldOpt.isDefined) {
_root_.scala.Some(TFieldBlob(_fieldOpt.get, Buf.ByteArray.Owned(_buff.getArray)))
} else {
_root_.scala.None
}
}
}
/**
* Collects TCompactProtocol-encoded field values according to `getFieldBlob` into a map.
*/
def getFieldBlobs(ids: TraversableOnce[Short]): immutable$Map[Short, TFieldBlob] =
(ids.flatMap { id => getFieldBlob(id).map { fieldBlob => (id, fieldBlob) } }).toMap
/**
* Sets a field using a TCompactProtocol-encoded binary blob. If the field is a known
* field, the blob is decoded and the field is set to the decoded value. If the field
* is unknown and passthrough fields are enabled, then the blob will be stored in
* _passthroughFields.
*/
def setField(_blob: TFieldBlob): Annotation = {
var timestamp: Long = this.timestamp
var value: String = this.value
var host: _root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint] = this.host
var _passthroughFields = this._passthroughFields
_blob.id match {
case 1 =>
timestamp = readTimestampValue(_blob.read)
case 2 =>
value = readValueValue(_blob.read)
case 3 =>
host = _root_.scala.Some(readHostValue(_blob.read))
case _ => _passthroughFields += _root_.scala.Tuple2(_blob.id, _blob)
}
new Immutable(
timestamp,
value,
host,
_passthroughFields
)
}
/**
* If the specified field is optional, it is set to None. Otherwise, if the field is
* known, it is reverted to its default value; if the field is unknown, it is removed
* from the passthroughFields map, if present.
*/
def unsetField(_fieldId: Short): Annotation = {
var timestamp: Long = this.timestamp
var value: String = this.value
var host: _root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint] = this.host
_fieldId match {
case 1 =>
timestamp = 0L
case 2 =>
value = null
case 3 =>
host = _root_.scala.None
case _ =>
}
new Immutable(
timestamp,
value,
host,
_passthroughFields - _fieldId
)
}
/**
* If the specified field is optional, it is set to None. Otherwise, if the field is
* known, it is reverted to its default value; if the field is unknown, it is removed
* from the passthroughFields map, if present.
*/
def unsetTimestamp: Annotation = unsetField(1)
def unsetValue: Annotation = unsetField(2)
def unsetHost: Annotation = unsetField(3)
override def write(_oprot: TProtocol): Unit = {
Annotation.validate(this)
_oprot.writeStructBegin(Struct)
writeTimestampField(timestamp, _oprot)
if (value ne null) writeValueField(value, _oprot)
if (host.isDefined) writeHostField(host.get, _oprot)
if (_passthroughFields.nonEmpty) {
_passthroughFields.values.foreach { _.write(_oprot) }
}
_oprot.writeFieldStop()
_oprot.writeStructEnd()
}
def copy(
timestamp: Long = this.timestamp,
value: String = this.value,
host: _root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint] = this.host,
_passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields
): Annotation =
new Immutable(
timestamp,
value,
host,
_passthroughFields
)
override def canEqual(other: Any): Boolean = other.isInstanceOf[Annotation]
private[this] def _equals(other: Annotation): Boolean =
this.productArity == other.productArity &&
this.productIterator.sameElements(other.productIterator) &&
this._passthroughFields == other._passthroughFields
override def equals(other: Any): Boolean =
canEqual(other) && _equals(other.asInstanceOf[Annotation])
override def hashCode: Int = {
_root_.scala.runtime.ScalaRunTime._hashCode(this)
}
override def toString: String = _root_.scala.runtime.ScalaRunTime._toString(this)
override def productPrefix: String = "Annotation"
def _codec: ValidatingThriftStructCodec3[Annotation] = Annotation
def newBuilder(): StructBuilder[Annotation] = new AnnotationStructBuilder(_root_.scala.Some(this), fieldTypes)
}
private[thriftscala] class AnnotationStructBuilder(instance: _root_.scala.Option[Annotation], fieldTypes: IndexedSeq[ClassTag[_]])
extends StructBuilder[Annotation](fieldTypes) {
def build(): Annotation = {
val _fieldArray = fieldArray // shadow variable
if (instance.isDefined) {
val instanceValue = instance.get
Annotation(
if (_fieldArray(0) == null) instanceValue.timestamp else _fieldArray(0).asInstanceOf[Long],
if (_fieldArray(1) == null) instanceValue.value else _fieldArray(1).asInstanceOf[String],
if (_fieldArray(2) == null) instanceValue.host else _fieldArray(2).asInstanceOf[_root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint]]
)
} else {
if (genericArrayOps(_fieldArray).contains(null)) throw new InvalidFieldsException(structBuildError("Annotation"))
Annotation(
_fieldArray(0).asInstanceOf[Long],
_fieldArray(1).asInstanceOf[String],
_fieldArray(2).asInstanceOf[_root_.scala.Option[com.twitter.finagle.thrift.thriftscala.Endpoint]]
)
}
}
}