### Eclipse Workspace Patch 1.0 #P apache-trunk Index: hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java (revision 1470373) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java (working copy) @@ -79,6 +79,7 @@ import org.apache.hadoop.hbase.filter.PrefixFilter; import org.apache.hadoop.hbase.filter.SingleColumnValueExcludeFilter; import org.apache.hadoop.hbase.filter.SingleColumnValueFilter; +import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding; import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler; import org.apache.hadoop.hbase.monitoring.MonitoredTask; import org.apache.hadoop.hbase.monitoring.TaskMonitor; @@ -151,6 +152,41 @@ EnvironmentEdgeManagerTestHelper.reset(); } + @Test + public void testScanner_PrefixTree() throws IOException { + byte[] tableName = Bytes.toBytes("testScanner_PrefixTree"); + byte[] fam1 = Bytes.toBytes("c1"); + this.region = initHRegion(tableName, getName(), conf, fam1); + try { + // now create data. + Put put = new Put(Bytes.toBytes("WBKIAY")); + put.add(fam1, Bytes.toBytes("q1"), Bytes.toBytes("v1")); + region.put(put); + + put = new Put(Bytes.toBytes("AWBKIA")); + put.add(fam1, Bytes.toBytes("q1"), Bytes.toBytes("v1")); + region.put(put); + + put = new Put(Bytes.toBytes("WBKIDD")); + put.add(fam1, Bytes.toBytes("q1"), Bytes.toBytes("v1")); + region.put(put); + + region.flushcache(); + + Scan scan = new Scan(Bytes.toBytes("WBKIAY")); + scan.addColumn(fam1, Bytes.toBytes("q1")); + InternalScanner s = region.getScanner(scan); + List results = new ArrayList(); + s.next(results); + assertTrue(Bytes.equals(Bytes.toBytes("WBKIAY"), results.get(0).getRow())); + results.clear(); + + } finally { + HRegion.closeHRegion(this.region); + this.region = null; + } + } + ////////////////////////////////////////////////////////////////////////////// // New tests that doesn't spin up a mini cluster but rather just test the // individual code pieces in the HRegion. Putting files locally in @@ -3916,7 +3952,8 @@ HTableDescriptor htd = new HTableDescriptor(tableName); htd.setReadOnly(isReadOnly); for(byte [] family : families) { - htd.addFamily(new HColumnDescriptor(family)); + htd.addFamily(new HColumnDescriptor(family) + .setDataBlockEncoding(DataBlockEncoding.PREFIX_TREE)); } HRegionInfo info = new HRegionInfo(htd.getName(), startKey, stopKey, false); Path path = new Path(DIR + callingMethod);