scray.service.qservice.thrifscala.ScrayTResultFrame.scala Maven / Gradle / Ivy
/**
* Generated by Scrooge
* version: 4.16.0
* rev: 0201cac9fdd6188248d42da91fd14c87744cc4a5
* built at: 20170421-124523
*/
package scray.service.qservice.thrifscala
import com.twitter.scrooge.{
HasThriftStructCodec3,
LazyTProtocol,
TFieldBlob,
ThriftException,
ThriftStruct,
ThriftStructCodec3,
ThriftStructFieldInfo,
ThriftStructMetaData,
ThriftUtil
}
import org.apache.thrift.protocol._
import org.apache.thrift.transport.{TMemoryBuffer, TTransport}
import java.nio.ByteBuffer
import java.util.Arrays
import scala.collection.immutable.{Map => immutable$Map}
import scala.collection.mutable.Builder
import scala.collection.mutable.{
ArrayBuffer => mutable$ArrayBuffer, Buffer => mutable$Buffer,
HashMap => mutable$HashMap, HashSet => mutable$HashSet}
import scala.collection.{Map, Set}
/**
* Subset of result rows as transmission units
*/
object ScrayTResultFrame extends ThriftStructCodec3[ScrayTResultFrame] {
private val NoPassthroughFields = immutable$Map.empty[Short, TFieldBlob]
val Struct = new TStruct("ScrayTResultFrame")
val QueryInfoField = new TField("queryInfo", TType.STRUCT, 1)
val QueryInfoFieldManifest = implicitly[Manifest[scray.service.qmodel.thrifscala.ScrayTQueryInfo]]
val RowsField = new TField("rows", TType.LIST, 2)
val RowsFieldManifest = implicitly[Manifest[Seq[scray.service.qmodel.thrifscala.ScrayTRow]]]
/**
* Field information in declaration order.
*/
lazy val fieldInfos: scala.List[ThriftStructFieldInfo] = scala.List[ThriftStructFieldInfo](
new ThriftStructFieldInfo(
QueryInfoField,
false,
false,
QueryInfoFieldManifest,
_root_.scala.None,
_root_.scala.None,
immutable$Map.empty[String, String],
immutable$Map.empty[String, String],
None
),
new ThriftStructFieldInfo(
RowsField,
false,
false,
RowsFieldManifest,
_root_.scala.None,
_root_.scala.Some(implicitly[Manifest[scray.service.qmodel.thrifscala.ScrayTRow]]),
immutable$Map.empty[String, String],
immutable$Map.empty[String, String],
None
)
)
lazy val structAnnotations: immutable$Map[String, String] =
immutable$Map.empty[String, String]
/**
* Checks that all required fields are non-null.
*/
def validate(_item: ScrayTResultFrame): Unit = {
}
def withoutPassthroughFields(original: ScrayTResultFrame): ScrayTResultFrame =
new Immutable(
queryInfo =
{
val field = original.queryInfo
scray.service.qmodel.thrifscala.ScrayTQueryInfo.withoutPassthroughFields(field)
},
rows =
{
val field = original.rows
field.map { field =>
scray.service.qmodel.thrifscala.ScrayTRow.withoutPassthroughFields(field)
}
}
)
override def encode(_item: ScrayTResultFrame, _oproto: TProtocol): Unit = {
_item.write(_oproto)
}
private[this] def lazyDecode(_iprot: LazyTProtocol): ScrayTResultFrame = {
var queryInfo: scray.service.qmodel.thrifscala.ScrayTQueryInfo = null
var rows: Seq[scray.service.qmodel.thrifscala.ScrayTRow] = Seq[scray.service.qmodel.thrifscala.ScrayTRow]()
var _passthroughFields: Builder[(Short, TFieldBlob), immutable$Map[Short, TFieldBlob]] = null
var _done = false
val _start_offset = _iprot.offset
_iprot.readStructBegin()
while (!_done) {
val _field = _iprot.readFieldBegin()
if (_field.`type` == TType.STOP) {
_done = true
} else {
_field.id match {
case 1 =>
_field.`type` match {
case TType.STRUCT =>
queryInfo = readQueryInfoValue(_iprot)
case _actualType =>
val _expectedType = TType.STRUCT
throw new TProtocolException(
"Received wrong type for field 'queryInfo' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case 2 =>
_field.`type` match {
case TType.LIST =>
rows = readRowsValue(_iprot)
case _actualType =>
val _expectedType = TType.LIST
throw new TProtocolException(
"Received wrong type for field 'rows' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case _ =>
if (_passthroughFields == null)
_passthroughFields = immutable$Map.newBuilder[Short, TFieldBlob]
_passthroughFields += (_field.id -> TFieldBlob.read(_field, _iprot))
}
_iprot.readFieldEnd()
}
}
_iprot.readStructEnd()
new LazyImmutable(
_iprot,
_iprot.buffer,
_start_offset,
_iprot.offset,
queryInfo,
rows,
if (_passthroughFields == null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
override def decode(_iprot: TProtocol): ScrayTResultFrame =
_iprot match {
case i: LazyTProtocol => lazyDecode(i)
case i => eagerDecode(i)
}
private[this] def eagerDecode(_iprot: TProtocol): ScrayTResultFrame = {
var queryInfo: scray.service.qmodel.thrifscala.ScrayTQueryInfo = null
var rows: Seq[scray.service.qmodel.thrifscala.ScrayTRow] = Seq[scray.service.qmodel.thrifscala.ScrayTRow]()
var _passthroughFields: Builder[(Short, TFieldBlob), immutable$Map[Short, TFieldBlob]] = null
var _done = false
_iprot.readStructBegin()
while (!_done) {
val _field = _iprot.readFieldBegin()
if (_field.`type` == TType.STOP) {
_done = true
} else {
_field.id match {
case 1 =>
_field.`type` match {
case TType.STRUCT =>
queryInfo = readQueryInfoValue(_iprot)
case _actualType =>
val _expectedType = TType.STRUCT
throw new TProtocolException(
"Received wrong type for field 'queryInfo' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case 2 =>
_field.`type` match {
case TType.LIST =>
rows = readRowsValue(_iprot)
case _actualType =>
val _expectedType = TType.LIST
throw new TProtocolException(
"Received wrong type for field 'rows' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case _ =>
if (_passthroughFields == null)
_passthroughFields = immutable$Map.newBuilder[Short, TFieldBlob]
_passthroughFields += (_field.id -> TFieldBlob.read(_field, _iprot))
}
_iprot.readFieldEnd()
}
}
_iprot.readStructEnd()
new Immutable(
queryInfo,
rows,
if (_passthroughFields == null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
def apply(
queryInfo: scray.service.qmodel.thrifscala.ScrayTQueryInfo,
rows: Seq[scray.service.qmodel.thrifscala.ScrayTRow] = Seq[scray.service.qmodel.thrifscala.ScrayTRow]()
): ScrayTResultFrame =
new Immutable(
queryInfo,
rows
)
def unapply(_item: ScrayTResultFrame): _root_.scala.Option[_root_.scala.Tuple2[scray.service.qmodel.thrifscala.ScrayTQueryInfo, Seq[scray.service.qmodel.thrifscala.ScrayTRow]]] = _root_.scala.Some(_item.toTuple)
@inline private def readQueryInfoValue(_iprot: TProtocol): scray.service.qmodel.thrifscala.ScrayTQueryInfo = {
scray.service.qmodel.thrifscala.ScrayTQueryInfo.decode(_iprot)
}
@inline private def writeQueryInfoField(queryInfo_item: scray.service.qmodel.thrifscala.ScrayTQueryInfo, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(QueryInfoField)
writeQueryInfoValue(queryInfo_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeQueryInfoValue(queryInfo_item: scray.service.qmodel.thrifscala.ScrayTQueryInfo, _oprot: TProtocol): Unit = {
queryInfo_item.write(_oprot)
}
@inline private def readRowsValue(_iprot: TProtocol): Seq[scray.service.qmodel.thrifscala.ScrayTRow] = {
val _list = _iprot.readListBegin()
if (_list.size == 0) {
_iprot.readListEnd()
Nil
} else {
val _rv = new mutable$ArrayBuffer[scray.service.qmodel.thrifscala.ScrayTRow](_list.size)
var _i = 0
while (_i < _list.size) {
_rv += {
scray.service.qmodel.thrifscala.ScrayTRow.decode(_iprot)
}
_i += 1
}
_iprot.readListEnd()
_rv
}
}
@inline private def writeRowsField(rows_item: Seq[scray.service.qmodel.thrifscala.ScrayTRow], _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(RowsField)
writeRowsValue(rows_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeRowsValue(rows_item: Seq[scray.service.qmodel.thrifscala.ScrayTRow], _oprot: TProtocol): Unit = {
_oprot.writeListBegin(new TList(TType.STRUCT, rows_item.size))
rows_item match {
case _: IndexedSeq[_] =>
var _i = 0
val _size = rows_item.size
while (_i < _size) {
val rows_item_element = rows_item(_i)
rows_item_element.write(_oprot)
_i += 1
}
case _ =>
rows_item.foreach { rows_item_element =>
rows_item_element.write(_oprot)
}
}
_oprot.writeListEnd()
}
object Immutable extends ThriftStructCodec3[ScrayTResultFrame] {
override def encode(_item: ScrayTResultFrame, _oproto: TProtocol): Unit = { _item.write(_oproto) }
override def decode(_iprot: TProtocol): ScrayTResultFrame = ScrayTResultFrame.decode(_iprot)
override lazy val metaData: ThriftStructMetaData[ScrayTResultFrame] = ScrayTResultFrame.metaData
}
/**
* The default read-only implementation of ScrayTResultFrame. You typically should not need to
* directly reference this class; instead, use the ScrayTResultFrame.apply method to construct
* new instances.
*/
class Immutable(
val queryInfo: scray.service.qmodel.thrifscala.ScrayTQueryInfo,
val rows: Seq[scray.service.qmodel.thrifscala.ScrayTRow],
override val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends ScrayTResultFrame {
def this(
queryInfo: scray.service.qmodel.thrifscala.ScrayTQueryInfo,
rows: Seq[scray.service.qmodel.thrifscala.ScrayTRow] = Seq[scray.service.qmodel.thrifscala.ScrayTRow]()
) = this(
queryInfo,
rows,
Map.empty
)
}
/**
* 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 queryInfo: scray.service.qmodel.thrifscala.ScrayTQueryInfo,
val rows: Seq[scray.service.qmodel.thrifscala.ScrayTRow],
override val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends ScrayTResultFrame {
override def write(_oprot: TProtocol): Unit = {
_oprot match {
case i: LazyTProtocol => i.writeRaw(_buf, _start_offset, _end_offset - _start_offset)
case _ => super.write(_oprot)
}
}
/**
* 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 = super.hashCode
}
/**
* This Proxy trait allows you to extend the ScrayTResultFrame trait with additional state or
* behavior and implement the read-only methods from ScrayTResultFrame using an underlying
* instance.
*/
trait Proxy extends ScrayTResultFrame {
protected def _underlying_ScrayTResultFrame: ScrayTResultFrame
override def queryInfo: scray.service.qmodel.thrifscala.ScrayTQueryInfo = _underlying_ScrayTResultFrame.queryInfo
override def rows: Seq[scray.service.qmodel.thrifscala.ScrayTRow] = _underlying_ScrayTResultFrame.rows
override def _passthroughFields = _underlying_ScrayTResultFrame._passthroughFields
}
}
trait ScrayTResultFrame
extends ThriftStruct
with _root_.scala.Product2[scray.service.qmodel.thrifscala.ScrayTQueryInfo, Seq[scray.service.qmodel.thrifscala.ScrayTRow]]
with HasThriftStructCodec3[ScrayTResultFrame]
with java.io.Serializable
{
import ScrayTResultFrame._
def queryInfo: scray.service.qmodel.thrifscala.ScrayTQueryInfo
def rows: Seq[scray.service.qmodel.thrifscala.ScrayTRow]
def _passthroughFields: immutable$Map[Short, TFieldBlob] = immutable$Map.empty
def _1 = queryInfo
def _2 = rows
def toTuple: _root_.scala.Tuple2[scray.service.qmodel.thrifscala.ScrayTQueryInfo, Seq[scray.service.qmodel.thrifscala.ScrayTRow]] = {
(
queryInfo,
rows
)
}
/**
* 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] = {
lazy val _buff = new TMemoryBuffer(32)
lazy val _oprot = new TCompactProtocol(_buff)
_passthroughFields.get(_fieldId) match {
case blob: _root_.scala.Some[TFieldBlob] => blob
case _root_.scala.None => {
val _fieldOpt: _root_.scala.Option[TField] =
_fieldId match {
case 1 =>
if (queryInfo ne null) {
writeQueryInfoValue(queryInfo, _oprot)
_root_.scala.Some(ScrayTResultFrame.QueryInfoField)
} else {
_root_.scala.None
}
case 2 =>
if (rows ne null) {
writeRowsValue(rows, _oprot)
_root_.scala.Some(ScrayTResultFrame.RowsField)
} else {
_root_.scala.None
}
case _ => _root_.scala.None
}
_fieldOpt match {
case _root_.scala.Some(_field) =>
val _data = Arrays.copyOfRange(_buff.getArray, 0, _buff.length)
_root_.scala.Some(TFieldBlob(_field, _data))
case _root_.scala.None =>
_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 { id -> _ } }).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): ScrayTResultFrame = {
var queryInfo: scray.service.qmodel.thrifscala.ScrayTQueryInfo = this.queryInfo
var rows: Seq[scray.service.qmodel.thrifscala.ScrayTRow] = this.rows
var _passthroughFields = this._passthroughFields
_blob.id match {
case 1 =>
queryInfo = readQueryInfoValue(_blob.read)
case 2 =>
rows = readRowsValue(_blob.read)
case _ => _passthroughFields += (_blob.id -> _blob)
}
new Immutable(
queryInfo,
rows,
_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): ScrayTResultFrame = {
var queryInfo: scray.service.qmodel.thrifscala.ScrayTQueryInfo = this.queryInfo
var rows: Seq[scray.service.qmodel.thrifscala.ScrayTRow] = this.rows
_fieldId match {
case 1 =>
queryInfo = null
case 2 =>
rows = Seq[scray.service.qmodel.thrifscala.ScrayTRow]()
case _ =>
}
new Immutable(
queryInfo,
rows,
_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 unsetQueryInfo: ScrayTResultFrame = unsetField(1)
def unsetRows: ScrayTResultFrame = unsetField(2)
override def write(_oprot: TProtocol): Unit = {
ScrayTResultFrame.validate(this)
_oprot.writeStructBegin(Struct)
if (queryInfo ne null) writeQueryInfoField(queryInfo, _oprot)
if (rows ne null) writeRowsField(rows, _oprot)
if (_passthroughFields.nonEmpty) {
_passthroughFields.values.foreach { _.write(_oprot) }
}
_oprot.writeFieldStop()
_oprot.writeStructEnd()
}
def copy(
queryInfo: scray.service.qmodel.thrifscala.ScrayTQueryInfo = this.queryInfo,
rows: Seq[scray.service.qmodel.thrifscala.ScrayTRow] = this.rows,
_passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields
): ScrayTResultFrame =
new Immutable(
queryInfo,
rows,
_passthroughFields
)
override def canEqual(other: Any): Boolean = other.isInstanceOf[ScrayTResultFrame]
private def _equals(x: ScrayTResultFrame, y: ScrayTResultFrame): Boolean =
x.productArity == y.productArity &&
x.productIterator.sameElements(y.productIterator)
override def equals(other: Any): Boolean =
canEqual(other) &&
_equals(this, other.asInstanceOf[ScrayTResultFrame]) &&
_passthroughFields == other.asInstanceOf[ScrayTResultFrame]._passthroughFields
override def hashCode: Int = _root_.scala.runtime.ScalaRunTime._hashCode(this)
override def toString: String = _root_.scala.runtime.ScalaRunTime._toString(this)
override def productArity: Int = 2
override def productElement(n: Int): Any = n match {
case 0 => this.queryInfo
case 1 => this.rows
case _ => throw new IndexOutOfBoundsException(n.toString)
}
override def productPrefix: String = "ScrayTResultFrame"
def _codec: ThriftStructCodec3[ScrayTResultFrame] = ScrayTResultFrame
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy