Skip to content

HBASE-28621 PrefixFilter should use SEEK_NEXT_USING_HINT - #6361

Merged
stoty merged 15 commits into
apache:masterfrom
PDavid:HBASE-28621-PrefixFilter-SEEK_NEXT_USING_HINT
Nov 6, 2024
Merged

HBASE-28621 PrefixFilter should use SEEK_NEXT_USING_HINT#6361
stoty merged 15 commits into
apache:masterfrom
PDavid:HBASE-28621-PrefixFilter-SEEK_NEXT_USING_HINT

Conversation

@PDavid

Copy link
Copy Markdown
Contributor

No description provided.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

Comment threadhbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java Outdated
@Apache-HBase

This comment has been minimized.

@PDavid
PDavid marked this pull request as ready for review October 10, 2024 08:52
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");

Copy link
Copy Markdown
ContributorAuthor

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.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@PDavid
PDavid marked this pull request as draft October 14, 2024 08:10
@stoty

Copy link
Copy Markdown
Contributor

please remove the colon from the commit message / PR description

@PDavidPDavid changed the title HBASE-28621: PrefixFilter should use SEEK_NEXT_USING_HINTHBASE-28621 PrefixFilter should use SEEK_NEXT_USING_HINTOct 14, 2024
@PDavid
PDavidforce-pushed the HBASE-28621-PrefixFilter-SEEK_NEXT_USING_HINT branch from 09fc843 to 02ed23aCompareOctober 14, 2024 12:38
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

Comment threadhbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java Outdated
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@PDavid
PDavidforce-pushed the HBASE-28621-PrefixFilter-SEEK_NEXT_USING_HINT branch from 5085fd8 to 0989fa1CompareOctober 24, 2024 07:02
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

Comment on lines +171 to +181
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;
}

Copy link
Copy Markdown
ContributorAuthor

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).

Copy link
Copy Markdown
Contributor

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.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@stotystoty left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadhbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java Outdated
Comment threadhbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java Outdated
…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 =

@stotystotyOct 30, 2024

Copy link
Copy Markdown
Contributor

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.

@PDavidPDavidOct 30, 2024

Copy link
Copy Markdown
ContributorAuthor

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.

Copy link
Copy Markdown
Contributor

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());

Copy link
Copy Markdown
Contributor

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...

@stotystoty left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 LGTM

@Apache-HBase

This comment has been minimized.

@PDavid

Copy link
Copy Markdown
ContributorAuthor

+1 LGTM

Many thanks. Unfortunately I still have to fix TestFilterList.testMPONE(). It will still fail but I'm on it.

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.
@Apache-HBase

This comment has been minimized.

Comment threadhbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java Outdated
@Apache-HBase

This comment has been minimized.

For reverse scans, smaller/bigger is not accurate. Use before/after instead.
@Apache-HBase

This comment has been minimized.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 45sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+0 🆗codespell0m 0scodespell was not available.
+0 🆗detsecrets0m 0sdetect-secrets was not available.
+1 💚@author0m 0sThe patch does not contain any @author tags.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
_ master Compile Tests _
+0 🆗mvndep0m 16sMaven dependency ordering for branch
+1 💚mvninstall3m 37smaster passed
+1 💚compile4m 43smaster passed
+1 💚checkstyle1m 3smaster passed
+1 💚spotbugs2m 34smaster passed
+1 💚spotless0m 54sbranch has no errors when running spotless:check.
_ Patch Compile Tests _
+0 🆗mvndep0m 11sMaven dependency ordering for patch
+1 💚mvninstall3m 42sthe patch passed
+1 💚compile4m 30sthe patch passed
+1 💚javac4m 30sthe patch passed
+1 💚blanks0m 0sThe patch has no blanks issues.
+1 💚checkstyle0m 23shbase-client: The patch generated 0 new + 0 unchanged - 5 fixed = 0 total (was 5)
+1 💚checkstyle0m 46shbase-server: The patch generated 0 new + 0 unchanged - 1 fixed = 0 total (was 1)
+1 💚spotbugs3m 18sthe patch passed
+1 💚hadoopcheck12m 32sPatch does not cause any errors with Hadoop 3.3.6 3.4.0.
+1 💚spotless0m 55spatch has no errors when running spotless:check.
_ Other Tests _
+1 💚asflicense0m 19sThe patch does not generate ASF License warnings.
48m 36s
SubsystemReport/Notes
DockerClientAPI=1.47 ServerAPI=1.47 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6361/16/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#6361
Optional Testsdupname asflicense javac spotbugs checkstyle codespell detsecrets compile hadoopcheck hbaseanti spotless
unameLinux f0d3ee8876df 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / ba21710
Default JavaEclipse Adoptium-17.0.11+9
Max. process+thread count83 (vs. ulimit of 30000)
modulesC: hbase-client hbase-server U: .
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6361/16/console
versionsgit=2.34.1 maven=3.9.8 spotbugs=4.7.3
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 17sDocker mode activated.
-0 ⚠️yetus0m 3sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --author-ignore-list --blanks-eol-ignore-file --blanks-tabs-ignore-file --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+0 🆗mvndep0m 14sMaven dependency ordering for branch
+1 💚mvninstall3m 0smaster passed
+1 💚compile1m 18smaster passed
+1 💚javadoc0m 48smaster passed
+1 💚shadedjars5m 23sbranch has no errors when building our shaded downstream artifacts.
_ Patch Compile Tests _
+0 🆗mvndep0m 13sMaven dependency ordering for patch
+1 💚mvninstall2m 53sthe patch passed
+1 💚compile1m 20sthe patch passed
+1 💚javac1m 20sthe patch passed
+1 💚javadoc0m 51sthe patch passed
+1 💚shadedjars5m 54spatch has no errors when building our shaded downstream artifacts.
_ Other Tests _
+1 💚unit1m 47shbase-client in the patch passed.
+1 💚unit232m 9shbase-server in the patch passed.
260m 26s
SubsystemReport/Notes
DockerClientAPI=1.47 ServerAPI=1.47 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6361/16/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR#6361
Optional Testsjavac javadoc unit compile shadedjars
unameLinux 55f290b297e3 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / ba21710
Default JavaEclipse Adoptium-17.0.11+9
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6361/16/testReport/
Max. process+thread count5011 (vs. ulimit of 30000)
modulesC: hbase-client hbase-server U: .
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6361/16/console
versionsgit=2.34.1 maven=3.9.8
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@stoty

Copy link
Copy Markdown
Contributor

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.

@PDavid
PDavid marked this pull request as ready for review October 31, 2024 08:47
@PDavid

PDavid commented Oct 31, 2024

Copy link
Copy Markdown
ContributorAuthor

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.

@PDavid

Copy link
Copy Markdown
ContributorAuthor

Prepared #6424 to backport this to branch-2.

@stoty
stoty merged commit 1687018 into apache:masterNov 6, 2024
stoty pushed a commit that referenced this pull request Nov 6, 2024
Co-authored-by: Dávid Paksy <paksyd@cloudera.com>
Signed-off-by: Istvan Toth <stoty@apache.org>
(cherry picked from commit 1687018)
@PDavid
PDavid deleted the HBASE-28621-PrefixFilter-SEEK_NEXT_USING_HINT branch November 6, 2024 09:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@PDavid@Apache-HBase@stoty