当前位置: 首页>>代码示例>>Java>>正文


Java StreamInput.readShort方法代码示例

本文整理汇总了Java中org.elasticsearch.common.io.stream.StreamInput.readShort方法的典型用法代码示例。如果您正苦于以下问题:Java StreamInput.readShort方法的具体用法?Java StreamInput.readShort怎么用?Java StreamInput.readShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.common.io.stream.StreamInput的用法示例。


在下文中一共展示了StreamInput.readShort方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TransportAddress

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
/**
 * Read from a stream and use the {@code hostString} when creating the InetAddress if the input comes from a version prior
 * {@link Version#V_5_0_3_UNRELEASED} as the hostString was not serialized
 */
public TransportAddress(StreamInput in, @Nullable String hostString) throws IOException {
    if (in.getVersion().before(Version.V_6_0_0_alpha1_UNRELEASED)) { // bwc layer for 5.x where we had more than one transport address
        final short i = in.readShort();
        if(i != 1) { // we fail hard to ensure nobody tries to use some custom transport address impl even if that is difficult to add
            throw new AssertionError("illegal transport ID from node of version: " + in.getVersion()  + " got: " + i + " expected: 1");
        }
    }
    final int len = in.readByte();
    final byte[] a = new byte[len]; // 4 bytes (IPv4) or 16 bytes (IPv6)
    in.readFully(a);
    final InetAddress inetAddress;
    if (in.getVersion().onOrAfter(Version.V_5_0_3_UNRELEASED)) {
        String host = in.readString(); // the host string was serialized so we can ignore the passed in version
        inetAddress = InetAddress.getByAddress(host, a);
    } else {
        // prior to this version, we did not serialize the host string so we used the passed in version
        inetAddress = InetAddress.getByAddress(hostString, a);
    }
    int port = in.readInt();
    this.address = new InetSocketAddress(inetAddress, port);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:TransportAddress.java

示例2: readSortValue

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
private static Comparable readSortValue(StreamInput in) throws IOException {
    byte type = in.readByte();
    if (type == 0) {
        return null;
    } else if (type == 1) {
        return in.readString();
    } else if (type == 2) {
        return in.readInt();
    } else if (type == 3) {
        return in.readLong();
    } else if (type == 4) {
        return in.readFloat();
    } else if (type == 5) {
        return in.readDouble();
    } else if (type == 6) {
        return in.readByte();
    } else if (type == 7) {
        return in.readShort();
    } else if (type == 8) {
        return in.readBoolean();
    } else if (type == 9) {
        return in.readBytesRef();
    } else {
        throw new IOException("Can't match type [" + type + "]");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:Lucene.java

示例3: readFrom

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:OsStats.java

示例4: SearchSortValues

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
public SearchSortValues(StreamInput in) throws IOException {
    int size = in.readVInt();
    if (size > 0) {
        sortValues = new Object[size];
        for (int i = 0; i < sortValues.length; i++) {
            byte type = in.readByte();
            if (type == 0) {
                sortValues[i] = null;
            } else if (type == 1) {
                sortValues[i] = in.readString();
            } else if (type == 2) {
                sortValues[i] = in.readInt();
            } else if (type == 3) {
                sortValues[i] = in.readLong();
            } else if (type == 4) {
                sortValues[i] = in.readFloat();
            } else if (type == 5) {
                sortValues[i] = in.readDouble();
            } else if (type == 6) {
                sortValues[i] = in.readByte();
            } else if (type == 7) {
                sortValues[i] = in.readShort();
            } else if (type == 8) {
                sortValues[i] = in.readBoolean();
            } else {
                throw new IOException("Can't match type [" + type + "]");
            }
        }
    } else {
        sortValues = new Object[0];
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:SearchSortValues.java

示例5: readFieldDoc

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
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);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:31,代码来源:Lucene.java

示例6: Cpu

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
public Cpu(StreamInput in) throws IOException {
    this.percent = in.readShort();
    if (in.readBoolean()) {
        this.loadAverage = in.readDoubleArray();
    } else {
        this.loadAverage = null;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:OsStats.java

示例7: readFrom

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
@Override
public void readFrom(final StreamInput in) throws IOException {
    super.readFrom(in);
    final short ct = in.readShort();
    request = RequestUtils.newRequest(ct);
    request.readFrom(in);
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:8,代码来源:WriteRequest.java

示例8: addressFromStream

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
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);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:TransportAddressSerializers.java

示例9: Cpu

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
public Cpu(StreamInput in) throws IOException {
    percent = in.readShort();
    total = in.readLong();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:ProcessStats.java

示例10: processRequests

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
private void processRequests(final StreamInput streamInput) {
    heartbeat = System.currentTimeMillis();
    if (terminated) {
        IOUtils.closeQuietly(streamInput);
        logger.warn("[Sender][" + index + "] Terminate DocIndexer.");
        return;
    }
    requestPosition++;
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("RequestSender(" + index + ") is processing requests.");
        }
        if (streamInput.available() > 0) {
            final short classType = streamInput.readShort();
            switch (classType) {
            case RequestUtils.TYPE_DELETE:
                processDeleteRequest(streamInput);
                break;
            case RequestUtils.TYPE_DELETE_BY_QUERY:
                processDeleteByQueryRequest(streamInput);
                break;
            case RequestUtils.TYPE_INDEX:
                processIndexRequest(streamInput);
                break;
            case RequestUtils.TYPE_UPDATE:
                processUpdateRequest(streamInput);
                break;
            case RequestUtils.TYPE_UPDATE_BY_QUERY:
                processUpdateByQueryRequest(streamInput);
                break;
            case RequestUtils.TYPE_BULK:
                processBulkRequest(streamInput);
                break;
            default:
                throw new ElasticsearchException("Unknown request type: " + classType);
            }
        } else {
            IOUtils.closeQuietly(streamInput);
            logger.info("[Sender][{}] Indexed:  {}", index, path.toAbsolutePath());

            processNext(getNextValue(filePosition));
        }
    } catch (final Exception e) {
        IOUtils.closeQuietly(streamInput);
        retryWithError("Failed to access streamInput.", e);
        // retry
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:49,代码来源:RequestSender.java

示例11: readValueFrom

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
@Override
public Short readValueFrom(StreamInput in) throws IOException {
    return in.readBoolean() ? null : in.readShort();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:ShortType.java

示例12: readFrom

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    percent = in.readShort();
    total = in.readLong();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:6,代码来源:ProcessStats.java


注:本文中的org.elasticsearch.common.io.stream.StreamInput.readShort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。