-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-28621 PrefixFilter should use SEEK_NEXT_USING_HINT #6361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HBASE-28621 PrefixFilter should use SEEK_NEXT_USING_HINT #6361
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
Show resolved
Hide resolved
| static final char FIRST_CHAR = 'a'; | ||
| static final char LAST_CHAR = 'e'; | ||
| static final String HOST_PREFIX = "org.apache.site-"; | ||
| static final byte[] GOOD_BYTES = Bytes.toBytes("abc"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also a bit unrelated - an unused constant field.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
please remove the colon from the commit message / PR description |
09fc843 to
02ed23a
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
5085fd8 to
0989fa1
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
Show resolved
Hide resolved
| private byte[] increaseLastNonMaxByte(byte[] bytes) { | ||
| byte[] result = Arrays.copyOf(bytes, bytes.length); | ||
| for (int i = bytes.length - 1; i >= 0; i--) { | ||
| byte b = bytes[i]; | ||
| if (b < Byte.MAX_VALUE) { | ||
| result[i] = (byte) (b + 1); | ||
| break; | ||
| } | ||
| } | ||
| return result; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I did not yet found an existing util method which would do the same.
What I tried for example PrivateCellUtil.createFirstOnNextRow(Cell) which is similar but not the same (and tests are failing if that is used).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's OK.
We can keep this here, or move it to PrivateCellUtil before commit.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
stoty
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good, I did not check the tests yet.
hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
Outdated
Show resolved
Hide resolved
hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
Outdated
Show resolved
Hide resolved
…ed methods so that the real logic is together.
to avoid re-computing it several times in the corner case where there are a lot of cells between the hint and the first real match.
| // On reversed scan hint should be the prefix with last byte incremented | ||
| byte[] reversedHintBytes = increaseLastNonMaxByte(this.prefix); | ||
| return PrivateCellUtil.createFirstOnRow(reversedHintBytes, 0, (short) reversedHintBytes.length); | ||
| this.reversedNextCellHint = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was about to say that we could choose the direction here, but interestingly the direction is not available here yet.
Another API awkwardness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. The direction can be influenced with setReversed() which can be invoked only after the filter creation.
So it is available but can be changed after creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Practically, I'm sure it's not changed after any of the Cell processing methods have been called.
It is called once when the Scan is set up. (perhaps also after reset() is called)
|
|
||
| assertTrue(filter.filterRowKey(afterCell)); | ||
| assertEquals(Filter.ReturnCode.NEXT_ROW, filter.filterCell(afterCell)); | ||
| assertTrue(filter.filterAllRemaining()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This API is so awkward...
stoty
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 LGTM
This comment has been minimized.
This comment has been minimized.
Many thanks. Unfortunately I still have to fix |
Before PrefixFilter.filterRowKey() had an early return with true when the cell length was smaller than prefix. In that case the filterRow boolean field was not changed to true (while it should have). Now that this early return was removed from PrefixFilter.filterRowKey() (to be able to provide hint even when the cell length is smaller than prefix) the filterRow boolean field is properly set also in this case.
This comment has been minimized.
This comment has been minimized.
hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
Show resolved
Hide resolved
hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
For reverse scans, smaller/bigger is not accurate. Use before/after instead.
This comment has been minimized.
This comment has been minimized.
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
If there are no outstanding issues, please remove the Draft flag so that I can merge this. Please also create a backport PR for branch-2, so that the CI tests can run on that. |
Many thanks! I just waited for the CI build to finish. Now that the build is green, this PR is ready to review. |
|
Prepared #6424 to backport this to |
Co-authored-by: Dávid Paksy <[email protected]> Signed-off-by: Istvan Toth <[email protected]> (cherry picked from commit 1687018)
No description provided.