hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1537989 - in /hbase/branches/0.96: hbase-client/src/main/java/org/apache/hadoop/hbase/client/ hbase-client/src/main/java/org/apache/hadoop/hbase/client/coprocessor/ hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ hbase-protoco...
Date Fri, 01 Nov 2013 17:11:29 GMT
Author: stack
Date: Fri Nov  1 17:11:29 2013
New Revision: 1537989

URL: http://svn.apache.org/r1537989
Log:
HBASE-9868 Remove some array copy, especially around protobuf

Modified:
    hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
    hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java
    hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
    hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/coprocessor/BigDecimalColumnInterpreter.java
    hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
    hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
    hbase/branches/0.96/hbase-protocol/src/main/java/com/google/protobuf/ZeroCopyLiteralByteString.java
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/constraint/Constraints.java

Modified: hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1537989&r1=1537988&r2=1537989&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
(original)
+++ hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Fri Nov  1 17:11:29 2013
@@ -2733,7 +2733,7 @@ public class HConnectionManager {
    * - nested exceptions
    * 
    * Looks for: RegionMovedException / RegionOpeningException / RegionTooBusyException
-   * @returns null if we didn't find the exception, the exception otherwise.
+   * @return null if we didn't find the exception, the exception otherwise.
    */
   public static Throwable findException(Object exception) {
     if (exception == null || !(exception instanceof Throwable)) {

Modified: hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java?rev=1537989&r1=1537988&r2=1537989&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java
(original)
+++ hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java
Fri Nov  1 17:11:29 2013
@@ -181,7 +181,8 @@ public class Increment extends Mutation 
       NavigableMap<byte [], Long> longs = new TreeMap<byte [], Long>(Bytes.BYTES_COMPARATOR);
       for (Cell cell: entry.getValue()) {
         KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
-        longs.put(kv.getQualifier(), Bytes.toLong(kv.getValue()));
+        longs.put(kv.getQualifier(),
+            Bytes.toLong(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()));
       }
       results.put(entry.getKey(), longs);
     }
@@ -224,7 +225,8 @@ public class Increment extends Mutation 
             moreThanOneB = true;
           }
           KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
-          sb.append(Bytes.toStringBinary(kv.getKey()) + "+=" + Bytes.toLong(kv.getValue()));
+          sb.append(Bytes.toStringBinary(kv.getKey()) + "+=" +
+              Bytes.toLong(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()));
         }
         sb.append("}");
       }

Modified: hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java?rev=1537989&r1=1537988&r2=1537989&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
(original)
+++ hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
Fri Nov  1 17:11:29 2013
@@ -128,7 +128,7 @@ public class Put extends Mutation implem
     List<Cell> list = getCellList(family);
     KeyValue kv = createPutKeyValue(family, qualifier, ts, value);
     list.add(kv);
-    familyMap.put(CellUtil.cloneFamily(kv), list);
+    familyMap.put(family, list);
     return this;
   }
 

Modified: hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/coprocessor/BigDecimalColumnInterpreter.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/coprocessor/BigDecimalColumnInterpreter.java?rev=1537989&r1=1537988&r2=1537989&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/coprocessor/BigDecimalColumnInterpreter.java
(original)
+++ hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/client/coprocessor/BigDecimalColumnInterpreter.java
Fri Nov  1 17:11:29 2013
@@ -47,7 +47,8 @@ public class BigDecimalColumnInterpreter
     if (kv == null || CellUtil.cloneValue(kv) == null) {
       return null;
     }
-    return Bytes.toBigDecimal(CellUtil.cloneValue(kv)).setScale(2, RoundingMode.HALF_EVEN);
+    return Bytes.toBigDecimal(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()).
+        setScale(2, RoundingMode.HALF_EVEN);
   }
 
   @Override

Modified: hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java?rev=1537989&r1=1537988&r2=1537989&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
(original)
+++ hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
Fri Nov  1 17:11:29 2013
@@ -957,8 +957,10 @@ public final class ProtobufUtil {
       if (values != null && values.size() > 0) {
         for (Cell cell: values) {
           KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
-          valueBuilder.setQualifier(ZeroCopyLiteralByteString.wrap(kv.getQualifier()));
-          valueBuilder.setValue(ZeroCopyLiteralByteString.wrap(kv.getValue()));
+          valueBuilder.setQualifier(ZeroCopyLiteralByteString.wrap(
+              kv.getQualifierArray(), kv.getQualifierOffset(), kv.getQualifierLength()));
+          valueBuilder.setValue(ZeroCopyLiteralByteString.wrap(
+              kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()));
           columnBuilder.addQualifierValue(valueBuilder.build());
         }
       }
@@ -994,8 +996,10 @@ public final class ProtobufUtil {
       columnBuilder.clearQualifierValue();
       for (Cell cell: family.getValue()) {
         KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
-        valueBuilder.setQualifier(ZeroCopyLiteralByteString.wrap(kv.getQualifier()));
-        valueBuilder.setValue(ZeroCopyLiteralByteString.wrap(kv.getValue()));
+        valueBuilder.setQualifier(ZeroCopyLiteralByteString.wrap(
+            kv.getQualifierArray(), kv.getQualifierOffset(), kv.getQualifierLength()));
+        valueBuilder.setValue(ZeroCopyLiteralByteString.wrap(
+            kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()));
         valueBuilder.setTimestamp(kv.getTimestamp());
         if (type == MutationType.DELETE) {
           KeyValue.Type keyValueType = KeyValue.Type.codeToType(kv.getType());

Modified: hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java?rev=1537989&r1=1537988&r2=1537989&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
(original)
+++ hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
Fri Nov  1 17:11:29 2013
@@ -487,10 +487,12 @@ public final class RequestConverter {
       final List<Action<R>> actions)
   throws IOException {
     RegionAction.Builder builder = getRegionActionBuilderWithRegion(regionName);
+    ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
+    MutationProto.Builder mutationBuilder = ClientProtos.MutationProto.newBuilder();
     for (Action<R> action: actions) {
       Row row = action.getAction();
-      ClientProtos.Action.Builder actionBuilder =
-          ClientProtos.Action.newBuilder().setIndex(action.getOriginalIndex());
+      actionBuilder.clear();
+      actionBuilder.setIndex(action.getOriginalIndex());
       if (row instanceof Get) {
         Get g = (Get)row;
         builder.addAction(actionBuilder.setGet(ProtobufUtil.toGet(g)));
@@ -535,10 +537,11 @@ public final class RequestConverter {
       final List<Action<R>> actions, final List<CellScannable> cells)
   throws IOException {
     RegionAction.Builder builder = getRegionActionBuilderWithRegion(regionName);
+    ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
     for (Action<R> action: actions) {
       Row row = action.getAction();
-      ClientProtos.Action.Builder actionBuilder =
-        ClientProtos.Action.newBuilder().setIndex(action.getOriginalIndex());
+      actionBuilder.clear();
+      actionBuilder.setIndex(action.getOriginalIndex());
       if (row instanceof Get) {
         Get g = (Get)row;
         builder.addAction(actionBuilder.setGet(ProtobufUtil.toGet(g)));

Modified: hbase/branches/0.96/hbase-protocol/src/main/java/com/google/protobuf/ZeroCopyLiteralByteString.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-protocol/src/main/java/com/google/protobuf/ZeroCopyLiteralByteString.java?rev=1537989&r1=1537988&r2=1537989&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-protocol/src/main/java/com/google/protobuf/ZeroCopyLiteralByteString.java
(original)
+++ hbase/branches/0.96/hbase-protocol/src/main/java/com/google/protobuf/ZeroCopyLiteralByteString.java
Fri Nov  1 17:11:29 2013
@@ -42,6 +42,13 @@ public final class ZeroCopyLiteralByteSt
     return new LiteralByteString(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 new BoundedByteString(array, offset, length);
+  }
+
   // TODO:
   // ZeroCopyLiteralByteString.wrap(this.buf, 0, this.count);
 

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/constraint/Constraints.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/constraint/Constraints.java?rev=1537989&r1=1537988&r2=1537989&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/constraint/Constraints.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/constraint/Constraints.java
Fri Nov  1 17:11:29 2013
@@ -294,7 +294,7 @@ public final class Constraints {
    *          <tt>true</tt> if it should be run
    * @param priority
    *          relative to other constraints
-   * @returns a new configuration, storable in the {@link HTableDescriptor}
+   * @return a new configuration, storable in the {@link HTableDescriptor}
    */
   private static Configuration configure(Configuration conf, boolean enabled,
       long priority) {



Mime
View raw message