[ 
https://issues.apache.org/jira/browse/AVRO-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12881017#action_12881017
 ] 

John Yu commented on AVRO-183:
------------------------------

Hi Doug,

Thanks for the reply. There are two ways of implementing this feature. First, 
when call function sizeof, i create an empty OutputStream, write to it and 
count how many bytes in it. Second, implement a recursive call of sizeof, for 
instance, sizeof(array) = sum of sizeof(element). 

Solution 1 only needs a few lines to implement while there are some performance 
issues in it. Solution 2 requires relatively big changes to existing code base 
but have better performance( Because sizeof a byte array only return an 
integer).

Which one do you think is better? 

> add DatumWriter#sizeOf method that computes the number of bytes an object 
> will be serialized as
> -----------------------------------------------------------------------------------------------
>
>                 Key: AVRO-183
>                 URL: https://issues.apache.org/jira/browse/AVRO-183
>             Project: Avro
>          Issue Type: New Feature
>          Components: java
>            Reporter: Doug Cutting
>            Assignee: John Yu
>
> Sometimes it is useful to know how large an object will be when serialized 
> before it is in fact serialized.

-- 
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