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



##########
File path: 
hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAccess.java
##########
@@ -471,4 +485,57 @@ public static byte toByte(ByteBuffer buf, int offset) {
   public static byte toByte(Object ref, long offset) {
     return theUnsafe.getByte(ref, offset);
   }
+
+  /**
+   * Zero fill a byte buffer as efficiently as possible.
+   * @param buf the byte buffer
+   */
+  public static void clear(final ByteBuffer buf) {
+    if (buf.isDirect()) {
+      clear(((DirectBuffer)buf).address(), buf.capacity());

Review comment:
       I think we could just use Unsafe.setMemory in this case, it should just 
be a memset call in the native code I suppose.

##########
File path: 
hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAccess.java
##########
@@ -330,6 +330,20 @@ public static void copy(byte[] src, int srcOffset, 
ByteBuffer dest, int destOffs
     unsafeCopy(src, srcAddress, destBase, destAddress, length);
   }
 
+  /**
+   * Copies the bytes from given array's offset to length part into the given 
array.
+   * @param src source array
+   * @param srcOffset offset into source buffer
+   * @param dest destination array
+   * @param destOffset offset into destination buffer
+   * @param length length of data to copy
+   */
+  public static void copy(byte[] src, int srcOffset, byte[] dest, int 
destOffset, int length) {

Review comment:
       For copying from byte array to byte array, we could just use 
System.arraycopy? It is a native method.

##########
File path: hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
##########
@@ -2523,4 +2523,11 @@ public static int findCommonPrefix(byte[] left, byte[] 
right, int leftLength, in
     }
     return result;
   }
+
+  public static int fill(final byte[] b, final int off, final int len, final 
byte val) {

Review comment:
       Just use Arrays.fill?




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