[67/77] [abbrv] hbase git commit: HBASE-16776 Remove duplicated versions of countRow() in tests
HBASE-16776 Remove duplicated versions of countRow() in tests Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/b548d497 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b548d497 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b548d497 Branch: refs/heads/hbase-12439 Commit: b548d4978b0bdbfc6bd4e68c3d13e00f8ea4002e Parents: 06758bf Author: Matteo Bertozzi Authored: Wed Oct 5 19:45:50 2016 -0700 Committer: Matteo Bertozzi Committed: Wed Oct 5 19:45:50 2016 -0700 -- .../hadoop/hbase/HBaseTestingUtility.java | 34 .../hadoop/hbase/client/TestFromClientSide.java | 37 + .../procedure/TestServerCrashProcedure.java | 12 +- .../regionserver/TestMobStoreCompaction.java| 39 -- .../TestRegionMergeTransaction.java | 37 + .../regionserver/TestSplitTransaction.java | 42 ++-- .../hadoop/hbase/util/BaseTestHBaseFsck.java| 18 ++--- 7 files changed, 72 insertions(+), 147 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/b548d497/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index cc384de..c74c399 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -2219,13 +2219,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { for (byte[] family: families) { scan.addFamily(family); } -ResultScanner results = table.getScanner(scan); -int count = 0; -for (@SuppressWarnings("unused") Result res : results) { - count++; -} -results.close(); -return count; +return countRows(table, scan); } /** @@ -2240,6 +2234,32 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { } } + public int countRows(final Region region) throws IOException { +return countRows(region, new Scan()); + } + + public int countRows(final Region region, final Scan scan) throws IOException { +InternalScanner scanner = region.getScanner(scan); +try { + return countRows(scanner); +} finally { + scanner.close(); +} + } + + public int countRows(final InternalScanner scanner) throws IOException { +// Do not retrieve the mob data when scanning +int scannedCount = 0; +List results = new ArrayList(); +boolean hasMore = true; +while (hasMore) { + hasMore = scanner.next(results); + scannedCount += results.size(); + results.clear(); +} +return scannedCount; + } + /** * Return an md5 digest of the entire contents of a table. */ http://git-wip-us.apache.org/repos/asf/hbase/blob/b548d497/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java index f10cce3a..50a566a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java @@ -504,7 +504,7 @@ public class TestFromClientSide { byte [] endKey = regions.get(0).getRegionInfo().getEndKey(); // Count rows with a filter that stops us before passed 'endKey'. // Should be count of rows in first region. -int endKeyCount = countRows(t, createScanWithRowFilter(endKey)); +int endKeyCount = TEST_UTIL.countRows(t, createScanWithRowFilter(endKey)); assertTrue(endKeyCount < rowCount); // How do I know I did not got to second region? Thats tough. Can't really @@ -516,29 +516,29 @@ public class TestFromClientSide { // New test. Make it so scan goes into next region by one and then two. // Make sure count comes out right. byte [] key = new byte [] {endKey[0], endKey[1], (byte)(endKey[2] + 1)}; -int plusOneCount = countRows(t, createScanWithRowFilter(key)); +int plusOneCount = TEST_UTIL.countRows(t, createScanWithRowFilter(key)); assertEquals(endKeyCount + 1, plusOneCount); key = new byte [] {endKey[0], endKey[1], (byte)(endKey[2] + 2)}; -int plusTwoCount = countRows(t, createScanWithRowFilter(key)); +int plusTwoCount = TEST_UTIL.countRows(t, createScanWithRowFilter(key)); assertEquals(endKeyCount + 2, plusTwoCount); // N
hbase git commit: HBASE-16776 Remove duplicated versions of countRow() in tests
Repository: hbase Updated Branches: refs/heads/master 06758bf63 -> b548d4978 HBASE-16776 Remove duplicated versions of countRow() in tests Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/b548d497 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b548d497 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b548d497 Branch: refs/heads/master Commit: b548d4978b0bdbfc6bd4e68c3d13e00f8ea4002e Parents: 06758bf Author: Matteo Bertozzi Authored: Wed Oct 5 19:45:50 2016 -0700 Committer: Matteo Bertozzi Committed: Wed Oct 5 19:45:50 2016 -0700 -- .../hadoop/hbase/HBaseTestingUtility.java | 34 .../hadoop/hbase/client/TestFromClientSide.java | 37 + .../procedure/TestServerCrashProcedure.java | 12 +- .../regionserver/TestMobStoreCompaction.java| 39 -- .../TestRegionMergeTransaction.java | 37 + .../regionserver/TestSplitTransaction.java | 42 ++-- .../hadoop/hbase/util/BaseTestHBaseFsck.java| 18 ++--- 7 files changed, 72 insertions(+), 147 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/b548d497/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index cc384de..c74c399 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -2219,13 +2219,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { for (byte[] family: families) { scan.addFamily(family); } -ResultScanner results = table.getScanner(scan); -int count = 0; -for (@SuppressWarnings("unused") Result res : results) { - count++; -} -results.close(); -return count; +return countRows(table, scan); } /** @@ -2240,6 +2234,32 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { } } + public int countRows(final Region region) throws IOException { +return countRows(region, new Scan()); + } + + public int countRows(final Region region, final Scan scan) throws IOException { +InternalScanner scanner = region.getScanner(scan); +try { + return countRows(scanner); +} finally { + scanner.close(); +} + } + + public int countRows(final InternalScanner scanner) throws IOException { +// Do not retrieve the mob data when scanning +int scannedCount = 0; +List results = new ArrayList(); +boolean hasMore = true; +while (hasMore) { + hasMore = scanner.next(results); + scannedCount += results.size(); + results.clear(); +} +return scannedCount; + } + /** * Return an md5 digest of the entire contents of a table. */ http://git-wip-us.apache.org/repos/asf/hbase/blob/b548d497/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java index f10cce3a..50a566a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java @@ -504,7 +504,7 @@ public class TestFromClientSide { byte [] endKey = regions.get(0).getRegionInfo().getEndKey(); // Count rows with a filter that stops us before passed 'endKey'. // Should be count of rows in first region. -int endKeyCount = countRows(t, createScanWithRowFilter(endKey)); +int endKeyCount = TEST_UTIL.countRows(t, createScanWithRowFilter(endKey)); assertTrue(endKeyCount < rowCount); // How do I know I did not got to second region? Thats tough. Can't really @@ -516,29 +516,29 @@ public class TestFromClientSide { // New test. Make it so scan goes into next region by one and then two. // Make sure count comes out right. byte [] key = new byte [] {endKey[0], endKey[1], (byte)(endKey[2] + 1)}; -int plusOneCount = countRows(t, createScanWithRowFilter(key)); +int plusOneCount = TEST_UTIL.countRows(t, createScanWithRowFilter(key)); assertEquals(endKeyCount + 1, plusOneCount); key = new byte [] {endKey[0], endKey[1], (byte)(endKey[2] + 2)}; -int plusTwoCount = countRows(t, createScanWithRowFilter(key)); +int plusTwoCount = TEST_UTIL.countRows(t, createScanWithRo