Java Code Examples for org.elasticsearch.common.io.stream.StreamOutput#writeShort()

The following examples show how to use org.elasticsearch.common.io.stream.StreamOutput#writeShort() . 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 writeTo(StreamOutput out) throws IOException {
    out.writeVLong(timestamp);
    if (out.getVersion().onOrAfter(Version.V_2_2_0)) {
        out.writeBoolean(cpuPercent != null);
        if (cpuPercent != null) {
            out.writeShort(cpuPercent);
        }
    }
    out.writeDouble(loadAverage);
    if (mem == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        mem.writeTo(out);
    }
    if (swap == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        swap.writeTo(out);
    }
}
 
Example 2
Source File: ShortType.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeValueTo(StreamOutput out, Object v) throws IOException {
    out.writeBoolean(v == null);
    if (v != null) {
        out.writeShort(((Number) v).shortValue());
    }
}
 
Example 3
Source File: OsStats.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeShort(percent);
    if (loadAverage == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        out.writeDoubleArray(loadAverage);
    }
}
 
Example 4
Source File: ShortType.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void writeValueTo(StreamOutput out, Short v) throws IOException {
    out.writeBoolean(v == null);
    if (v != null) {
        out.writeShort(v);
    }
}
 
Example 5
Source File: ExtendedOsStats.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    if (out.getVersion().onOrAfter(Version.V_4_1_0)) {
        out.writeShort(percent);
    } else {
        out.writeShort((short) -1); // sys
        out.writeShort((short) -1); // user
        out.writeShort((short) -1); // idle
        out.writeShort((short) -1); // stolen
        out.writeShort(percent);
    }
}
 
Example 6
Source File: TransportAddressSerializers.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public static void addressToStream(StreamOutput out, TransportAddress address) throws IOException {
    out.writeShort(address.uniqueAddressTypeId());
    address.writeTo(out);
}
 
Example 7
Source File: Lucene.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public static void writeFieldDoc(StreamOutput out, FieldDoc fieldDoc) throws IOException {
    out.writeVInt(fieldDoc.fields.length);
    for (Object field : fieldDoc.fields) {
        if (field == null) {
            out.writeByte((byte) 0);
        } else {
            Class type = field.getClass();
            if (type == String.class) {
                out.writeByte((byte) 1);
                out.writeString((String) field);
            } else if (type == Integer.class) {
                out.writeByte((byte) 2);
                out.writeInt((Integer) field);
            } else if (type == Long.class) {
                out.writeByte((byte) 3);
                out.writeLong((Long) field);
            } else if (type == Float.class) {
                out.writeByte((byte) 4);
                out.writeFloat((Float) field);
            } else if (type == Double.class) {
                out.writeByte((byte) 5);
                out.writeDouble((Double) field);
            } else if (type == Byte.class) {
                out.writeByte((byte) 6);
                out.writeByte((Byte) field);
            } else if (type == Short.class) {
                out.writeByte((byte) 7);
                out.writeShort((Short) field);
            } else if (type == Boolean.class) {
                out.writeByte((byte) 8);
                out.writeBoolean((Boolean) field);
            } else if (type == BytesRef.class) {
                out.writeByte((byte) 9);
                out.writeBytesRef((BytesRef) field);
            } else {
                throw new IOException("Can't handle sort field value of type [" + type + "]");
            }
        }
    }
    out.writeVInt(fieldDoc.doc);
    out.writeFloat(fieldDoc.score);
}
 
Example 8
Source File: ProcessStats.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeShort(percent);
    out.writeLong(total);
}
 
Example 9
Source File: ProcessStats.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeShort(percent);
    out.writeLong(total);
}