Github user t3rmin4t0r commented on a diff in the pull request: https://github.com/apache/orc/pull/186#discussion_r148716091 --- Diff: java/core/src/java/org/apache/orc/impl/BitFieldReader.java --- @@ -162,53 +92,32 @@ public void seek(PositionProvider index) throws IOException { consumed + " in " + input); } else if (consumed != 0) { readByte(); - bitsLeft = 8 - consumed; + currentIdx = (byte) consumed; } else { - bitsLeft = 0; + currentIdx = 8; } } public void skip(long items) throws IOException { - long totalBits = bitSize * items; - if (bitsLeft >= totalBits) { - bitsLeft -= totalBits; + final long totalBits = bitSize * items; + final int availableBits = 8 - (currentIdx + 1); + if (totalBits <= availableBits) { + currentIdx += totalBits; } else { - totalBits -= bitsLeft; - input.skip(totalBits / 8); - current = input.next(); - bitsLeft = (int) (8 - (totalBits % 8)); + final long bitsToSkip = (totalBits - availableBits); + input.skip(Math.min(1, bitsToSkip / 8)); --- End diff -- Looks a bit odd - the min(1) might be a problem if availableBits = 0 and items=3, it will end up skip(1) where it should really be doing skip(0).
---