Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
0.11.0
-
None
Description
The get[field] method in generated Java code generates a new copy of a binary field every time it is called. This seems incredibly inefficient. Take a simple example struct:
struct StructWithBinary { 1: required binary field; }
a portion of the generated code for this is:
public byte[] getField() { setField(org.apache.thrift.TBaseHelper.rightSize(field)); return field == null ? null : field.array(); } ... public StructWithBinary setField(java.nio.ByteBuffer field) { this.field = org.apache.thrift.TBaseHelper.copyBinary(field); return this; }
So whenever getField is called, setField calls copyBinary and generates another copy. This adds quite a lot of overhead to the getter here and should be fixed.
Attachments
Issue Links
- links to