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


Java CountingOutputStream.close方法代码示例

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


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

示例1: write

import com.google.common.io.CountingOutputStream; //导入方法依赖的package包/类
private long write(String type, Copier copier) throws IOException {
    synchronized (lock) {
        if (closed) {
            return -1;
        }
        long startTick = ticker.read();
        out.startBlock();
        NonClosingCountingOutputStream countingStreamAfterCompression =
                new NonClosingCountingOutputStream(out);
        CountingOutputStream countingStreamBeforeCompression =
                new CountingOutputStream(newLZFOutputStream(countingStreamAfterCompression));
        copier.copyTo(countingStreamBeforeCompression);
        countingStreamBeforeCompression.close();
        long endTick = ticker.read();
        CappedDatabaseStats stats = statsByType.get(type);
        if (stats == null) {
            stats = new CappedDatabaseStats();
            statsByType.put(type, stats);
        }
        stats.record(countingStreamBeforeCompression.getCount(),
                countingStreamAfterCompression.getCount(), endTick - startTick);
        return out.endBlock();
    }
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:25,代码来源:CappedDatabase.java

示例2: write

import com.google.common.io.CountingOutputStream; //导入方法依赖的package包/类
/**
 * @param path root lsm tree index directory
 * @param iterator the iterator
 * @param keySerializer the key serializer
 * @param valueSerializer the value serializer
 * @param blocksize block size
 * @param keepDeletions true to keep deletion
 * @param <K> the key type
 * @param <V> the value type
 * @throws IOException  if an I/O error occurs
 */
public static <K, V> void write(
        Path path,
        Iterator<Generation.Entry<K,V>> iterator,
        Serializer<K> keySerializer,
        Serializer<V> valueSerializer,
        final int blocksize,
        boolean keepDeletions
) throws IOException {
    if (blocksize > 65536) throw new IllegalArgumentException("block size must be less than 65536");
    Files.createDirectories(path);
    final BufferedFileDataOutputStream fileOut = new BufferedFileDataOutputStream(path.resolve("index.bin"));
    final CountingOutputStream out = new CountingOutputStream(fileOut);
    //tempFile is deleted in writeIndex
    final Path tempPath = Files.createTempFile("tmp", ".bin");
    final WriteLevelResult result = writeLevel(out, tempPath, iterator, keySerializer, valueSerializer, blocksize, keepDeletions);
    final int tmpCount = result.tmpCount;
    final long size = result.size;

    final long valueLevelLength = out.getCount();
    final Header header = writeIndex(out, tempPath, tmpCount, keySerializer, blocksize);
    header.valueLevelLength = valueLevelLength;
    header.size = size;
    header.hasDeletions = keepDeletions;
    new HeaderSerializer().write(header, new LittleEndianDataOutputStream(out));
    fileOut.sync();
    out.close();
}
 
开发者ID:indeedeng,项目名称:lsmtree,代码行数:39,代码来源:ImmutableBTreeIndex.java


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