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

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

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


##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/TestAbfsBlobClientPhotonHeaders.java:
##########
@@ -0,0 +1,214 @@
+/**
+ * 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.services;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.memory.RootAllocator;
+import org.apache.arrow.vector.VarCharVector;
+import org.apache.arrow.vector.VectorSchemaRoot;
+import org.apache.arrow.vector.ipc.ArrowStreamWriter;
+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.junit.jupiter.api.Test;
+
+import org.apache.hadoop.fs.azurebfs.AbfsConfiguration;
+import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsDriverException;
+import 
org.apache.hadoop.fs.azurebfs.contracts.exceptions.AzureBlobFileSystemException;
+
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.APPLICATION_APACHE_ARROW_STREAM;
+import static 
org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.APPLICATION_XML;
+import static 
org.apache.hadoop.fs.azurebfs.constants.HttpHeaderConfigurations.ACCEPT;
+import static 
org.apache.hadoop.fs.azurebfs.constants.HttpHeaderConfigurations.CONTENT_TYPE;
+import static 
org.apache.hadoop.fs.azurebfs.services.AbfsErrors.ERR_ARROW_LIST_PARSING;
+import static org.apache.hadoop.test.LambdaTestUtils.intercept;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.CALLS_REAL_METHODS;
+import static org.mockito.Mockito.withSettings;
+
+/**
+ * Unit tests for the Photon (Apache Arrow based ListBlob) request header
+ * behavior of {@link AbfsBlobClient#applyPhotonRequestHeadersIfEnabled(List)}.
+ */
+public class TestAbfsBlobClientPhotonHeaders {
+
+  /** Row count large enough to exhaust the tiny allocator limit. */
+  private static final int OVER_LIMIT_ROW_COUNT = 2000;
+
+  private AbfsBlobClient clientWithPhoton(final boolean photonEnabled) {
+    return clientWithPhoton(photonEnabled, false);
+  }
+
+  private AbfsBlobClient clientWithPhoton(final boolean photonEnabled,
+      final boolean namespaceEnabled) {
+    AbfsConfiguration configuration = mock(AbfsConfiguration.class);
+    doReturn(photonEnabled).when(configuration).isPhotonEnabled();
+    AbfsBlobClient client = mock(AbfsBlobClient.class,
+        withSettings().defaultAnswer(CALLS_REAL_METHODS));
+    doReturn(configuration).when(client).getAbfsConfiguration();
+    try {
+      doReturn(namespaceEnabled).when(client).getIsNamespaceEnabled();
+    } catch (AzureBlobFileSystemException e) {
+      throw new RuntimeException(e);
+    }
+    return client;
+  }
+
+  private List<AbfsHttpHeader> defaultHeaders() {
+    List<AbfsHttpHeader> headers = new ArrayList<>();
+    headers.add(new AbfsHttpHeader(ACCEPT, "application/json, 
application/xml"));
+    return headers;
+  }
+
+  private String acceptValue(final List<AbfsHttpHeader> headers) {
+    return headers.stream()
+        .filter(header -> ACCEPT.equals(header.getName()))

Review Comment:
   The helper matches with equals, but the production code removes with 
ACCEPT.equalsIgnoreCase(...). So if the default headers ever carry accept in 
different casing, the prod code removes it while this helper can't see it — and 
the test would still pass. Please use equalsIgnoreCase here, and add a case 
where defaultHeaders() uses "accept" lowercase to prove the removal is 
genuinely case-insensitive.





> 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