presto-orc/src/main/java/io/prestosql/orc/stream/DecimalInputStream.java/DecimalInputStream/nextShortDecimal
class DecimalInputStream:    @SuppressWarnings("PointlessBitwiseExpression")
    public void nextShortDecimal(long[] result, int batchSize)
            throws IOException
    {
        verify(result.length >= batchSize);
        int count = 0;

        while (count < batchSize) {
            if (blockOffset == block.length()) {
                advance();
            }

            while (blockOffset <= block.length() - 12) { // we'll read 1 longs + 1 int
                long low;
                int high = 0;

                // low bits
                long current = block.getLong(blockOffset);
                int zeros = Long.numberOfTrailingZeros(~current & LONG_MASK);
                int end = (zeros + 1) / 8;
                blockOffset += end;

                low = (current & 0x7F_00_00_00_00_00_00_00L) >>> 7;
                low |= (current & 0x7F_00_00_00_00_00_00L) >>> 6;
                low |= (current & 0x7F_00_00_00_00_00L) >>> 5;
                low |= (current & 0x7F_00_00_00_00L) >>> 4;
                low |= (current & 0x7F_00_00_00) >>> 3;
                low |= (current & 0x7F_00_00) >>> 2;
                low |= (current & 0x7F_00) >>> 1;
                low |= (current & 0x7F) >>> 0;

                low = low & ((1L << (end * 7)) - 1);

                // high bits
                if (zeros == 64) {
                    int last = block.getInt(blockOffset);
                    zeros = Integer.numberOfTrailingZeros(~last & INT_MASK);
                    end = (zeros + 1) / 8;

                    blockOffset += end;

                    high = (last & 0x7F_00) >>> 1;
                    high |= (last & 0x7F) >>> 0;

                    high = high & ((1 << (end * 7)) - 1);

                    if (end >= 3 || high > 0xFF) { // only 63 - (55) = 8 bits allowed in high
                        throw new OrcCorruptionException(chunkLoader.getOrcDataSourceId(), "Decimal does not fit long (invalid table schema?)");
                    }
                }

                emitShortDecimal(result, count, low, high);
                count++;

                if (count == batchSize) {
                    return;
                }
            }

            // handle the tail of the current block
            count = decodeShortDecimalTail(result, count, batchSize);
        }
    }