當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。