Skip to content

Commit

Permalink
[hbase] Use a PageFilter in HBase scans.
Browse files Browse the repository at this point in the history
Other bindings limit the number of results retrieved from the server.
The HBase bindings just close the scanner once they have received the
desired number of records. Adding a PageFilter matches the behavior of
other bindings, and may improve performance.
  • Loading branch information
cmccoy committed Sep 24, 2015
1 parent 4aede92 commit 744e859
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 6 additions & 9 deletions hbase098/src/main/java/com/yahoo/ycsb/db/HBaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,25 @@

package com.yahoo.ycsb.db;


import com.yahoo.ycsb.DBException;
import com.yahoo.ycsb.ByteIterator;
import com.yahoo.ycsb.ByteArrayByteIterator;
import com.yahoo.ycsb.measurements.Measurements;

import java.io.IOException;
import java.util.*;
//import java.util.HashMap;
//import java.util.Properties;
//import java.util.Set;
//import java.util.Vector;

import com.yahoo.ycsb.measurements.Measurements;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.HTable;
//import org.apache.hadoop.hbase.client.Scanner;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
//import org.apache.hadoop.hbase.io.Cell;
//import org.apache.hadoop.hbase.io.RowResult;
import org.apache.hadoop.hbase.filter.PageFilter;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.HBaseConfiguration;

Expand Down Expand Up @@ -246,6 +239,7 @@ public int scan(String table, String startkey, int recordcount, Set<String> fiel
//HBase has no record limit. Here, assume recordcount is small enough to bring back in one call.
//We get back recordcount records
s.setCaching(recordcount);
s.setFilter(new PageFilter(recordcount));

//add specified fields or else all fields
if (fields == null)
Expand Down Expand Up @@ -284,6 +278,9 @@ public int scan(String table, String startkey, int recordcount, Set<String> fiel
//add rowResult to result vector
result.add(rowResult);
numResults++;

// PageFilter does not guarantee that the number of results is <= pageSize, so this
// break is required.
if (numResults >= recordcount) //if hit recordcount, bail out
{
break;
Expand Down
5 changes: 5 additions & 0 deletions hbase10/src/main/java/com/yahoo/ycsb/db/HBaseClient10.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.filter.PageFilter;
import org.apache.hadoop.hbase.util.Bytes;

import java.io.IOException;
Expand Down Expand Up @@ -291,6 +292,7 @@ public int scan(String table, String startkey, int recordcount, Set<String> fiel
//HBase has no record limit. Here, assume recordcount is small enough to bring back in one call.
//We get back recordcount records
s.setCaching(recordcount);
s.setFilter(new PageFilter(recordcount));

//add specified fields or else all fields
if (fields == null)
Expand Down Expand Up @@ -332,6 +334,9 @@ public int scan(String table, String startkey, int recordcount, Set<String> fiel
//add rowResult to result vector
result.add(rowResult);
numResults++;

// PageFilter does not guarantee that the number of results is <= pageSize, so this
// break is required.
if (numResults >= recordcount) //if hit recordcount, bail out
{
break;
Expand Down

0 comments on commit 744e859

Please sign in to comment.