write the rest of PackedOutputStream.write()

This commit is contained in:
David Renshaw 2014-09-26 14:10:14 -04:00
parent 5549d4dbf7
commit e9614ab094
2 changed files with 26 additions and 3 deletions

View file

@ -158,6 +158,22 @@ public final class PackedOutputStream implements WritableByteChannel {
//# to the output stream in one chunk and let it //# to the output stream in one chunk and let it
//# decide what to do. //# decide what to do.
if (out == slowBuffer) {
int oldLimit = out.limit();
out.limit(out.position());
out.rewind();
this.inner.write(out);
out.limit(oldLimit);
}
inBuf.position(runStart);
ByteBuffer slice = inBuf.slice();
slice.limit(count);
while(slice.hasRemaining()) {
this.inner.write(slice);
}
out = this.inner.getWriteBuffer();
} }
} }
} }

View file

@ -30,8 +30,15 @@ class SerializePackedSuite extends FunSuite {
expectPacksTo(Array(1,3,2,4,5,7,6,8, 8,6,7,4,5,2,3,1), expectPacksTo(Array(1,3,2,4,5,7,6,8, 8,6,7,4,5,2,3,1),
Array(0xff.toByte,1,3,2,4,5,7,6,8,1,8,6,7,4,5,2,3,1)); Array(0xff.toByte,1,3,2,4,5,7,6,8,1,8,6,7,4,5,2,3,1));
//expectPacksTo(Array(1,2,3,4,5,6,7,8, 1,2,3,4,5,6,7,8, 1,2,3,4,5,6,7,8, 0,2,4,0,9,0,5,1), expectPacksTo(Array(1,2,3,4,5,6,7,8, 1,2,3,4,5,6,7,8, 1,2,3,4,5,6,7,8, 1,2,3,4,5,6,7,8, 0,2,4,0,9,0,5,1),
// Array(0xff.toByte,1,2,3,4,5,6,7,8, 3, 1,2,3,4,5,6,7,8, 1,2,3,4,5,6,7,8, 1,2,3,4,5,6,7,8, Array(0xff.toByte,1,2,3,4,5,6,7,8, 3, 1,2,3,4,5,6,7,8, 1,2,3,4,5,6,7,8, 1,2,3,4,5,6,7,8,
// 0xd6.toByte,2,4,9,5,1)); 0xd6.toByte,2,4,9,5,1));
expectPacksTo(Array(1,2,3,4,5,6,7,8, 1,2,3,4,5,6,7,8, 6,2,4,3,9,0,5,1, 1,2,3,4,5,6,7,8, 0,2,4,0,9,0,5,1),
Array(0xff.toByte,1,2,3,4,5,6,7,8, 3, 1,2,3,4,5,6,7,8, 6,2,4,3,9,0,5,1, 1,2,3,4,5,6,7,8,
0xd6.toByte,2,4,9,5,1));
expectPacksTo(Array(8,0,100,6,0,1,1,2, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,1,0,2,0,3,1),
Array(0xed.toByte,8,100,6,1,1,2, 0,2, 0xd4.toByte,1,2,3,1));
} }
} }