hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [24/32] hbase git commit: HBASE-14770 RowCounter argument input parse error
Date Mon, 08 Feb 2016 23:14:04 GMT
HBASE-14770 RowCounter argument input parse error

Signed-off-by: stack <stack@apache.org>


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

Branch: refs/heads/hbase-12439
Commit: 59b03c77de659f426b6290e19faed76787b72872
Parents: efc7a0d
Author: Adrian Muraru <amuraru@adobe.com>
Authored: Sun Jan 24 18:10:35 2016 +0200
Committer: stack <stack@apache.org>
Committed: Fri Feb 5 21:41:30 2016 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/mapreduce/RowCounter.java      | 17 ++++++------
 .../hadoop/hbase/mapreduce/TestRowCounter.java  | 27 ++++++++++++++++----
 2 files changed, 30 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/59b03c77/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/RowCounter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/RowCounter.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/RowCounter.java
index 145b366..8522a61 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/RowCounter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/RowCounter.java
@@ -118,10 +118,7 @@ public class RowCounter extends Configured implements Tool {
         }
         startKey = startEnd[0];
         endKey = startEnd[1];
-      }
-      if (startTime < endTime) {
-        printUsage("--endtime=" + endTime + " needs to be greater than --starttime=" + startTime);
-        return null;
+        continue;
       }
       if (args[i].startsWith(startTimeArgKey)) {
         startTime = Long.parseLong(args[i].substring(startTimeArgKey.length()));
@@ -136,11 +133,13 @@ public class RowCounter extends Configured implements Tool {
             Long.parseLong(args[i].substring(expectedCountArg.length())));
         continue;
       }
-      else {
-        // if no switch, assume column names
-        sb.append(args[i]);
-        sb.append(" ");
-      }
+      // if no switch, assume column names
+      sb.append(args[i]);
+      sb.append(" ");
+    }
+    if (endTime < startTime) {
+      printUsage("--endtime=" + endTime + " needs to be greater than --starttime=" + startTime);
+      return null;
     }
 
     Job job = Job.getInstance(conf, conf.get(JOB_NAME_CONF_KEY, NAME + "_" + tableName));

http://git-wip-us.apache.org/repos/asf/hbase/blob/59b03c77/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
index 8501164..6657d0f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
@@ -57,6 +57,7 @@ public class TestRowCounter {
   private static final Log LOG = LogFactory.getLog(TestRowCounter.class);
   private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
   private final static String TABLE_NAME = "testRowCounter";
+  private final static String TABLE_NAME_TS_RANGE = "testRowCounter_ts_range";
   private final static String COL_FAM = "col_fam";
   private final static String COL1 = "c1";
   private final static String COL2 = "c2";
@@ -138,6 +139,21 @@ public class TestRowCounter {
     runRowCount(args, 10);
   }
 
+
+  /**
+   * Test a case when the column specified in command line arguments is
+   * exclusive for few rows and also a row range filter is specified
+   *
+   * @throws Exception
+   */
+  @Test
+  public void testRowCounterColumnAndRowRange() throws Exception {
+    String[] args = new String[] {
+            TABLE_NAME, "--range=rov,rox", COL_FAM + ":" + COL1
+    };
+    runRowCount(args, 8);
+  }
+
    /**
    * Test a case when the timerange is specified with --starttime and --endtime options
    *
@@ -154,7 +170,8 @@ public class TestRowCounter {
     long ts;
 
     // clean up content of TABLE_NAME
-    Table table = TEST_UTIL.deleteTableData(TableName.valueOf(TABLE_NAME));
+    Table table = TEST_UTIL.createTable(TableName.valueOf(TABLE_NAME_TS_RANGE), Bytes.toBytes(COL_FAM));
+
     ts = System.currentTimeMillis();
     put1.addColumn(family, col1, ts, Bytes.toBytes("val1"));
     table.put(put1);
@@ -168,28 +185,28 @@ public class TestRowCounter {
     table.close();
 
     String[] args = new String[] {
-        TABLE_NAME, COL_FAM + ":" + COL1,
+        TABLE_NAME_TS_RANGE, COL_FAM + ":" + COL1,
         "--starttime=" + 0,
         "--endtime=" + ts
     };
     runRowCount(args, 1);
 
     args = new String[] {
-        TABLE_NAME, COL_FAM + ":" + COL1,
+        TABLE_NAME_TS_RANGE, COL_FAM + ":" + COL1,
         "--starttime=" + 0,
         "--endtime=" + (ts - 10)
     };
     runRowCount(args, 1);
 
     args = new String[] {
-        TABLE_NAME, COL_FAM + ":" + COL1,
+        TABLE_NAME_TS_RANGE, COL_FAM + ":" + COL1,
         "--starttime=" + ts,
         "--endtime=" + (ts + 1000)
     };
     runRowCount(args, 2);
 
     args = new String[] {
-        TABLE_NAME, COL_FAM + ":" + COL1,
+        TABLE_NAME_TS_RANGE, COL_FAM + ":" + COL1,
         "--starttime=" + (ts - 30 * 1000),
         "--endtime=" + (ts + 30 * 1000),
     };


Mime
View raw message