Skip to content

Instantly share code, notes, and snippets.

@imownbey
Created March 31, 2011 21:16
Show Gist options
  • Save imownbey/897275 to your computer and use it in GitHub Desktop.
Save imownbey/897275 to your computer and use it in GitHub Desktop.
package com.twitter.scrooge
import org.apache.thrift.protocol._
/**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
object Bonk {
def apply(iprot: TProtocol) = {
var field: TField = null
var message: String = null
var another: Int = null
while(true) {
field = iprot.readFieldBegin
if(field.type == TType.STOP) {
break
}
field.id match {
case 1 => {
field.type match {
case TType.STRING => message = iprot.readString
case _ => TProtocolUtil.skip(iprot, field.type)
}
break
}
case 2 => {
field.type match {
case TType.I32 => another = iprot.readI32()
case _ => TProtocolUtil.skip(iprot, field.type)
}
}
case _ => TProtocolUtil.skip(iprot, field.type)
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
Bonk(message, another)
}
}
case class Bonk(message: String, another: Int) {
private val STRUCT_DESC = new TStruct("Bonk")
private val MESSAGE_FIELD_DESC = new TField("message", TType.STRING, 1)
private val ANOTHER_FIELD_DESC = new TField("another", TType.I32, 2)
def write(oprot: TProtocol) {
validate
oprot.writeStructBegin(STRUCT_DESC)
if(message ne null) {
oprot.writeFieldBegin(MESSAGE_FIELD_DESC)
oprot.writeString(message)
oprot.writeFieldEnd()
}
oprot.WriteFieldBegin(ANOTHER_FIELD_DESC)
oprot.writeI32(another)
oprot.writeFieldEnd()
oprot.writeFieldStop()
oprot.writeStructEnd()
}
def validate = true // TODO: Implement?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment