[ 
https://issues.apache.org/jira/browse/THRIFT-167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12642788#action_12642788
 ] 

Alexander Shigin commented on THRIFT-167:
-----------------------------------------

Bryan, why do you want to keep something-begin and something-end.

Here is your code:
{code}
   public abstract void writeMapBegin(TMap map) throws TException;
+  
+  public void writeMapFieldBegin(TField field, TMap map) throws TException {
+    writeFieldBegin(field);
+    writeMapBegin(map);
+  }
 
   public abstract void writeMapEnd() throws TException;
{code}

I think it's much better to make 
{code}
public void writeMapField(TField field, TMap map) {
  writeFieldBegin(field);
  writeMapBegin(map);
  writeMapEnd();
}
{code}

I think what sort of changes should be done for every language libs. I've tried 
implement true/false type for python using current interface, so I can 
understand your improvement.

> Improve the TProtocol interface to facilitate more complex protocols
> --------------------------------------------------------------------
>
>                 Key: THRIFT-167
>                 URL: https://issues.apache.org/jira/browse/THRIFT-167
>             Project: Thrift
>          Issue Type: Improvement
>            Reporter: Bryan Duxbury
>         Attachments: thrift-167.patch
>
>
> In doing some exploratory coding on THRIFT-110, it's clear that some 
> improvements to the TProtocol interface would make things much easier. 
> What I'm thinking is that we should add a new set of methods that take the 
> TField and value simultaneously. For instance, we'd have writeString(str) and 
> writeStringField(field, str). This way, the protocol would know explicitly 
> that it can write the field id, type header, and value all at once. The 
> exsiting overload (writeString(str)) would still be used when writing 
> containers' contents. 
> Existing protocols can implement this behavior very simply as a call to 
> writeField then writeString, so we wouldn't have to do a ton of work to 
> recode them completely. Code generators would have to change to take full 
> advantage of this new interface, but existing generated code would still 
> work, since we'd retain all the original methods. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to