rajarshisarkar commented on a change in pull request #4011:
URL: https://github.com/apache/iceberg/pull/4011#discussion_r826608670
##########
File path: core/src/main/java/org/apache/iceberg/util/PropertyUtil.java
##########
@@ -70,4 +73,26 @@ public static String propertyAsString(Map<String, String>
properties,
}
return defaultValue;
}
+
+ /**
+ * Returns subset of provided map with keys matching the provided prefix.
Matching is case-sensitive and the matching
+ * prefix is removed from the keys in returned map.
+ *
+ * @param properties input map
+ * @param prefix prefix to choose keys from input map
+ * @return subset of input map with keys starting with provided prefix and
prefix trimmed out
+ */
+ public static Map<String, String> propertiesWithPrefix(Map<String, String>
properties,
+ String prefix) {
+ if (properties == null || properties.isEmpty()) {
+ return ImmutableMap.of();
+ }
+
+ Preconditions.checkState(prefix != null, "prefix can't be null.");
+
+ return properties.entrySet().stream()
+ .filter(e -> e.getKey().startsWith(prefix))
+ .collect(Collectors.toMap(
+ e -> e.getKey().replaceFirst(prefix, ""), Map.Entry::getValue));
+ }
Review comment:
We recently took this method in `master` to extract a map having s3
write tags prefix (https://github.com/apache/iceberg/pull/4259).
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]