In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
2 、 Dedicated Filters
2.1 SingleColumnValueFilter √
2.2 SingleColumnValueExcludeFilter √
2.3 PrefixFilter √
2.4 PageFilter √
2.5 KeyOnlyFilter √
2.6 FirstKeyOnlyFilter √
2.7 TimestampsFilter x
2.8RandomRowFilter √
2.1 SingleColumnValueFilter
Example: Filter filter=new SingleColumnValueExcludeFilter (Bytes.toBytes (Family), Bytes.toBytes (Qualifier), CompareOp.EQUAL, Bytes.toBytes (Value))
2.2 SingleColumnValueExcludeFilter
Use: contrary to singlecolumnvaluefilter, this shows all the data in the table except the filtered one
Example:
Filter filter=new SingleColumnValueExcludeFilter (Bytes.toBytes (Family), Bytes.toBytes (Qualifier), CompareOp.EQUAL, Bytes.toBytes (Value)); ((SingleColumnValueExcludeFilter) filter) .setFilterIfMissing (true)
Note:! Need to add ((SingleColumnValueExcludeFilter) filter) .setFilterIfMissing (true)
2.3 PrefixFilter and ColumnPrefixFilter
Use: fetch data based on the prefix of Row or Column
Example: Filter filter=new PrefixFilter (Bytes.toBytes ("r"))
Take out all data that RowKey starts with r
2.4 PageFilter
Return the number of page per page by setting pageside
Final byte [] POSTFIX = new byte [] {0x00}; HTable table;try {table = new HTable (config, tablename); Filter filter = new PageFilter (pageside); byte [] lastRow = null; int totalRows = 0; while (true) {Scan scan = new Scan (); scan.setFilter (filter) If (lastRow! = null) {/ / Note that the POSTFIX operation is added here, otherwise byte [] startRow = Bytes.add (lastRow,POSTFIX); scan.setStartRow (startRow);} ResultScanner scanner = table.getScanner (scan); int localRows = 0; Result result While ((result = scanner.next ())! = null) {System.out.println (localRows++ + ":" + result); totalRows + +; lastRow = result.getRow ();} scanner.close (); if (localRows = = 0) break } System.out.println ("total rows:" + totalRows);} catch (IOException e) {/ / TODO Auto-generated catch blocke.printStackTrace ();}
2.5 KeyOnlyFilter
* generally used in conjunction with other filters
* Filter:KeyOnlyFilter (boolean lenAsVal)
* lenAsVal is false by default, which means that the length of val is not regarded as val. Otherwise, the length of the val will be output as val.
* the key filter can simply set the filtered result set to contain only keys and ignore values. There is an option to save the value of the result set as the length of the value.
Example: Filter filter = new KeyOnlyFilter (false)
2.6 firstkeyonlyFilter
Usage: same as above, but only the first kv of the same key will be returned
2.8 RandomRowFilter
Immediately returns the data of row, and the constructor is
RandomRowFilter (float chance)
Chance values range from 0 to 1.0, and if 1 contains all rows.
Example: Filter filter=new RandomRowFilter (0.5f)
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.