Skip to content
Snippets Groups Projects
Commit 744e859f authored by Connor McCoy's avatar Connor McCoy
Browse files

[hbase] Use a PageFilter in HBase scans.

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.
parent 4aede920
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......@@ -246,6 +239,7 @@ public class HBaseClient extends com.yahoo.ycsb.DB
//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)
......@@ -284,6 +278,9 @@ public class HBaseClient extends com.yahoo.ycsb.DB
//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;
......
......@@ -42,6 +42,7 @@ import org.apache.hadoop.hbase.client.Result;
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;
......@@ -291,6 +292,7 @@ public class HBaseClient10 extends com.yahoo.ycsb.DB
//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)
......@@ -332,6 +334,9 @@ public class HBaseClient10 extends com.yahoo.ycsb.DB
//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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment