Skip to content

Commit

Permalink
Optimize copyBytes flow in RemoteIndexOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin Kale committed Apr 21, 2022
1 parent a6e05db commit 70b4cd9
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@

import org.apache.lucene.store.DataInput;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.opensearch.common.blobstore.BlobContainer;
import org.opensearch.common.lucene.store.InputStreamIndexInput;

import java.io.ByteArrayInputStream;
import java.io.IOException;

public class RemoteIndexOutput extends IndexOutput {
Expand Down Expand Up @@ -54,9 +55,8 @@ public long getChecksum() throws IOException {
@Override
public void copyBytes(DataInput input, long numBytes) throws IOException {
assert numBytes >= 0: "numBytes=" + numBytes;
byte[] copyBuffer = new byte[(int) numBytes];
input.readBytes(copyBuffer, 0, (int)numBytes);
blobContainer.writeBlob(getName(), new ByteArrayInputStream(copyBuffer), numBytes, false);
assert input instanceof IndexInput: "input should be instance of IndexInput";
blobContainer.writeBlob(getName(), new InputStreamIndexInput((IndexInput) input, numBytes), numBytes, false);
}

}

0 comments on commit 70b4cd9

Please sign in to comment.