XBaith commented on code in PR #3300:
URL: https://github.com/apache/amoro/pull/3300#discussion_r1820275580
##########
amoro-common/src/main/java/org/apache/amoro/ServerTableIdentifier.java:
##########
@@ -123,6 +123,10 @@ public String toString() {
return String.format("%s.%s.%s(tableId=%d)", catalog, database, tableName,
id);
}
+ public String getTableFullName() {
Review Comment:
Is this method nessessary? How about invoke `getIdentifier().toString()` to
get full name?
##########
amoro-common/src/main/java/org/apache/amoro/resource/ResourceGroup.java:
##########
@@ -52,6 +77,81 @@ public String getContainer() {
return container;
}
+ public String getOptimizeGroupRule() {
+ return this.properties.getOrDefault(OPTIMIZE_GROUP_RULE_MATCH_KEY, null);
+ }
+
+ public boolean match(TableIdentifier tableIdentifier) {
+ return match(this.properties, tableIdentifier);
+ }
+
+ /**
+ * if only numbers, letters, and underscores are contained, then the rule is
not regexp and the
+ * rule will overwrite the regexp rule
+ */
+ private boolean noRegExp(String rule) {
+ String fmtString = rule.replaceAll(getSpaceSeparator(rule), "");
+ if (fmtString.replaceAll("[a-zA-Z0-9_]", "").length() == 0) {
+ return true;
+ }
+ return false;
+ }
+
+ public List<String> getFullMatchNameInRules() {
+ return
Arrays.stream(properties.getOrDefault(OPTIMIZE_GROUP_RULE_MATCH_KEY,
"").split(","))
+ .filter(item -> noRegExp(item))
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Full match means we manually assign the table to this group.
+ *
+ * @param tableIdentifier
+ * @return
+ */
+ public boolean fullMatch(TableIdentifier tableIdentifier) {
+ final String tableName =
+ String.format(
+ "%s.%s.%s",
+ tableIdentifier.getCatalog(),
+ tableIdentifier.getDatabase(),
+ tableIdentifier.getTableName());
+ return
Arrays.stream(properties.getOrDefault(OPTIMIZE_GROUP_RULE_MATCH_KEY,
"").split(","))
+ .filter(item -> item.contains(tableName))
+ .findAny()
+ .isPresent();
+ }
+
+ private boolean match(Map<String, String> properties, TableIdentifier
tableIdentifier) {
+ String rulePropertyKey = OPTIMIZE_GROUP_RULE_MATCH_KEY;
+ if (properties != null && properties.containsKey(rulePropertyKey)) {
+ List<String> matchRules =
+ Arrays.stream(properties.getOrDefault(rulePropertyKey,
"").split(","))
+ .collect(Collectors.toList());
+
+ final String tableName =
+ String.format(
Review Comment:
tableIdentifier.toString()
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]