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:58 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 3645223d3 -> 817f30110


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/817f3011
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/817f3011
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/817f3011

Branch: refs/heads/0.98
Commit: 817f30110e6fdcba468c848f4dc458ecf164ce1e
Parents: 3645223
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:51 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/817f3011/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 9083586..6fd485f 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
@@ -118,8 +118,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/817f3011/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/817f3011/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 68d2fe0..63e13b5 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
@@ -22,7 +22,9 @@ import static org.junit.Assert.assertFalse;
 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;
 
@@ -85,4 +87,22 @@ public class TestSplitTable {
         .toBytes("tableA"), Bytes.toBytes("aaa"), Bytes.toBytes("ddd"),
         "locationA")));
   }
+
+  @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/817f3011/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