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


Java StreamInput类代码示例

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


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

示例1: read

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
public static FieldStats read(StreamInput in) throws IOException {
    FieldStats stats;
    byte type = in.readByte();
    switch (type) {
        case 0:
            stats = new Long();
            break;
        case 1:
            stats = new Float();
            break;
        case 2:
            stats = new Double();
            break;
        case 3:
            stats = new Text();
            break;
        case 4:
            stats = new Date();
            break;
        default:
            throw new IllegalArgumentException("Illegal type [" + type + "]");
    }
    stats.type = type;
    stats.readFrom(in);
    return stats;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:27,代码来源:FieldStats.java

示例2: readFrom

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    int size = in.readVInt();
    locations = new IntArrayList(size);
    failures = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        locations.add(in.readVInt());
        if (in.readBoolean()) {
            failures.add(Failure.readFailure(in));
        } else {
            failures.add(null);
        }
    }
    if (in.readBoolean()) {
        failure = in.readThrowable();
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:ShardResponse.java

示例3: readFrom

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    int size = in.readVInt();
    ImmutableOpenMap.Builder<String, List<AliasMetaData>> aliasesBuilder = ImmutableOpenMap.builder();
    for (int i = 0; i < size; i++) {
        String key = in.readString();
        int valueSize = in.readVInt();
        List<AliasMetaData> value = new ArrayList<>(valueSize);
        for (int j = 0; j < valueSize; j++) {
            value.add(new AliasMetaData(in));
        }
        aliasesBuilder.put(key, Collections.unmodifiableList(value));
    }
    aliases = aliasesBuilder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:GetAliasesResponse.java

示例4: readFrom

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    minScore = in.readFloat();

    querySource = in.readBytesReference();

    int typesSize = in.readVInt();
    if (typesSize > 0) {
        types = new String[typesSize];
        for (int i = 0; i < typesSize; i++) {
            types[i] = in.readString();
        }
    }
    int aliasesSize = in.readVInt();
    if (aliasesSize > 0) {
        filteringAliases = new String[aliasesSize];
        for (int i = 0; i < aliasesSize; i++) {
            filteringAliases[i] = in.readString();
        }
    }
    nowInMillis = in.readVLong();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:ShardExistsRequest.java

示例5: testSerializationBwc

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
public void testSerializationBwc() throws IOException {
    final byte[] data = Base64.getDecoder().decode("ADwDATECe30=");
    final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
        Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
    try (StreamInput in = StreamInput.wrap(data)) {
        in.setVersion(version);
        PutPipelineRequest request = new PutPipelineRequest();
        request.readFrom(in);
        assertEquals(XContentType.JSON, request.getXContentType());
        assertEquals("{}", request.getSource().utf8ToString());

        try (BytesStreamOutput out = new BytesStreamOutput()) {
            out.setVersion(version);
            request.writeTo(out);
            assertArrayEquals(data, out.bytes().toBytesRef().bytes);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:PutPipelineRequestTests.java

示例6: RangeQueryBuilder

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
/**
 * Read from a stream.
 */
public RangeQueryBuilder(StreamInput in) throws IOException {
    super(in);
    fieldName = in.readString();
    from = in.readGenericValue();
    to = in.readGenericValue();
    includeLower = in.readBoolean();
    includeUpper = in.readBoolean();
    timeZone = in.readOptionalTimeZone();
    String formatString = in.readOptionalString();
    if (formatString != null) {
        format = Joda.forPattern(formatString);
    }
    if (in.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
        String relationString = in.readOptionalString();
        if (relationString != null) {
            relation = ShapeRelation.getRelationByName(relationString);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:RangeQueryBuilder.java

示例7: testStreamInputBulkReadWithOffset

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
public void testStreamInputBulkReadWithOffset() throws IOException {
    final int length = randomIntBetween(10, scaledRandomIntBetween(PAGE_SIZE * 2, PAGE_SIZE * 20));
    BytesReference pbr = newBytesReference(length);
    StreamInput si = pbr.streamInput();
    assertNotNull(si);

    // read a bunch of single bytes one by one
    int offset = randomIntBetween(1, length / 2);
    for (int i = 0; i < offset; i++) {
        assertEquals(si.available(), length - i);
        assertEquals(pbr.get(i), si.readByte());
    }

    // now do NOT reset the stream - keep the stream's offset!

    // buffer to compare remaining bytes against bulk read
    byte[] pbrBytesWithOffset = Arrays.copyOfRange(BytesReference.toBytes(pbr), offset, length);
    // randomized target buffer to ensure no stale slots
    byte[] targetBytes = new byte[pbrBytesWithOffset.length];
    random().nextBytes(targetBytes);

    // bulk-read all
    si.readFully(targetBytes);
    assertArrayEquals(pbrBytesWithOffset, targetBytes);
    assertEquals(si.available(), 0);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:AbstractBytesReferenceTestCase.java

示例8: testSerializationWithXContentBwc

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
public void testSerializationWithXContentBwc() throws IOException {
    final byte[] data = Base64.getDecoder().decode("AAAAAnt9AAA=");
    final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
        Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
    try (StreamInput in = StreamInput.wrap(data)) {
        in.setVersion(version);
        SimulatePipelineRequest request = new SimulatePipelineRequest();
        request.readFrom(in);
        assertEquals(XContentType.JSON, request.getXContentType());
        assertEquals("{}", request.getSource().utf8ToString());

        try (BytesStreamOutput out = new BytesStreamOutput()) {
            out.setVersion(version);
            request.writeTo(out);
            assertArrayEquals(data, out.bytes().toBytesRef().bytes);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:SimulatePipelineRequestTests.java

示例9: readOrder

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
/**
 * Reads an order from the given input (based on the id of the order).
 *
 * @see Streams#writeOrder(InternalOrder, org.elasticsearch.common.io.stream.StreamOutput)
 */
public static InternalOrder readOrder(StreamInput in) throws IOException {
    byte id = in.readByte();
    switch (id) {
        case 1: return (InternalOrder) Histogram.Order.KEY_ASC;
        case 2: return (InternalOrder) Histogram.Order.KEY_DESC;
        case 3: return (InternalOrder) Histogram.Order.COUNT_ASC;
        case 4: return (InternalOrder) Histogram.Order.COUNT_DESC;
        case 0:
            boolean asc = in.readBoolean();
            String key = in.readString();
            return new InternalOrder.Aggregation(key, asc);
        default:
            throw new RuntimeException("unknown histogram order");
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:21,代码来源:InternalOrder.java

示例10: readFrom

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    id = in.readLong();
    int termsSize = in.readVInt();
    if (termsSize == 0) {
        terms = EMPTY_TERMS;
    } else {
        terms = new Term[termsSize];
        for (int i = 0; i < terms.length; i++) {
            terms[i] = new Term(in.readString(), in.readBytesRef());
        }
    }
    this.termStatistics = readTermStats(in, terms);
    readFieldStats(in, fieldStatistics);


    maxDoc = in.readVInt();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:DfsSearchResult.java

示例11: readFrom

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    index = in.readString();
    type = in.readOptionalString();
    id = in.readString();
    version = in.readLong();
    exists = in.readBoolean();
    if (exists) {
        source = in.readBytesReference();
        if (source.length() == 0) {
            source = null;
        }
        int size = in.readVInt();
        if (size == 0) {
            fields = emptyMap();
        } else {
            fields = new HashMap<>(size);
            for (int i = 0; i < size; i++) {
                GetField field = readGetField(in);
                fields.put(field.getName(), field);
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:GetResult.java

示例12: readFrom

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    indices = in.readStringArray();
    types = in.readStringArray();
    indicesOptions = IndicesOptions.readIndicesOptions(in);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:ClusterInfoRequest.java

示例13: readFrom

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    if (in.readBoolean()) {
        internalShardId = ShardId.readShardId(in);
    }
    index = in.readOptionalString();
    // no need to pass threading over the network, they are always false when coming throw a thread pool
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:SingleShardRequest.java

示例14: readExplanation

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
public static Explanation readExplanation(StreamInput in) throws IOException {
    boolean match = in.readBoolean();
    String description = in.readString();
    final Explanation[] subExplanations = new Explanation[in.readVInt()];
    for (int i = 0; i < subExplanations.length; ++i) {
        subExplanations[i] = readExplanation(in);
    }
    if (match) {
        return Explanation.match(in.readFloat(), description, subExplanations);
    } else {
        return Explanation.noMatch(description, subExplanations);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:Lucene.java

示例15: validateRequest

import org.elasticsearch.common.io.stream.StreamInput; //导入依赖的package包/类
@Override
protected void validateRequest(StreamInput buffer, long requestId, String action)
        throws IOException {
    super.validateRequest(buffer, requestId, action);
    String error = threadPool.getThreadContext().getHeader("ERROR");
    if (error != null) {
        throw new ElasticsearchException(error);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:Netty4TransportIT.java


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