Java Code Examples for org.elasticsearch.common.io.stream.StreamInput#readShort()

The following examples show how to use org.elasticsearch.common.io.stream.StreamInput#readShort() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OsStats.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    timestamp = in.readVLong();
    if (in.getVersion().onOrAfter(Version.V_2_2_0)) {
        if (in.readBoolean()) {
            cpuPercent = in.readShort();
        } else {
            cpuPercent = null;
        }
    }
    loadAverage = in.readDouble();
    if (in.readBoolean()) {
        mem = Mem.readMem(in);
    }
    if (in.readBoolean()) {
        swap = Swap.readSwap(in);
    }
}
 
Example 2
Source File: TransportAddressSerializers.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public static TransportAddress addressFromStream(StreamInput input) throws IOException {
    short addressUniqueId = input.readShort();
    TransportAddress addressType = ADDRESS_REGISTRY.get(addressUniqueId);
    if (addressType == null) {
        throw new IOException("No transport address mapped to [" + addressUniqueId + "]");
    }
    return addressType.readFrom(input);
}
 
Example 3
Source File: Lucene.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public static FieldDoc readFieldDoc(StreamInput in) throws IOException {
    Comparable[] cFields = new Comparable[in.readVInt()];
    for (int j = 0; j < cFields.length; j++) {
        byte type = in.readByte();
        if (type == 0) {
            cFields[j] = null;
        } else if (type == 1) {
            cFields[j] = in.readString();
        } else if (type == 2) {
            cFields[j] = in.readInt();
        } else if (type == 3) {
            cFields[j] = in.readLong();
        } else if (type == 4) {
            cFields[j] = in.readFloat();
        } else if (type == 5) {
            cFields[j] = in.readDouble();
        } else if (type == 6) {
            cFields[j] = in.readByte();
        } else if (type == 7) {
            cFields[j] = in.readShort();
        } else if (type == 8) {
            cFields[j] = in.readBoolean();
        } else if (type == 9) {
            cFields[j] = in.readBytesRef();
        } else {
            throw new IOException("Can't match type [" + type + "]");
        }
    }
    return new FieldDoc(in.readVInt(), in.readFloat(), cFields);
}
 
Example 4
Source File: OsStats.java    From crate with Apache License 2.0 5 votes vote down vote up
public Cpu(StreamInput in) throws IOException {
    this.percent = in.readShort();
    if (in.readBoolean()) {
        this.loadAverage = in.readDoubleArray();
    } else {
        this.loadAverage = null;
    }
}
 
Example 5
Source File: ExtendedOsStats.java    From crate with Apache License 2.0 5 votes vote down vote up
public Cpu(StreamInput in) throws IOException {
    if (in.getVersion().onOrAfter(Version.V_4_1_0)) {
        percent = in.readShort();
    } else {
        in.readShort(); // sys
        in.readShort(); // user
        in.readShort(); // idle
        in.readShort(); // stolen
        percent = in.readShort();
    }
}
 
Example 6
Source File: ShortType.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public Short readValueFrom(StreamInput in) throws IOException {
    return in.readBoolean() ? null : in.readShort();
}
 
Example 7
Source File: ProcessStats.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    percent = in.readShort();
    total = in.readLong();
}
 
Example 8
Source File: ProcessStats.java    From crate with Apache License 2.0 4 votes vote down vote up
public Cpu(StreamInput in) throws IOException {
    percent = in.readShort();
    total = in.readLong();
}
 
Example 9
Source File: ShortType.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public Short readValueFrom(StreamInput in) throws IOException {
    return in.readBoolean() ? null : in.readShort();
}