You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Anthony Molinaro (JIRA)" <ji...@apache.org> on 2011/06/18 05:51:47 UTC

[jira] [Created] (THRIFT-1213) Membuffer should provide a way to get back the buffer

Membuffer should provide a way to get back the buffer
-----------------------------------------------------

                 Key: THRIFT-1213
                 URL: https://issues.apache.org/jira/browse/THRIFT-1213
             Project: Thrift
          Issue Type: Improvement
            Reporter: Anthony Molinaro
            Assignee: Anthony Molinaro


I wanted to get the binary representation of a serialized thrift object and had to do something like

{{monospaced}}
thrift_something_to_binary (SomeThing) ->
  {ok, TF} = thrift_memory_buffer:new_transport_factory(),
  {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
  {ok, P0} = PF(),
  {{ protocol, thrift_binary_protocol,{ binary_protocol,{transport, thrift_memory_buffer, {memory_buffer,B} },true,true}},ok} 
    = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
  iolist_to_binary(B).
{{monospaced}}

With the attached patch instead the flush call of the transport will return the buffer so the large brittle pattern match above can be accomplished instead with

{{monospaced}}
thrift_something_to_binary (SomeThing) ->
  {ok, TF} = thrift_memory_buffer:new_transport_factory(),
  {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
  {ok, P0} = PF(),
  {P1, ok} = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
  {_P2, B} = thrift_protocol:flush_transport (P1),
  iolist_to_binary(B).
{{monospaced}}


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (THRIFT-1213) Membuffer should provide a way to get back the buffer

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13053351#comment-13053351 ] 

Hudson commented on THRIFT-1213:
--------------------------------

Integrated in Thrift #171 (See [https://builds.apache.org/job/Thrift/171/])
    

> Membuffer should provide a way to get back the buffer
> -----------------------------------------------------
>
>                 Key: THRIFT-1213
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1213
>             Project: Thrift
>          Issue Type: Improvement
>            Reporter: Anthony Molinaro
>            Assignee: Anthony Molinaro
>             Fix For: 0.7
>
>         Attachments: THRIFT-1213
>
>
> I wanted to get the binary representation of a serialized thrift object and had to do something like
> {code:none}
> thrift_something_to_binary (SomeThing) ->
>   {ok, TF} = thrift_memory_buffer:new_transport_factory(),
>   {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
>   {ok, P0} = PF(),
>   {{ protocol, thrift_binary_protocol,{ binary_protocol,{transport, thrift_memory_buffer, {memory_buffer,B} },true,true}},ok} 
>     = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
>   iolist_to_binary(B).
> {code}
> With the attached patch instead the flush call of the transport will return the buffer so the large brittle pattern match above can be accomplished instead with
> {code:none}
> thrift_something_to_binary (SomeThing) ->
>   {ok, TF} = thrift_memory_buffer:new_transport_factory(),
>   {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
>   {ok, P0} = PF(),
>   {P1, ok} = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
>   {_P2, B} = thrift_protocol:flush_transport (P1),
>   iolist_to_binary(B).
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (THRIFT-1213) Membuffer should provide a way to get back the buffer

Posted by "Anthony Molinaro (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1213?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Anthony Molinaro updated THRIFT-1213:
-------------------------------------

    Description: 
I wanted to get the binary representation of a serialized thrift object and had to do something like

{code:none}
thrift_something_to_binary (SomeThing) ->
  {ok, TF} = thrift_memory_buffer:new_transport_factory(),
  {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
  {ok, P0} = PF(),
  {{ protocol, thrift_binary_protocol,{ binary_protocol,{transport, thrift_memory_buffer, {memory_buffer,B} },true,true}},ok} 
    = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
  iolist_to_binary(B).
{code}

With the attached patch instead the flush call of the transport will return the buffer so the large brittle pattern match above can be accomplished instead with

{code:none}
thrift_something_to_binary (SomeThing) ->
  {ok, TF} = thrift_memory_buffer:new_transport_factory(),
  {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
  {ok, P0} = PF(),
  {P1, ok} = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
  {_P2, B} = thrift_protocol:flush_transport (P1),
  iolist_to_binary(B).
{code}


  was:
I wanted to get the binary representation of a serialized thrift object and had to do something like

{{monospaced}}
thrift_something_to_binary (SomeThing) ->
  {ok, TF} = thrift_memory_buffer:new_transport_factory(),
  {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
  {ok, P0} = PF(),
  {{ protocol, thrift_binary_protocol,{ binary_protocol,{transport, thrift_memory_buffer, {memory_buffer,B} },true,true}},ok} 
    = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
  iolist_to_binary(B).
{{monospaced}}

With the attached patch instead the flush call of the transport will return the buffer so the large brittle pattern match above can be accomplished instead with

{{monospaced}}
thrift_something_to_binary (SomeThing) ->
  {ok, TF} = thrift_memory_buffer:new_transport_factory(),
  {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
  {ok, P0} = PF(),
  {P1, ok} = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
  {_P2, B} = thrift_protocol:flush_transport (P1),
  iolist_to_binary(B).
{{monospaced}}



> Membuffer should provide a way to get back the buffer
> -----------------------------------------------------
>
>                 Key: THRIFT-1213
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1213
>             Project: Thrift
>          Issue Type: Improvement
>            Reporter: Anthony Molinaro
>            Assignee: Anthony Molinaro
>         Attachments: THRIFT-1213
>
>
> I wanted to get the binary representation of a serialized thrift object and had to do something like
> {code:none}
> thrift_something_to_binary (SomeThing) ->
>   {ok, TF} = thrift_memory_buffer:new_transport_factory(),
>   {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
>   {ok, P0} = PF(),
>   {{ protocol, thrift_binary_protocol,{ binary_protocol,{transport, thrift_memory_buffer, {memory_buffer,B} },true,true}},ok} 
>     = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
>   iolist_to_binary(B).
> {code}
> With the attached patch instead the flush call of the transport will return the buffer so the large brittle pattern match above can be accomplished instead with
> {code:none}
> thrift_something_to_binary (SomeThing) ->
>   {ok, TF} = thrift_memory_buffer:new_transport_factory(),
>   {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
>   {ok, P0} = PF(),
>   {P1, ok} = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
>   {_P2, B} = thrift_protocol:flush_transport (P1),
>   iolist_to_binary(B).
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (THRIFT-1213) Membuffer should provide a way to get back the buffer

Posted by "Anthony Molinaro (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1213?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Anthony Molinaro updated THRIFT-1213:
-------------------------------------

    Attachment: THRIFT-1213

Patch mentioned in description

> Membuffer should provide a way to get back the buffer
> -----------------------------------------------------
>
>                 Key: THRIFT-1213
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1213
>             Project: Thrift
>          Issue Type: Improvement
>            Reporter: Anthony Molinaro
>            Assignee: Anthony Molinaro
>         Attachments: THRIFT-1213
>
>
> I wanted to get the binary representation of a serialized thrift object and had to do something like
> {code:none}
> thrift_something_to_binary (SomeThing) ->
>   {ok, TF} = thrift_memory_buffer:new_transport_factory(),
>   {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
>   {ok, P0} = PF(),
>   {{ protocol, thrift_binary_protocol,{ binary_protocol,{transport, thrift_memory_buffer, {memory_buffer,B} },true,true}},ok} 
>     = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
>   iolist_to_binary(B).
> {code}
> With the attached patch instead the flush call of the transport will return the buffer so the large brittle pattern match above can be accomplished instead with
> {code:none}
> thrift_something_to_binary (SomeThing) ->
>   {ok, TF} = thrift_memory_buffer:new_transport_factory(),
>   {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
>   {ok, P0} = PF(),
>   {P1, ok} = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
>   {_P2, B} = thrift_protocol:flush_transport (P1),
>   iolist_to_binary(B).
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (THRIFT-1213) Membuffer should provide a way to get back the buffer

Posted by "Anthony Molinaro (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1213?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Anthony Molinaro resolved THRIFT-1213.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: 0.7

Fix as outlined in description.

> Membuffer should provide a way to get back the buffer
> -----------------------------------------------------
>
>                 Key: THRIFT-1213
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1213
>             Project: Thrift
>          Issue Type: Improvement
>            Reporter: Anthony Molinaro
>            Assignee: Anthony Molinaro
>             Fix For: 0.7
>
>         Attachments: THRIFT-1213
>
>
> I wanted to get the binary representation of a serialized thrift object and had to do something like
> {code:none}
> thrift_something_to_binary (SomeThing) ->
>   {ok, TF} = thrift_memory_buffer:new_transport_factory(),
>   {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
>   {ok, P0} = PF(),
>   {{ protocol, thrift_binary_protocol,{ binary_protocol,{transport, thrift_memory_buffer, {memory_buffer,B} },true,true}},ok} 
>     = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
>   iolist_to_binary(B).
> {code}
> With the attached patch instead the flush call of the transport will return the buffer so the large brittle pattern match above can be accomplished instead with
> {code:none}
> thrift_something_to_binary (SomeThing) ->
>   {ok, TF} = thrift_memory_buffer:new_transport_factory(),
>   {ok, PF} = thrift_binary_protocol:new_protocol_factory(TF,[]),
>   {ok, P0} = PF(),
>   {P1, ok} = thrift_protocol:write (P0,{{list, some_types:struct_info('some')}, SomeThing }),
>   {_P2, B} = thrift_protocol:flush_transport (P1),
>   iolist_to_binary(B).
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira