Skip to content

Instantly share code, notes, and snippets.

@awhogue
Created July 8, 2014 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awhogue/72c0f6546c61960f8511 to your computer and use it in GitHub Desktop.
Save awhogue/72c0f6546c61960f8511 to your computer and use it in GitHub Desktop.
/**
* Class that wraps a TSerializer.
*/
class ThriftSerializerWithClassName[T <: BoundedTBase] {
val protocolFactory = new TCompactProtocol.Factory()
// TSerializer reuses a ByteArrayOutputStream, but isn't threadsafe.
val serializer = new TSerializer(protocolFactory)
def serialize(t: T): Array[Byte] = {
serializer.serialize(t)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment