Skip to content

Commit 2fa4a08

Browse files
authored
Merge pull request #326 from mcspring/copy_large
Copy large
2 parents 50a04bf + 98b1869 commit 2fa4a08

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

dev/cosbench-driver/src/com/intel/cosbench/driver/operator/Lister.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
1+
/**
2+
33
Copyright 2013 Intel Corporation, All Rights Reserved.
44
55
Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,7 +12,7 @@
1212
distributed under the License is distributed on an "AS IS" BASIS,
1313
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
See the License for the specific language governing permissions and
15-
limitations under the License.
15+
limitations under the License.
1616
*/
1717

1818
package com.intel.cosbench.driver.operator;
@@ -37,7 +37,7 @@ public class Lister extends AbstractOperator {
3737
public static final String OP_TYPE = "list";
3838

3939
private ObjectPicker objPicker = new ObjectPicker();
40-
40+
4141
private byte buffer[] = new byte[1024*1024];
4242

4343
public Lister() {
@@ -78,7 +78,7 @@ private Sample doList(OutputStream out, String conName, String objName,
7878
long start = System.nanoTime();
7979
long xferTime = 0L;
8080
try {
81-
doLogDebug(session.getLogger(), "worker "+ session.getIndex() + " List target " + conName + "/" + objName);
81+
doLogDebug(session.getLogger(), "worker "+ session.getIndex() + " List target " + conName + "/" + objName);
8282
in = session.getApi().getList(conName, objName, config);
8383
long xferStart = System.nanoTime();
8484
copyLarge(in, cout);
@@ -104,10 +104,7 @@ private Sample doList(OutputStream out, String conName, String objName,
104104
public OutputStream copyLarge(InputStream input, OutputStream output)
105105
throws IOException
106106
{
107-
for(int n = 0; -1 != (n = input.read(buffer));)
108-
{
109-
output.write(buffer, 0, n);
110-
}
107+
IOUtils.copyLarge(input, output);
111108

112109
return output;
113110
}

dev/cosbench-driver/src/com/intel/cosbench/driver/operator/Reader.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
1+
/**
2+
33
Copyright 2013 Intel Corporation, All Rights Reserved.
44
55
Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,8 +12,8 @@
1212
distributed under the License is distributed on an "AS IS" BASIS,
1313
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
See the License for the specific language governing permissions and
15-
limitations under the License.
16-
*/
15+
limitations under the License.
16+
*/
1717

1818
package com.intel.cosbench.driver.operator;
1919

@@ -32,18 +32,18 @@
3232

3333
/**
3434
* This class represents primitive READ operation.
35-
*
35+
*
3636
* @author ywang19, qzheng7
37-
*
37+
*
3838
*/
3939
class Reader extends AbstractOperator {
4040

4141
public static final String OP_TYPE = "read";
42-
42+
4343
private boolean hashCheck = false;
4444

4545
private ObjectPicker objPicker = new ObjectPicker();
46-
46+
4747
private byte buffer[] = new byte[1024*1024];
4848

4949
public Reader() {
@@ -101,7 +101,7 @@ private Sample doRead(OutputStream out, String conName, String objName,
101101
} catch (Exception e) {
102102
isUnauthorizedException(e, session);
103103
errorStatisticsHandle(e, session, conName + "/" + objName);
104-
104+
105105
return new Sample(new Date(), getId(), getOpType(), getSampleType(), getName(), false);
106106
} finally {
107107
IOUtils.closeQuietly(in);
@@ -117,14 +117,11 @@ private Sample doRead(OutputStream out, String conName, String objName,
117117
public OutputStream copyLarge(InputStream input, OutputStream output)
118118
throws IOException
119119
{
120-
for(int n = 0; -1 != (n = input.read(buffer));)
121-
{
122-
output.write(buffer, 0, n);
123-
}
120+
IOUtils.copyLarge(input, output);
124121

125122
return output;
126123
}
127-
124+
128125
private static boolean validateChecksum(String conName, String objName,
129126
Session session, InputStream in, OutputStream out)
130127
throws IOException {
@@ -138,7 +135,7 @@ private static boolean validateChecksum(String conName, String objName,
138135

139136
String storedHash = new String();
140137
String calculatedHash = new String();
141-
138+
142139
int br1 = in.read(buf1);
143140

144141
if (br1 <= hashLen) {

0 commit comments

Comments
 (0)