a bit of progress on PackedInputStream

This commit is contained in:
David Renshaw 2014-09-27 00:56:21 -04:00
parent e9614ab094
commit cea3c9740a

View file

@ -33,11 +33,53 @@ public final class PackedInputStream implements ReadableByteChannel {
//if (outBuf
if (inBuf.remaining() < 10) {
if (out >= outEnd) {
return len;
}
if (inBuf.remaining() == 0) {
// refresh buffer...
continue;
}
//# We have at least 1, but not 10, bytes available. We need to read
//# slowly, doing a bounds check on each byte.
// TODO
} else {
tag = inBuf.get();
for (int n = 0; n < 8; ++n) {
boolean isNonzero = (tag & (1 << n)) != 0;
// ...
}
}
// TODO
if (tag == 0) {
if (inBuf.remaining() == 0) {
throw new Error("Should always have non-empty buffer here.");
}
int runLength = inBuf.get() * 8;
if (runLength > outEnd - out) {
throw new Error("Packed input did not end cleanly on a segment boundary");
}
} else if (tag == (byte)0xff) {
int runLength = inBuf.get() * 8;
if (inBuf.remaining() >= runLength) {
} else {
}
}
if (out == outEnd) {
return len;