@@ -2174,6 +2174,7 @@ public void reverseAndForwardScanMoreThanMaxKVs() throws Exception{
21742174
21752175 }
21762176
2177+ /** Scan metrics tests. */
21772178 @ Test
21782179 public void scanMetrics () throws Exception {
21792180 final String table6 = args [0 ] + "6" ;
@@ -2261,6 +2262,41 @@ public void scanMetrics() throws Exception {
22612262 assertTrue ("incorrect count of bytes in results" , metrics_final .getCountOfBytesInResults () == prevBytesInResult );
22622263 }
22632264
2265+ /** Scan metrics of filtered rows tests. */
2266+ @ Test
2267+ public void scanMetricsFilter () throws Exception {
2268+ client .setFlushInterval (FAST_FLUSH );
2269+ // Keep only rows with a column qualifier that starts with "qa".
2270+ final PutRequest put1 = new PutRequest (table , "cpf1" , family , "qa1" , "v1" );
2271+ final PutRequest put2 = new PutRequest (table , "cpf2" , family , "qb2" , "v2" );
2272+ final PutRequest put3 = new PutRequest (table , "cpf3" , family , "qb3" , "v3" );
2273+ final PutRequest put4 = new PutRequest (table , "cpf4" , family , "qa4" , "v4" );
2274+ Deferred .group (Deferred .group (client .put (put1 ), client .put (put2 )),
2275+ Deferred .group (client .put (put3 ), client .put (put4 ))).join ();
2276+ final Scanner scanner = client .newScanner (table );
2277+ scanner .setFamily (family );
2278+ scanner .setStartKey ("cpf1" );
2279+ scanner .setStopKey ("cpf5" );
2280+ scanner .setFilter (new ColumnPrefixFilter ("qa" ));
2281+ scanner .setScanMetricsEnabled (true );
2282+ final ArrayList <ArrayList <KeyValue >> rows = scanner .nextRows ().join ();
2283+
2284+ assertSizeIs (2 , rows );
2285+ ArrayList <KeyValue > kvs1 = rows .get (0 );
2286+ assertSizeIs (1 , kvs1 );
2287+ assertEq ("v1" , kvs1 .get (0 ).value ());
2288+ ArrayList <KeyValue > kvs4 = rows .get (1 );
2289+ assertSizeIs (1 , kvs4 );
2290+ assertEq ("v4" , kvs4 .get (0 ).value ());
2291+
2292+ Scanner .ScanMetrics metrics = scanner .getScanMetrics ();
2293+ assertEquals ("incorrect count of rows scanned" , 4 , metrics .getCountOfRowsScanned ());
2294+ assertEquals ("incorrect count of rows filtered" , 2 , metrics .getCountOfRowsFiltered ());
2295+ assertEquals ("incorrect count of RPC calls" , 1 , metrics .getCountOfRPCcalls ()); // 1 open
2296+
2297+ scanner .close ().join ();
2298+ }
2299+
22642300 /** Regression test for issue #2. */
22652301 @ Test
22662302 public void regression2 () throws Exception {
0 commit comments