I have some Scala classes I generated with Thrift (Scrooge). Now I need to somehow instantiate those as TBase class, b/c the TSerializer class needs this as an input
This is my approach:
def createTestBinary(): String = {
val proto = new TBinaryProtocol.Factory
val err = new ClientError{}
val binary = new TSerializer().serialize(err)
""
}
ClientError is the generated class. How can I instantiate it or wrap it as a TBase member?
Any ideas how to do this? Thanks in advance!
You don't need TSerializer
, that's for "vanilla" thrift, not for scrooge-generated classes.
You need to do something like this instead:
val transport = TMemoryBuffer(1024) // or whatever
err.write(new TBinaryProtocol(transport))
val binary = transport.getArray