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


Java StreamOutput.write方法代码示例

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


在下文中一共展示了StreamOutput.write方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.write(processors.size());
    for (ProcessorInfo info : processors) {
        info.writeTo(out);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:IngestInfo.java

示例3: writeTo

import org.elasticsearch.common.io.stream.StreamOutput; //导入方法依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeInt(existingDigests.length);
    for (byte[] digest: existingDigests){
        out.write(digest);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:BlobStartPrefixResponse.java

示例4: writeTo

import org.elasticsearch.common.io.stream.StreamOutput; //导入方法依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    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);
    // 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:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:InetSocketTransportAddress.java

示例5: writeIndicesOptions

import org.elasticsearch.common.io.stream.StreamOutput; //导入方法依赖的package包/类
public void writeIndicesOptions(StreamOutput out) throws IOException {
    out.write(id);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:IndicesOptions.java

示例6: doTest

import org.elasticsearch.common.io.stream.StreamOutput; //导入方法依赖的package包/类
private void doTest(byte bytes[]) throws IOException {
    ByteBuffer bb = ByteBuffer.wrap(bytes);
    StreamInput rawIn = new ByteBufferStreamInput(bb);
    Compressor c = compressor;

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    OutputStreamStreamOutput rawOs = new OutputStreamStreamOutput(bos);
    StreamOutput os = c.streamOutput(rawOs);

    Random r = random();
    int bufferSize = r.nextBoolean() ? 65535 : TestUtil.nextInt(random(), 1, 70000);
    int prepadding = r.nextInt(70000);
    int postpadding = r.nextInt(70000);
    byte buffer[] = new byte[prepadding + bufferSize + postpadding];
    r.nextBytes(buffer); // fill block completely with junk
    int len;
    while ((len = rawIn.read(buffer, prepadding, bufferSize)) != -1) {
        os.write(buffer, prepadding, len);
    }
    os.close();
    rawIn.close();

    // now we have compressed byte array

    byte compressed[] = bos.toByteArray();
    ByteBuffer bb2 = ByteBuffer.wrap(compressed);
    StreamInput compressedIn = new ByteBufferStreamInput(bb2);
    StreamInput in = c.streamInput(compressedIn);

    // randomize constants again
    bufferSize = r.nextBoolean() ? 65535 : TestUtil.nextInt(random(), 1, 70000);
    prepadding = r.nextInt(70000);
    postpadding = r.nextInt(70000);
    buffer = new byte[prepadding + bufferSize + postpadding];
    r.nextBytes(buffer); // fill block completely with junk

    ByteArrayOutputStream uncompressedOut = new ByteArrayOutputStream();
    while ((len = in.read(buffer, prepadding, bufferSize)) != -1) {
        uncompressedOut.write(buffer, prepadding, len);
    }
    uncompressedOut.close();

    assertArrayEquals(bytes, uncompressedOut.toByteArray());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:45,代码来源:DeflateCompressTests.java

示例7: writeTo

import org.elasticsearch.common.io.stream.StreamOutput; //导入方法依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.write(digest);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:6,代码来源:DeleteBlobRequest.java

示例8: writeTo

import org.elasticsearch.common.io.stream.StreamOutput; //导入方法依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.write(digest);
    out.writeVLong(currentPos);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:PutChunkRequest.java


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