[
https://issues.apache.org/jira/browse/AVRO-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12880364#action_12880364
]
John Yu commented on AVRO-183:
------------------------------
Hi All,
I am working on this issue now and have some doubts of it. First, is the
function to be implemented DatumWriter#sizeof(Object datum, Encoder encoder)? I
am thinking this because different encoder will output different sizeof given
an object. If this is true, there are several different ways to implement this.
(1) Add a function sizeof(Object o) in Encoder, then DatumWriter will call
Encoder#sizeof(Object o) . Each encoder implements sizeof(Object o). In this
function, Encoder needs to do reflection to know what type o is, similar as
DatumWriter#sizeof did. The bad thing is that Encoder should never do this. It
just needs to know how to write int, float, etc. This has break some existing
design.
(2) Add a series of functions in Encoder, such as sizeOfInt(), sizeOfFloat(),
the DatumWriter will call these functions just like it calls writeInt() or
writeFLoat. The good thing about this is encoder does not need to do
reflection. However, this will require to add a lot of functions to exising
code structures.
Which solution is better or there are even better solution for this?
> 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.