Skip to content
Snippets Groups Projects
Commit 5efe718f authored by brinn's avatar brinn
Browse files

fix: very slow operation of HDF5ContainerWriter due to inappropriate buffer...

fix: very slow operation of HDF5ContainerWriter due to inappropriate buffer size of IOUtils.copyLarge()

SVN: 22570
parent 5078a768
No related branches found
No related tags found
No related merge requests found
......@@ -20,8 +20,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.io.IOUtils;
import ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked;
import ch.systemsx.cisd.hdf5.HDF5GenericStorageFeatures;
import ch.systemsx.cisd.hdf5.IHDF5Writer;
......@@ -44,6 +42,8 @@ class HDF5ContainerWriter implements IHDF5ContainerWriter
final static int BUFFER_SIZE = 10 * MB;
private final byte[] buffer = new byte[BUFFER_SIZE];
private final IHDF5Writer writer;
private final HDF5GenericStorageFeatures genericStorageFeatures;
......@@ -60,6 +60,18 @@ class HDF5ContainerWriter implements IHDF5ContainerWriter
}
}
private long copy(InputStream input, OutputStream output) throws IOException
{
long count = 0;
int n = 0;
while (-1 != (n = input.read(buffer)))
{
output.write(buffer, 0, n);
count += n;
}
return count;
}
public void writeToHDF5Container(String objectPath, InputStream istream, long size)
throws IOExceptionUnchecked
{
......@@ -79,7 +91,7 @@ class HDF5ContainerWriter implements IHDF5ContainerWriter
IOException e = null;
try
{
IOUtils.copyLarge(istream, ostream);
copy(istream, ostream);
} catch (IOException ex)
{
e = ex;
......
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