Apache9 commented on a change in pull request #4026:
URL: https://github.com/apache/hbase/pull/4026#discussion_r787884353



##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
##########
@@ -1522,9 +1523,15 @@ public BucketEntry writeToCache(final IOEngine ioEngine, 
final BucketAllocator a
           // If an instance of HFileBlock, save on some allocations.
           HFileBlock block = (HFileBlock) data;
           ByteBuff sliceBuf = block.getBufferReadOnly();
-          ByteBuffer metadata = block.getMetaData();
+          block.getMetaData(metaBuff);
           ioEngine.write(sliceBuf, offset);
-          ioEngine.write(metadata, offset + len - metadata.limit());
+          ioEngine.write(metaBuff, offset + len - metaBuff.limit());
+          // Reset the position for reuse.
+          // The data in metaBuff should be guaranteed that has been 
transferred to the ioEngine
+          // safely. Otherwise, this reuse is problematic. Fortunately, the 
data is already
+          // transferred with our current IOEngines. Should take care, when we 
have new types of
+          // IOEngine in the future.
+          metaBuff.clear();

Review comment:
       Since the metaBuff is passed in from upper layer, I prefer we also do 
this in upper layer? And what if the above ioEngine.write throws IOException 
out?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to