You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2014/10/22 16:29:55 UTC
git commit: HBASE-12306 CellCounter output's wrong value for Total
Families Across all Rows in output file (Ashish Singhi)
Repository: hbase
Updated Branches:
refs/heads/0.98 babc3a7ab -> ddcc47203
HBASE-12306 CellCounter output's wrong value for Total Families Across all Rows in output file (Ashish Singhi)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ddcc4720
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ddcc4720
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ddcc4720
Branch: refs/heads/0.98
Commit: ddcc47203a8c9c597725c11f460449d15cce6196
Parents: babc3a7
Author: Ted Yu <te...@apache.org>
Authored: Wed Oct 22 14:29:50 2014 +0000
Committer: Ted Yu <te...@apache.org>
Committed: Wed Oct 22 14:29:50 2014 +0000
----------------------------------------------------------------------
.../hadoop/hbase/mapreduce/CellCounter.java | 7 +--
.../hadoop/hbase/mapreduce/TestCellCounter.java | 47 +++++++++++++++++++-
2 files changed, 50 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/ddcc4720/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCounter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCounter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCounter.java
index c25c69c..476ca36 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCounter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCounter.java
@@ -122,9 +122,10 @@ public class CellCounter {
if (!thisRowFamilyName.equals(currentFamilyName)) {
currentFamilyName = thisRowFamilyName;
context.getCounter("CF", thisRowFamilyName).increment(1);
- context.write(new Text("Total Families Across all Rows"),
- new IntWritable(1));
- context.write(new Text(thisRowFamilyName), new IntWritable(1));
+ if (1 == context.getCounter("CF", thisRowFamilyName).getValue()) {
+ context.write(new Text("Total Families Across all Rows"), new IntWritable(1));
+ context.write(new Text(thisRowFamilyName), new IntWritable(1));
+ }
}
String thisRowQualifierName = thisRowFamilyName + separator
+ Bytes.toStringBinary(CellUtil.cloneQualifier(value));
http://git-wip-us.apache.org/repos/asf/hbase/blob/ddcc4720/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellCounter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellCounter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellCounter.java
index 1ccc57d..eaf8288 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellCounter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellCounter.java
@@ -155,4 +155,49 @@ public class TestCellCounter {
System.setSecurityManager(SECURITY_MANAGER);
}
}
-}
\ No newline at end of file
+
+ /**
+ * Test CellCounter for complete table all data should print to output
+ */
+ @Test(timeout = 300000)
+ public void testCellCounterForCompleteTable() throws Exception {
+ String sourceTable = "testCellCounterForCompleteTable";
+ String outputPath = OUTPUT_DIR + sourceTable;
+ LocalFileSystem localFileSystem = new LocalFileSystem();
+ Path outputDir =
+ new Path(outputPath).makeQualified(localFileSystem.getUri(),
+ localFileSystem.getWorkingDirectory());
+ byte[][] families = { FAMILY_A, FAMILY_B };
+ Table t = UTIL.createTable(Bytes.toBytes(sourceTable), families);
+ try {
+ Put p = new Put(ROW1);
+ p.add(FAMILY_A, QUALIFIER, now, Bytes.toBytes("Data11"));
+ p.add(FAMILY_B, QUALIFIER, now + 1, Bytes.toBytes("Data12"));
+ p.add(FAMILY_A, QUALIFIER, now + 2, Bytes.toBytes("Data13"));
+ t.put(p);
+ p = new Put(ROW2);
+ p.add(FAMILY_B, QUALIFIER, now, Bytes.toBytes("Dat21"));
+ p.add(FAMILY_A, QUALIFIER, now + 1, Bytes.toBytes("Data22"));
+ p.add(FAMILY_B, QUALIFIER, now + 2, Bytes.toBytes("Data23"));
+ t.put(p);
+ String[] args = { sourceTable, outputDir.toString(), ";" };
+ runCount(args);
+ FileInputStream inputStream =
+ new FileInputStream(outputPath + File.separator + "part-r-00000");
+ String data = IOUtils.toString(inputStream);
+ inputStream.close();
+ assertTrue(data.contains("Total Families Across all Rows" + "\t" + "2"));
+ assertTrue(data.contains("Total Qualifiers across all Rows" + "\t" + "4"));
+ assertTrue(data.contains("Total ROWS" + "\t" + "2"));
+ assertTrue(data.contains("b;q" + "\t" + "2"));
+ assertTrue(data.contains("a;q" + "\t" + "2"));
+ assertTrue(data.contains("row1;a;q_Versions" + "\t" + "1"));
+ assertTrue(data.contains("row1;b;q_Versions" + "\t" + "1"));
+ assertTrue(data.contains("row2;a;q_Versions" + "\t" + "1"));
+ assertTrue(data.contains("row2;b;q_Versions" + "\t" + "1"));
+ } finally {
+ t.close();
+ FileUtil.fullyDelete(new File(outputPath));
+ }
+ }
+}