You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Ted Ross <tr...@redhat.com> on 2016/12/15 13:54:42 UTC

Proton-C Codec Question

I have a map, held in a pn_data_t structure.  I want to replace the 
value of one of the entries in the map with a new value.  Is there a way 
to do this in-place or do I need to create a new pn_data_t and copy the 
old into the new, replacing the value I want to replace?

Thanks,

-Ted

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Proton-C Codec Question

Posted by Ted Ross <tr...@redhat.com>.
On 12/15/2016 11:44 AM, Andrew Stitcher wrote:
> On Thu, 2016-12-15 at 08:54 -0500, Ted Ross wrote:
>> I have a map, held in a pn_data_t structure.  I want to replace the
>> value of one of the entries in the map with a new value.  Is there a
>> way
>> to do this in-place or do I need to create a new pn_data_t and copy
>> the
>> old into the new, replacing the value I want to replace?
>
> In principle, the current pn_data_t datastructure does allow you to do
> this by using pn_data_next until you find the element then
> pn_data_put_xx to replace. There is no path based navigation, although
> there seems to be (an unused) way to directly search symbols or
> strings.
>
> HOWEVER (big however!)
>
> Currently there is *no* code that actually modifies the middle of
> pn_data_t in place. Code only decodes AMQP data bytes then reads the
> data structure from the pn_data_t or creates the pn_data_t and writes
> the bytes. The pn_data_t code is complex and the structure is much
> larger and more complex (and hance almost certainly slower) than 2
> different structures one specialised for read and one for write would
> be.
>
> Given this it has been in mind for a while now to transition the use of
> pn_data_t to 2 new read and write only structures.

For the record, Dispatch has a similar facility.  There are two modules: 
Parse and Compose.  Parse is for reading encoded data and Compose is for 
writing encoded data.  In both cases, the data is stored in the encoded 
format in buffer chains.

Thank you, this is helpful.  I will follow your advice.

>
> So I'd really appreciate it if you just copy the pn_data_t changing the
>  element you need to change on the way! From what I can see of the API
> this is hardly less time efficient anyway, but may use more space due
> to needing a pn_data_t to copy into.
>
> HTH
>
> Andrew
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Proton-C Codec Question

Posted by Andrew Stitcher <as...@redhat.com>.
On Thu, 2016-12-15 at 08:54 -0500, Ted Ross wrote:
> I have a map, held in a pn_data_t structure.��I want to replace the�
> value of one of the entries in the map with a new value.��Is there a
> way�
> to do this in-place or do I need to create a new pn_data_t and copy
> the�
> old into the new, replacing the value I want to replace?

In principle, the current pn_data_t datastructure does allow you to do
this by using pn_data_next until you find the element then
pn_data_put_xx to replace. There is no path based navigation, although
there seems to be (an unused) way to directly search symbols or
strings.

HOWEVER (big however!)

Currently there is *no* code that actually modifies the middle of
pn_data_t in place. Code only decodes AMQP data bytes then reads the
data structure from the pn_data_t or creates the pn_data_t and writes
the bytes. The pn_data_t code is complex and the structure is much
larger and more complex (and hance almost certainly slower) than 2
different structures one specialised for read and one for write would
be.

Given this it has been in mind for a while now to transition the use of
pn_data_t to 2 new read and write only structures.

So I'd really appreciate it if you just copy the pn_data_t changing the
 element you need to change on the way! From what I can see of the API
this is hardly less time efficient anyway, but may use more space due
to needing a pn_data_t to copy into.

HTH

Andrew


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org