Example usage for org.apache.lucene.store ByteArrayDataInput readByte

List of usage examples for org.apache.lucene.store ByteArrayDataInput readByte

Introduction

In this page you can find the example usage for org.apache.lucene.store ByteArrayDataInput readByte.

Prototype

@Override
    public byte readByte() 

Source Link

Usage

From source file:org.codelibs.elasticsearch.common.util.ByteUtils.java

License:Apache License

/** Same as DataOutput#readVLong but can read negative values (read on 9 bytes). */
public static long readVLong(ByteArrayDataInput in) {
    // unwinded because of hotspot bugs, see Lucene's impl
    byte b = in.readByte();
    if (b >= 0) {
        return b;
    }//from  w w  w. j  a  v  a2s . c  o  m
    long i = b & 0x7FL;
    b = in.readByte();
    i |= (b & 0x7FL) << 7;
    if (b >= 0) {
        return i;
    }
    b = in.readByte();
    i |= (b & 0x7FL) << 14;
    if (b >= 0) {
        return i;
    }
    b = in.readByte();
    i |= (b & 0x7FL) << 21;
    if (b >= 0) {
        return i;
    }
    b = in.readByte();
    i |= (b & 0x7FL) << 28;
    if (b >= 0) {
        return i;
    }
    b = in.readByte();
    i |= (b & 0x7FL) << 35;
    if (b >= 0) {
        return i;
    }
    b = in.readByte();
    i |= (b & 0x7FL) << 42;
    if (b >= 0) {
        return i;
    }
    b = in.readByte();
    i |= (b & 0x7FL) << 49;
    if (b >= 0) {
        return i;
    }
    b = in.readByte();
    i |= (b & 0xFFL) << 56;
    return i;
}

From source file:org.elasticsearch.common.util.ByteUtils.java

License:Apache License

/** Same as DataOutput#readVLong but can read negative values (read on 9 bytes). */
public static long readVLong(ByteArrayDataInput in) {
    // unwinded because of hotspot bugs, see Lucene's impl
    byte b = in.readByte();
    if (b >= 0)
        return b;
    long i = b & 0x7FL;
    b = in.readByte();//from  w w  w  . j  av  a  2  s .co m
    i |= (b & 0x7FL) << 7;
    if (b >= 0)
        return i;
    b = in.readByte();
    i |= (b & 0x7FL) << 14;
    if (b >= 0)
        return i;
    b = in.readByte();
    i |= (b & 0x7FL) << 21;
    if (b >= 0)
        return i;
    b = in.readByte();
    i |= (b & 0x7FL) << 28;
    if (b >= 0)
        return i;
    b = in.readByte();
    i |= (b & 0x7FL) << 35;
    if (b >= 0)
        return i;
    b = in.readByte();
    i |= (b & 0x7FL) << 42;
    if (b >= 0)
        return i;
    b = in.readByte();
    i |= (b & 0x7FL) << 49;
    if (b >= 0)
        return i;
    b = in.readByte();
    i |= (b & 0xFFL) << 56;
    return i;
}