hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject git commit: HBASE-11877 Make TableSplit more readable (Liu Shaohui)
Date Fri, 05 Sep 2014 04:26:31 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 5fa07efd7 -> c0d81e9ad


HBASE-11877 Make TableSplit more readable (Liu Shaohui)


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

Branch: refs/heads/branch-1
Commit: c0d81e9ad014609c7a5e118e66b902f828818edd
Parents: 5fa07ef
Author: stack <stack@apache.org>
Authored: Thu Sep 4 21:25:54 2014 -0700
Committer: stack <stack@apache.org>
Committed: Thu Sep 4 21:26:22 2014 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hbase/mapred/TableSplit.java  | 10 ++++++++--
 .../hadoop/hbase/mapreduce/TableSplit.java      | 11 +++++++++--
 .../hadoop/hbase/mapred/TestSplitTable.java     | 20 ++++++++++++++++++++
 .../hadoop/hbase/mapreduce/TestTableSplit.java  | 16 ++++++++++++++++
 4 files changed, 53 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/c0d81e9a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableSplit.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableSplit.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableSplit.java
index b3c8b82..8a1beee 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableSplit.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableSplit.java
@@ -119,8 +119,14 @@ public class TableSplit implements InputSplit, Comparable<TableSplit>
{
 
   @Override
   public String toString() {
-    return m_regionLocation + ":" +
-      Bytes.toStringBinary(m_startRow) + "," + Bytes.toStringBinary(m_endRow);
+      StringBuilder sb = new StringBuilder();
+      sb.append("HBase table split(");
+      sb.append("table name: ").append(m_tableName);
+      sb.append(", start row: ").append(Bytes.toStringBinary(m_startRow));
+      sb.append(", end row: ").append(Bytes.toStringBinary(m_endRow));
+      sb.append(", region location: ").append(m_regionLocation);
+      sb.append(")");
+      return sb.toString();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hbase/blob/c0d81e9a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSplit.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSplit.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSplit.java
index 5e3aeef..b43e870 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSplit.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSplit.java
@@ -314,8 +314,15 @@ implements Writable, Comparable<TableSplit> {
    */
   @Override
   public String toString() {
-    return regionLocation + ":" +
-      Bytes.toStringBinary(startRow) + "," + Bytes.toStringBinary(endRow);
+    StringBuilder sb = new StringBuilder();
+    sb.append("HBase table split(");
+    sb.append("table name: ").append(tableName);
+    sb.append(", scan: ").append(scan);
+    sb.append(", start row: ").append(Bytes.toStringBinary(startRow));
+    sb.append(", end row: ").append(Bytes.toStringBinary(endRow));
+    sb.append(", region location: ").append(regionLocation);
+    sb.append(")");
+    return sb.toString();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/c0d81e9a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestSplitTable.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestSplitTable.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestSplitTable.java
index 86f6272..d60a5e7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestSplitTable.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestSplitTable.java
@@ -23,7 +23,9 @@ import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
 
 import org.apache.hadoop.hbase.SmallTests;
+import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -88,4 +90,22 @@ public class TestSplitTable {
     assertEquals(tablesplit.hashCode(), same.hashCode());
     assertEquals(tablesplit, same);
   }
+
+  @Test
+  @SuppressWarnings("deprecation")
+  public void testToString() {
+    TableSplit split =
+        new TableSplit(TableName.valueOf("table"), "row-start".getBytes(), "row-end".getBytes(),
+            "location");
+    String str =
+        "HBase table split(table name: table, start row: row-start, "
+            + "end row: row-end, region location: location)";
+    Assert.assertEquals(str, split.toString());
+
+    split = new TableSplit((TableName) null, null, null, null);
+    str =
+        "HBase table split(table name: null, start row: null, "
+            + "end row: null, region location: null)";
+    Assert.assertEquals(str, split.toString());
+  }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/c0d81e9a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSplit.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSplit.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSplit.java
index 9daef9a..e40c5fc 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSplit.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSplit.java
@@ -85,5 +85,21 @@ public class TestTableSplit {
     Assert.assertEquals(666, deserialized.getLength());
   }
 
+  @Test
+  public void testToString() {
+    TableSplit split =
+        new TableSplit(TableName.valueOf("table"), "row-start".getBytes(), "row-end".getBytes(),
+            "location");
+    String str =
+        "HBase table split(table name: table, scan: , start row: row-start, "
+            + "end row: row-end, region location: location)";
+    Assert.assertEquals(str, split.toString());
+
+    split = new TableSplit((TableName) null, null, null, null);
+    str =
+        "HBase table split(table name: null, scan: , start row: null, "
+            + "end row: null, region location: null)";
+    Assert.assertEquals(str, split.toString());
+  }
 }
 


Mime
View raw message