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


Java BytesStreamOutput.close方法代码示例

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


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

示例1: writeHeader

import org.elasticsearch.common.io.stream.BytesStreamOutput; //导入方法依赖的package包/类
private BytesReference writeHeader(int numFieldsWritten, boolean getTermStatistics, boolean getFieldStatistics, boolean scores) throws IOException {
    // now, write the information about offset of the terms in the
    // termVectors field
    BytesStreamOutput header = new BytesStreamOutput();
    header.writeString(HEADER);
    header.writeInt(CURRENT_VERSION);
    header.writeBoolean(getTermStatistics);
    header.writeBoolean(getFieldStatistics);
    header.writeBoolean(scores);
    header.writeVInt(numFieldsWritten);
    for (int i = 0; i < fields.size(); i++) {
        header.writeString(fields.get(i));
        header.writeVLong(fieldOffset.get(i).longValue());
    }
    header.close();
    return header.bytes();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:TermVectorsWriter.java

示例2: testSerialization

import org.elasticsearch.common.io.stream.BytesStreamOutput; //导入方法依赖的package包/类
public void testSerialization() throws Exception {
    UnassignedInfo.Reason reason = RandomPicks.randomFrom(random(), UnassignedInfo.Reason.values());
    UnassignedInfo meta = reason == UnassignedInfo.Reason.ALLOCATION_FAILED ?
        new UnassignedInfo(reason, randomBoolean() ? randomAsciiOfLength(4) : null, null, randomIntBetween(1, 100), System.nanoTime(),
                           System.currentTimeMillis(), false, AllocationStatus.NO_ATTEMPT):
        new UnassignedInfo(reason, randomBoolean() ? randomAsciiOfLength(4) : null);
    BytesStreamOutput out = new BytesStreamOutput();
    meta.writeTo(out);
    out.close();

    UnassignedInfo read = new UnassignedInfo(out.bytes().streamInput());
    assertThat(read.getReason(), equalTo(meta.getReason()));
    assertThat(read.getUnassignedTimeInMillis(), equalTo(meta.getUnassignedTimeInMillis()));
    assertThat(read.getMessage(), equalTo(meta.getMessage()));
    assertThat(read.getDetails(), equalTo(meta.getDetails()));
    assertThat(read.getNumFailedAllocations(), equalTo(meta.getNumFailedAllocations()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:UnassignedInfoTests.java

示例3: writeOperation

import org.elasticsearch.common.io.stream.BytesStreamOutput; //导入方法依赖的package包/类
/**
 * 
 * @param operation
 * @return
 * @throws IOException 
 */
public Tuple<Future<DLSN>, Tuple<BytesReference, Long>> writeOperation(Translog.Operation operation, AtomicLong txid) throws IOException {
    BytesStreamOutput out = new BytesStreamOutput();
    try (ReleasableLock lock = writeLock.acquire()) {
        Future<DLSN> writeResult = null;
        out.writeByte(operation.opType().id());
        operation.writeTo(out);
        BytesReference bytes = out.bytes();
        LogRecord logRecord = new LogRecord(txid.incrementAndGet(), bytes.toBytes());
        writeResult = logWriter.write(logRecord);
        sizeInBytes += (20 + logRecord.getPayload().length);
        ++ numOperations;
        return new Tuple<Future<DLSN>, Tuple<BytesReference, Long>>(writeResult, new Tuple<BytesReference, Long>(bytes, txid.get()));
    } catch (TransactionIdOutOfOrderException e) {
        throw e;
    } finally {
        out.close();
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:DistributedTranslog.java

示例4: testWriteToOutputStream

import org.elasticsearch.common.io.stream.BytesStreamOutput; //导入方法依赖的package包/类
public void testWriteToOutputStream() throws IOException {
    int length = randomIntBetween(10, PAGE_SIZE * 4);
    BytesReference pbr = newBytesReference(length);
    BytesStreamOutput out = new BytesStreamOutput();
    pbr.writeTo(out);
    assertEquals(pbr.length(), out.size());
    assertArrayEquals(BytesReference.toBytes(pbr), BytesReference.toBytes(out.bytes()));
    out.close();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:AbstractBytesReferenceTestCase.java

示例5: testSliceWriteToOutputStream

import org.elasticsearch.common.io.stream.BytesStreamOutput; //导入方法依赖的package包/类
public void testSliceWriteToOutputStream() throws IOException {
    int length = randomIntBetween(10, PAGE_SIZE * randomIntBetween(2, 5));
    BytesReference pbr = newBytesReference(length);
    int sliceOffset = randomIntBetween(1, length / 2);
    int sliceLength = length - sliceOffset;
    BytesReference slice = pbr.slice(sliceOffset, sliceLength);
    BytesStreamOutput sliceOut = new BytesStreamOutput(sliceLength);
    slice.writeTo(sliceOut);
    assertEquals(slice.length(), sliceOut.size());
    assertArrayEquals(BytesReference.toBytes(slice), BytesReference.toBytes(sliceOut.bytes()));
    sliceOut.close();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:AbstractBytesReferenceTestCase.java

示例6: serializeDeserialize

import org.elasticsearch.common.io.stream.BytesStreamOutput; //导入方法依赖的package包/类
public T serializeDeserialize() throws IOException {
    BytesStreamOutput out = new BytesStreamOutput();
    source.writeTo(out);
    out.close();
    StreamInput in = out.bytes().streamInput();
    T obj = deserialize(in);
    lastRead = obj;
    return obj;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:RecoveryTargetTests.java


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