From a9f5c0453dd90cbba595b581c620473cf3ab9bbd Mon Sep 17 00:00:00 2001
From: Boris Osher <boris.osher@nexenta.com>
Date: Thu, 7 Sep 2017 06:02:24 -0700
Subject: [PATCH] [s3] S3Client could not estimate read perfomance correctly
 (#1010)

closes #994
---
 s3/src/main/java/com/yahoo/ycsb/db/S3Client.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/s3/src/main/java/com/yahoo/ycsb/db/S3Client.java b/s3/src/main/java/com/yahoo/ycsb/db/S3Client.java
index 71b7f7cd..8be4738a 100644
--- a/s3/src/main/java/com/yahoo/ycsb/db/S3Client.java
+++ b/s3/src/main/java/com/yahoo/ycsb/db/S3Client.java
@@ -429,7 +429,11 @@ public class S3Client extends DB {
       // writing the stream to bytes and to results
       int sizeOfFile = (int)objectAndMetadata.getValue().getContentLength();
       byte[] inputStreamToByte = new byte[sizeOfFile];
-      objectData.read(inputStreamToByte, 0, sizeOfFile);
+      int len;
+      int offset = 0;
+      while ((len = objectData.read(inputStreamToByte, offset, sizeOfFile - offset)) > 0) {
+        offset += len;
+      }
       result.put(key, new ByteArrayByteIterator(inputStreamToByte));
       objectData.close();
       objectAndMetadata.getKey().close();
-- 
GitLab