當前位置: 首頁>>代碼示例>>Java>>正文


Java StreamOutput.writeShort方法代碼示例

本文整理匯總了Java中org.elasticsearch.common.io.stream.StreamOutput.writeShort方法的典型用法代碼示例。如果您正苦於以下問題:Java StreamOutput.writeShort方法的具體用法?Java StreamOutput.writeShort怎麽用?Java StreamOutput.writeShort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.common.io.stream.StreamOutput的用法示例。


在下文中一共展示了StreamOutput.writeShort方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeTo

import org.elasticsearch.common.io.stream.StreamOutput; //導入方法依賴的package包/類
@Override
public void writeTo(StreamOutput out) throws IOException {
    if (out.getVersion().before(Version.V_6_0_0_alpha1_UNRELEASED)) {
        out.writeShort((short)1); // this maps to InetSocketTransportAddress in 5.x
    }
    byte[] bytes = address.getAddress().getAddress();  // 4 bytes (IPv4) or 16 bytes (IPv6)
    out.writeByte((byte) bytes.length); // 1 byte
    out.write(bytes, 0, bytes.length);
    if (out.getVersion().onOrAfter(Version.V_5_0_3_UNRELEASED)) {
        out.writeString(address.getHostString());
    }
    // don't serialize scope ids over the network!!!!
    // these only make sense with respect to the local machine, and will only formulate
    // the address incorrectly remotely.
    out.writeInt(address.getPort());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,代碼來源:TransportAddress.java

示例2: writeTo

import org.elasticsearch.common.io.stream.StreamOutput; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:24,代碼來源:OsStats.java

示例3: writeTo

import org.elasticsearch.common.io.stream.StreamOutput; //導入方法依賴的package包/類
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeVInt(sortValues.length);
    for (Object sortValue : sortValues) {
        if (sortValue == null) {
            out.writeByte((byte) 0);
        } else {
            Class type = sortValue.getClass();
            if (type == String.class) {
                out.writeByte((byte) 1);
                out.writeString((String) sortValue);
            } else if (type == Integer.class) {
                out.writeByte((byte) 2);
                out.writeInt((Integer) sortValue);
            } else if (type == Long.class) {
                out.writeByte((byte) 3);
                out.writeLong((Long) sortValue);
            } else if (type == Float.class) {
                out.writeByte((byte) 4);
                out.writeFloat((Float) sortValue);
            } else if (type == Double.class) {
                out.writeByte((byte) 5);
                out.writeDouble((Double) sortValue);
            } else if (type == Byte.class) {
                out.writeByte((byte) 6);
                out.writeByte((Byte) sortValue);
            } else if (type == Short.class) {
                out.writeByte((byte) 7);
                out.writeShort((Short) sortValue);
            } else if (type == Boolean.class) {
                out.writeByte((byte) 8);
                out.writeBoolean((Boolean) sortValue);
            } else {
                throw new IOException("Can't handle sort field value of type [" + type + "]");
            }
        }
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:39,代碼來源:SearchSortValues.java

示例4: writeSortValue

import org.elasticsearch.common.io.stream.StreamOutput; //導入方法依賴的package包/類
private static void writeSortValue(StreamOutput out, Object field) throws IOException {
    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 + "]");
        }
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:38,代碼來源:Lucene.java

示例5: writeTo

import org.elasticsearch.common.io.stream.StreamOutput; //導入方法依賴的package包/類
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeShort(percent);
    if (loadAverage == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        out.writeDoubleArray(loadAverage);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:OsStats.java

示例6: writeValueTo

import org.elasticsearch.common.io.stream.StreamOutput; //導入方法依賴的package包/類
@Override
public void writeValueTo(StreamOutput out, Object v) throws IOException {
    out.writeBoolean(v == null);
    if (v != null) {
        out.writeShort(((Number) v).shortValue());
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:8,代碼來源:ShortType.java

示例7: writeTo

import org.elasticsearch.common.io.stream.StreamOutput; //導入方法依賴的package包/類
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeShort(percent);
    out.writeLong(total);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:6,代碼來源:ProcessStats.java

示例8: writeTo

import org.elasticsearch.common.io.stream.StreamOutput; //導入方法依賴的package包/類
@Override
public void writeTo(final StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeShort(classType);
    request.writeTo(out);
}
 
開發者ID:codelibs,項目名稱:elasticsearch-indexing-proxy,代碼行數:7,代碼來源:WriteRequest.java

示例9: addressToStream

import org.elasticsearch.common.io.stream.StreamOutput; //導入方法依賴的package包/類
public static void addressToStream(StreamOutput out, TransportAddress address) throws IOException {
    out.writeShort(address.uniqueAddressTypeId());
    address.writeTo(out);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:5,代碼來源:TransportAddressSerializers.java

示例10: writeFieldDoc

import org.elasticsearch.common.io.stream.StreamOutput; //導入方法依賴的package包/類
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);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:43,代碼來源:Lucene.java


注:本文中的org.elasticsearch.common.io.stream.StreamOutput.writeShort方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。