hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anoopsamj...@apache.org
Subject hbase git commit: HBASE-17245 Replace HTableDescriptor#htd.getColumnFamilies().length with a low-cost implementation. (huaxiang sun)
Date Mon, 05 Dec 2016 07:59:17 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 004f0abb4 -> e10baacd3


HBASE-17245 Replace HTableDescriptor#htd.getColumnFamilies().length with a low-cost implementation.
(huaxiang sun)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e10baacd
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e10baacd
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e10baacd

Branch: refs/heads/master
Commit: e10baacd3e3e0c46ad4a0473990b682ed834c5f5
Parents: 004f0ab
Author: anoopsamjohn <anoopsamjohn@gmail.com>
Authored: Mon Dec 5 13:28:57 2016 +0530
Committer: anoopsamjohn <anoopsamjohn@gmail.com>
Committed: Mon Dec 5 13:28:57 2016 +0530

----------------------------------------------------------------------
 .../main/java/org/apache/hadoop/hbase/HTableDescriptor.java | 9 +++++++++
 .../hadoop/hbase/IntegrationTestDDLMasterFailover.java      | 2 +-
 .../main/java/org/apache/hadoop/hbase/master/HMaster.java   | 2 +-
 .../hadoop/hbase/master/procedure/CreateTableProcedure.java | 2 +-
 .../hbase/master/procedure/DeleteColumnFamilyProcedure.java | 2 +-
 .../hadoop/hbase/master/procedure/ModifyTableProcedure.java | 2 +-
 .../hbase/master/procedure/RestoreSnapshotProcedure.java    | 2 +-
 .../java/org/apache/hadoop/hbase/regionserver/HRegion.java  | 2 +-
 .../apache/hadoop/hbase/client/TestReplicaWithCluster.java  | 4 ++--
 .../TestDeleteColumnFamilyProcedureFromClient.java          | 4 ++--
 .../apache/hadoop/hbase/wal/WALPerformanceEvaluation.java   | 2 +-
 11 files changed, 21 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e10baacd/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java
index 3d8d7da..be8e858 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java
@@ -1198,6 +1198,15 @@ public class HTableDescriptor implements Comparable<HTableDescriptor>
{
   }
 
   /**
+   * Returns the count of the column families of the table.
+   *
+   * @return Count of column families of the table
+   */
+  public int getColumnFamilyCount() {
+    return families.size();
+  }
+
+  /**
    * Returns an array all the {@link HColumnDescriptor} of the column families
    * of the table.
    *

http://git-wip-us.apache.org/repos/asf/hbase/blob/e10baacd/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestDDLMasterFailover.java
----------------------------------------------------------------------
diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestDDLMasterFailover.java
b/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestDDLMasterFailover.java
index 741c2d2..59cb8dd 100644
--- a/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestDDLMasterFailover.java
+++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestDDLMasterFailover.java
@@ -733,7 +733,7 @@ public class IntegrationTestDDLMasterFailover extends IntegrationTestBase
{
 
       Admin admin = connection.getAdmin();
       try {
-        if (selected.getColumnFamilies().length < 2) {
+        if (selected.getColumnFamilyCount() < 2) {
           LOG.info("No enough column families to delete in table " + selected.getTableName());
           return;
         }

http://git-wip-us.apache.org/repos/asf/hbase/blob/e10baacd/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index 710c48a..af05c16 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -1694,7 +1694,7 @@ public class HMaster extends HRegionServer implements MasterServices
{
       warnOrThrowExceptionForFailure(false, CONF_KEY, e.getMessage(), e);
     }
     // check that we have at least 1 CF
-    if (htd.getColumnFamilies().length == 0) {
+    if (htd.getColumnFamilyCount() == 0) {
       String message = "Table should have at least one column family.";
       warnOrThrowExceptionForFailure(logWarn, CONF_KEY, message, null);
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/e10baacd/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
index 7e772e2..0d24f51 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
@@ -231,7 +231,7 @@ public class CreateTableProcedure
     }
 
     // check that we have at least 1 CF
-    if (hTableDescriptor.getColumnFamilies().length == 0) {
+    if (hTableDescriptor.getColumnFamilyCount() == 0) {
       setFailure("master-create-table", new DoNotRetryIOException("Table " +
           getTableName().toString() + " should have at least one column family."));
       return false;

http://git-wip-us.apache.org/repos/asf/hbase/blob/e10baacd/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
index 238ecf2..096172a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
@@ -242,7 +242,7 @@ public class DeleteColumnFamilyProcedure
           + "' does not exist, so it cannot be deleted");
     }
 
-    if (unmodifiedHTableDescriptor.getColumnFamilies().length == 1) {
+    if (unmodifiedHTableDescriptor.getColumnFamilyCount() == 1) {
       throw new InvalidFamilyOperationException("Family '" + getColumnFamilyName()
         + "' is the only column family in the table, so it cannot be deleted");
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/e10baacd/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java
index 052d4d8..f1b411a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java
@@ -237,7 +237,7 @@ public class ModifyTableProcedure
     }
 
     // check that we have at least 1 CF
-    if (modifiedHTableDescriptor.getColumnFamilies().length == 0) {
+    if (modifiedHTableDescriptor.getColumnFamilyCount() == 0) {
       throw new DoNotRetryIOException("Table " + getTableName().toString() +
         " should have at least one column family.");
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/e10baacd/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RestoreSnapshotProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RestoreSnapshotProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RestoreSnapshotProcedure.java
index be693fe..d99bd6b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RestoreSnapshotProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RestoreSnapshotProcedure.java
@@ -326,7 +326,7 @@ public class RestoreSnapshotProcedure
     env.getMasterServices().checkTableModifiable(tableName);
 
     // Check that we have at least 1 CF
-    if (modifiedHTableDescriptor.getColumnFamilies().length == 0) {
+    if (modifiedHTableDescriptor.getColumnFamilyCount() == 0) {
       throw new DoNotRetryIOException("Table " + getTableName().toString() +
         " should have at least one column family.");
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/e10baacd/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index 86da348..ed8c5d2 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -802,7 +802,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver,
Regi
   private long initialize(final CancelableProgressable reporter) throws IOException {
 
     //Refuse to open the region if there is no column family in the table
-    if (htableDescriptor.getColumnFamilies().length == 0) {
+    if (htableDescriptor.getColumnFamilyCount() == 0) {
       throw new DoNotRetryIOException("Table " + htableDescriptor.getNameAsString() +
           " should have at least one column family.");
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/e10baacd/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicaWithCluster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicaWithCluster.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicaWithCluster.java
index 1687a4d..9f9037f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicaWithCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicaWithCluster.java
@@ -246,7 +246,7 @@ public class TestReplicaWithCluster {
     HTU.getHBaseAdmin().enableTable(hdt.getTableName());
     HTableDescriptor nHdt = HTU.getHBaseAdmin().getTableDescriptor(hdt.getTableName());
     Assert.assertEquals("fams=" + Arrays.toString(nHdt.getColumnFamilies()),
-        bHdt.getColumnFamilies().length + 1, nHdt.getColumnFamilies().length);
+        bHdt.getColumnFamilyCount() + 1, nHdt.getColumnFamilyCount());
 
     p = new Put(row);
     p.addColumn(row, row, row);
@@ -270,7 +270,7 @@ public class TestReplicaWithCluster {
     Admin admin = HTU.getHBaseAdmin();
     nHdt =admin.getTableDescriptor(hdt.getTableName());
     Assert.assertEquals("fams=" + Arrays.toString(nHdt.getColumnFamilies()),
-        bHdt.getColumnFamilies().length + 1, nHdt.getColumnFamilies().length);
+        bHdt.getColumnFamilyCount() + 1, nHdt.getColumnFamilyCount());
 
     admin.disableTable(hdt.getTableName());
     admin.deleteTable(hdt.getTableName());

http://git-wip-us.apache.org/repos/asf/hbase/blob/e10baacd/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteColumnFamilyProcedureFromClient.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteColumnFamilyProcedureFromClient.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteColumnFamilyProcedureFromClient.java
index 4524a37..fd17f30 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteColumnFamilyProcedureFromClient.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteColumnFamilyProcedureFromClient.java
@@ -107,7 +107,7 @@ public class TestDeleteColumnFamilyProcedureFromClient {
     assertTrue(admin.isTableAvailable(TABLENAME));
 
     // 2 - Check if all three families exist in descriptor
-    assertEquals(3, beforehtd.getColumnFamilies().length);
+    assertEquals(3, beforehtd.getColumnFamilyCount());
     HColumnDescriptor[] families = beforehtd.getColumnFamilies();
     for (int i = 0; i < families.length; i++) {
       assertTrue(families[i].getNameAsString().equals("cf" + (i + 1)));
@@ -147,7 +147,7 @@ public class TestDeleteColumnFamilyProcedureFromClient {
 
     // 5 - Check if only 2 column families exist in the descriptor
     HTableDescriptor afterhtd = admin.getTableDescriptor(TABLENAME);
-    assertEquals(2, afterhtd.getColumnFamilies().length);
+    assertEquals(2, afterhtd.getColumnFamilyCount());
     HColumnDescriptor[] newFamilies = afterhtd.getColumnFamilies();
     assertTrue(newFamilies[0].getNameAsString().equals("cf1"));
     assertTrue(newFamilies[1].getNameAsString().equals("cf3"));

http://git-wip-us.apache.org/repos/asf/hbase/blob/e10baacd/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/WALPerformanceEvaluation.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/WALPerformanceEvaluation.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/WALPerformanceEvaluation.java
index 1b513b2..7300ee4 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/WALPerformanceEvaluation.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/WALPerformanceEvaluation.java
@@ -138,7 +138,7 @@ public final class WALPerformanceEvaluation extends Configured implements
Tool {
       this.numIterations = numIterations;
       this.noSync = noSync;
       this.syncInterval = syncInterval;
-      this.numFamilies = htd.getColumnFamilies().length;
+      this.numFamilies = htd.getColumnFamilyCount();
       this.region = region;
       this.htd = htd;
       scopes = new TreeMap<byte[], Integer>(


Mime
View raw message