Implemented the thrift encoder.