Skip to content

Commit

Permalink
Refactor outputstream usage.
Browse files Browse the repository at this point in the history
Signed-off-by: Rishikesh1159 <[email protected]>
  • Loading branch information
Rishikesh1159 committed Feb 22, 2024
1 parent d3ae7cb commit 7806639
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.opensearch.index.store.remote.filecache.FileCache;
import org.opensearch.index.store.remote.filecache.FileCachedIndexInput;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand All @@ -29,8 +30,6 @@
import java.util.concurrent.CompletionException;
import java.util.concurrent.atomic.AtomicBoolean;

import static java.nio.file.StandardOpenOption.APPEND;

/**
* This acts as entry point to fetch {@link BlobFetchRequest} and return actual {@link IndexInput}. Utilizes the BlobContainer interface to
* read snapshot files located within a repository. This basically adapts BlobContainer snapshots files into IndexInput
Expand Down Expand Up @@ -87,11 +86,8 @@ private static FileCachedIndexInput createIndexInput(FileCache fileCache, BlobCo
try {
if (Files.exists(request.getFilePath()) == false) {
try (
// Create a new empty file in the specified path
OutputStream fileOutputStream = Files.newOutputStream(request.getFilePath());

// All blob parts will be appended to file iteratively.
OutputStream localFileOutputStream = Files.newOutputStream(request.getFilePath(), APPEND)
OutputStream localFileOutputStream = new BufferedOutputStream(fileOutputStream)
) {
for (BlobFetchRequest.BlobPart blobPart : request.blobParts()) {
try (
Expand Down

0 comments on commit 7806639

Please sign in to comment.