<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question How to get the last key/value of rowpefix filter in hbase ? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/How-to-get-the-last-key-value-of-rowpefix-filter-in-hbase/m-p/187065#M149167</link>
    <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;My hbase table rowkey are in following format:&lt;/P&gt;&lt;P&gt;vin1ts1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vin1ts2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vin1ts3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vin2ts1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vin2ts2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vin2ts3&lt;/P&gt;&lt;P&gt;vin2ts4&lt;/P&gt;&lt;P&gt;etc....&lt;/P&gt;&lt;P&gt;I would like to get the last available key of each ROWPREFIX , where ROWPREFIX ={VIN1, VIN2, VIN3,...}&lt;/P&gt;&lt;P&gt;Example: for RowPrefix= VIN1, It should return "Rowkey=vin1ts3"   &amp;amp; its values.&lt;/P&gt;&lt;P&gt;--------&lt;/P&gt;&lt;P&gt;I am trying to use the reverse scan feature as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Scan scan = &lt;STRONG&gt;new&lt;/STRONG&gt; Scan();&lt;/P&gt;&lt;P&gt;scan.setCaching(1)&lt;/P&gt;&lt;P&gt;
&lt;/P&gt;&lt;P&gt;FilterList allFilters = new FilterList(FilterList.Operator.MUST_PASS_ALL);&lt;/P&gt;&lt;P&gt;
&lt;/P&gt;&lt;P&gt;allFilters.addFilter(new PrefixFilter(Bytes.toBytes(prefixFilterValue)));&lt;/P&gt;&lt;P&gt;
&lt;/P&gt;&lt;P&gt;scan.setFilter(allFilters);&lt;/P&gt;&lt;P&gt;
&lt;/P&gt;&lt;P&gt;scan.setReversed(&lt;STRONG&gt;true&lt;/STRONG&gt;); //Read the latest available key and value&lt;/P&gt;&lt;P&gt;
&lt;/P&gt;&lt;P&gt;scan.setMaxResultSize(1);&lt;/P&gt;&lt;P&gt;
&lt;/P&gt;&lt;P&gt;ResultScanner scanner = tblConn.getScanner(scan);&lt;/P&gt;&lt;P&gt;		Result result = scanner.next();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;
&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;LOGGER&lt;/STRONG&gt;&lt;/EM&gt;.log(Level.&lt;STRONG&gt;&lt;EM&gt;INFO&lt;/EM&gt;&lt;/STRONG&gt;, "Latest Key " + Bytes.&lt;EM&gt;toString&lt;/EM&gt;(result.getRow()));&lt;/P&gt;&lt;P&gt;scanner.close(); &lt;/P&gt;&lt;P&gt;-----------&lt;/P&gt;&lt;P&gt;Above code works but takes around ~40 second to retrieve the target rowkey.&lt;/P&gt;&lt;P&gt;Is there any better approach to get the same since 40 second is not sufficing our business condition ?&lt;/P&gt;&lt;P&gt;Or do I need to set any scan property to reduce the scanner time ?&lt;/P&gt;&lt;P&gt;Any pointers would be appreciated..&lt;/P&gt;&lt;P&gt;CLUSER INFO:&lt;/P&gt;&lt;P&gt;HDP:&lt;/P&gt;&lt;P&gt;HDP-2.5.5.0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hbase -version:&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Version 1.1.2.2.5.5.0-157, r002c801447187c620c26ffc130ff17a9b0a62ac1, Fri Apr 21 01:13:10 UTC 2017&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Revan&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jul 2018 13:24:23 GMT</pubDate>
    <dc:creator>wabale_revan</dc:creator>
    <dc:date>2018-07-04T13:24:23Z</dc:date>
  </channel>
</rss>

