All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scray.service.qmodel.thrifscala.ScrayTTableInfo.scala Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
/**
 * Generated by Scrooge
 *   version: 4.16.0
 *   rev: 0201cac9fdd6188248d42da91fd14c87744cc4a5
 *   built at: 20170421-124523
 */
package scray.service.qmodel.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}

/**
 * Table identifier
 */
object ScrayTTableInfo extends ThriftStructCodec3[ScrayTTableInfo] {
  private val NoPassthroughFields = immutable$Map.empty[Short, TFieldBlob]
  val Struct = new TStruct("ScrayTTableInfo")
  val DbSystemField = new TField("dbSystem", TType.STRING, 1)
  val DbSystemFieldManifest = implicitly[Manifest[String]]
  val DbIdField = new TField("dbId", TType.STRING, 2)
  val DbIdFieldManifest = implicitly[Manifest[String]]
  val TableIdField = new TField("tableId", TType.STRING, 3)
  val TableIdFieldManifest = implicitly[Manifest[String]]
  val KeyTField = new TField("keyT", TType.STRING, 4)
  val KeyTFieldManifest = implicitly[Manifest[String]]

  /**
   * Field information in declaration order.
   */
  lazy val fieldInfos: scala.List[ThriftStructFieldInfo] = scala.List[ThriftStructFieldInfo](
    new ThriftStructFieldInfo(
      DbSystemField,
      false,
      false,
      DbSystemFieldManifest,
      _root_.scala.None,
      _root_.scala.None,
      immutable$Map.empty[String, String],
      immutable$Map.empty[String, String],
      None
    ),
    new ThriftStructFieldInfo(
      DbIdField,
      false,
      false,
      DbIdFieldManifest,
      _root_.scala.None,
      _root_.scala.None,
      immutable$Map.empty[String, String],
      immutable$Map.empty[String, String],
      None
    ),
    new ThriftStructFieldInfo(
      TableIdField,
      false,
      false,
      TableIdFieldManifest,
      _root_.scala.None,
      _root_.scala.None,
      immutable$Map.empty[String, String],
      immutable$Map.empty[String, String],
      None
    ),
    new ThriftStructFieldInfo(
      KeyTField,
      true,
      false,
      KeyTFieldManifest,
      _root_.scala.None,
      _root_.scala.None,
      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: ScrayTTableInfo): Unit = {
  }

  def withoutPassthroughFields(original: ScrayTTableInfo): ScrayTTableInfo =
    new Immutable(
      dbSystem =
        {
          val field = original.dbSystem
          field
        },
      dbId =
        {
          val field = original.dbId
          field
        },
      tableId =
        {
          val field = original.tableId
          field
        },
      keyT =
        {
          val field = original.keyT
          field.map { field =>
            field
          }
        }
    )

  override def encode(_item: ScrayTTableInfo, _oproto: TProtocol): Unit = {
    _item.write(_oproto)
  }

  private[this] def lazyDecode(_iprot: LazyTProtocol): ScrayTTableInfo = {

    var dbSystemOffset: Int = -1
    var dbIdOffset: Int = -1
    var tableIdOffset: Int = -1
    var keyTOffset: Int = -1

    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.STRING =>
                dbSystemOffset = _iprot.offsetSkipString
    
              case _actualType =>
                val _expectedType = TType.STRING
                throw new TProtocolException(
                  "Received wrong type for field 'dbSystem' (expected=%s, actual=%s).".format(
                    ttypeToString(_expectedType),
                    ttypeToString(_actualType)
                  )
                )
            }
          case 2 =>
            _field.`type` match {
              case TType.STRING =>
                dbIdOffset = _iprot.offsetSkipString
    
              case _actualType =>
                val _expectedType = TType.STRING
                throw new TProtocolException(
                  "Received wrong type for field 'dbId' (expected=%s, actual=%s).".format(
                    ttypeToString(_expectedType),
                    ttypeToString(_actualType)
                  )
                )
            }
          case 3 =>
            _field.`type` match {
              case TType.STRING =>
                tableIdOffset = _iprot.offsetSkipString
    
              case _actualType =>
                val _expectedType = TType.STRING
                throw new TProtocolException(
                  "Received wrong type for field 'tableId' (expected=%s, actual=%s).".format(
                    ttypeToString(_expectedType),
                    ttypeToString(_actualType)
                  )
                )
            }
          case 4 =>
            _field.`type` match {
              case TType.STRING =>
                keyTOffset = _iprot.offsetSkipString
    
              case _actualType =>
                val _expectedType = TType.STRING
                throw new TProtocolException(
                  "Received wrong type for field 'keyT' (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,
      dbSystemOffset,
      dbIdOffset,
      tableIdOffset,
      keyTOffset,
      if (_passthroughFields == null)
        NoPassthroughFields
      else
        _passthroughFields.result()
    )
  }

  override def decode(_iprot: TProtocol): ScrayTTableInfo =
    _iprot match {
      case i: LazyTProtocol => lazyDecode(i)
      case i => eagerDecode(i)
    }

  private[this] def eagerDecode(_iprot: TProtocol): ScrayTTableInfo = {
    var dbSystem: String = null
    var dbId: String = null
    var tableId: String = null
    var keyT: _root_.scala.Option[String] = _root_.scala.None
    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.STRING =>
                dbSystem = readDbSystemValue(_iprot)
              case _actualType =>
                val _expectedType = TType.STRING
                throw new TProtocolException(
                  "Received wrong type for field 'dbSystem' (expected=%s, actual=%s).".format(
                    ttypeToString(_expectedType),
                    ttypeToString(_actualType)
                  )
                )
            }
          case 2 =>
            _field.`type` match {
              case TType.STRING =>
                dbId = readDbIdValue(_iprot)
              case _actualType =>
                val _expectedType = TType.STRING
                throw new TProtocolException(
                  "Received wrong type for field 'dbId' (expected=%s, actual=%s).".format(
                    ttypeToString(_expectedType),
                    ttypeToString(_actualType)
                  )
                )
            }
          case 3 =>
            _field.`type` match {
              case TType.STRING =>
                tableId = readTableIdValue(_iprot)
              case _actualType =>
                val _expectedType = TType.STRING
                throw new TProtocolException(
                  "Received wrong type for field 'tableId' (expected=%s, actual=%s).".format(
                    ttypeToString(_expectedType),
                    ttypeToString(_actualType)
                  )
                )
            }
          case 4 =>
            _field.`type` match {
              case TType.STRING =>
                keyT = _root_.scala.Some(readKeyTValue(_iprot))
              case _actualType =>
                val _expectedType = TType.STRING
                throw new TProtocolException(
                  "Received wrong type for field 'keyT' (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(
      dbSystem,
      dbId,
      tableId,
      keyT,
      if (_passthroughFields == null)
        NoPassthroughFields
      else
        _passthroughFields.result()
    )
  }

  def apply(
    dbSystem: String,
    dbId: String,
    tableId: String,
    keyT: _root_.scala.Option[String] = _root_.scala.None
  ): ScrayTTableInfo =
    new Immutable(
      dbSystem,
      dbId,
      tableId,
      keyT
    )

  def unapply(_item: ScrayTTableInfo): _root_.scala.Option[_root_.scala.Tuple4[String, String, String, Option[String]]] = _root_.scala.Some(_item.toTuple)


  @inline private def readDbSystemValue(_iprot: TProtocol): String = {
    _iprot.readString()
  }

  @inline private def writeDbSystemField(dbSystem_item: String, _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(DbSystemField)
    writeDbSystemValue(dbSystem_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeDbSystemValue(dbSystem_item: String, _oprot: TProtocol): Unit = {
    _oprot.writeString(dbSystem_item)
  }

  @inline private def readDbIdValue(_iprot: TProtocol): String = {
    _iprot.readString()
  }

  @inline private def writeDbIdField(dbId_item: String, _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(DbIdField)
    writeDbIdValue(dbId_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeDbIdValue(dbId_item: String, _oprot: TProtocol): Unit = {
    _oprot.writeString(dbId_item)
  }

  @inline private def readTableIdValue(_iprot: TProtocol): String = {
    _iprot.readString()
  }

  @inline private def writeTableIdField(tableId_item: String, _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(TableIdField)
    writeTableIdValue(tableId_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeTableIdValue(tableId_item: String, _oprot: TProtocol): Unit = {
    _oprot.writeString(tableId_item)
  }

  @inline private def readKeyTValue(_iprot: TProtocol): String = {
    _iprot.readString()
  }

  @inline private def writeKeyTField(keyT_item: String, _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(KeyTField)
    writeKeyTValue(keyT_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeKeyTValue(keyT_item: String, _oprot: TProtocol): Unit = {
    _oprot.writeString(keyT_item)
  }


  object Immutable extends ThriftStructCodec3[ScrayTTableInfo] {
    override def encode(_item: ScrayTTableInfo, _oproto: TProtocol): Unit = { _item.write(_oproto) }
    override def decode(_iprot: TProtocol): ScrayTTableInfo = ScrayTTableInfo.decode(_iprot)
    override lazy val metaData: ThriftStructMetaData[ScrayTTableInfo] = ScrayTTableInfo.metaData
  }

  /**
   * The default read-only implementation of ScrayTTableInfo.  You typically should not need to
   * directly reference this class; instead, use the ScrayTTableInfo.apply method to construct
   * new instances.
   */
  class Immutable(
      val dbSystem: String,
      val dbId: String,
      val tableId: String,
      val keyT: _root_.scala.Option[String],
      override val _passthroughFields: immutable$Map[Short, TFieldBlob])
    extends ScrayTTableInfo {
    def this(
      dbSystem: String,
      dbId: String,
      tableId: String,
      keyT: _root_.scala.Option[String] = _root_.scala.None
    ) = this(
      dbSystem,
      dbId,
      tableId,
      keyT,
      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,
      dbSystemOffset: Int,
      dbIdOffset: Int,
      tableIdOffset: Int,
      keyTOffset: Int,
      override val _passthroughFields: immutable$Map[Short, TFieldBlob])
    extends ScrayTTableInfo {

    override def write(_oprot: TProtocol): Unit = {
      _oprot match {
        case i: LazyTProtocol => i.writeRaw(_buf, _start_offset, _end_offset - _start_offset)
        case _ => super.write(_oprot)
      }
    }

    lazy val dbSystem: String =
      if (dbSystemOffset == -1)
        null
      else {
        _proto.decodeString(_buf, dbSystemOffset)
      }
    lazy val dbId: String =
      if (dbIdOffset == -1)
        null
      else {
        _proto.decodeString(_buf, dbIdOffset)
      }
    lazy val tableId: String =
      if (tableIdOffset == -1)
        null
      else {
        _proto.decodeString(_buf, tableIdOffset)
      }
    lazy val keyT: _root_.scala.Option[String] =
      if (keyTOffset == -1)
        None
      else {
        Some(_proto.decodeString(_buf, keyTOffset))
      }

    /**
     * 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 ScrayTTableInfo trait with additional state or
   * behavior and implement the read-only methods from ScrayTTableInfo using an underlying
   * instance.
   */
  trait Proxy extends ScrayTTableInfo {
    protected def _underlying_ScrayTTableInfo: ScrayTTableInfo
    override def dbSystem: String = _underlying_ScrayTTableInfo.dbSystem
    override def dbId: String = _underlying_ScrayTTableInfo.dbId
    override def tableId: String = _underlying_ScrayTTableInfo.tableId
    override def keyT: _root_.scala.Option[String] = _underlying_ScrayTTableInfo.keyT
    override def _passthroughFields = _underlying_ScrayTTableInfo._passthroughFields
  }
}

trait ScrayTTableInfo
  extends ThriftStruct
  with _root_.scala.Product4[String, String, String, Option[String]]
  with HasThriftStructCodec3[ScrayTTableInfo]
  with java.io.Serializable
{
  import ScrayTTableInfo._

  def dbSystem: String
  def dbId: String
  def tableId: String
  def keyT: _root_.scala.Option[String]

  def _passthroughFields: immutable$Map[Short, TFieldBlob] = immutable$Map.empty

  def _1 = dbSystem
  def _2 = dbId
  def _3 = tableId
  def _4 = keyT

  def toTuple: _root_.scala.Tuple4[String, String, String, Option[String]] = {
    (
      dbSystem,
      dbId,
      tableId,
      keyT
    )
  }


  /**
   * 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 (dbSystem ne null) {
                writeDbSystemValue(dbSystem, _oprot)
                _root_.scala.Some(ScrayTTableInfo.DbSystemField)
              } else {
                _root_.scala.None
              }
            case 2 =>
              if (dbId ne null) {
                writeDbIdValue(dbId, _oprot)
                _root_.scala.Some(ScrayTTableInfo.DbIdField)
              } else {
                _root_.scala.None
              }
            case 3 =>
              if (tableId ne null) {
                writeTableIdValue(tableId, _oprot)
                _root_.scala.Some(ScrayTTableInfo.TableIdField)
              } else {
                _root_.scala.None
              }
            case 4 =>
              if (keyT.isDefined) {
                writeKeyTValue(keyT.get, _oprot)
                _root_.scala.Some(ScrayTTableInfo.KeyTField)
              } 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): ScrayTTableInfo = {
    var dbSystem: String = this.dbSystem
    var dbId: String = this.dbId
    var tableId: String = this.tableId
    var keyT: _root_.scala.Option[String] = this.keyT
    var _passthroughFields = this._passthroughFields
    _blob.id match {
      case 1 =>
        dbSystem = readDbSystemValue(_blob.read)
      case 2 =>
        dbId = readDbIdValue(_blob.read)
      case 3 =>
        tableId = readTableIdValue(_blob.read)
      case 4 =>
        keyT = _root_.scala.Some(readKeyTValue(_blob.read))
      case _ => _passthroughFields += (_blob.id -> _blob)
    }
    new Immutable(
      dbSystem,
      dbId,
      tableId,
      keyT,
      _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): ScrayTTableInfo = {
    var dbSystem: String = this.dbSystem
    var dbId: String = this.dbId
    var tableId: String = this.tableId
    var keyT: _root_.scala.Option[String] = this.keyT

    _fieldId match {
      case 1 =>
        dbSystem = null
      case 2 =>
        dbId = null
      case 3 =>
        tableId = null
      case 4 =>
        keyT = _root_.scala.None
      case _ =>
    }
    new Immutable(
      dbSystem,
      dbId,
      tableId,
      keyT,
      _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 unsetDbSystem: ScrayTTableInfo = unsetField(1)

  def unsetDbId: ScrayTTableInfo = unsetField(2)

  def unsetTableId: ScrayTTableInfo = unsetField(3)

  def unsetKeyT: ScrayTTableInfo = unsetField(4)


  override def write(_oprot: TProtocol): Unit = {
    ScrayTTableInfo.validate(this)
    _oprot.writeStructBegin(Struct)
    if (dbSystem ne null) writeDbSystemField(dbSystem, _oprot)
    if (dbId ne null) writeDbIdField(dbId, _oprot)
    if (tableId ne null) writeTableIdField(tableId, _oprot)
    if (keyT.isDefined) writeKeyTField(keyT.get, _oprot)
    if (_passthroughFields.nonEmpty) {
      _passthroughFields.values.foreach { _.write(_oprot) }
    }
    _oprot.writeFieldStop()
    _oprot.writeStructEnd()
  }

  def copy(
    dbSystem: String = this.dbSystem,
    dbId: String = this.dbId,
    tableId: String = this.tableId,
    keyT: _root_.scala.Option[String] = this.keyT,
    _passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields
  ): ScrayTTableInfo =
    new Immutable(
      dbSystem,
      dbId,
      tableId,
      keyT,
      _passthroughFields
    )

  override def canEqual(other: Any): Boolean = other.isInstanceOf[ScrayTTableInfo]

  private def _equals(x: ScrayTTableInfo, y: ScrayTTableInfo): Boolean =
      x.productArity == y.productArity &&
      x.productIterator.sameElements(y.productIterator)

  override def equals(other: Any): Boolean =
    canEqual(other) &&
      _equals(this, other.asInstanceOf[ScrayTTableInfo]) &&
      _passthroughFields == other.asInstanceOf[ScrayTTableInfo]._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 = 4

  override def productElement(n: Int): Any = n match {
    case 0 => this.dbSystem
    case 1 => this.dbId
    case 2 => this.tableId
    case 3 => this.keyT
    case _ => throw new IndexOutOfBoundsException(n.toString)
  }

  override def productPrefix: String = "ScrayTTableInfo"

  def _codec: ThriftStructCodec3[ScrayTTableInfo] = ScrayTTableInfo
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy