This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.2 by this push:
new 2edbce1c2ba branch-4.2: [perf](storage) Prune Azure glob listing with
expanded prefixes (#70430)
2edbce1c2ba is described below
commit 2edbce1c2ba7aed923bd58a45e027e61d23372e7
Author: hui lai <[email protected]>
AuthorDate: Mon Nov 23 08:30:53 2026 +0800
branch-4.2: [perf](storage) Prune Azure glob listing with expanded prefixes
(#70430)
Backport https://github.com/apache/doris/pull/69383 to branch-4.2.
Adapt prefix expansion, numeric range matching, and provider-specific
cursor ordering to the fe-core object storage implementations. Azure
passes expanded prefixes directly to the SDK and carries listing limits
and resume keys across prefixes. S3 directory buckets retain
slash-terminated prefixes and reject key-based pagination.
Local validation was limited to `git diff --check`. Compilation and
tests were skipped.
---
.../doris/common/util/ObjectStorageGlob.java | 734 +++++++++++++++++++++
.../java/org/apache/doris/common/util/S3Util.java | 280 +-------
.../org/apache/doris/fs/obj/AzureObjStorage.java | 143 ++--
.../java/org/apache/doris/fs/obj/S3ObjStorage.java | 27 +-
.../apache/doris/fs/remote/AzureFileSystem.java | 8 +
.../job/offset/s3/S3SourceOffsetProvider.java | 10 +-
.../doris/common/util/ObjectStorageGlobTest.java | 197 ++++++
.../apache/doris/fs/obj/AzureObjStorageTest.java | 27 +-
.../org/apache/doris/fs/obj/S3ObjStorageTest.java | 4 +
.../job/offset/s3/S3SourceOffsetProviderTest.java | 10 +
10 files changed, 1087 insertions(+), 353 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/util/ObjectStorageGlob.java
b/fe/fe-core/src/main/java/org/apache/doris/common/util/ObjectStorageGlob.java
new file mode 100644
index 00000000000..27723a789bc
--- /dev/null
+++
b/fe/fe-core/src/main/java/org/apache/doris/common/util/ObjectStorageGlob.java
@@ -0,0 +1,734 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.common.util;
+
+import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Provider-neutral glob helpers for object-storage keys.
+ */
+public final class ObjectStorageGlob {
+
+ private static final int MAX_EXPANDED_GLOB_LIST_PREFIXES = 256;
+ private static final Comparator<String> UTF8_BINARY_ORDER =
ObjectStorageGlob::compareUtf8Binary;
+ private static final Pattern NUMERIC_RANGE_PATTERN =
Pattern.compile("-?\\d+\\.\\.-?\\d+");
+ private static final Pattern NUMERIC_RANGE_ALTERNATIVE =
Pattern.compile("(-?\\d+)\\.\\.(-?\\d+)");
+
+ private ObjectStorageGlob() {
+ }
+
+ /**
+ * Returns the longest key prefix that contains no glob metacharacters.
+ */
+ public static String longestNonGlobPrefix(String globPattern) {
+ int earliest = globPattern.length();
+ for (char c : new char[]{'*', '?', '[', '{', '\\'}) {
+ int idx = globPattern.indexOf(c);
+ if (idx >= 0 && idx < earliest) {
+ earliest = idx;
+ }
+ }
+ return globPattern.substring(0, earliest);
+ }
+
+ /**
+ * Returns object-store list prefixes that are safe to push down for a
glob pattern.
+ *
+ * <p>Unlike {@link #longestNonGlobPrefix(String)}, this expands bounded
glob constructs
+ * ({@code {...}} alternation and positive {@code [...]} character
classes) before the first
+ * unbounded wildcard. For example,
+ * {@code date=2025-{0[3-9],1[0-2]}-01/mp_id=8/*} becomes concrete date
prefixes instead
+ * of one broad {@code date=2025-} scan. If expansion would be too large
or unsafe, it
+ * falls back to the conservative longest static prefix.
+ */
+ public static List<String> expandedGlobListPrefixes(String globPattern) {
+ return expandedGlobListPrefixes(globPattern, UTF8_BINARY_ORDER);
+ }
+
+ /** Returns safe list prefixes sorted in the provider's key order. */
+ public static List<String> expandedGlobListPrefixes(String globPattern,
Comparator<String> keyOrder) {
+ List<String> prefixes = expandGlobListPrefixes(globPattern, true);
+ if (prefixes == null) {
+ return
Collections.singletonList(longestNonGlobPrefix(globPattern));
+ }
+ List<String> sorted = new ArrayList<>(prefixes);
+ sorted.sort(keyOrder);
+ return sorted;
+ }
+
+ /** Returns the complete keys for a bounded HEAD lookup, or null if
listing is required. */
+ public static List<String> exactKeys(String pattern) {
+ List<String> keys =
expandGlobListPrefixes(expandNumericRanges(pattern), false);
+ return keys == null ? null : new ArrayList<>(new
LinkedHashSet<>(keys));
+ }
+
+ private static List<String> expandGlobListPrefixes(String globPattern,
boolean allowPartialPrefix) {
+ List<String> prefixes = new ArrayList<>();
+ prefixes.add("");
+ int i = 0;
+ while (i < globPattern.length()) {
+ char c = globPattern.charAt(i);
+ if (c == '*' || c == '?') {
+ return allowPartialPrefix ? compactPrefixes(prefixes) : null;
+ }
+ if (c == '\\') {
+ if (i + 1 < globPattern.length()) {
+ appendLiteral(prefixes, globPattern.charAt(i + 1));
+ i += 2;
+ } else {
+ appendLiteral(prefixes, c);
+ i++;
+ }
+ continue;
+ }
+ if (c == '[') {
+ PrefixExpansion charClass = expandCharacterClass(globPattern,
i);
+ if (charClass == null) {
+ return allowPartialPrefix ? compactPrefixes(prefixes) :
null;
+ }
+ prefixes = appendAlternatives(prefixes, charClass.values);
+ if (prefixes == null) {
+ return null;
+ }
+ i = charClass.nextIndex;
+ continue;
+ }
+ if (c == '{') {
+ PrefixExpansion brace = expandBraceGroup(globPattern, i);
+ if (brace == null) {
+ return allowPartialPrefix ? compactPrefixes(prefixes) :
null;
+ }
+ prefixes = appendAlternatives(prefixes, brace.values);
+ if (prefixes == null) {
+ return null;
+ }
+ i = brace.nextIndex;
+ continue;
+ }
+ appendLiteral(prefixes, c);
+ i++;
+ }
+ // Complete brace arms must retain distinct values until the
surrounding suffix is appended.
+ return allowPartialPrefix ? compactPrefixes(prefixes) : prefixes;
+ }
+
+ private static void appendLiteral(List<String> prefixes, char c) {
+ for (int i = 0; i < prefixes.size(); i++) {
+ prefixes.set(i, prefixes.get(i) + c);
+ }
+ }
+
+ private static List<String> appendAlternatives(List<String> prefixes,
List<String> alternatives) {
+ long expandedSize = (long) prefixes.size() * alternatives.size();
+ if (expandedSize > MAX_EXPANDED_GLOB_LIST_PREFIXES) {
+ return null;
+ }
+ List<String> expanded = new ArrayList<>((int) expandedSize);
+ for (String prefix : prefixes) {
+ for (String alternative : alternatives) {
+ expanded.add(prefix + alternative);
+ }
+ }
+ return expanded;
+ }
+
+ private static PrefixExpansion expandCharacterClass(String globPattern,
int openIndex) {
+ int closeIndex = findClosingBracket(globPattern, openIndex);
+ if (closeIndex < 0 || closeIndex == openIndex + 1) {
+ return null;
+ }
+ int i = openIndex + 1;
+ char first = globPattern.charAt(i);
+ if (first == '!' || first == '^') {
+ return null;
+ }
+ // Escaped characters can be range endpoints in the full matcher. Keep
a conservative
+ // prefix rather than interpreting those endpoints differently during
expansion.
+ if (containsSurrogate(globPattern, i, closeIndex)
+ || globPattern.substring(i, closeIndex).indexOf('\\') >= 0) {
+ return null;
+ }
+ List<String> values = new ArrayList<>();
+ while (i < closeIndex) {
+ char current = globPattern.charAt(i);
+ if (i + 2 < closeIndex && globPattern.charAt(i + 1) == '-') {
+ char rangeEnd = globPattern.charAt(i + 2);
+ int step = current <= rangeEnd ? 1 : -1;
+ for (char ch = current; step > 0 ? ch <= rangeEnd : ch >=
rangeEnd; ch += step) {
+ values.add(String.valueOf(ch));
+ if (values.size() > MAX_EXPANDED_GLOB_LIST_PREFIXES) {
+ return null;
+ }
+ }
+ i += 3;
+ continue;
+ }
+ values.add(String.valueOf(current));
+ i++;
+ }
+ return new PrefixExpansion(values, closeIndex + 1);
+ }
+
+ private static int findClosingBracket(String globPattern, int openIndex) {
+ for (int i = openIndex + 1; i < globPattern.length(); i++) {
+ char c = globPattern.charAt(i);
+ if (c == '\\') {
+ i++;
+ continue;
+ }
+ if (c == ']') {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ private static boolean containsSurrogate(String text, int start, int end) {
+ for (int i = start; i < end; i++) {
+ if (Character.isSurrogate(text.charAt(i))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static PrefixExpansion expandBraceGroup(String globPattern, int
openIndex) {
+ int closeIndex = findClosingBrace(globPattern, openIndex);
+ if (closeIndex < 0) {
+ return null;
+ }
+ List<String> alternatives = splitBraceAlternatives(
+ globPattern.substring(openIndex + 1, closeIndex));
+ if (alternatives.isEmpty()) {
+ return null;
+ }
+ List<String> values = new ArrayList<>();
+ for (String alternative : alternatives) {
+ if (containsNumericRange(alternative)) {
+ return null;
+ }
+ List<String> expandedAlternative =
expandGlobListPrefixes(alternative, false);
+ if (expandedAlternative == null) {
+ return null;
+ }
+ values.addAll(expandedAlternative);
+ if (values.size() > MAX_EXPANDED_GLOB_LIST_PREFIXES) {
+ return null;
+ }
+ }
+ return new PrefixExpansion(values, closeIndex + 1);
+ }
+
+ private static int findClosingBrace(String globPattern, int openIndex) {
+ int depth = 0;
+ for (int i = openIndex; i < globPattern.length(); i++) {
+ char c = globPattern.charAt(i);
+ if (c == '\\') {
+ i++;
+ continue;
+ }
+ if (c == '[') {
+ int closeBracket = findClosingBracket(globPattern, i);
+ if (closeBracket >= 0) {
+ i = closeBracket;
+ continue;
+ }
+ }
+ if (c == '{') {
+ depth++;
+ } else if (c == '}') {
+ depth--;
+ if (depth == 0) {
+ return i;
+ }
+ }
+ }
+ return -1;
+ }
+
+ private static List<String> splitBraceAlternatives(String content) {
+ List<String> alternatives = new ArrayList<>();
+ int depth = 0;
+ int start = 0;
+ for (int i = 0; i < content.length(); i++) {
+ char c = content.charAt(i);
+ if (c == '\\') {
+ i++;
+ continue;
+ }
+ if (c == '[') {
+ int closeBracket = findClosingBracket(content, i);
+ if (closeBracket >= 0) {
+ i = closeBracket;
+ continue;
+ }
+ }
+ if (c == '{') {
+ depth++;
+ } else if (c == '}') {
+ if (depth == 0) {
+ return Collections.emptyList();
+ }
+ depth--;
+ } else if (c == ',' && depth == 0) {
+ alternatives.add(content.substring(start, i));
+ start = i + 1;
+ }
+ }
+ if (depth != 0) {
+ return Collections.emptyList();
+ }
+ alternatives.add(content.substring(start));
+ return alternatives;
+ }
+
+ private static List<String> compactPrefixes(List<String> prefixes) {
+ List<String> sorted = new ArrayList<>(prefixes);
+ sorted.sort(UTF8_BINARY_ORDER);
+ List<String> compact = new ArrayList<>();
+ for (String prefix : sorted) {
+ if (prefix.isEmpty()) {
+ return Collections.singletonList("");
+ }
+ boolean covered = false;
+ for (String existing : compact) {
+ if (prefix.startsWith(existing)) {
+ covered = true;
+ break;
+ }
+ }
+ if (!covered) {
+ compact.add(prefix);
+ }
+ }
+ return compact;
+ }
+
+ /**
+ * Compares object keys by unsigned UTF-8 byte order, matching S3 listing
order.
+ */
+ public static int compareUtf8Binary(String left, String right) {
+ byte[] leftBytes = left.getBytes(StandardCharsets.UTF_8);
+ byte[] rightBytes = right.getBytes(StandardCharsets.UTF_8);
+ int commonLength = Math.min(leftBytes.length, rightBytes.length);
+ for (int i = 0; i < commonLength; i++) {
+ int result = Integer.compare(
+ Byte.toUnsignedInt(leftBytes[i]),
Byte.toUnsignedInt(rightBytes[i]));
+ if (result != 0) {
+ return result;
+ }
+ }
+ return Integer.compare(leftBytes.length, rightBytes.length);
+ }
+
+ /**
+ * Expands bounded {N..M} numeric ranges inside brace groups into
comma-separated alternatives.
+ */
+ public static String expandNumericRanges(String pattern) {
+ StringBuilder expanded = new StringBuilder();
+ for (int i = 0; i < pattern.length(); i++) {
+ char c = pattern.charAt(i);
+ if (c == '\\') {
+ expanded.append(c);
+ if (i + 1 < pattern.length()) {
+ expanded.append(pattern.charAt(++i));
+ }
+ } else if (c == '[') {
+ int closeIndex = findClosingBracket(pattern, i);
+ if (closeIndex >= 0) {
+ expanded.append(pattern, i, closeIndex + 1);
+ i = closeIndex;
+ } else {
+ expanded.append(c);
+ }
+ } else if (c == '{') {
+ int closeIndex = findClosingBrace(pattern, i);
+ if (closeIndex >= 0) {
+ expanded.append('{').append(expandNumericBraceGroup(
+ pattern.substring(i + 1, closeIndex))).append('}');
+ i = closeIndex;
+ } else {
+ expanded.append(c);
+ }
+ } else {
+ expanded.append(c);
+ }
+ }
+ return expanded.toString();
+ }
+
+ private static String expandNumericBraceGroup(String content) {
+ List<String> segments = splitBraceAlternatives(content);
+ boolean isMixed = segments.size() > 1;
+ LinkedHashSet<String> values = new LinkedHashSet<>();
+ for (String segment : segments) {
+ Matcher range = numericRangeMatcher(segment, isMixed);
+ if (range == null) {
+ values.add(expandNumericRanges(segment));
+ } else {
+ long from;
+ long to;
+ try {
+ from = Long.parseLong(range.group(1));
+ to = Long.parseLong(range.group(2));
+ } catch (NumberFormatException e) {
+ return content;
+ }
+ long cardinality = numericRangeCardinality(from, to);
+ if (cardinality < 0 || cardinality >
MAX_EXPANDED_GLOB_LIST_PREFIXES - values.size()) {
+ return content;
+ }
+ long step = from <= to ? 1L : -1L;
+ boolean zeroPad = hasLeadingZero(range.group(1)) ||
hasLeadingZero(range.group(2));
+ int width = Math.max(digitWidth(range.group(1)),
digitWidth(range.group(2)));
+ for (long offset = 0; offset < cardinality; offset++) {
+ long value = step > 0 ? from + offset : from - offset;
+ values.add(formatRangeValue(value, width, zeroPad));
+ }
+ }
+ if (values.size() > MAX_EXPANDED_GLOB_LIST_PREFIXES) {
+ return content;
+ }
+ }
+ return String.join(",", values);
+ }
+
+ private static Matcher numericRangeMatcher(String alternative, boolean
isMixed) {
+ Matcher matcher = NUMERIC_RANGE_ALTERNATIVE.matcher(isMixed ?
alternative.trim() : alternative);
+ if (!matcher.matches() || (!isMixed
+ && (matcher.group(1).startsWith("-") ||
matcher.group(2).startsWith("-")))) {
+ return null;
+ }
+ return matcher;
+ }
+
+ private static boolean containsNumericRange(String text) {
+ return NUMERIC_RANGE_PATTERN.matcher(text).find();
+ }
+
+ private static long numericRangeCardinality(long from, long to) {
+ try {
+ long distance = from <= to
+ ? Math.subtractExact(to, from)
+ : Math.subtractExact(from, to);
+ return Math.addExact(distance, 1L);
+ } catch (ArithmeticException e) {
+ return -1L;
+ }
+ }
+
+ private static boolean hasLeadingZero(String value) {
+ String digits = value.startsWith("-") ? value.substring(1) : value;
+ return digits.length() > 1 && digits.charAt(0) == '0';
+ }
+
+ private static int digitWidth(String value) {
+ return value.startsWith("-") ? value.length() - 1 : value.length();
+ }
+
+ private static String formatRangeValue(long value, int width, boolean
zeroPad) {
+ if (!zeroPad) {
+ return Long.toString(value);
+ }
+ String sign = value < 0 ? "-" : "";
+ String text = Long.toString(value);
+ String digits = value < 0 ? text.substring(1) : text;
+ StringBuilder padded = new StringBuilder(sign);
+ for (int i = digits.length(); i < width; i++) {
+ padded.append('0');
+ }
+ return padded.append(digits).toString();
+ }
+
+ /**
+ * Translates a Java NIO glob pattern to a regex matched against raw
object keys.
+ */
+ public static String globToRegex(String glob) {
+ StringBuilder sb = new StringBuilder("^");
+ appendGlobRegex(sb, glob);
+ sb.append('$');
+ return sb.toString();
+ }
+
+ private static void appendGlobRegex(StringBuilder sb, String glob) {
+ boolean inClass = false;
+ boolean inGroup = false;
+ int i = 0;
+ while (i < glob.length()) {
+ char c = glob.charAt(i);
+ if (c == '\\') {
+ if (i + 1 < glob.length()) {
+ sb.append(Pattern.quote(String.valueOf(glob.charAt(i +
1))));
+ i += 2;
+ } else {
+ sb.append("\\\\");
+ i++;
+ }
+ continue;
+ }
+ if (inClass) {
+ if (c == ']') {
+ inClass = false;
+ sb.append(']');
+ } else if (c == '\\' || c == '[') {
+ sb.append('\\').append(c);
+ } else {
+ sb.append(c);
+ }
+ i++;
+ continue;
+ }
+ switch (c) {
+ case '*':
+ if (i + 1 < glob.length() && glob.charAt(i + 1) == '*') {
+ sb.append(".*");
+ i += 2;
+ } else {
+ sb.append("[^/]*");
+ i++;
+ }
+ break;
+ case '?':
+ sb.append("[^/]");
+ i++;
+ break;
+ case '[':
+ inClass = true;
+ sb.append('[');
+ i++;
+ if (i < glob.length() && glob.charAt(i) == '!') {
+ sb.append('^');
+ i++;
+ }
+ break;
+ case '{':
+ int closeIndex = findClosingBrace(glob, i);
+ if (closeIndex >= 0) {
+ appendBraceGroupRegex(sb, glob.substring(i + 1,
closeIndex));
+ i = closeIndex + 1;
+ break;
+ }
+ inGroup = true;
+ sb.append("(?:");
+ i++;
+ break;
+ case '}':
+ inGroup = false;
+ sb.append(')');
+ i++;
+ break;
+ case ',':
+ if (inGroup) {
+ sb.append('|');
+ } else {
+ sb.append(',');
+ }
+ i++;
+ break;
+ default:
+ if ("\\.^$|+()".indexOf(c) >= 0) {
+ sb.append('\\').append(c);
+ } else {
+ sb.append(c);
+ }
+ i++;
+ break;
+ }
+ }
+ }
+
+ private static void appendBraceGroupRegex(StringBuilder sb, String
content) {
+ List<String> alternatives = splitBraceAlternatives(content);
+ if (alternatives.isEmpty()) {
+ sb.append("(?:)");
+ return;
+ }
+ boolean isMixed = alternatives.size() > 1;
+ sb.append("(?:");
+ for (int i = 0; i < alternatives.size(); i++) {
+ if (i > 0) {
+ sb.append('|');
+ }
+ String rangeRegex = numericRangeRegex(alternatives.get(i),
isMixed);
+ if (rangeRegex != null) {
+ sb.append(rangeRegex);
+ } else {
+ appendGlobRegex(sb, alternatives.get(i));
+ }
+ }
+ sb.append(')');
+ }
+
+ private static String numericRangeRegex(String alternative, boolean
isMixed) {
+ Matcher matcher = numericRangeMatcher(alternative, isMixed);
+ if (matcher == null) {
+ return null;
+ }
+ String fromText = matcher.group(1);
+ String toText = matcher.group(2);
+ BigInteger from = new BigInteger(fromText);
+ BigInteger to = new BigInteger(toText);
+ BigInteger min = from.min(to);
+ BigInteger max = from.max(to);
+ boolean zeroPad = hasLeadingZero(fromText) || hasLeadingZero(toText);
+ int width = Math.max(digitWidth(fromText), digitWidth(toText));
+
+ List<String> alternatives = new ArrayList<>();
+ if (min.signum() < 0) {
+ BigInteger negativeUpper = max.min(BigInteger.ONE.negate());
+ alternatives.add("-" + unsignedRangeRegex(
+ negativeUpper.abs(), min.abs(), width, zeroPad));
+ }
+ if (min.signum() <= 0 && max.signum() >= 0) {
+ alternatives.add(zeroPad ? repeatDigit('0', width) : "0");
+ }
+ if (max.signum() > 0) {
+ alternatives.add(unsignedRangeRegex(
+ min.max(BigInteger.ONE), max, width, zeroPad));
+ }
+ return joinRegexAlternatives(alternatives);
+ }
+
+ private static String unsignedRangeRegex(BigInteger from, BigInteger to,
+ int width, boolean zeroPad) {
+ if (zeroPad) {
+ return sameLengthRangeRegex(leftPadWithZeros(from.toString(),
width),
+ leftPadWithZeros(to.toString(), width));
+ }
+ List<String> alternatives = new ArrayList<>();
+ int minLength = from.toString().length();
+ int maxLength = to.toString().length();
+ for (int length = minLength; length <= maxLength; length++) {
+ BigInteger low = from.max(minValueForLength(length));
+ BigInteger high = to.min(maxValueForLength(length));
+ if (low.compareTo(high) <= 0) {
+ alternatives.add(sameLengthRangeRegex(low.toString(),
high.toString()));
+ }
+ }
+ return joinRegexAlternatives(alternatives);
+ }
+
+ private static BigInteger minValueForLength(int length) {
+ if (length == 1) {
+ return BigInteger.ZERO;
+ }
+ return BigInteger.TEN.pow(length - 1);
+ }
+
+ private static BigInteger maxValueForLength(int length) {
+ return BigInteger.TEN.pow(length).subtract(BigInteger.ONE);
+ }
+
+ private static String sameLengthRangeRegex(String low, String high) {
+ if (low.isEmpty()) {
+ return "";
+ }
+ if (low.equals(high)) {
+ return low;
+ }
+ if (isAll(low, '0') && isAll(high, '9')) {
+ return digitRepeat(low.length());
+ }
+
+ char lowFirst = low.charAt(0);
+ char highFirst = high.charAt(0);
+ String lowRest = low.substring(1);
+ String highRest = high.substring(1);
+ if (lowFirst == highFirst) {
+ return lowFirst + sameLengthRangeRegex(lowRest, highRest);
+ }
+ int restLength = low.length() - 1;
+
+ List<String> alternatives = new ArrayList<>();
+ alternatives.add(lowFirst + sameLengthRangeRegex(
+ lowRest, repeatDigit('9', restLength)));
+ if (lowFirst + 1 <= highFirst - 1) {
+ alternatives.add(digitClass((char) (lowFirst + 1), (char)
(highFirst - 1))
+ + digitRepeat(restLength));
+ }
+ alternatives.add(highFirst + sameLengthRangeRegex(
+ repeatDigit('0', restLength), highRest));
+ return joinRegexAlternatives(alternatives);
+ }
+
+ private static boolean isAll(String value, char expected) {
+ for (int i = 0; i < value.length(); i++) {
+ if (value.charAt(i) != expected) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static String leftPadWithZeros(String value, int width) {
+ if (value.length() >= width) {
+ return value;
+ }
+ return repeatDigit('0', width - value.length()) + value;
+ }
+
+ private static String digitClass(char from, char to) {
+ if (from == to) {
+ return String.valueOf(from);
+ }
+ return "[" + from + "-" + to + "]";
+ }
+
+ private static String digitRepeat(int count) {
+ if (count == 0) {
+ return "";
+ }
+ if (count == 1) {
+ return "\\d";
+ }
+ return "\\d{" + count + "}";
+ }
+
+ private static String repeatDigit(char digit, int count) {
+ StringBuilder sb = new StringBuilder(count);
+ for (int i = 0; i < count; i++) {
+ sb.append(digit);
+ }
+ return sb.toString();
+ }
+
+ private static String joinRegexAlternatives(List<String> alternatives) {
+ if (alternatives.size() == 1) {
+ return alternatives.get(0);
+ }
+ return "(?:" + String.join("|", alternatives) + ")";
+ }
+
+ private static class PrefixExpansion {
+ private final List<String> values;
+ private final int nextIndex;
+
+ private PrefixExpansion(List<String> values, int nextIndex) {
+ this.values = values;
+ this.nextIndex = nextIndex;
+ }
+ }
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/S3Util.java
b/fe/fe-core/src/main/java/org/apache/doris/common/util/S3Util.java
index a89912294d9..a66c32e0d64 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/S3Util.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/S3Util.java
@@ -58,20 +58,15 @@ import
software.amazon.awssdk.services.sts.auth.StsAssumeRoleCredentialsProvider
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
-import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class S3Util {
private static final Logger LOG = LogManager.getLogger(Util.class);
- private static final int MAX_EXPANDED_GLOB_LIST_PREFIXES = 256;
- private static final Comparator<String> UTF8_BINARY_ORDER =
S3Util::compareUtf8Binary;
private static AwsCredentialsProvider
getAwsCredencialsProvider(CloudCredential credential) {
AwsCredentials awsCredential;
@@ -344,282 +339,11 @@ public class S3Util {
}
public static String getLongestPrefix(String globPattern) {
- int length = globPattern.length();
- int earliestSpecialCharIndex = length;
-
- char[] specialChars = {'*', '?', '[', '{', '\\'};
-
- for (char specialChar : specialChars) {
- int index = globPattern.indexOf(specialChar);
- if (index != -1 && index < earliestSpecialCharIndex) {
- earliestSpecialCharIndex = index;
- }
- }
-
- return globPattern.substring(0, earliestSpecialCharIndex);
+ return ObjectStorageGlob.longestNonGlobPrefix(globPattern);
}
- /**
- * Returns object-store list prefixes that are safe to push down for a
glob pattern.
- * Bounded brace alternatives and positive character classes are expanded
before the first
- * unbounded wildcard. Unsafe or oversized expansions fall back to the
longest static prefix.
- */
public static List<String> getGlobListPrefixes(String globPattern) {
- List<String> prefixes = expandGlobListPrefixes(globPattern, true);
- return prefixes == null ?
Collections.singletonList(getLongestPrefix(globPattern)) : prefixes;
- }
-
- private static List<String> expandGlobListPrefixes(String globPattern,
boolean allowPartialPrefix) {
- List<String> prefixes = new ArrayList<>();
- prefixes.add("");
- int i = 0;
- while (i < globPattern.length()) {
- char c = globPattern.charAt(i);
- if (c == '*' || c == '?') {
- return allowPartialPrefix ? compactPrefixes(prefixes) : null;
- }
- if (c == '\\') {
- if (i + 1 < globPattern.length()) {
- appendLiteral(prefixes, globPattern.charAt(i + 1));
- i += 2;
- } else {
- appendLiteral(prefixes, c);
- i++;
- }
- continue;
- }
- if (c == '[') {
- PrefixExpansion charClass = expandCharacterClass(globPattern,
i);
- if (charClass == null) {
- return allowPartialPrefix ? compactPrefixes(prefixes) :
null;
- }
- prefixes = appendAlternatives(prefixes, charClass.values);
- if (prefixes == null) {
- return null;
- }
- i = charClass.nextIndex;
- continue;
- }
- if (c == '{') {
- PrefixExpansion brace = expandBraceGroup(globPattern, i);
- if (brace == null) {
- return allowPartialPrefix ? compactPrefixes(prefixes) :
null;
- }
- prefixes = appendAlternatives(prefixes, brace.values);
- if (prefixes == null) {
- return null;
- }
- i = brace.nextIndex;
- continue;
- }
- appendLiteral(prefixes, c);
- i++;
- }
- return compactPrefixes(prefixes);
- }
-
- private static void appendLiteral(List<String> prefixes, char c) {
- for (int i = 0; i < prefixes.size(); i++) {
- prefixes.set(i, prefixes.get(i) + c);
- }
- }
-
- private static List<String> appendAlternatives(List<String> prefixes,
List<String> alternatives) {
- long expandedSize = (long) prefixes.size() * alternatives.size();
- if (expandedSize > MAX_EXPANDED_GLOB_LIST_PREFIXES) {
- return null;
- }
- List<String> expanded = new ArrayList<>((int) expandedSize);
- for (String prefix : prefixes) {
- for (String alternative : alternatives) {
- expanded.add(prefix + alternative);
- }
- }
- return expanded;
- }
-
- private static PrefixExpansion expandCharacterClass(String globPattern,
int openIndex) {
- int closeIndex = findClosingBracket(globPattern, openIndex);
- if (closeIndex < 0 || closeIndex == openIndex + 1) {
- return null;
- }
- int i = openIndex + 1;
- char first = globPattern.charAt(i);
- if (first == '!' || first == '^') {
- return null;
- }
- if (containsSurrogate(globPattern, i, closeIndex)) {
- return null;
- }
- List<String> values = new ArrayList<>();
- while (i < closeIndex) {
- char current = globPattern.charAt(i);
- if (current == '\\') {
- if (i + 1 >= closeIndex) {
- return null;
- }
- values.add(String.valueOf(globPattern.charAt(i + 1)));
- i += 2;
- continue;
- }
- if (i + 2 < closeIndex && globPattern.charAt(i + 1) == '-') {
- char rangeEnd = globPattern.charAt(i + 2);
- int step = current <= rangeEnd ? 1 : -1;
- for (char ch = current; step > 0 ? ch <= rangeEnd : ch >=
rangeEnd; ch += step) {
- values.add(String.valueOf(ch));
- if (values.size() > MAX_EXPANDED_GLOB_LIST_PREFIXES) {
- return null;
- }
- }
- i += 3;
- continue;
- }
- values.add(String.valueOf(current));
- i++;
- }
- return new PrefixExpansion(values, closeIndex + 1);
- }
-
- private static int findClosingBracket(String globPattern, int openIndex) {
- for (int i = openIndex + 1; i < globPattern.length(); i++) {
- char c = globPattern.charAt(i);
- if (c == '\\') {
- i++;
- continue;
- }
- if (c == ']') {
- return i;
- }
- }
- return -1;
- }
-
- private static boolean containsSurrogate(String text, int start, int end) {
- for (int i = start; i < end; i++) {
- if (Character.isSurrogate(text.charAt(i))) {
- return true;
- }
- }
- return false;
- }
-
- private static PrefixExpansion expandBraceGroup(String globPattern, int
openIndex) {
- int closeIndex = findClosingBrace(globPattern, openIndex);
- if (closeIndex < 0) {
- return null;
- }
- List<String> alternatives = splitBraceAlternatives(
- globPattern.substring(openIndex + 1, closeIndex));
- if (alternatives.isEmpty()) {
- return null;
- }
- List<String> values = new ArrayList<>();
- for (String alternative : alternatives) {
- List<String> expandedAlternative =
expandGlobListPrefixes(alternative, false);
- if (expandedAlternative == null) {
- return null;
- }
- values.addAll(expandedAlternative);
- if (values.size() > MAX_EXPANDED_GLOB_LIST_PREFIXES) {
- return null;
- }
- }
- return new PrefixExpansion(values, closeIndex + 1);
- }
-
- private static int findClosingBrace(String globPattern, int openIndex) {
- int depth = 0;
- for (int i = openIndex; i < globPattern.length(); i++) {
- char c = globPattern.charAt(i);
- if (c == '\\') {
- i++;
- continue;
- }
- if (c == '{') {
- depth++;
- } else if (c == '}') {
- depth--;
- if (depth == 0) {
- return i;
- }
- }
- }
- return -1;
- }
-
- private static List<String> splitBraceAlternatives(String content) {
- List<String> alternatives = new ArrayList<>();
- int depth = 0;
- int start = 0;
- for (int i = 0; i < content.length(); i++) {
- char c = content.charAt(i);
- if (c == '\\') {
- i++;
- continue;
- }
- if (c == '{') {
- depth++;
- } else if (c == '}') {
- if (depth == 0) {
- return Collections.emptyList();
- }
- depth--;
- } else if (c == ',' && depth == 0) {
- alternatives.add(content.substring(start, i));
- start = i + 1;
- }
- }
- if (depth != 0) {
- return Collections.emptyList();
- }
- alternatives.add(content.substring(start));
- return alternatives;
- }
-
- private static List<String> compactPrefixes(List<String> prefixes) {
- List<String> sorted = new ArrayList<>(prefixes);
- sorted.sort(UTF8_BINARY_ORDER);
- List<String> compact = new ArrayList<>();
- for (String prefix : sorted) {
- if (prefix.isEmpty()) {
- return Collections.singletonList("");
- }
- boolean covered = false;
- for (String existing : compact) {
- if (prefix.startsWith(existing)) {
- covered = true;
- break;
- }
- }
- if (!covered) {
- compact.add(prefix);
- }
- }
- return compact;
- }
-
- private static int compareUtf8Binary(String left, String right) {
- byte[] leftBytes = left.getBytes(StandardCharsets.UTF_8);
- byte[] rightBytes = right.getBytes(StandardCharsets.UTF_8);
- int commonLength = Math.min(leftBytes.length, rightBytes.length);
- for (int i = 0; i < commonLength; i++) {
- int result = Integer.compare(
- Byte.toUnsignedInt(leftBytes[i]),
Byte.toUnsignedInt(rightBytes[i]));
- if (result != 0) {
- return result;
- }
- }
- return Integer.compare(leftBytes.length, rightBytes.length);
- }
-
- private static class PrefixExpansion {
- private final List<String> values;
- private final int nextIndex;
-
- private PrefixExpansion(List<String> values, int nextIndex) {
- this.values = values;
- this.nextIndex = nextIndex;
- }
+ return ObjectStorageGlob.expandedGlobListPrefixes(globPattern);
}
// Apply some rules to extend the globs parsing behavior
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/fs/obj/AzureObjStorage.java
b/fe/fe-core/src/main/java/org/apache/doris/fs/obj/AzureObjStorage.java
index 4929e34e7f5..aeba04159c5 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/obj/AzureObjStorage.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/obj/AzureObjStorage.java
@@ -21,10 +21,12 @@ import org.apache.doris.backup.Status;
import org.apache.doris.common.Config;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.UserException;
+import org.apache.doris.common.util.ObjectStorageGlob;
import org.apache.doris.common.util.S3URI;
import org.apache.doris.common.util.S3Util;
import org.apache.doris.datasource.property.storage.AzureProperties;
import org.apache.doris.datasource.property.storage.AzurePropertyUtils;
+import org.apache.doris.fs.GlobListResult;
import org.apache.doris.fs.remote.RemoteFile;
import com.azure.core.http.rest.PagedIterable;
@@ -59,16 +61,16 @@ import java.io.File;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import java.nio.file.FileSystems;
-import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Base64;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class AzureObjStorage implements ObjStorage<BlobServiceClient> {
@@ -350,11 +352,23 @@ public class AzureObjStorage implements
ObjStorage<BlobServiceClient> {
}
public Status globList(String remotePath, List<RemoteFile> result, boolean
fileNameOnly) {
+ return globListInternal(remotePath, result, fileNameOnly, false, null,
-1, -1).getStatus();
+ }
+
+ public GlobListResult globListWithLimit(String remotePath,
List<RemoteFile> result, String startFile,
+ long fileSizeLimit, long fileNumLimit) {
+ return globListInternal(remotePath, result, false, true, startFile,
fileSizeLimit, fileNumLimit);
+ }
+
+ private GlobListResult globListInternal(String remotePath,
List<RemoteFile> result, boolean fileNameOnly,
+ boolean filesOnly, String startFile, long fileSizeLimit, long
fileNumLimit) {
long roundCnt = 0;
long elementCnt = 0;
long matchCnt = 0;
long startTime = System.nanoTime();
- Status st = Status.OK;
+ Status st;
+ String lastMatchedKey = "";
+ long matchedBytes = 0;
try {
remotePath =
AzurePropertyUtils.validateAndNormalizeUri(remotePath);
S3URI uri = S3URI.create(remotePath, isUsePathStyle,
forceParsingByStandardUri);
@@ -365,76 +379,93 @@ public class AzureObjStorage implements
ObjStorage<BlobServiceClient> {
// Controlled by config: s3_skip_list_for_deterministic_path
// Note: Skip when using path style (see S3ObjStorage for detailed
explanation)
String keyPattern = uri.getKey();
- if (Config.s3_skip_list_for_deterministic_path
+ if (!filesOnly && Config.s3_skip_list_for_deterministic_path
&& !isUsePathStyle
&& S3Util.isDeterministicPattern(keyPattern)) {
Status headStatus = globListByGetProperties(bucket,
keyPattern, result, fileNameOnly, startTime);
if (headStatus != null) {
- return headStatus;
+ return new GlobListResult(headStatus);
}
// If headStatus is null, fall through to use listing
}
- String globPath = S3Util.extendGlobs(uri.getKey());
+ String globPath =
ObjectStorageGlob.expandNumericRanges(keyPattern);
if (LOG.isDebugEnabled()) {
LOG.debug("try to glob list for azure, remote path {}, orig
{}", globPath, remotePath);
}
BlobContainerClient client =
getClient().getBlobContainerClient(bucket);
- java.nio.file.Path pathPattern = Paths.get(globPath);
- if (LOG.isDebugEnabled()) {
- LOG.debug("azure glob list pathPattern: {}, bucket: {}",
pathPattern, bucket);
- }
- PathMatcher matcher =
FileSystems.getDefault().getPathMatcher("glob:" + pathPattern);
+ Pattern matcher =
Pattern.compile(ObjectStorageGlob.globToRegex(globPath));
HashSet<String> directorySet = new HashSet<>();
String listPrefix = S3Util.getLongestPrefix(globPath);
if (LOG.isDebugEnabled()) {
LOG.debug("azure glob list prefix is {}", listPrefix);
}
- ListBlobsOptions options = new
ListBlobsOptions().setPrefix(listPrefix);
- String newContinuationToken = null;
- do {
- roundCnt++;
- PagedResponse<BlobItem> pagedResponse =
getPagedBlobItems(client, options, newContinuationToken);
-
- for (BlobItem blobItem : pagedResponse.getElements()) {
- elementCnt++;
- java.nio.file.Path blobPath =
Paths.get(blobItem.getName());
-
- boolean isPrefix = false;
- while (null != blobPath &&
blobPath.normalize().toString().startsWith(listPrefix)) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("get blob {}",
blobPath.normalize().toString());
- }
- if (!matcher.matches(blobPath)) {
- isPrefix = true;
- blobPath = blobPath.getParent();
+ for (String prefix :
ObjectStorageGlob.expandedGlobListPrefixes(globPath,
Comparator.naturalOrder())) {
+ ListBlobsOptions options = new
ListBlobsOptions().setPrefix(prefix);
+ String newContinuationToken = null;
+ do {
+ roundCnt++;
+ PagedResponse<BlobItem> pagedResponse =
getPagedBlobItems(client, options, newContinuationToken);
+
+ for (BlobItem blobItem : pagedResponse.getElements()) {
+ elementCnt++;
+ if (filesOnly) {
+ String key = blobItem.getName();
+ if (key.endsWith("/") || (startFile != null &&
key.compareTo(startFile) <= 0)
+ || !matcher.matcher(key).matches()) {
+ continue;
+ }
+ if ((fileNumLimit > 0 && matchCnt >= fileNumLimit)
+ || (fileSizeLimit > 0 && matchedBytes >=
fileSizeLimit)) {
+ return new GlobListResult(Status.OK, key,
bucket, listPrefix);
+ }
+ BlobItemProperties props =
blobItem.getProperties();
+ long size = props.getContentLength();
+ result.add(new RemoteFile(constructS3Path(key,
bucket), true, size, size,
+
props.getLastModified().toInstant().toEpochMilli()));
+ matchedBytes += size;
+ matchCnt++;
+ lastMatchedKey = key;
continue;
}
- if
(directorySet.contains(blobPath.normalize().toString())) {
- break;
- }
- if (isPrefix) {
- directorySet.add(blobPath.normalize().toString());
- }
+ java.nio.file.Path blobPath =
Paths.get(blobItem.getName());
+
+ boolean isPrefix = false;
+ while (null != blobPath &&
blobPath.normalize().toString().startsWith(listPrefix)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("get blob {}",
blobPath.normalize().toString());
+ }
+ if
(!matcher.matcher(blobPath.toString()).matches()) {
+ isPrefix = true;
+ blobPath = blobPath.getParent();
+ continue;
+ }
+ if
(directorySet.contains(blobPath.normalize().toString())) {
+ break;
+ }
+ if (isPrefix) {
+
directorySet.add(blobPath.normalize().toString());
+ }
+
+ matchCnt++;
+ RemoteFile remoteFile = new RemoteFile(
+ fileNameOnly ?
blobPath.getFileName().toString()
+ :
constructS3Path(blobPath.toString(), bucket),
+ !isPrefix,
+ isPrefix ? -1 :
blobItem.getProperties().getContentLength(),
+ isPrefix ? -1 :
blobItem.getProperties().getContentLength(),
+ isPrefix ? 0 :
blobItem.getProperties().getLastModified().getSecond());
+ result.add(remoteFile);
- matchCnt++;
- RemoteFile remoteFile = new RemoteFile(
- fileNameOnly ?
blobPath.getFileName().toString() : constructS3Path(blobPath.toString(),
- uri.getBucket()),
- !isPrefix,
- isPrefix ? -1 :
blobItem.getProperties().getContentLength(),
- isPrefix ? -1 :
blobItem.getProperties().getContentLength(),
- isPrefix ? 0 :
blobItem.getProperties().getLastModified().getSecond());
- result.add(remoteFile);
-
- blobPath = blobPath.getParent();
- isPrefix = true;
+ blobPath = blobPath.getParent();
+ isPrefix = true;
+ }
}
- }
- newContinuationToken = pagedResponse.getContinuationToken();
- } while (newContinuationToken != null);
-
+ newContinuationToken =
pagedResponse.getContinuationToken();
+ } while (newContinuationToken != null);
+ }
+ return new GlobListResult(Status.OK, lastMatchedKey, bucket,
listPrefix);
} catch (BlobStorageException e) {
LOG.warn("glob file " + remotePath + " failed because azure error:
" + e.getMessage());
st = new Status(Status.ErrCode.COMMON_ERROR, "glob file " +
remotePath
@@ -450,7 +481,7 @@ public class AzureObjStorage implements
ObjStorage<BlobServiceClient> {
remotePath, elementCnt, roundCnt, matchCnt,
duration / 1000);
}
- return st;
+ return new GlobListResult(st);
}
/**
@@ -467,10 +498,10 @@ public class AzureObjStorage implements
ObjStorage<BlobServiceClient> {
private Status globListByGetProperties(String bucket, String keyPattern,
List<RemoteFile> result, boolean fileNameOnly, long startTime) {
try {
- // First expand [...] brackets to {...} braces, then expand {..}
ranges, then expand braces
- String expandedPattern = S3Util.expandBracketPatterns(keyPattern);
- expandedPattern = S3Util.extendGlobs(expandedPattern);
- List<String> expandedPaths =
S3Util.expandBracePatterns(expandedPattern);
+ List<String> expandedPaths =
ObjectStorageGlob.exactKeys(keyPattern);
+ if (expandedPaths == null) {
+ return null;
+ }
// Fall back to listing if too many paths to avoid overwhelming
Azure with requests
// Controlled by config: s3_head_request_max_paths
diff --git a/fe/fe-core/src/main/java/org/apache/doris/fs/obj/S3ObjStorage.java
b/fe/fe-core/src/main/java/org/apache/doris/fs/obj/S3ObjStorage.java
index c2d7fa1c8e7..a1d54e718a6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/obj/S3ObjStorage.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/obj/S3ObjStorage.java
@@ -21,6 +21,7 @@ import org.apache.doris.backup.Status;
import org.apache.doris.common.Config;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.UserException;
+import org.apache.doris.common.util.ObjectStorageGlob;
import org.apache.doris.common.util.S3URI;
import org.apache.doris.common.util.S3Util;
import org.apache.doris.common.util.Util;
@@ -83,8 +84,6 @@ import software.amazon.awssdk.services.sts.model.Credentials;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
-import java.nio.file.FileSystems;
-import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
@@ -94,6 +93,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class S3ObjStorage implements ObjStorage<S3Client> {
@@ -636,8 +636,8 @@ public class S3ObjStorage implements ObjStorage<S3Client> {
try {
S3URI uri = S3URI.create(remotePath, isUsePathStyle,
forceParsingByStandardUri);
// Directory bucket check for limit scenario
- if (hasLimits && uri.useS3DirectoryBucket()) {
- throw new RuntimeException("Not support glob with limit for
directory bucket");
+ if ((hasLimits || (startFile != null && !startFile.isEmpty())) &&
uri.useS3DirectoryBucket()) {
+ throw new RuntimeException("S3 directory buckets do not
support key-based pagination");
}
bucket = uri.getBucket();
@@ -663,13 +663,12 @@ public class S3ObjStorage implements ObjStorage<S3Client>
{
// If headResult is null, fall through to use listing
}
- String globPath = S3Util.extendGlobs(uri.getKey());
+ String globPath =
ObjectStorageGlob.expandNumericRanges(keyPattern);
if (LOG.isDebugEnabled()) {
LOG.debug("globList globPath:{}, remotePath:{}", globPath,
remotePath);
}
- java.nio.file.Path pathPattern = Paths.get(globPath);
- PathMatcher matcher =
FileSystems.getDefault().getPathMatcher("glob:" + pathPattern);
+ Pattern matcher =
Pattern.compile(ObjectStorageGlob.globToRegex(globPath));
HashSet<String> directorySet = new HashSet<>();
String listPrefix = S3Util.getLongestPrefix(globPath); // similar
to Azure
@@ -701,7 +700,7 @@ public class S3ObjStorage implements ObjStorage<S3Client> {
Builder builder = ListObjectsV2Request.builder()
.bucket(bucket)
.prefix(currentListPrefix);
- if (startFile != null) {
+ if (startFile != null && !startFile.isEmpty()) {
builder.startAfter(startFile);
}
ListObjectsV2Request request = builder.build();
@@ -717,7 +716,7 @@ public class S3ObjStorage implements ObjStorage<S3Client> {
// remaining page(s) and expanded prefixes so
pagination remains correct.
if (reachLimit) {
java.nio.file.Path checkPath =
Paths.get(obj.key());
- if (matcher.matches(checkPath)) {
+ if
(matcher.matcher(checkPath.toString()).matches()) {
currentMaxFile = obj.key();
break listPrefixesLoop;
}
@@ -728,7 +727,7 @@ public class S3ObjStorage implements ObjStorage<S3Client> {
boolean isPrefix = false;
while (objPath != null &&
objPath.normalize().toString().startsWith(listPrefix)) {
- if (!matcher.matches(objPath)) {
+ if
(!matcher.matcher(objPath.toString()).matches()) {
isPrefix = true;
objPath = objPath.getParent();
continue;
@@ -814,10 +813,10 @@ public class S3ObjStorage implements ObjStorage<S3Client>
{
private GlobListResult globListByHeadRequests(String bucket, String
keyPattern,
List<RemoteFile> result, boolean fileNameOnly, long startTime) {
try {
- // First expand [...] brackets to {...} braces, then expand {..}
ranges, then expand braces
- String expandedPattern = S3Util.expandBracketPatterns(keyPattern);
- expandedPattern = S3Util.extendGlobs(expandedPattern);
- List<String> expandedPaths =
S3Util.expandBracePatterns(expandedPattern);
+ List<String> expandedPaths =
ObjectStorageGlob.exactKeys(keyPattern);
+ if (expandedPaths == null) {
+ return null;
+ }
// Fall back to listing if too many paths to avoid overwhelming S3
with HEAD requests
// Controlled by config: s3_head_request_max_paths
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/fs/remote/AzureFileSystem.java
b/fe/fe-core/src/main/java/org/apache/doris/fs/remote/AzureFileSystem.java
index c568b6b6f9c..7c0c609fe9d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/remote/AzureFileSystem.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/remote/AzureFileSystem.java
@@ -21,6 +21,7 @@ import org.apache.doris.analysis.StorageBackend.StorageType;
import org.apache.doris.backup.Status;
import org.apache.doris.datasource.property.storage.AzureProperties;
import org.apache.doris.datasource.property.storage.StorageProperties;
+import org.apache.doris.fs.GlobListResult;
import org.apache.doris.fs.obj.AzureObjStorage;
import org.apache.logging.log4j.LogManager;
@@ -58,6 +59,13 @@ public class AzureFileSystem extends ObjFileSystem {
return azureObjStorage.globList(remotePath, result, fileNameOnly);
}
+ @Override
+ public GlobListResult globListWithLimit(String remotePath,
List<RemoteFile> result, String startFile,
+ long fileSizeLimit, long fileNumLimit) {
+ AzureObjStorage storage = (AzureObjStorage) getObjStorage();
+ return storage.globListWithLimit(remotePath, result, startFile,
fileSizeLimit, fileNumLimit);
+ }
+
@Override
public Status listDirectories(String remotePath, Set<String> result) {
AzureObjStorage azureObjStorage = (AzureObjStorage) getObjStorage();
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/job/offset/s3/S3SourceOffsetProvider.java
b/fe/fe-core/src/main/java/org/apache/doris/job/offset/s3/S3SourceOffsetProvider.java
index 1e8170d0562..3a261e4521b 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/job/offset/s3/S3SourceOffsetProvider.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/job/offset/s3/S3SourceOffsetProvider.java
@@ -19,6 +19,8 @@ package org.apache.doris.job.offset.s3;
import org.apache.doris.backup.Status;
import org.apache.doris.common.util.DebugPointUtil;
+import org.apache.doris.common.util.ObjectStorageGlob;
+import org.apache.doris.datasource.property.storage.AzureProperties;
import org.apache.doris.datasource.property.storage.StorageProperties;
import org.apache.doris.fs.FileSystemFactory;
import org.apache.doris.fs.GlobListResult;
@@ -46,6 +48,7 @@ import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -57,6 +60,7 @@ public class S3SourceOffsetProvider implements
SourceOffsetProvider {
private volatile S3Offset noMoreFilesAfterOffset;
volatile S3Offset currentOffset;
volatile String maxEndFile;
+ private volatile Comparator<String> fileKeyOrder =
ObjectStorageGlob::compareUtf8Binary;
public S3SourceOffsetProvider() {
this.oneTimeMode = false;
@@ -80,6 +84,8 @@ public class S3SourceOffsetProvider implements
SourceOffsetProvider {
String startFile = currentOffset == null ? null :
currentOffset.endFile;
String filePath = null;
StorageProperties storageProperties =
StorageProperties.createPrimary(copiedProps);
+ fileKeyOrder = storageProperties instanceof AzureProperties ?
Comparator.naturalOrder()
+ : ObjectStorageGlob::compareUtf8Binary;
try (RemoteFileSystem fileSystem =
FileSystemFactory.get(storageProperties)) {
String uri = storageProperties.validateAndGetUri(copiedProps);
filePath = storageProperties.validateAndNormalizeUri(uri);
@@ -198,6 +204,8 @@ public class S3SourceOffsetProvider implements
SourceOffsetProvider {
Map<String, String> copiedProps =
Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
copiedProps.putAll(properties);
StorageProperties storageProperties =
StorageProperties.createPrimary(copiedProps);
+ fileKeyOrder = storageProperties instanceof AzureProperties ?
Comparator.naturalOrder()
+ : ObjectStorageGlob::compareUtf8Binary;
S3Offset offsetAtScan = currentOffset;
String startFile = offsetAtScan == null ? null : offsetAtScan.endFile;
try (RemoteFileSystem fileSystem =
FileSystemFactory.get(storageProperties)) {
@@ -233,7 +241,7 @@ public class S3SourceOffsetProvider implements
SourceOffsetProvider {
return true;
}
- if (maxEndFile != null && currentOffset.endFile.compareTo(maxEndFile)
< 0) {
+ if (maxEndFile != null && fileKeyOrder.compare(currentOffset.endFile,
maxEndFile) < 0) {
return true;
}
return false;
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/common/util/ObjectStorageGlobTest.java
b/fe/fe-core/src/test/java/org/apache/doris/common/util/ObjectStorageGlobTest.java
new file mode 100644
index 00000000000..89d61174b11
--- /dev/null
+++
b/fe/fe-core/src/test/java/org/apache/doris/common/util/ObjectStorageGlobTest.java
@@ -0,0 +1,197 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.common.util;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.regex.Pattern;
+
+class ObjectStorageGlobTest {
+
+ @Test
+ void expandNumericRanges_preservesZeroPadding() {
+ Assertions.assertEquals("date=2025-{01,02,03}-01/",
+
ObjectStorageGlob.expandNumericRanges("date=2025-{01..03}-01/"));
+ }
+
+ @Test
+ void expandNumericRanges_preservesPaddedMinimumLong() {
+ for (String range :
Arrays.asList("-09223372036854775808..-09223372036854775807",
+ "-09223372036854775807..-09223372036854775808")) {
+ String glob = "data_{" + range + ",x}.csv";
+ String expanded = ObjectStorageGlob.expandNumericRanges(glob);
+ Pattern matcher =
Pattern.compile(ObjectStorageGlob.globToRegex(expanded));
+ Pattern fallback =
Pattern.compile(ObjectStorageGlob.globToRegex(glob));
+ for (String key : Arrays.asList("data_-09223372036854775808.csv",
"data_-09223372036854775807.csv",
+ "data_x.csv")) {
+ Assertions.assertTrue(matcher.matcher(key).matches(), key);
+ Assertions.assertTrue(fallback.matcher(key).matches(), key);
+
Assertions.assertTrue(ObjectStorageGlob.expandedGlobListPrefixes(expanded).contains(key),
key);
+ }
+
Assertions.assertFalse(matcher.matcher("data_-9223372036854775808.csv").matches());
+
Assertions.assertFalse(matcher.matcher("data_-09223372036854775806.csv").matches());
+ }
+ }
+
+ @Test
+ void expandedGlobListPrefixes_fallsBackForEscapedCharacterClassRanges() {
+ for (String characterClass : Arrays.asList("[\\a-z]", "[a-\\c]",
"[\\a-\\c]")) {
+ String glob = "data/" + characterClass + "/*/file.csv";
+ Assertions.assertEquals(Collections.singletonList("data/"),
ObjectStorageGlob.expandedGlobListPrefixes(glob));
+
Assertions.assertTrue(Pattern.matches(ObjectStorageGlob.globToRegex(glob),
"data/b/sub/file.csv"));
+ Assertions.assertEquals(Collections.singletonList("data/"),
+ ObjectStorageGlob.expandedGlobListPrefixes("data/{fixed,"
+ characterClass + "}/*"));
+ }
+ }
+
+ @Test
+ void expandedGlobListPrefixes_usesProviderOrder() {
+ String fullwidth = new String(Character.toChars(0xFF21));
+ String emoji = new String(Character.toChars(0x1F600));
+ String glob = "data/{" + fullwidth + "," + emoji + "}/file.csv";
+ Assertions.assertEquals(Arrays.asList("data/" + fullwidth +
"/file.csv", "data/" + emoji + "/file.csv"),
+ ObjectStorageGlob.expandedGlobListPrefixes(glob));
+ Assertions.assertEquals(Arrays.asList("data/" + emoji + "/file.csv",
"data/" + fullwidth + "/file.csv"),
+ ObjectStorageGlob.expandedGlobListPrefixes(glob,
Comparator.naturalOrder()));
+ Assertions.assertEquals(Collections.singletonList(""),
+ ObjectStorageGlob.expandedGlobListPrefixes("*",
Comparator.naturalOrder()));
+ }
+
+ @Test
+ void expandNumericRanges_skipsOversizedRanges() {
+ String pattern = "date={1..10000000}/*";
+
+ Assertions.assertEquals(pattern,
ObjectStorageGlob.expandNumericRanges(pattern));
+ }
+
+ @Test
+ void expandNumericRanges_skipsMixedOversizedRanges() {
+ String pattern = "date={x,0..9223372036854775807}/*";
+
+ Assertions.assertEquals(pattern,
ObjectStorageGlob.expandNumericRanges(pattern));
+ }
+
+ @Test
+ void expandNumericRanges_preservesLiteralSpacesInMixedBraceArms() {
+ Assertions.assertEquals("data/{ x,1,2}/*.csv",
+ ObjectStorageGlob.expandNumericRanges("data/{ x,1..2}/*.csv"));
+ }
+
+ @Test
+ void expandedGlobListPrefixes_fallsBackForUnexpandedNumericRanges() {
+ Assertions.assertEquals(Collections.singletonList("date="),
+
ObjectStorageGlob.expandedGlobListPrefixes("date={1..10000000}/*"));
+ }
+
+ @Test
+ void compareUtf8Binary_matchesObjectStoreOrderForNonBmpKeys() {
+ String privateUseKey = "data/" + new String(Character.toChars(0xE000))
+ "/file.csv";
+ String emojiKey = "data/" + new String(Character.toChars(0x1F600)) +
"/file.csv";
+
+ Assertions.assertTrue(privateUseKey.compareTo(emojiKey) > 0);
+
Assertions.assertTrue(ObjectStorageGlob.compareUtf8Binary(privateUseKey,
emojiKey) < 0);
+ }
+
+ @Test
+ void globToRegex_preservesOversizedNumericRangeSemantics() {
+ Pattern matcher =
Pattern.compile(ObjectStorageGlob.globToRegex("date={1..10000000}/*"));
+
+ Assertions.assertTrue(matcher.matcher("date=123/file.csv").matches());
+
Assertions.assertTrue(matcher.matcher("date=10000000/file.csv").matches());
+ Assertions.assertFalse(matcher.matcher("date=0/file.csv").matches());
+
Assertions.assertFalse(matcher.matcher("date=10000001/file.csv").matches());
+
Assertions.assertFalse(matcher.matcher("date=0001/file.csv").matches());
+ }
+
+ @Test
+ void globToRegex_preservesLiteralSpacesInMixedBraceArms() {
+ Pattern matcher = Pattern.compile(ObjectStorageGlob.globToRegex(
+ ObjectStorageGlob.expandNumericRanges("data/{
x,1..2}/*.csv")));
+
+ Assertions.assertTrue(matcher.matcher("data/ x/file.csv").matches());
+ Assertions.assertTrue(matcher.matcher("data/1/file.csv").matches());
+ Assertions.assertFalse(matcher.matcher("data/x/file.csv").matches());
+ }
+
+ @Test
+ void globToRegex_preservesMixedOversizedNumericRangeSemantics() {
+ Pattern matcher = Pattern.compile(ObjectStorageGlob.globToRegex(
+ "date={x,0..9223372036854775807}/*"));
+
+ Assertions.assertTrue(matcher.matcher("date=x/file.csv").matches());
+
Assertions.assertTrue(matcher.matcher("date=9223372036854775807/file.csv").matches());
+ Assertions.assertFalse(matcher.matcher("date=-1/file.csv").matches());
+
Assertions.assertFalse(matcher.matcher("date=9223372036854775808/file.csv").matches());
+ }
+
+ @Test
+ void globToRegex_preservesOversizedZeroPaddedNumericRangeSemantics() {
+ Pattern matcher =
Pattern.compile(ObjectStorageGlob.globToRegex("date={0001..1000}/*"));
+
+ Assertions.assertTrue(matcher.matcher("date=0001/file.csv").matches());
+ Assertions.assertTrue(matcher.matcher("date=0999/file.csv").matches());
+ Assertions.assertTrue(matcher.matcher("date=1000/file.csv").matches());
+ Assertions.assertFalse(matcher.matcher("date=999/file.csv").matches());
+
Assertions.assertFalse(matcher.matcher("date=1001/file.csv").matches());
+ }
+
+ @Test
+ void expandNumericRanges_preservesEscapesAndCharacterClasses() {
+ Assertions.assertEquals("data_\\{1..3\\}.csv",
+ ObjectStorageGlob.expandNumericRanges("data_\\{1..3\\}.csv"));
+ Assertions.assertEquals("[{1..3}]/{1,2}",
+ ObjectStorageGlob.expandNumericRanges("[{1..3}]/{1..2}"));
+ Assertions.assertEquals("{1,2,a\\,b,\\{literal\\},[{},]}",
+
ObjectStorageGlob.expandNumericRanges("{1..2,a\\,b,\\{literal\\},[{},]}"));
+ Pattern matcher = Pattern.compile(ObjectStorageGlob.globToRegex(
+
ObjectStorageGlob.expandNumericRanges("data_{1..2,a\\,b,\\{literal\\},[{},]}.csv")));
+ for (String name : Arrays.asList("1", "2", "a,b", "{literal}", "{",
"}", ",")) {
+ Assertions.assertTrue(matcher.matcher("data_" + name +
".csv").matches(), name);
+ }
+ Assertions.assertFalse(matcher.matcher("data_3.csv").matches());
+ }
+
+ @Test
+ void expandedGlobListPrefixes_preservesBraceArmsUntilSuffixIsAppended() {
+ Assertions.assertEquals(Arrays.asList("data_1.csv", "data_101.csv"),
+
ObjectStorageGlob.expandedGlobListPrefixes("data_{1,101}.csv"));
+ Assertions.assertEquals(Arrays.asList("a101suffix", "a1suffix",
"bsuffix"),
+
ObjectStorageGlob.expandedGlobListPrefixes("{a{1,101},b}suffix"));
+ Assertions.assertEquals(Arrays.asList("asuffix", "suffix"),
+ ObjectStorageGlob.expandedGlobListPrefixes("{,a}suffix"));
+ }
+
+ @Test
+ void globToRegex_preservesNestedRangeAlternatives() {
+ String glob = "data_{a{01..02},b{3..10000000},plain}.csv";
+ String expanded = ObjectStorageGlob.expandNumericRanges(glob);
+ Assertions.assertEquals(Collections.singletonList("data_"),
ObjectStorageGlob.expandedGlobListPrefixes(expanded));
+ Pattern matcher =
Pattern.compile(ObjectStorageGlob.globToRegex(expanded));
+ for (String name : Arrays.asList("a01", "a02", "b3", "b10000000",
"plain")) {
+ Assertions.assertTrue(matcher.matcher("data_" + name +
".csv").matches(), name);
+ }
+ for (String name : Arrays.asList("a1", "a03", "b2", "b10000001",
"a01,b3,plain")) {
+ Assertions.assertFalse(matcher.matcher("data_" + name +
".csv").matches(), name);
+ }
+ }
+
+}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/fs/obj/AzureObjStorageTest.java
b/fe/fe-core/src/test/java/org/apache/doris/fs/obj/AzureObjStorageTest.java
index 5e1681adbda..f5d690ff8aa 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/fs/obj/AzureObjStorageTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/fs/obj/AzureObjStorageTest.java
@@ -21,6 +21,7 @@ import org.apache.doris.backup.Status;
import org.apache.doris.datasource.property.storage.AzureProperties;
import org.apache.doris.datasource.property.storage.S3Properties;
import org.apache.doris.datasource.property.storage.StorageProperties;
+import org.apache.doris.fs.GlobListResult;
import org.apache.doris.fs.remote.RemoteFile;
import com.azure.core.http.HttpHeaders;
@@ -135,6 +136,25 @@ public class AzureObjStorageTest {
});
}
+ @Test
+ public void testLimitAndResumeAcrossPrefixes() {
+ String glob = "s3://gavin-test-jp/azure-test/{2,3}/tmp.ehJi0Y5QKt";
+ AzureObjStorage storage = genMockedAzureObjStorage(2);
+ List<RemoteFile> result = new ArrayList<>();
+ GlobListResult page = storage.globListWithLimit(glob, result, null, 0,
1);
+ Assertions.assertEquals(Status.OK, page.getStatus());
+ Assertions.assertEquals(1, result.size());
+
Assertions.assertEquals("s3://gavin-test-jp/azure-test/2/tmp.ehJi0Y5QKt",
result.get(0).getName());
+ Assertions.assertEquals("azure-test/3/tmp.ehJi0Y5QKt",
page.getMaxFile());
+
+ result.clear();
+ page = storage.globListWithLimit(glob, result,
"azure-test/2/tmp.ehJi0Y5QKt", 1, 0);
+ Assertions.assertEquals(Status.OK, page.getStatus());
+ Assertions.assertEquals(1, result.size());
+ Assertions.assertEquals("s3://gavin-test-jp/" + page.getMaxFile(),
result.get(0).getName());
+ Assertions.assertEquals("azure-test/3/tmp.ehJi0Y5QKt",
page.getMaxFile());
+ }
+
@Test
public void testFsGlob() {
for (I i : genInputs()) {
@@ -205,12 +225,11 @@ public class AzureObjStorageTest {
AzureProperties azureProps = (AzureProperties)
StorageProperties.createPrimary(props);
AzureObjStorage azs = new AzureObjStorage(azureProps);
List<String> allBlobKeys = genObjectKeys();
- final Integer[] batchIndex = {0}; // from 0 to numBatch
new MockUp<AzureObjStorage>(AzureObjStorage.class) {
@Mock
public PagedResponse<BlobItem>
getPagedBlobItems(BlobContainerClient client, ListBlobsOptions options,
String
newContinuationToken) {
- batchIndex[0]++;
+ int batchIndex = newContinuationToken == null ? 0 :
Integer.parseInt(newContinuationToken);
return new PagedResponse<BlobItem>() {
public final List<List<String>> batches = new
ArrayList<List<String>>() {
{
@@ -234,7 +253,7 @@ public class AzureObjStorageTest {
@Override
public IterableStream<BlobItem> getElements() {
List<BlobItem> blobItems = new ArrayList<>();
- batches.get(batchIndex[0] - 1).forEach(x ->
blobItems.add(new BlobItem().setName(x).setIsPrefix(false)
+ batches.get(batchIndex).forEach(x -> blobItems.add(new
BlobItem().setName(x).setIsPrefix(false)
.setProperties(new
BlobItemProperties().setContentLength(17L)
.setLastModified(OffsetDateTime.now()))));
return new IterableStream<>(blobItems);
@@ -242,7 +261,7 @@ public class AzureObjStorageTest {
@Override
public String getContinuationToken() {
- return (batchIndex[0] >= numBatch) ? null : "what ever
it is";
+ return batchIndex + 1 >= numBatch ? null :
Integer.toString(batchIndex + 1);
}
@Override
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/fs/obj/S3ObjStorageTest.java
b/fe/fe-core/src/test/java/org/apache/doris/fs/obj/S3ObjStorageTest.java
index 018113841ed..2c655623ba2 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/fs/obj/S3ObjStorageTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/fs/obj/S3ObjStorageTest.java
@@ -563,6 +563,10 @@ public class S3ObjStorageTest {
// Verify that the prefix was adjusted correctly for the directory
bucket.
// "data/files*.csv" -> longest prefix is "data/files", adjusted to
"data/"
Assertions.assertEquals("data/", captor.getValue().prefix());
+ Assertions.assertFalse(storage.globListWithLimit(remotePath, new
ArrayList<>(), "data/files1.csv", 0, 0)
+ .getStatus().ok());
+ Assertions.assertFalse(storage.globListWithLimit(remotePath, new
ArrayList<>(), null, 0, 1)
+ .getStatus().ok());
}
@Test
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/job/offset/s3/S3SourceOffsetProviderTest.java
b/fe/fe-core/src/test/java/org/apache/doris/job/offset/s3/S3SourceOffsetProviderTest.java
index fdd51d00c7b..9db36e1ab83 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/job/offset/s3/S3SourceOffsetProviderTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/job/offset/s3/S3SourceOffsetProviderTest.java
@@ -242,4 +242,14 @@ public class S3SourceOffsetProviderTest {
Assertions.assertFalse(matcher.matches(Paths.get(key)),
"Unexpected file: " + key);
}
}
+
+ @Test
+ void hasMoreDataToConsumeUsesUtf8BinaryOrder() {
+ S3Offset currentOffset = new S3Offset();
+ currentOffset.setEndFile("data/" + new
String(Character.toChars(0xE000)));
+ S3SourceOffsetProvider provider = new S3SourceOffsetProvider();
+ provider.currentOffset = currentOffset;
+ provider.maxEndFile = "data/" + new String(Character.toChars(0x1F600));
+ Assertions.assertTrue(provider.hasMoreDataToConsume());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]