hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jianwei Cui (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-14397) PrefixFilter doesn't filter all remaining rows if the prefix is longer than rowkey being compared
Date Wed, 23 Sep 2015 02:42:04 GMT

    [ https://issues.apache.org/jira/browse/HBASE-14397?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14903849#comment-14903849
] 

Jianwei Cui commented on HBASE-14397:
-------------------------------------

Thanks for your comment [~apurtell].
>>Why skip only some rows where the prefix is longer than the key being compared? Why
not all?
It seems we can not skip all the following rows in this situation. User may set a smaller
startRow in scan when using PrefixFilter. For example, if there three rows 'a', 'bb', 'c'
in the table, and user issue a scan with:
{code}
  Scan scan = new Scan(Bytes.toBytes("a"));
  scan.setFilter(new PrefixFilter(Bytes.toBytes("bb")));
{code} 
If we skip all rows when prefix is longer than the row being compared, the matched row 'bb'
won't be returned.

> PrefixFilter doesn't filter all remaining rows if the prefix is longer than rowkey being
compared
> -------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-14397
>                 URL: https://issues.apache.org/jira/browse/HBASE-14397
>             Project: HBase
>          Issue Type: Improvement
>          Components: Filters
>    Affects Versions: 2.0.0
>            Reporter: Jianwei Cui
>            Assignee: Jianwei Cui
>            Priority: Minor
>         Attachments: HBASE-14397-trunk-v1.patch
>
>
> The PrefixFilter will filter rowkey as:
> {code}
>   public boolean filterRowKey(Cell firstRowCell) {
>     ...
>     int length = firstRowCell.getRowLength();
>     if (length < prefix.length) return true; // ===> return directly if the prefix
is longer
>     ....
>     if ((!isReversed() && cmp > 0) || (isReversed() && cmp < 0))
{
>       passedPrefix = true;
>     }
>     filterRow = (cmp != 0);
>     return filterRow;
>   }
> {code}
> If the prefix is longer than the current rowkey, PrefixFilter#filterRowKey will filter
the rowkey directly without comparing, so that won't set 'passedPrefix' flag even the current
row is larger than the prefix.
> For example, if there are three rows 'a', 'b' and 'c' in the table, and we issue a scan
request as:
> {code}
> hbase(main):001:0> scan 'test_table', {STARTROW => 'a', FILTER => "(PrefixFilter
('aa'))"}
> {code}
> The region server will check the three rows before returning.  In our production, the
user issue a scan with a PrefixFilter. The prefix is longer than the rowkeys of following
millions of rows, so the region server will continue to check rows until hit a rowkey longer
than the prefix. This make the client easily timeout. To fix this case, it seems we need to
compare the prefix with the rowkey every serveral rows even when the prefix is longer.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message