You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tajo.apache.org by "Henry Saputra (JIRA)" <ji...@apache.org> on 2013/07/29 20:03:50 UTC

[jira] [Commented] (TAJO-95) Eliminate the laze copy approach from the classes wrapping protobuf-generated classes.

    [ https://issues.apache.org/jira/browse/TAJO-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13722746#comment-13722746 ] 

Henry Saputra commented on TAJO-95:
-----------------------------------

Assign to hsaputra per discussion in TAJO-92
                
> Eliminate the laze copy approach from the classes wrapping protobuf-generated classes.
> --------------------------------------------------------------------------------------
>
>                 Key: TAJO-95
>                 URL: https://issues.apache.org/jira/browse/TAJO-95
>             Project: Tajo
>          Issue Type: Improvement
>            Reporter: Hyunsik Choi
>            Assignee: Henry Saputra
>
> We have used two (de)serialization methods, such as JSON and Protocol Buffer. In a (de) serializable object, each attribute can be placed on the  corresponding member variable or the member variable of the protocol buffer object.
> For reducing the frequency of data copies, we have used the laze copy approach that delays copying values from the contents of PB object to member variables or vice versa. It is similar to copy-on-wrote (COW).
> In many cases, however, this mechanism is actually burden rather than the performance benefit like the below code. Especially, this problem becomes more complicated if the wrapper class can be (de)serialized via both JSON and protocol buffer.
> {code:title=a getter method based on the lazy copy approach}
>   protected TableDescProto proto = TableDescProto.getDefaultInstance();
>   protected TableDescProto.Builder builder = null;
>   protected boolean viaProto = false;
>   
>   @Expose protected String tableId;
>   @Expose protected Path uri;
>   @Expose protected TableMeta meta;
>    
>   .
>   .
>   public String getId() { // <- even a simple getter becomes very complicated.
>     TableDescProtoOrBuilder p = viaProto ? proto : builder;
>     
>     if (tableId != null) {
>       return this.tableId;
>     }
>     if (!p.hasId()) {
>       return null;
>     }
>     this.tableId = p.getId();
>     
>     return this.tableId;
>   }
> {code}
> Therefore, I would like to propose the simplification of wrapper classes by eliminating the laze copy approach. My proposal is as follows:
>  * A wrapper class only keeps values in member variables when it is created.
>  * A wrapper class only builds the corresponding protobuf object when getProto() is called.
> I think that the performance benefit has been very low. We should remove the lazy copy approach for more robust system.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira