From cddd095f11e0da0ea21fbfc7eaa0b4535ec04399 Mon Sep 17 00:00:00 2001 From: Vova Kolmakov Date: Fri, 12 Jun 2026 12:32:29 +0700 Subject: [PATCH] Azure: Reduce allocations in ADLSLocation URI parsing Co-Authored-By: Claude Opus 4.8 (1M context) --- .../apache/iceberg/azure/adlsv2/ADLSLocation.java | 13 +++++++------ .../iceberg/azure/adlsv2/TestADLSLocation.java | 11 +++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/azure/src/main/java/org/apache/iceberg/azure/adlsv2/ADLSLocation.java b/azure/src/main/java/org/apache/iceberg/azure/adlsv2/ADLSLocation.java index 6fe2629774dc..df784f318dbb 100644 --- a/azure/src/main/java/org/apache/iceberg/azure/adlsv2/ADLSLocation.java +++ b/azure/src/main/java/org/apache/iceberg/azure/adlsv2/ADLSLocation.java @@ -64,17 +64,18 @@ class ADLSLocation { ValidationException.check(matcher.matches(), "Invalid ADLS URI: %s", location); String authority = matcher.group(2); - String[] parts = authority.split("@", -1); - if (parts.length > 1) { - this.container = parts[0]; - this.host = parts[1]; - this.storageAccount = host.split("\\.", -1)[0]; + int containerSplit = authority.indexOf('@'); + if (containerSplit >= 0) { + this.container = authority.substring(0, containerSplit); + this.host = authority.substring(containerSplit + 1); } else { this.container = null; this.host = authority; - this.storageAccount = authority.split("\\.", -1)[0]; } + int accountSplit = host.indexOf('.'); + this.storageAccount = accountSplit < 0 ? host : host.substring(0, accountSplit); + String uriPath = matcher.group(3); this.path = uriPath == null ? "" : uriPath.startsWith("/") ? uriPath.substring(1) : uriPath; } diff --git a/azure/src/test/java/org/apache/iceberg/azure/adlsv2/TestADLSLocation.java b/azure/src/test/java/org/apache/iceberg/azure/adlsv2/TestADLSLocation.java index 643e11fb7f97..793747926b86 100644 --- a/azure/src/test/java/org/apache/iceberg/azure/adlsv2/TestADLSLocation.java +++ b/azure/src/test/java/org/apache/iceberg/azure/adlsv2/TestADLSLocation.java @@ -84,6 +84,17 @@ public void testNoContainer() { assertThat(location.path()).isEqualTo("path/to/file"); } + @Test + public void testHostWithoutDot() { + String p1 = "abfs://container@account/path/to/file"; + ADLSLocation location = new ADLSLocation(p1); + + assertThat(location.storageAccount()).isEqualTo("account"); + assertThat(location.container().get()).isEqualTo("container"); + assertThat(location.host()).isEqualTo("account"); + assertThat(location.path()).isEqualTo("path/to/file"); + } + @Test public void testNoPath() { String p1 = "abfs://container@account.dfs.core.windows.net";