hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nkey...@apache.org
Subject svn commit: r1545609 - in /hbase/branches/0.96: hbase-client/src/main/java/org/apache/hadoop/hbase/client/ hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/ hbase-server/src/main/ja...
Date Tue, 26 Nov 2013 10:56:53 GMT
Author: nkeywal
Date: Tue Nov 26 10:56:52 2013
New Revision: 1545609

URL: http://svn.apache.org/r1545609
Log:
HBASE-10024 Add an interface to create put with immutable arrays

Modified:
    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/protobuf/ProtobufUtil.java
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaMigrationConvertingToPB.java
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeAssignmentHelper.java
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlLists.java
    hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitLogWorker.java
    hbase/branches/0.96/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
    hbase/branches/0.96/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java

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=1545609&r1=1545608&r2=1545609&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
Tue Nov 26 10:56:52 2013
@@ -135,6 +135,15 @@ public class Put extends Mutation implem
   }
 
   /**
+   * See {@link #add(byte[], byte[], byte[])}. This version expects
+   * that the underlying arrays won't change. It's intended
+   * for usage internal HBase to and for advanced client applications.
+   */
+  public Put addImmutable(byte [] family, byte [] qualifier, byte [] value) {
+    return addImmutable(family, qualifier, this.ts, value);
+  }
+
+  /**
    * Add the specified column and value, with the specified timestamp as
    * its version to this Put operation.
    * @param family family name
@@ -150,6 +159,22 @@ 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);
+    return this;
+  }
+
+  /**
+   * See {@link #add(byte[], byte[], long, byte[])}. This version expects
+   * that the underlying arrays won't change. It's intended
+   * for usage internal HBase to and for advanced client applications.
+   */
+  public Put addImmutable(byte [] family, byte [] qualifier, long ts, byte [] value) {
+    if (ts < 0) {
+      throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts);
+    }
+    List<Cell> list = getCellList(family);
+    KeyValue kv = createPutKeyValue(family, qualifier, ts, value);
+    list.add(kv);
     familyMap.put(family, list);
     return this;
   }
@@ -170,7 +195,24 @@ public class Put extends Mutation implem
     List<Cell> list = getCellList(family);
     KeyValue kv = createPutKeyValue(family, qualifier, ts, value);
     list.add(kv);
-    familyMap.put(kv.getFamily(), list);
+    familyMap.put(CellUtil.cloneFamily(kv), list);
+    return this;
+  }
+
+  /**
+   * See {@link #add(byte[], ByteBuffer, long, ByteBuffer)}. This version expects
+   * that the underlying arrays won't change. It's intended
+   * for usage internal HBase to and for advanced client applications.
+   */
+  @SuppressWarnings("unchecked")
+  public Put addImmutable(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value)
{
+    if (ts < 0) {
+      throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts);
+    }
+    List<Cell> list = getCellList(family);
+    KeyValue kv = createPutKeyValue(family, qualifier, ts, value);
+    list.add(kv);
+    familyMap.put(family, list);
     return this;
   }
 

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=1545609&r1=1545608&r2=1545609&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
Tue Nov 26 10:56:52 2013
@@ -500,7 +500,7 @@ public final class ProtobufUtil {
         if (put == null) {
           put = new Put(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), timestamp);
         }
-        put.add(KeyValueUtil.ensureKeyValue(cell));
+        put.add(cell);
       }
     } else {
       if (proto.hasRow()) {
@@ -524,7 +524,7 @@ public final class ProtobufUtil {
           if (qv.hasTimestamp()) {
             ts = qv.getTimestamp();
           }
-          put.add(family, qualifier, ts, value);
+          put.addImmutable(family, qualifier, ts, value);
         }
       }
     }

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java?rev=1545609&r1=1545608&r2=1545609&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
Tue Nov 26 10:56:52 2013
@@ -84,10 +84,12 @@ public class MetaEditor {
    */
   public static Put addDaughtersToPut(Put put, HRegionInfo splitA, HRegionInfo splitB) {
     if (splitA != null) {
-      put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER, splitA.toByteArray());
+      put.addImmutable(
+          HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER, splitA.toByteArray());
     }
     if (splitB != null) {
-      put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER, splitB.toByteArray());
+      put.addImmutable(
+          HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER, splitB.toByteArray());
     }
     return put;
   }
@@ -315,9 +317,9 @@ public class MetaEditor {
 
       // Put for parent
       Put putOfMerged = makePutFromRegionInfo(copyOfMerged);
-      putOfMerged.add(HConstants.CATALOG_FAMILY, HConstants.MERGEA_QUALIFIER,
+      putOfMerged.addImmutable(HConstants.CATALOG_FAMILY, HConstants.MERGEA_QUALIFIER,
           regionA.toByteArray());
-      putOfMerged.add(HConstants.CATALOG_FAMILY, HConstants.MERGEB_QUALIFIER,
+      putOfMerged.addImmutable(HConstants.CATALOG_FAMILY, HConstants.MERGEB_QUALIFIER,
           regionB.toByteArray());
 
       // Deletes for merging regions
@@ -561,17 +563,17 @@ public class MetaEditor {
 
   private static Put addRegionInfo(final Put p, final HRegionInfo hri)
   throws IOException {
-    p.add(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
+    p.addImmutable(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
         hri.toByteArray());
     return p;
   }
 
   private static Put addLocation(final Put p, final ServerName sn, long openSeqNum) {
-    p.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
+    p.addImmutable(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
       Bytes.toBytes(sn.getHostAndPort()));
-    p.add(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER,
+    p.addImmutable(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER,
       Bytes.toBytes(sn.getStartcode()));
-    p.add(HConstants.CATALOG_FAMILY, HConstants.SEQNUM_QUALIFIER,
+    p.addImmutable(HConstants.CATALOG_FAMILY, HConstants.SEQNUM_QUALIFIER,
         Bytes.toBytes(openSeqNum));
     return p;
   }

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaMigrationConvertingToPB.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaMigrationConvertingToPB.java?rev=1545609&r1=1545608&r2=1545609&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaMigrationConvertingToPB.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaMigrationConvertingToPB.java
Tue Nov 26 10:56:52 2013
@@ -91,7 +91,7 @@ public class MetaMigrationConvertingToPB
       //This will 'migrate' the HRI from 092.x and 0.94.x to 0.96+ by reading the
       //writable serialization
       HRegionInfo hri = parseFrom(hriSplitBytes);
-      p.add(HConstants.CATALOG_FAMILY, which, hri.toByteArray());
+      p.addImmutable(HConstants.CATALOG_FAMILY, which, hri.toByteArray());
     }
   }
 

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java?rev=1545609&r1=1545608&r2=1545609&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java
Tue Nov 26 10:56:52 2013
@@ -154,7 +154,7 @@ public class TableNamespaceManager {
 
   private void upsert(HTable table, NamespaceDescriptor ns) throws IOException {
     Put p = new Put(Bytes.toBytes(ns.getName()));
-    p.add(HTableDescriptor.NAMESPACE_FAMILY_INFO_BYTES,
+    p.addImmutable(HTableDescriptor.NAMESPACE_FAMILY_INFO_BYTES,
         HTableDescriptor.NAMESPACE_COL_DESC_BYTES,
         ProtobufUtil.toProtoNamespaceDescriptor(ns).toByteArray());
     table.put(p);

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeAssignmentHelper.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeAssignmentHelper.java?rev=1545609&r1=1545608&r2=1545609&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeAssignmentHelper.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeAssignmentHelper.java
Tue Nov 26 10:56:52 2013
@@ -143,7 +143,7 @@ public class FavoredNodeAssignmentHelper
     if (favoredNodeList != null) {
       put = MetaEditor.makePutFromRegionInfo(regionInfo);
       byte[] favoredNodes = getFavoredNodes(favoredNodeList);
-      put.add(HConstants.CATALOG_FAMILY, FAVOREDNODES_QUALIFIER,
+      put.addImmutable(HConstants.CATALOG_FAMILY, FAVOREDNODES_QUALIFIER,
           EnvironmentEdgeManager.currentTimeMillis(), favoredNodes);
       LOG.info("Create the region " + regionInfo.getRegionNameAsString() +
           " with favored nodes " + favoredNodes);

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java?rev=1545609&r1=1545608&r2=1545609&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
Tue Nov 26 10:56:52 2013
@@ -462,7 +462,7 @@ public class NamespaceUpgrade implements
     // create a put for new _acl_ entry with rowkey as hbase:acl
     Put p = new Put(AccessControlLists.ACL_GLOBAL_NAME);
     for (Cell c : r.rawCells()) {
-      p.add(CellUtil.cloneFamily(c), CellUtil.cloneQualifier(c), CellUtil.cloneValue(c));
+      p.addImmutable(CellUtil.cloneFamily(c), CellUtil.cloneQualifier(c), CellUtil.cloneValue(c));
     }
     region.put(p);
     // delete the old entry

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java?rev=1545609&r1=1545608&r2=1545609&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java
Tue Nov 26 10:56:52 2013
@@ -224,7 +224,7 @@ public class RowResource extends Resourc
               .type(MIMETYPE_TEXT).entity("Bad request" + CRLF)
               .build();
           }
-          put.add(parts[0], parts[1], cell.getTimestamp(), cell.getValue());
+          put.addImmutable(parts[0], parts[1], cell.getTimestamp(), cell.getValue());
         }
         puts.add(put);
         if (LOG.isDebugEnabled()) {
@@ -293,7 +293,7 @@ public class RowResource extends Resourc
           .type(MIMETYPE_TEXT).entity("Bad request" + CRLF)
           .build();
       }
-      put.add(parts[0], parts[1], timestamp, message);
+      put.addImmutable(parts[0], parts[1], timestamp, message);
       table = servlet.getTable(tableResource.getName());
       table.put(put);
       if (LOG.isDebugEnabled()) {
@@ -471,7 +471,7 @@ public class RowResource extends Resourc
           .type(MIMETYPE_TEXT).entity("Bad request" + CRLF)
           .build();
       }
-      put.add(valueToPutParts[0], valueToPutParts[1], valueToPutCell
+      put.addImmutable(valueToPutParts[0], valueToPutParts[1], valueToPutCell
         .getTimestamp(), valueToPutCell.getValue());
 
       table = servlet.getTable(this.tableResource.getName());

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlLists.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlLists.java?rev=1545609&r1=1545608&r2=1545609&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlLists.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlLists.java
Tue Nov 26 10:56:52 2013
@@ -157,7 +157,7 @@ public class AccessControlLists {
     for (int i = 0; i < actions.length; i++) {
       value[i] = actions[i].code();
     }
-    p.add(ACL_LIST_FAMILY, key, value);
+    p.addImmutable(ACL_LIST_FAMILY, key, value);
     if (LOG.isDebugEnabled()) {
       LOG.debug("Writing permission with rowKey "+
           Bytes.toString(rowKey)+" "+

Modified: hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitLogWorker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitLogWorker.java?rev=1545609&r1=1545608&r2=1545609&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitLogWorker.java
(original)
+++ hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitLogWorker.java
Tue Nov 26 10:56:52 2013
@@ -32,7 +32,6 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.MediumTests;
-import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.SplitLogCounters;
 import org.apache.hadoop.hbase.SplitLogTask;
@@ -357,7 +356,7 @@ public class TestSplitLogWorker {
     SplitLogWorker slw = new SplitLogWorker(zkw, testConf, mockedRS, neverEndingTask);
     slw.start();
     try {
-      waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 0, maxTasks, 3000);
+      waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 0, maxTasks, 6000);
       for (int i = 0; i < maxTasks; i++) {
         byte[] bytes = ZKUtil.getData(zkw, ZKSplitLog.getEncodedNodeName(zkw, TATAS + i));
         SplitLogTask slt = SplitLogTask.parseFrom(bytes);
@@ -402,7 +401,7 @@ public class TestSplitLogWorker {
     slw.start();
     try {
       int acquiredTasks = 0;
-      waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 0, 2, 3000);
+      waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 0, 2, 6000);
       for (int i = 0; i < maxTasks; i++) {
         byte[] bytes = ZKUtil.getData(zkw, ZKSplitLog.getEncodedNodeName(zkw, TATAS + i));
         SplitLogTask slt = SplitLogTask.parseFrom(bytes);

Modified: hbase/branches/0.96/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java?rev=1545609&r1=1545608&r2=1545609&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
(original)
+++ hbase/branches/0.96/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
Tue Nov 26 10:56:52 2013
@@ -1033,7 +1033,7 @@ public class ThriftServerRunner implemen
               LOG.warn("No column qualifier specified. Delete is the only mutation supported
"
                   + "over the whole column family.");
             } else {
-              put.add(famAndQf[0], famAndQf[1],
+              put.addImmutable(famAndQf[0], famAndQf[1],
                   m.value != null ? getBytes(m.value)
                       : HConstants.EMPTY_BYTE_ARRAY);
             }
@@ -1092,7 +1092,7 @@ public class ThriftServerRunner implemen
                   + "over the whole column family.");
             }
             if (famAndQf.length == 2) {
-              put.add(famAndQf[0], famAndQf[1],
+              put.addImmutable(famAndQf[0], famAndQf[1],
                   m.value != null ? getBytes(m.value)
                       : HConstants.EMPTY_BYTE_ARRAY);
             } else {

Modified: hbase/branches/0.96/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java?rev=1545609&r1=1545608&r2=1545609&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java
(original)
+++ hbase/branches/0.96/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java
Tue Nov 26 10:56:52 2013
@@ -198,10 +198,12 @@ public class ThriftUtilities {
 
     for (TColumnValue columnValue : in.getColumnValues()) {
       if (columnValue.isSetTimestamp()) {
-        out.add(columnValue.getFamily(), columnValue.getQualifier(), columnValue.getTimestamp(),
+        out.addImmutable(
+            columnValue.getFamily(), columnValue.getQualifier(), columnValue.getTimestamp(),
             columnValue.getValue());
       } else {
-        out.add(columnValue.getFamily(), columnValue.getQualifier(), columnValue.getValue());
+        out.addImmutable(
+            columnValue.getFamily(), columnValue.getQualifier(), columnValue.getValue());
       }
     }
 



Mime
View raw message