You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2018/02/07 16:06:39 UTC

[GitHub] keith-turner commented on a change in pull request #373: ACCUMULO-4709 sanity check in Mutation

keith-turner commented on a change in pull request #373: ACCUMULO-4709 sanity check in Mutation
URL: https://github.com/apache/accumulo/pull/373#discussion_r166650901
 
 

 ##########
 File path: core/src/main/java/org/apache/accumulo/core/data/Mutation.java
 ##########
 @@ -306,6 +340,9 @@ private void put(byte[] cf, int cfLength, byte[] cq, int cqLength, byte[] cv, bo
     if (buffer == null) {
       throw new IllegalStateException("Can not add to mutation after serializing it");
     }
+    long length = cfLength + cqLength + valLength;
 
 Review comment:
   This does not capture the complete picture.  When data is serialized, the length is written in addition to the data.  For example if a 20 byte family is written it may actually write 21 bytes including the length.  The length is written as a variable length long, so its hard to know how many bytes it will take beforehand.  Because this hard to know beforehand, I would suggest just doing the worst case and assuming 5 bytes.  
   
   Also could take the strategy of only tracking the length of long values and asking the buffer for the size of everything else.  This way an accurate size for what is already serialized is obtained and we only need to estimated what is about to be serialized. 
   
   ```java
     long estimatedNewSize = (cfLength + cqLength + valLength + cv.lenght() + 4* 5 + 1 + (hasTs ? 8 : 0)) + buffer.currentSize() + valueLenghts;
     //sanity check estimated new size
   
   // if large value, then increment valueLenghts
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services