public static int readZigZagVarInt(ByteBuffer in) {
        int raw = readUnsignedVarInt(in);
        int temp = (((raw << 31) >> 31) ^ raw) >> 1;
        return temp ^ (raw & (1 << 31));
    }
uses a trick mentioned in https://developers.google.com/protocol-buffers/docs/encoding to read zigZag encoded data
indexr-vlt-segment/src/main/java/io/indexr/vlt/codec/VarInteger.java