File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed
src/main/java/org/janelia/saalfeldlab/n5 Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,5 @@ static <T> void writeBlock(
5757
5858 final DataBlockCodec <T > codec = datasetAttributes .getDataBlockCodec ();
5959 codec .encode (dataBlock ).writeTo (out );
60- out .flush ();
6160 }
6261}
Original file line number Diff line number Diff line change 2626package org .janelia .saalfeldlab .n5 ;
2727
2828import java .io .IOException ;
29+ import java .io .OutputStream ;
2930import java .io .UncheckedIOException ;
3031import java .util .Arrays ;
3132import java .util .List ;
@@ -217,8 +218,11 @@ default <T> void writeBlock(
217218 final DataBlock <T > dataBlock ) throws N5Exception {
218219
219220 final String blockPath = absoluteDataBlockPath (N5URI .normalizeGroupPath (path ), dataBlock .getGridPosition ());
220- try (final LockedChannel lock = getKeyValueAccess ().lockForWriting (blockPath )) {
221- DefaultBlockWriter .writeBlock (lock .newOutputStream (), datasetAttributes , dataBlock );
221+ try (
222+ final LockedChannel lock = getKeyValueAccess ().lockForWriting (blockPath );
223+ final OutputStream out = lock .newOutputStream ()
224+ ) {
225+ DefaultBlockWriter .writeBlock (out , datasetAttributes , dataBlock );
222226 } catch (final IOException | UncheckedIOException e ) {
223227 throw new N5IOException (
224228 "Failed to write block " + Arrays .toString (dataBlock .getGridPosition ()) + " into dataset " + path ,
Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ public ReadData encode(final DataBlock<T> dataBlock) throws IOException {
6666 return ReadData .from (out -> {
6767 new BlockHeader (dataBlock .getSize (), dataBlock .getNumElements ()).writeTo (out );
6868 compression .encode (dataCodec .serialize (dataBlock .getData ())).writeTo (out );
69- out .flush ();
7069 });
7170 }
7271
@@ -104,7 +103,6 @@ public ReadData encode(final DataBlock<String[]> dataBlock) throws IOException {
104103 final byte [] serializedData = flattenedArray .getBytes (ENCODING );
105104 new BlockHeader (dataBlock .getSize (), serializedData .length ).writeTo (out );
106105 compression .encode (ReadData .from (serializedData )).writeTo (out );
107- out .flush ();
108106 });
109107 }
110108
@@ -137,7 +135,6 @@ public ReadData encode(final DataBlock<byte[]> dataBlock) throws IOException {
137135 return ReadData .from (out -> {
138136 new BlockHeader (null , dataBlock .getNumElements ()).writeTo (out );
139137 compression .encode (ReadData .from (dataBlock .getData ())).writeTo (out );
140- out .flush ();
141138 });
142139 }
143140
You can’t perform that action at this time.
0 commit comments