当前位置: 首页>>代码示例>>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;未经允许,请勿转载。