Re: Need help on RowFilter
HI Rajesh, If you know the rowkeys already, you don't need to perform a scan, you can just perform a get on the list of rowkeys e.g. ListGet RowKeyList = new ArrayListGet(); # for each rowkey RowKeyList.add(new Get(Bytes.toBytes(rowkey))); Result[] results = table.get(RowKeyList); for (Result r : results) { for(KeyValue kv : r.raw()) { System.out.print(new String(kv.getRow()) + ); } } -Ian Brooks On Thursday 10 Jul 2014 16:38:04 Madabhattula Rajesh Kumar wrote: Hi Team, Could you please help me to resolve below issue. In my hbase table, i've a 30 records. I need to retrieve records based on list of rowkeys. I'm using below code base. It is not giving records HTable table = new HTable(configuration, tableName); ListFilter filters = new ArrayListFilter(); Filter rowFilter=new RowFilter(CompareFilter.CompareOp.EQUAL, new BinaryPrefixComparator(Bytes.toBytes(rowkey))); filters.add(rowFilter); Filter rowFilter=new RowFilter(CompareFilter.CompareOp.EQUAL, new BinaryPrefixComparator(Bytes.toBytes(rowkey1))); filters.add(rowFilter); FilterList fl = new FilterList(filters); Scan s = new Scan(); s.setFilter(fl); ResultScanner ss = table.getScanner(s); { for(KeyValue kv : r.raw()) { System.out.print(new String(kv.getRow()) + ); } } Thank you for support Regards, Rajesh
Re: Need help on RowFilter
Hi Ian, Thank you very much of the solution. Could you please explain at what are the use cases we need to use RowFilter? Regards, Rajesh On Thu, Jul 10, 2014 at 4:48 PM, Ian Brooks i.bro...@sensewhere.com wrote: HI Rajesh, If you know the rowkeys already, you don't need to perform a scan, you can just perform a get on the list of rowkeys e.g. ListGet RowKeyList = new ArrayListGet(); # for each rowkey RowKeyList.add(new Get(Bytes.toBytes(rowkey))); Result[] results = table.get(RowKeyList); for (Result r : results) { for(KeyValue kv : r.raw()) { System.out.print(new String(kv.getRow()) + ); } } -Ian Brooks On Thursday 10 Jul 2014 16:38:04 Madabhattula Rajesh Kumar wrote: Hi Team, Could you please help me to resolve below issue. In my hbase table, i've a 30 records. I need to retrieve records based on list of rowkeys. I'm using below code base. It is not giving records HTable table = new HTable(configuration, tableName); ListFilter filters = new ArrayListFilter(); Filter rowFilter=new RowFilter(CompareFilter.CompareOp.EQUAL, new BinaryPrefixComparator(Bytes.toBytes(rowkey))); filters.add(rowFilter); Filter rowFilter=new RowFilter(CompareFilter.CompareOp.EQUAL, new BinaryPrefixComparator(Bytes.toBytes(rowkey1))); filters.add(rowFilter); FilterList fl = new FilterList(filters); Scan s = new Scan(); s.setFilter(fl); ResultScanner ss = table.getScanner(s); { for(KeyValue kv : r.raw()) { System.out.print(new String(kv.getRow()) + ); } } Thank you for support Regards, Rajesh
Re: Need help on RowFilter
Hi Rajesh From personal use, the rowFilter allows for finer grained results when performing a large scan where the row keys don't exaclty match your criteria. For example if you use start and end rows to constrain your scan, the results may contain some results that you don't want and you can use the row Prefix filter to only get the ones you want. In the setup im using start and end rows are the fastest way to get to the segments of data I need within hbase. The row filter is then used to clean/restict the data, think of it like the HAVING clause in SQL if you are used to that, It happens more in post processing of the result set. Thats my understanding of how it should be used, others may have different feedback on this. -Ian Brooks On Thursday 10 Jul 2014 17:08:58 Madabhattula Rajesh Kumar wrote: Hi Ian, Thank you very much of the solution. Could you please explain at what are the use cases we need to use RowFilter? Regards, Rajesh On Thu, Jul 10, 2014 at 4:48 PM, Ian Brooks i.bro...@sensewhere.com wrote: HI Rajesh, If you know the rowkeys already, you don't need to perform a scan, you can just perform a get on the list of rowkeys e.g. ListGet RowKeyList = new ArrayListGet(); # for each rowkey RowKeyList.add(new Get(Bytes.toBytes(rowkey))); Result[] results = table.get(RowKeyList); for (Result r : results) { for(KeyValue kv : r.raw()) { System.out.print(new String(kv.getRow()) + ); } } -Ian Brooks On Thursday 10 Jul 2014 16:38:04 Madabhattula Rajesh Kumar wrote: Hi Team, Could you please help me to resolve below issue. In my hbase table, i've a 30 records. I need to retrieve records based on list of rowkeys. I'm using below code base. It is not giving records HTable table = new HTable(configuration, tableName); ListFilter filters = new ArrayListFilter(); Filter rowFilter=new RowFilter(CompareFilter.CompareOp.EQUAL, new BinaryPrefixComparator(Bytes.toBytes(rowkey))); filters.add(rowFilter); Filter rowFilter=new RowFilter(CompareFilter.CompareOp.EQUAL, new BinaryPrefixComparator(Bytes.toBytes(rowkey1))); filters.add(rowFilter); FilterList fl = new FilterList(filters); Scan s = new Scan(); s.setFilter(fl); ResultScanner ss = table.getScanner(s); { for(KeyValue kv : r.raw()) { System.out.print(new String(kv.getRow()) + ); } } Thank you for support Regards, Rajesh
Re: Need help on RowFilter
Hi Ian, Thank you very much Regards, Rajesh On Thu, Jul 10, 2014 at 5:16 PM, Ian Brooks i.bro...@sensewhere.com wrote: Hi Rajesh From personal use, the rowFilter allows for finer grained results when performing a large scan where the row keys don't exaclty match your criteria. For example if you use start and end rows to constrain your scan, the results may contain some results that you don't want and you can use the row Prefix filter to only get the ones you want. In the setup im using start and end rows are the fastest way to get to the segments of data I need within hbase. The row filter is then used to clean/restict the data, think of it like the HAVING clause in SQL if you are used to that, It happens more in post processing of the result set. Thats my understanding of how it should be used, others may have different feedback on this. -Ian Brooks On Thursday 10 Jul 2014 17:08:58 Madabhattula Rajesh Kumar wrote: Hi Ian, Thank you very much of the solution. Could you please explain at what are the use cases we need to use RowFilter? Regards, Rajesh On Thu, Jul 10, 2014 at 4:48 PM, Ian Brooks i.bro...@sensewhere.com wrote: HI Rajesh, If you know the rowkeys already, you don't need to perform a scan, you can just perform a get on the list of rowkeys e.g. ListGet RowKeyList = new ArrayListGet(); # for each rowkey RowKeyList.add(new Get(Bytes.toBytes(rowkey))); Result[] results = table.get(RowKeyList); for (Result r : results) { for(KeyValue kv : r.raw()) { System.out.print(new String(kv.getRow()) + ); } } -Ian Brooks On Thursday 10 Jul 2014 16:38:04 Madabhattula Rajesh Kumar wrote: Hi Team, Could you please help me to resolve below issue. In my hbase table, i've a 30 records. I need to retrieve records based on list of rowkeys. I'm using below code base. It is not giving records HTable table = new HTable(configuration, tableName); ListFilter filters = new ArrayListFilter(); Filter rowFilter=new RowFilter(CompareFilter.CompareOp.EQUAL, new BinaryPrefixComparator(Bytes.toBytes(rowkey))); filters.add(rowFilter); Filter rowFilter=new RowFilter(CompareFilter.CompareOp.EQUAL, new BinaryPrefixComparator(Bytes.toBytes(rowkey1))); filters.add(rowFilter); FilterList fl = new FilterList(filters); Scan s = new Scan(); s.setFilter(fl); ResultScanner ss = table.getScanner(s); { for(KeyValue kv : r.raw()) { System.out.print(new String(kv.getRow()) + ); } } Thank you for support Regards, Rajesh
Re: Need help on RowFilter
Hi Rajesh, It looks like the filter list combines filters with 'AND' operator. In your case you had two 'equal' rowfilters and expected each return a result. Mingtao Sent from iPhone On Jul 10, 2014, at 7:08 AM, Madabhattula Rajesh Kumar mrajaf...@gmail.com wrote: Rajesh