Skip to content
Snippets Groups Projects
Commit 34268a10 authored by Vojtech Moravec's avatar Vojtech Moravec
Browse files

First prototype of client decompression.

parent 0b59586b
No related branches found
No related tags found
No related merge requests found
......@@ -29,21 +29,22 @@
*/
package bdv.img.remote;
import azgracompress.compression.ImageDecompressor;
import bdv.img.cache.CacheArrayLoader;
import net.imglib2.img.basictypeaccess.volatiles.array.VolatileShortArray;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import azgracompress.compression.ImageDecompressor;
import bdv.img.cache.CacheArrayLoader;
import net.imglib2.img.basictypeaccess.volatiles.array.VolatileShortArray;
public class RemoteVolatileShortArrayLoader implements CacheArrayLoader<VolatileShortArray> {
private final RemoteImageLoader imgLoader;
private ImageDecompressor decompressor;
private boolean requestCompressedData = false;
private ImageDecompressor decompressor;
public RemoteVolatileShortArrayLoader(final RemoteImageLoader imgLoader) {
this.imgLoader = imgLoader;
......@@ -115,17 +116,10 @@ public class RemoteVolatileShortArrayLoader implements CacheArrayLoader<Volatile
connection.setRequestMethod("GET");
connection.connect();
final byte[] buf = new byte[connection.getContentLength()];
final InputStream urlStream = connection.getInputStream();
//noinspection StatementWithEmptyBody
for (int i = 0, l = urlStream.read(buf, 0, buf.length);
l > 0;
i += l, l = urlStream.read(buf, i, buf.length - i))
;
final int contentLength = connection.getContentLength();
data = decompressor.decompressStream(urlStream);
final InputStream urlStream = connection.getInputStream();
data = decompressor.decompressStream(urlStream, contentLength);
urlStream.close();
} catch (final Exception e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment