This is an automated email from the ASF dual-hosted git repository.

jsedding pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 251fde23e0 OAK-12040 - segment-azure: reduce HTTP requests for writes 
(#2665)
251fde23e0 is described below

commit 251fde23e03a4cc1d92e06a64ff6f52f619295f2
Author: Julian Sedding <[email protected]>
AuthorDate: Thu Dec 18 10:56:57 2025 +0100

    OAK-12040 - segment-azure: reduce HTTP requests for writes (#2665)
---
 .../oak/segment/azure/AzureSegmentArchiveWriter.java        | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git 
a/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentArchiveWriter.java
 
b/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentArchiveWriter.java
index d96dce3171..5daeb3586f 100644
--- 
a/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentArchiveWriter.java
+++ 
b/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentArchiveWriter.java
@@ -17,8 +17,10 @@
 package org.apache.jackrabbit.oak.segment.azure;
 
 import com.azure.core.util.BinaryData;
+import com.azure.core.util.Context;
 import com.azure.storage.blob.BlobContainerClient;
 import com.azure.storage.blob.models.BlobStorageException;
+import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions;
 import com.azure.storage.blob.specialized.BlockBlobClient;
 import org.apache.jackrabbit.oak.commons.Buffer;
 import org.apache.jackrabbit.oak.commons.time.Stopwatch;
@@ -29,9 +31,9 @@ import 
org.apache.jackrabbit.oak.segment.remote.WriteAccessController;
 import org.apache.jackrabbit.oak.segment.spi.monitor.FileStoreMonitor;
 import org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitor;
 
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
-import java.util.Arrays;
 import java.util.concurrent.TimeUnit;
 
 import static 
org.apache.jackrabbit.oak.segment.azure.AzureUtilities.readBufferFully;
@@ -77,8 +79,13 @@ public class AzureSegmentArchiveWriter extends 
AbstractRemoteSegmentArchiveWrite
         ioMonitor.beforeSegmentWrite(new File(blob.getBlobName()), msb, lsb, 
size);
         Stopwatch stopwatch = Stopwatch.createStarted();
         try {
-            blob.upload(BinaryData.fromBytes(Arrays.copyOfRange(data, offset, 
offset + size)), true);
-            blob.setMetadata(AzureBlobMetadata.toSegmentMetadata(indexEntry));
+            // Upload the binary data and set its metadata using a single HTTP 
call,
+            // overwriting an existing blob if necessary. Wrapping the byte 
array in a
+            // ByteArrayInputStream avoids creating a copy of the data range.
+            BinaryData binaryData = BinaryData.fromStream(new 
ByteArrayInputStream(data, offset, size), (long) size);
+            BlockBlobSimpleUploadOptions options = new 
BlockBlobSimpleUploadOptions(binaryData)
+                    
.setMetadata(AzureBlobMetadata.toSegmentMetadata(indexEntry));
+            blob.uploadWithResponse(options, null, Context.NONE);
         } catch (BlobStorageException e) {
             throw new IOException(e);
         }

Reply via email to