Database Reference
In-Depth Information
Typically, ilters can be categorized into multiple types, as follows:
• Utility ilters
• Comparison ilters
• Custom ilters
Utility ilters
These types of ilter classes provide the speciic needs and directly extend the
FilterBase class. Some of the utility ilters are discussed as follows:
TimeStampFilter : This ilter returns the scan results with the cells whose
timestamp (Version) is in the speciied list of timestamps (Versions), as
shown in the following code:
public class TSFilterExample {
public static void main(String[] args) throws IOException
{
// Get instance of Default Configuration
Configuration conf = HBaseConfiguration.create();
// Get table instance
HTable table = new HTable(conf, "tab1");
// Add the timestamp range as minStamp and
// maxStams.
List<Long> ts = new ArrayList<Long>();
ts.add(new Long(2));
ts.add(new Long(10));
// filter output the column values for
// specified timestamps
Filter filter = new TimestampsFilter(ts);
// Create Scan instance
Scan scan = new Scan();
scan.setFilter(filter);
// Get Scanner Results
ResultScanner scanner = table.getScanner(scan);
for (Result res : scanner) {
System.out.println("Row Value: " + res);
}
 
Search WWH ::




Custom Search