You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by wc...@apache.org on 2024/10/07 20:03:26 UTC
(hbase) branch master updated: HBASE-28905: Skip excessive evaluations of LINK_NAME_PATTERN and REF_NAME_PATTERN regular expressions (#6348)
This is an automated email from the ASF dual-hosted git repository.
wchevreuil pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new ddcef33aaad HBASE-28905: Skip excessive evaluations of LINK_NAME_PATTERN and REF_NAME_PATTERN regular expressions (#6348)
ddcef33aaad is described below
commit ddcef33aaadbe78ccd45a41be84bce6e9aca30a1
Author: Charles Connell <cc...@hubspot.com>
AuthorDate: Mon Oct 7 16:03:21 2024 -0400
HBASE-28905: Skip excessive evaluations of LINK_NAME_PATTERN and REF_NAME_PATTERN regular expressions (#6348)
Signed-off-by: Wellington Chevreuil <wc...@apache.org>
---
.../src/main/java/org/apache/hadoop/hbase/io/HFileLink.java | 7 +++++++
.../org/apache/hadoop/hbase/regionserver/StoreFileInfo.java | 11 +++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java
index 84323e5c659..a036a90d7cf 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java
@@ -188,6 +188,13 @@ public class HFileLink extends FileLink {
* @return True if the path is a HFileLink.
*/
public static boolean isHFileLink(String fileName) {
+ // The LINK_NAME_PATTERN regex is not computationally trivial, so see if we can fast-fail
+ // on a simple heuristic first. The regex contains a literal "=", so if that character
+ // isn't in the fileName, then the regex cannot match.
+ if (!fileName.contains("=")) {
+ return false;
+ }
+
Matcher m = LINK_NAME_PATTERN.matcher(fileName);
if (!m.matches()) {
return false;
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java
index 052dd511231..19b28a9ee22 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java
@@ -54,7 +54,7 @@ public class StoreFileInfo implements Configurable {
/**
* A non-capture group, for hfiles, so that this can be embedded. HFiles are uuid ([0-9a-z]+).
- * Bulk loaded hfiles has (_SeqId_[0-9]+_) has suffix. The mob del file has (_del) as suffix.
+ * Bulk loaded hfiles have (_SeqId_[0-9]+_) as a suffix. The mob del file has (_del) as a suffix.
*/
public static final String HFILE_NAME_REGEX = "[0-9a-f]+(?:(?:_SeqId_[0-9]+_)|(?:_del))?";
@@ -66,7 +66,7 @@ public class StoreFileInfo implements Configurable {
* hfilelink reference names ({@code
*
<table>
- * =<region>-<hfile>.<parentEncRegion>}) If reference, then the regex has more than just one
+ * =<region>-<hfile>.<parentEncRegion>}). If reference, then the regex has more than just one
* group. Group 1, hfile/hfilelink pattern, is this file's id. Group 2 '(.+)' is the reference's
* parent region name.
*/
@@ -533,6 +533,13 @@ public class StoreFileInfo implements Configurable {
* @return True if the path has format of a HStoreFile reference.
*/
public static boolean isReference(final String name) {
+ // The REF_NAME_PATTERN regex is not computationally trivial, so see if we can fast-fail
+ // on a simple heuristic first. The regex contains a literal ".", so if that character
+ // isn't in the name, then the regex cannot match.
+ if (!name.contains(".")) {
+ return false;
+ }
+
Matcher m = REF_NAME_PATTERN.matcher(name);
return m.matches() && m.groupCount() > 1;
}