a bit of progress on PackedInputStream
This commit is contained in:
parent
e9614ab094
commit
cea3c9740a
1 changed files with 43 additions and 1 deletions
|
@ -33,11 +33,53 @@ public final class PackedInputStream implements ReadableByteChannel {
|
||||||
//if (outBuf
|
//if (outBuf
|
||||||
|
|
||||||
if (inBuf.remaining() < 10) {
|
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
|
// 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) {
|
if (out == outEnd) {
|
||||||
return len;
|
return len;
|
||||||
|
|
Loading…
Reference in a new issue