Uploaded image for project: 'Tajo (Retired)'
  1. Tajo (Retired)
  2. TAJO-95

Eliminate the lazy copy approach from the classes wrapping protobuf-generated classes.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • None
    • 0.2-incubating
    • None
    • None

    Description

      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.

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

      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.

      Attachments

        1. TAJO-95.patch
          282 kB
          Hyunsik Choi
        2. TAJO-95_2.patch
          282 kB
          Hyunsik Choi
        3. TAJO-95_3.patch
          282 kB
          Hyunsik Choi

        Issue Links

          Activity

            People

              hyunsik Hyunsik Choi
              hyunsik Hyunsik Choi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: