Skip to content
Snippets Groups Projects
Commit 0350c37e authored by Kevin Risden's avatar Kevin Risden Committed by GitHub
Browse files

[s3] Use AWS IOUtils to read object data (#1021)

parent d69345fc
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.net.*;
import com.amazonaws.util.IOUtils;
import com.yahoo.ycsb.ByteArrayByteIterator;
import com.yahoo.ycsb.ByteIterator;
import com.yahoo.ycsb.DB;
......@@ -427,14 +428,7 @@ public class S3Client extends DB {
Map.Entry<S3Object, ObjectMetadata> objectAndMetadata = getS3ObjectAndMetadata(bucket, key, ssecLocal);
InputStream objectData = objectAndMetadata.getKey().getObjectContent(); //consuming the stream
// writing the stream to bytes and to results
int sizeOfFile = (int)objectAndMetadata.getValue().getContentLength();
byte[] inputStreamToByte = new byte[sizeOfFile];
int len;
int offset = 0;
while ((len = objectData.read(inputStreamToByte, offset, sizeOfFile - offset)) > 0) {
offset += len;
}
result.put(key, new ByteArrayByteIterator(inputStreamToByte));
result.put(key, new ByteArrayByteIterator(IOUtils.toByteArray(objectData)));
objectData.close();
objectAndMetadata.getKey().close();
} catch (Exception e){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment