[ 
https://issues.apache.org/jira/browse/HADOOP-19941?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18107312#comment-18107312
 ] 

ASF GitHub Bot commented on HADOOP-19941:
-----------------------------------------

anmolanmol1234 commented on code in PR #8611:
URL: https://github.com/apache/hadoop/pull/8611#discussion_r3842633625


##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/contract/TestArrowListBlobParser.java:
##########
@@ -0,0 +1,1193 @@
+/**
+ * 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.hadoop.fs.azurebfs.contract;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.channels.Channels;
+import java.nio.charset.StandardCharsets;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.arrow.memory.ArrowBuf;
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.memory.RootAllocator;
+import org.apache.arrow.vector.BigIntVector;
+import org.apache.arrow.vector.BitVector;
+import org.apache.arrow.vector.TimeStampMilliTZVector;
+import org.apache.arrow.vector.TimeStampSecVector;
+import org.apache.arrow.vector.UInt8Vector;
+import org.apache.arrow.vector.VarCharVector;
+import org.apache.arrow.vector.VectorSchemaRoot;
+import org.apache.arrow.vector.complex.MapVector;
+import org.apache.arrow.vector.complex.impl.UnionMapWriter;
+import org.apache.arrow.vector.ipc.ArrowStreamWriter;
+import org.apache.arrow.vector.types.TimeUnit;
+import org.apache.arrow.vector.types.pojo.ArrowType;
+import org.apache.arrow.vector.types.pojo.Field;
+import org.apache.arrow.vector.types.pojo.FieldType;
+import org.apache.arrow.vector.types.pojo.Schema;
+import org.apache.arrow.vector.util.Text;
+import org.junit.jupiter.api.Test;
+
+import org.apache.hadoop.fs.azurebfs.contracts.services.ArrowListBlobParser;
+import 
org.apache.hadoop.fs.azurebfs.contracts.services.BlobListResultEntrySchema;
+import org.apache.hadoop.fs.azurebfs.contracts.services.BlobListResultSchema;
+import org.apache.hadoop.fs.azurebfs.utils.DateTimeUtils;
+
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_CONTENT_LENGTH;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_COPY_COMPLETION_TIME;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_COPY_ID;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_COPY_PROGRESS;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_COPY_SOURCE;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_COPY_STATUS;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_COPY_STATUS_DESCRIPTION;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_CREATION_TIME;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_ETAG;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_IS_DIRECTORY;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_LAST_MODIFIED;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_METADATA;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_NAME;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_COL_RESOURCE_TYPE;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_METADATA_NEXT_MARKER;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ARROW_RESOURCE_TYPE_BLOB_PREFIX;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.DIRECTORY;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.XML_TAG_HDI_ISFOLDER;
+import static 
org.apache.hadoop.fs.azurebfs.constants.HttpHeaderConfigurations.X_MS_META_HDI_ISFOLDER;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * Unit tests for {@link ArrowListBlobParser}, the Photon (Apache Arrow based)
+ * ListBlobs response parser.
+ */
+public class TestArrowListBlobParser {
+
+  private static final String URL = 
"https://account.blob.core.windows.net/container";;
+
+  /** Generous allocator limit used by the functional parsing tests. */
+  private static final long MEMORY_LIMIT = 256L * 1024 * 1024;
+
+  /** Deliberately tiny allocator limit used to force an over-limit failure. */
+  private static final long TINY_MEMORY_LIMIT = 1024L;
+
+  /** Arrow integer bit width used for the content-length column. */
+  private static final int ARROW_INT_BIT_WIDTH = 64;
+
+  /** Row count large enough to exhaust the tiny allocator limit. */
+  private static final int OVER_LIMIT_ROW_COUNT = 2000;
+
+  // Sample content-length values shared between builder rows and assertions.
+  private static final long CONTENT_LENGTH_A = 20L;
+  private static final long CONTENT_LENGTH_B = 30L;
+  private static final long CONTENT_LENGTH_C = 40L;
+  private static final long CONTENT_LENGTH_D = 42L;
+  private static final long CONTENT_LENGTH_SAMPLE = 1234L;
+
+  /**
+   * Verify an Arrow response with a single blob is parsed correctly and all
+   * common blob properties are populated.
+   */
+  @Test
+  public void testSingleBlob() throws Exception {
+    byte[] stream = new ArrowStreamBuilder()
+        .addRow("file1.txt", "0x8DB6668EAB50E67", CONTENT_LENGTH_SAMPLE,
+            "Tue, 06 Jun 2023 08:35:00 GMT",
+            "Tue, 06 Jun 2023 08:34:28 GMT", false)
+        .build();
+
+    BlobListResultSchema result = parse(stream);
+
+    assertThat(result.paths()).hasSize(1);
+    BlobListResultEntrySchema entry = result.paths().get(0);
+    assertThat(entry.name()).isEqualTo("file1.txt");
+    assertThat(entry.path().toUri().getPath()).isEqualTo("/file1.txt");
+    assertThat(entry.url()).isEqualTo(URL + "/file1.txt");
+    assertThat(entry.eTag()).isEqualTo("0x8DB6668EAB50E67");
+    assertThat(entry.contentLength()).isEqualTo(CONTENT_LENGTH_SAMPLE);
+    assertThat(entry.lastModified()).isEqualTo("Tue, 06 Jun 2023 08:35:00 
GMT");
+    assertThat(entry.creation()).isEqualTo("Tue, 06 Jun 2023 08:34:28 GMT");
+    assertThat(entry.isDirectory()).isFalse();
+  }
+
+  /**
+   * Verify that an ISO-8601 date-time from the Arrow response (as Photon
+   * serializes timestamps, without an explicit zone) is normalized to the same
+   * RFC 1123 GMT representation used by the XML ListBlobs path, and that it
+   * yields the expected epoch when parsed downstream.
+   */
+  @Test
+  public void testArrowIsoDateTimeNormalizedToRfc1123() throws Exception {
+    byte[] stream = new ArrowStreamBuilder()
+        .addRow("file1.txt", "etag", 1L,
+            "2026-07-06T10:31:19", "2026-07-06T10:30:00", false)
+        .build();
+
+    BlobListResultSchema result = parse(stream);
+
+    BlobListResultEntrySchema entry = result.paths().get(0);
+    assertThat(entry.lastModified())
+        .isEqualTo("Mon, 06 Jul 2026 10:31:19 GMT");
+    assertThat(entry.creation())
+        .isEqualTo("Mon, 06 Jul 2026 10:30:00 GMT");
+
+    long arrowEpoch = DateTimeUtils.parseLastModifiedTime(
+        entry.lastModified());
+    long xmlEpoch = DateTimeUtils.parseLastModifiedTime(
+        "Mon, 06 Jul 2026 10:31:19 GMT");
+    assertThat(arrowEpoch).isEqualTo(xmlEpoch);

Review Comment:
   Please add a sibling test here for an invalid calendar date. 
fastIsoUtcToRfc1123() only checks loose bounds (day <= 31, second <= 60) with 
no real calendar validation, so 2026-02-31T00:00:00 returns a confident but 
bogus RFC 1123 string, while the slow parseToInstant() path would reject it. 
Let's pin the intended behaviour — either reject on the fast path too, or add a 
comment saying invalid dates pass through by design.





> ABFS: Support Photon (Apache Arrow) based ListBlobs on Blob endpoint with XML 
> fallback
> --------------------------------------------------------------------------------------
>
>                 Key: HADOOP-19941
>                 URL: https://issues.apache.org/jira/browse/HADOOP-19941
>             Project: Hadoop Common
>          Issue Type: New Feature
>          Components: fs/azure
>            Reporter: Manish Bhatt
>            Assignee: Manish Bhatt
>            Priority: Major
>              Labels: pull-request-available
>
> Add config-gated support (fs.azure.photon.enabled, default off) for consuming 
> ListBlobs responses in the Apache Arrow (Photon) format on the ABFS Blob 
> endpoint. When enabled, ABFS advertises Arrow via an Accept header; the 
> response Content-Type selects an Arrow or the existing XML parser, both 
> producing identical FileStatus results, so downstream behaviour is unchanged. 
> Includes automatic, transparent fallback to XML, full parsing parity 
> (metadata, directory markers, implicit directories, copy properties, native 
> timestamp/length vectors), interrupt-safe Arrow parsing, and Photon telemetry 
> (request, response, fallback, parse-failure counts and listing latency). No 
> public API changes. Covered by unit and integration tests.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to