mboehm7 commented on code in PR #2019:
URL: https://github.com/apache/systemds/pull/2019#discussion_r1567359431
##########
src/main/java/org/apache/sysds/runtime/util/DoubleBufferingOutputStream.java:
##########
@@ -43,42 +42,49 @@ public DoubleBufferingOutputStream(OutputStream out, int
num, int size) {
super(out);
if(size <= 0)
throw new IllegalArgumentException("Buffer size <= 0.");
- if( size%8 != 0 )
+ if(size % 8 != 0)
throw new IllegalArgumentException("Buffer size not a
multiple of 8.");
_buff = new byte[num][size];
_locks = new Future<?>[num];
- for(int i=0; i<num; i++)
+ for(int i = 0; i < num; i++) // fill the futures to avoid null
pointers.
_locks[i] = ConcurrentUtils.constantFuture(null);
}
@Override
public void write(int b) throws IOException {
- throw new IOException("Not supported");
+ throw new IOException("Not supported");
}
@Override
- public void write(byte[] b, int off, int len)
- throws IOException
- {
+ public void write(byte[] b, int off, int len) throws IOException {
Review Comment:
Thanks, but could you also elaborate what the intended improvement is. From
what I see you try to avoid a copy for tiny arrays, but it introduces brittle
code that is prone to race conditions if the originating data stream flushes at
certain points (danger that the array being currently written out to disk being
overwritten by subsequent serialization).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]