Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Summary of knowledge points of HBase built-in filter java api

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the "knowledge summary of HBase built-in filter java api". In daily operation, I believe many people have doubts about the summary of knowledge points of HBase built-in filter java api. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "HBase built-in filter java api knowledge point summary". Next, please follow the editor to study!

1. RowFilter: filter out all matching rows (used)

/ / rowkey equals test | id9Filter filter=new RowFilter (CompareOperator.EQUAL,new BinaryComparator (Bytes.toBytes ("test | id9")

2. PrefixFilter: filter out the data of row keys with a specific prefix

/ / rowkey begins with test Filter filter=new PrefixFilter (Bytes.toBytes ("test"))

3. KeyOnlyFilter: only the row keys of each row are returned

/ / only the row keys of each row are returned, but the values are all empty Filter filter=new KeyOnlyFilter ()

4. RandomRowFilter: return random result sets according to a certain probability

/ / return random data Filter filter=new RandomRowFilter (0.5f)

5. InclusiveStopFilter: when scanning, we can set a start line key and an end line key. By default, the return of this row key is an open interval before closing and then opening, that is, including the start line, but not the end line, if we want to include both the start line and the end line.

/ / encounter rowkey equals test | id4 stops querying Filter filter=new InclusiveStopFilter (Bytes.toBytes ("test | id4"))

6. FirsterKeyOnlyFilter: the returned result set contains only the data of the first column. It stops scanning after finding the first column of each row.

/ / filter out the first cell Filter filter=new FirstKeyOnlyFilter ()

7. ColumnsPrefixFilter: filter cells by the prefix of the column name. We can use this filter if we want to limit the prefix of the returned column.

/ / column name begins with ss Filter filter=new ColumnPrefixFilter (Bytes.toBytes ("ss"))

8. ValueFilter: filter cells according to specific values

/ / record Filter filter=new ValueFilter (CompareOperator.EQUAL,new SubstringComparator ("one")) containing one in the value

9. ColumnsCountGetFilter: this filter returns the maximum number of columns returned per row, and ends the scan operation when the number of columns per row exceeds the limit set by us

Filter ccf=new ColumnCountGetFilter (2); / / OK if you suddenly find that the number of columns in a row exceeds the set maximum, the entire scan operation will stop.

10. SingleColumnValueFilter: use the value of a column to determine whether the data in this row is filtered

SingleColumnValueFilter scvf=new SingleColumnValueFilter (Bytes.toBytes ("colfam1"), Bytes.toBytes ("qual2"), CompareFilter.CompareOp.NOT_EQUAL,new SubstringComparator ("BOGUS")); scvf.setFilterIfMissing (false); scvf.setLatestVersionOnly (true); / / OK

11. SingColumnValueExcludeFilter: the only difference between this and 10 filters is that columns that serve as filter criteria are not included in the returned results.

12. SkipFilter: this is an additional filter used in conjunction with ValueFilter. If a column in a row is found to be ineligible, the entire row will be filtered out.

Filter skf=new SkipFilter (vf); / / when OK finds that a column in a row needs to be filtered, the entire row will be filtered out.

13. WhileMatchFilter: you can use this filter if you want data prior to certain conditional data; when you encounter data that does not meet the set conditions, the whole scan is over

Filter wmf=new WhileMatchFilter (rf); / / OK is similar to takewhile in Pythonitertools

14. FilterList: for the comprehensive use of multiple filters (used)

Listfilters=new ArrayList (); filters.add (rf); filters.add (vf); FilterList fl=?new FilterList (FilterList.Operator.MUST_PASS_ALL,filters); / / OK uses multiple filters, AND and OR relationships

Obtain result set cases through Filter

FilterList filterList=new FilterList (); Filter filter=new RowFilter (CompareOperator.EQUAL,new BinaryComparator ("test | id9")); filterList.addFilter (filter); ResultScanner www = HBaseUtil.getScanner ("www", filterList); for (Result re:www) {for (Cell kv:re.rawCells ()) {System.out.println ("=" + kv.toString ()) System.out.println ("column family:" + Bytes.toString (kv.getFamilyArray (), kv.getFamilyOffset (), kv.getFamilyLength (); System.out.println ("RowKey:" + Bytes.toString (kv.getRowArray (), kv.getRowOffset (), kv.getRowLength (); System.out.println ("column name:" + Bytes.toString (kv.getQualifierArray (), kv.getQualifierOffset (), kv.getQualifierLength () System.out.println ("value:" + Bytes.toString (kv.getValueArray (), kv.getValueOffset (), kv.getValueLength (); System.out.println ("=");}} at this point, the study on "knowledge summary of HBase built-in filter java api" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report