hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [01/29] hbase git commit: HBASE-16567 Upgrade to protobuf-3.1.x Regenerate all protos in this module with protoc3. Redo ByteStringer to use new pb3.1.0 unsafebytesutil instead of HBaseZeroCopyByteString
Date Fri, 30 Sep 2016 00:30:30 GMT
Repository: hbase
Updated Branches:
  refs/heads/HBASE-16264 17d4b70df -> 35cf55048


http://git-wip-us.apache.org/repos/asf/hbase/blob/b4a729ed/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/util/ByteStringer.java
----------------------------------------------------------------------
diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/util/ByteStringer.java
b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/util/ByteStringer.java
index 4ccf154..38cc0bd 100644
--- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/util/ByteStringer.java
+++ b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/util/ByteStringer.java
@@ -17,37 +17,17 @@
  */
 package org.apache.hadoop.hbase.shaded.util;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 
 import com.google.protobuf.ByteString;
-import com.google.protobuf.HBaseZeroCopyByteString;
+import com.google.protobuf.UnsafeByteOperations;
 
 /**
  * Hack to workaround HBASE-10304 issue that keeps bubbling up when a mapreduce context.
  */
+// Depends on protobuf-3.1.0 feature.
 @InterfaceAudience.Private
 public class ByteStringer {
-  private static final Log LOG = LogFactory.getLog(ByteStringer.class);
-
-  /**
-   * Flag set at class loading time.
-   */
-  private static boolean USE_ZEROCOPYBYTESTRING = true;
-
-  // Can I classload HBaseZeroCopyByteString without IllegalAccessError?
-  // If we can, use it passing ByteStrings to pb else use native ByteString though more costly
-  // because it makes a copy of the passed in array.
-  static {
-    try {
-      HBaseZeroCopyByteString.wrap(new byte [0]);
-    } catch (IllegalAccessError iae) {
-      USE_ZEROCOPYBYTESTRING = false;
-      LOG.debug("Failed to classload HBaseZeroCopyByteString: " + iae.toString());
-    }
-  }
-
   private ByteStringer() {
     super();
   }
@@ -56,14 +36,13 @@ public class ByteStringer {
    * Wraps a byte array in a {@link ByteString} without copying it.
    */
   public static ByteString wrap(final byte[] array) {
-    return USE_ZEROCOPYBYTESTRING? HBaseZeroCopyByteString.wrap(array): ByteString.copyFrom(array);
+    return UnsafeByteOperations.unsafeWrap(array);
   }
 
   /**
    * Wraps a subset of a byte array in a {@link ByteString} without copying it.
    */
   public static ByteString wrap(final byte[] array, int offset, int length) {
-    return USE_ZEROCOPYBYTESTRING? HBaseZeroCopyByteString.wrap(array, offset, length):
-      ByteString.copyFrom(array, offset, length);
+    return UnsafeByteOperations.unsafeWrap(array, offset, length);
   }
 }


Mime
View raw message