You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by la...@apache.org on 2013/11/30 00:03:58 UTC
svn commit: r1546659 -
/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java
Author: larsh
Date: Fri Nov 29 23:03:57 2013
New Revision: 1546659
URL: http://svn.apache.org/r1546659
Log:
HBASE-10058 Test for HBASE-9915 (avoid reading index blocks)
Modified:
hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java
Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java?rev=1546659&r1=1546658&r2=1546659&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java Fri Nov 29 23:03:57 2013
@@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.HTableDes
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.SmallTests;
import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
import org.apache.hadoop.hbase.io.hfile.Compression;
import org.apache.hadoop.hbase.io.hfile.BlockType.BlockCategory;
import org.apache.hadoop.hbase.regionserver.metrics.SchemaMetrics;
@@ -39,7 +40,6 @@ import org.junit.experimental.categories
@SuppressWarnings("deprecation")
@Category(SmallTests.class)
public class TestBlocksScanned extends HBaseTestCase {
- private static byte [] TABLE = Bytes.toBytes("TestBlocksScanned");
private static byte [] FAMILY = Bytes.toBytes("family");
private static byte [] COL = Bytes.toBytes("col");
private static byte [] START_KEY = Bytes.toBytes("aaa");
@@ -47,34 +47,54 @@ public class TestBlocksScanned extends H
private static int BLOCK_SIZE = 70;
private static HBaseTestingUtility TEST_UTIL = null;
- private static HTableDescriptor TESTTABLEDESC = null;
- @Override
- public void setUp() throws Exception {
- super.setUp();
- SchemaMetrics.setUseTableNameInTest(true);
- TEST_UTIL = new HBaseTestingUtility();
- TESTTABLEDESC = new HTableDescriptor(TABLE);
-
- TESTTABLEDESC.addFamily(
- new HColumnDescriptor(FAMILY)
- .setMaxVersions(10)
- .setBlockCacheEnabled(true)
- .setBlocksize(BLOCK_SIZE)
- .setCompressionType(Compression.Algorithm.NONE)
- );
- }
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ SchemaMetrics.setUseTableNameInTest(true);
+ TEST_UTIL = new HBaseTestingUtility();
+ }
- @Test
+ @Test
public void testBlocksScanned() throws Exception {
- HRegion r = createNewHRegion(TESTTABLEDESC, START_KEY, END_KEY,
+ byte [] tableName = Bytes.toBytes("TestBlocksScanned");
+ HTableDescriptor table = new HTableDescriptor(tableName);
+
+ table.addFamily(
+ new HColumnDescriptor(FAMILY)
+ .setMaxVersions(10)
+ .setBlockCacheEnabled(true)
+ .setBlocksize(BLOCK_SIZE)
+ .setCompressionType(Compression.Algorithm.NONE)
+ );
+ _testBlocksScanned(table);
+ }
+
+ @Test
+ public void testBlocksScannedWithEncoding() throws Exception {
+ byte [] tableName = Bytes.toBytes("TestBlocksScannedWithEncoding");
+ HTableDescriptor table = new HTableDescriptor(tableName);
+
+ table.addFamily(
+ new HColumnDescriptor(FAMILY)
+ .setMaxVersions(10)
+ .setBlockCacheEnabled(true)
+ .setDataBlockEncoding(DataBlockEncoding.FAST_DIFF)
+ .setBlocksize(BLOCK_SIZE)
+ .setCompressionType(Compression.Algorithm.NONE)
+ );
+ _testBlocksScanned(table);
+ }
+
+ private void _testBlocksScanned(HTableDescriptor table) throws Exception {
+ HRegion r = createNewHRegion(table, START_KEY, END_KEY,
TEST_UTIL.getConfiguration());
addContent(r, FAMILY, COL);
r.flushcache();
// Get the per-cf metrics
SchemaMetrics schemaMetrics =
- SchemaMetrics.getInstance(Bytes.toString(TABLE), Bytes.toString(FAMILY));
+ SchemaMetrics.getInstance(Bytes.toString(table.getName()), Bytes.toString(FAMILY));
Map<String, Long> schemaMetricSnapshot = SchemaMetrics.getMetricsSnapshot();
// Do simple test of getting one row only first.