Example usage for org.apache.lucene.util BitUtil zigZagDecode

List of usage examples for org.apache.lucene.util BitUtil zigZagDecode

Introduction

In this page you can find the example usage for org.apache.lucene.util BitUtil zigZagDecode.

Prototype

public static long zigZagDecode(long l) 

Source Link

Document

Decode a long previously encoded with #zigZagEncode(long) .

Usage

From source file:org.codelibs.elasticsearch.common.io.stream.StreamInput.java

License:Apache License

public long readZLong() throws IOException {
    long accumulator = 0L;
    int i = 0;//from  w  w w  . j a  va 2  s.c  o m
    long currentByte;
    while (((currentByte = readByte()) & 0x80L) != 0) {
        accumulator |= (currentByte & 0x7F) << i;
        i += 7;
        if (i > 63) {
            throw new IOException("variable-length stream is too long");
        }
    }
    return BitUtil.zigZagDecode(accumulator | (currentByte << i));
}