Example usage for org.apache.hadoop.io WritableComparator readInt

List of usage examples for org.apache.hadoop.io WritableComparator readInt

Introduction

In this page you can find the example usage for org.apache.hadoop.io WritableComparator readInt.

Prototype

public static int readInt(byte[] bytes, int start) 

Source Link

Document

Parse an integer from a byte array.

Usage

From source file:com.asakusafw.runtime.value.ByteArrayUtil.java

License:Apache License

static int readInt(byte[] bytes, int offset) {
    return WritableComparator.readInt(bytes, offset);
}

From source file:com.netflix.aegisthus.io.writable.AegisthusKey.java

License:Apache License

/**
 * Zero copy readFields.//from  www.  ja  v a 2 s .  co  m
 * Note: As defensive copying is not done, caller should not mutate b1 while using instance.
 * */
public void readFields(byte[] bytes, int start, int length) {
    int pos = start; // start at the input position
    int keyLength = WritableComparator.readInt(bytes, pos);
    pos += 4; // move forward by the int that held the key length
    this.key = ByteBuffer.wrap(bytes, pos, keyLength);
    pos += keyLength; // move forward by the key length

    if (bytes[pos] == 0) {
        pos += 1; // move forward by a boolean
        this.name = null;
    } else {
        pos += 1; // move forward by a boolean
        int nameLength = WritableComparator.readInt(bytes, pos);
        pos += 4; // move forward by an int that held the name length
        this.name = ByteBuffer.wrap(bytes, pos, nameLength);
        pos += nameLength; // move forward by the name length
    }

    if (bytes[pos] == 0) {
        // pos += 1; // move forward by a boolean
        this.timestamp = null;
    } else {
        pos += 1; // move forward by a boolean
        this.timestamp = WritableComparator.readLong(bytes, pos);
        // pos += 8; // move forward by a long
    }
}