• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BlockWritable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addBloomFilter

import org.apache.hadoop.hbase.io.hfile.HFileBlock.BlockWritable; //导入依赖的package包/类
private void addBloomFilter(final BloomFilterWriter bfw,
    final BlockType blockType) {
  if (bfw.getKeyCount() <= 0)
    return;

  if (blockType != BlockType.GENERAL_BLOOM_META &&
      blockType != BlockType.DELETE_FAMILY_BLOOM_META) {
    throw new RuntimeException("Block Type: " + blockType.toString() +
        "is not supported");
  }
  additionalLoadOnOpenData.add(new BlockWritable() {
    @Override
    public BlockType getBlockType() {
      return blockType;
    }

    @Override
    public void writeToBlock(DataOutput out) throws IOException {
      bfw.getMetaWriter().write(out);
      Writable dataWriter = bfw.getDataWriter();
      if (dataWriter != null)
        dataWriter.write(out);
    }
  });
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:HFileWriterV2.java


示例2: addBloomFilter

import org.apache.hadoop.hbase.io.hfile.HFileBlock.BlockWritable; //导入依赖的package包/类
@Override
public void addBloomFilter(final BloomFilterWriter bfw) {
  if (bfw.getKeyCount() <= 0)
    return;

  additionalLoadOnOpenData.add(new BlockWritable() {
    @Override
    public BlockType getBlockType() {
      return BlockType.BLOOM_META;
    }

    @Override
    public void writeToBlock(DataOutput out) throws IOException {
      bfw.getMetaWriter().write(out);
      Writable dataWriter = bfw.getDataWriter();
      if (dataWriter != null)
        dataWriter.write(out);
    }
  });
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:21,代码来源:HFileWriterV2.java


示例3: close

import org.apache.hadoop.hbase.io.hfile.HFileBlock.BlockWritable; //导入依赖的package包/类
@Override
public void close() throws IOException {
  if (outputStream == null) {
    return;
  }
  // Save data block encoder metadata in the file info.
  blockEncoder.saveMetadata(this);
  // Write out the end of the data blocks, then write meta data blocks.
  // followed by fileinfo, data block index and meta block index.

  finishBlock();
  writeInlineBlocks(true);

  FixedFileTrailer trailer = new FixedFileTrailer(getMajorVersion(), getMinorVersion());

  // Write out the metadata blocks if any.
  if (!metaNames.isEmpty()) {
    for (int i = 0; i < metaNames.size(); ++i) {
      // store the beginning offset
      long offset = outputStream.getPos();
      // write the metadata content
      DataOutputStream dos = fsBlockWriter.startWriting(BlockType.META);
      metaData.get(i).write(dos);

      fsBlockWriter.writeHeaderAndData(outputStream);
      totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();

      // Add the new meta block to the meta index.
      metaBlockIndexWriter.addEntry(metaNames.get(i), offset,
          fsBlockWriter.getOnDiskSizeWithHeader());
    }
  }

  // Load-on-open section.

  // Data block index.
  //
  // In version 2, this section of the file starts with the root level data
  // block index. We call a function that writes intermediate-level blocks
  // first, then root level, and returns the offset of the root level block
  // index.

  long rootIndexOffset = dataBlockIndexWriter.writeIndexBlocks(outputStream);
  trailer.setLoadOnOpenOffset(rootIndexOffset);

  // Meta block index.
  metaBlockIndexWriter.writeSingleLevelIndex(fsBlockWriter.startWriting(
      BlockType.ROOT_INDEX), "meta");
  fsBlockWriter.writeHeaderAndData(outputStream);
  totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();

  if (this.hFileContext.isIncludesMvcc()) {
    appendFileInfo(MAX_MEMSTORE_TS_KEY, Bytes.toBytes(maxMemstoreTS));
    appendFileInfo(KEY_VALUE_VERSION, Bytes.toBytes(KEY_VALUE_VER_WITH_MEMSTORE));
  }

  // File info
  writeFileInfo(trailer, fsBlockWriter.startWriting(BlockType.FILE_INFO));
  fsBlockWriter.writeHeaderAndData(outputStream);
  totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();

  // Load-on-open data supplied by higher levels, e.g. Bloom filters.
  for (BlockWritable w : additionalLoadOnOpenData){
    fsBlockWriter.writeBlock(w, outputStream);
    totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();
  }

  // Now finish off the trailer.
  trailer.setNumDataIndexLevels(dataBlockIndexWriter.getNumLevels());
  trailer.setUncompressedDataIndexSize(
      dataBlockIndexWriter.getTotalUncompressedSize());
  trailer.setFirstDataBlockOffset(firstDataBlockOffset);
  trailer.setLastDataBlockOffset(lastDataBlockOffset);
  trailer.setComparatorClass(comparator.getClass());
  trailer.setDataIndexCount(dataBlockIndexWriter.getNumRootEntries());


  finishClose(trailer);

  fsBlockWriter.release();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:82,代码来源:HFileWriterV2.java


示例4: close

import org.apache.hadoop.hbase.io.hfile.HFileBlock.BlockWritable; //导入依赖的package包/类
@Override
public void close() throws IOException {
  if (outputStream == null) {
    return;
  }
  // Save data block encoder metadata in the file info.
  blockEncoder.saveMetadata(this);
  // Write out the end of the data blocks, then write meta data blocks.
  // followed by fileinfo, data block index and meta block index.

  finishBlock();
  writeInlineBlocks(true);

  FixedFileTrailer trailer = new FixedFileTrailer(2, minorVersion);

  // Write out the metadata blocks if any.
  if (!metaNames.isEmpty()) {
    for (int i = 0; i < metaNames.size(); ++i) {
      // store the beginning offset
      long offset = outputStream.getPos();
      // write the metadata content
      DataOutputStream dos = fsBlockWriter.startWriting(BlockType.META);
      metaData.get(i).write(dos);

      fsBlockWriter.writeHeaderAndData(outputStream);
      totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();

      // Add the new meta block to the meta index.
      metaBlockIndexWriter.addEntry(metaNames.get(i), offset,
          fsBlockWriter.getOnDiskSizeWithHeader());
    }
  }

  // Load-on-open section.

  // Data block index.
  //
  // In version 2, this section of the file starts with the root level data
  // block index. We call a function that writes intermediate-level blocks
  // first, then root level, and returns the offset of the root level block
  // index.

  long rootIndexOffset = dataBlockIndexWriter.writeIndexBlocks(outputStream);
  trailer.setLoadOnOpenOffset(rootIndexOffset);

  // Meta block index.
  metaBlockIndexWriter.writeSingleLevelIndex(fsBlockWriter.startWriting(
      BlockType.ROOT_INDEX), "meta");
  fsBlockWriter.writeHeaderAndData(outputStream);
  totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();

  if (this.includeMemstoreTS) {
    appendFileInfo(MAX_MEMSTORE_TS_KEY, Bytes.toBytes(maxMemstoreTS));
    appendFileInfo(KEY_VALUE_VERSION, Bytes.toBytes(KEY_VALUE_VER_WITH_MEMSTORE));
  }

  // File info
  writeFileInfo(trailer, fsBlockWriter.startWriting(BlockType.FILE_INFO));
  fsBlockWriter.writeHeaderAndData(outputStream);
  totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();

  // Load-on-open data supplied by higher levels, e.g. Bloom filters.
  for (BlockWritable w : additionalLoadOnOpenData){
    fsBlockWriter.writeBlock(w, outputStream);
    totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();
  }

  // Now finish off the trailer.
  trailer.setNumDataIndexLevels(dataBlockIndexWriter.getNumLevels());
  trailer.setUncompressedDataIndexSize(
      dataBlockIndexWriter.getTotalUncompressedSize());
  trailer.setFirstDataBlockOffset(firstDataBlockOffset);
  trailer.setLastDataBlockOffset(lastDataBlockOffset);
  trailer.setComparatorClass(comparator.getClass());
  trailer.setDataIndexCount(dataBlockIndexWriter.getNumRootEntries());


  finishClose(trailer);
  fsBlockWriter.releaseCompressor();
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:81,代码来源:HFileWriterV2.java


示例5: close

import org.apache.hadoop.hbase.io.hfile.HFileBlock.BlockWritable; //导入依赖的package包/类
@Override
public void close() throws IOException {
  if (outputStream == null) {
    return;
  }
  // Save data block encoder metadata in the file info.
  blockEncoder.saveMetadata(this);
  // Write out the end of the data blocks, then write meta data blocks.
  // followed by fileinfo, data block index and meta block index.

  finishBlock();
  writeInlineBlocks(true);

  FixedFileTrailer trailer = new FixedFileTrailer(2, minorVersion);

  // Write out the metadata blocks if any.
  if (!metaNames.isEmpty()) {
    for (int i = 0; i < metaNames.size(); ++i) {
      // store the beginning offset
      long offset = outputStream.getPos();
      // write the metadata content
      DataOutputStream dos = fsBlockWriter.startWriting(BlockType.META);
      metaData.get(i).write(dos);

      fsBlockWriter.writeHeaderAndData(outputStream);
      totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();

      // Add the new meta block to the meta index.
      metaBlockIndexWriter.addEntry(metaNames.get(i), offset,
          fsBlockWriter.getOnDiskSizeWithHeader());
    }
  }

  // Load-on-open section.

  // Data block index.
  //
  // In version 2, this section of the file starts with the root level data
  // block index. We call a function that writes intermediate-level blocks
  // first, then root level, and returns the offset of the root level block
  // index.

  long rootIndexOffset = dataBlockIndexWriter.writeIndexBlocks(outputStream);
  trailer.setLoadOnOpenOffset(rootIndexOffset);

  // Meta block index.
  metaBlockIndexWriter.writeSingleLevelIndex(fsBlockWriter.startWriting(
      BlockType.ROOT_INDEX), "meta");
  fsBlockWriter.writeHeaderAndData(outputStream);
  totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();

  if (this.includeMemstoreTS) {
    appendFileInfo(MAX_MEMSTORE_TS_KEY, Bytes.toBytes(maxMemstoreTS));
    appendFileInfo(KEY_VALUE_VERSION, Bytes.toBytes(KEY_VALUE_VER_WITH_MEMSTORE));
  }

  // File info
  writeFileInfo(trailer, fsBlockWriter.startWriting(BlockType.FILE_INFO));
  fsBlockWriter.writeHeaderAndData(outputStream);
  totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();

  // Load-on-open data supplied by higher levels, e.g. Bloom filters.
  for (BlockWritable w : additionalLoadOnOpenData){
    fsBlockWriter.writeBlock(w, outputStream);
    totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();
  }

  // Now finish off the trailer.
  trailer.setNumDataIndexLevels(dataBlockIndexWriter.getNumLevels());
  trailer.setUncompressedDataIndexSize(
      dataBlockIndexWriter.getTotalUncompressedSize());
  trailer.setFirstDataBlockOffset(firstDataBlockOffset);
  trailer.setLastDataBlockOffset(lastDataBlockOffset);
  trailer.setComparatorClass(comparator.getClass());
  trailer.setDataIndexCount(dataBlockIndexWriter.getNumRootEntries());


  finishClose(trailer);

  fsBlockWriter.releaseCompressor();
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:82,代码来源:HFileWriterV2.java


示例6: close

import org.apache.hadoop.hbase.io.hfile.HFileBlock.BlockWritable; //导入依赖的package包/类
@Override
public void close() throws IOException {
  if (outputStream == null) {
    return;
  }
  // Save data block encoder metadata in the file info.
  blockEncoder.saveMetadata(this);
  // Write out the end of the data blocks, then write meta data blocks.
  // followed by fileinfo, data block index and meta block index.

  finishBlock();
  writeInlineBlocks(true);

  FixedFileTrailer trailer = new FixedFileTrailer(getMajorVersion(), getMinorVersion());

  // Write out the metadata blocks if any.
  if (!metaNames.isEmpty()) {
    for (int i = 0; i < metaNames.size(); ++i) {
      // store the beginning offset
      long offset = outputStream.getPos();
      // write the metadata content
      DataOutputStream dos = blockWriter.startWriting(BlockType.META);
      metaData.get(i).write(dos);

      blockWriter.writeHeaderAndData(outputStream);
      totalUncompressedBytes += blockWriter.getUncompressedSizeWithHeader();

      // Add the new meta block to the meta index.
      metaBlockIndexWriter.addEntry(metaNames.get(i), offset,
          blockWriter.getOnDiskSizeWithHeader());
    }
  }

  // Load-on-open section.

  // Data block index.
  //
  // In version 2, this section of the file starts with the root level data
  // block index. We call a function that writes intermediate-level blocks
  // first, then root level, and returns the offset of the root level block
  // index.

  long rootIndexOffset = dataBlockIndexWriter.writeIndexBlocks(outputStream);
  trailer.setLoadOnOpenOffset(rootIndexOffset);

  // Meta block index.
  metaBlockIndexWriter.writeSingleLevelIndex(blockWriter.startWriting(
      BlockType.ROOT_INDEX), "meta");
  blockWriter.writeHeaderAndData(outputStream);
  totalUncompressedBytes += blockWriter.getUncompressedSizeWithHeader();

  if (this.hFileContext.isIncludesMvcc()) {
    appendFileInfo(MAX_MEMSTORE_TS_KEY, Bytes.toBytes(maxMemstoreTS));
    appendFileInfo(KEY_VALUE_VERSION, Bytes.toBytes(KEY_VALUE_VER_WITH_MEMSTORE));
  }

  // File info
  writeFileInfo(trailer, blockWriter.startWriting(BlockType.FILE_INFO));
  blockWriter.writeHeaderAndData(outputStream);
  totalUncompressedBytes += blockWriter.getUncompressedSizeWithHeader();

  // Load-on-open data supplied by higher levels, e.g. Bloom filters.
  for (BlockWritable w : additionalLoadOnOpenData){
    blockWriter.writeBlock(w, outputStream);
    totalUncompressedBytes += blockWriter.getUncompressedSizeWithHeader();
  }

  // Now finish off the trailer.
  trailer.setNumDataIndexLevels(dataBlockIndexWriter.getNumLevels());
  trailer.setUncompressedDataIndexSize(
      dataBlockIndexWriter.getTotalUncompressedSize());
  trailer.setFirstDataBlockOffset(firstDataBlockOffset);
  trailer.setLastDataBlockOffset(lastDataBlockOffset);
  trailer.setComparatorClass(comparator.getClass());
  trailer.setDataIndexCount(dataBlockIndexWriter.getNumRootEntries());


  finishClose(trailer);

  blockWriter.release();
}
 
开发者ID:apache,项目名称:hbase,代码行数:82,代码来源:HFileWriterImpl.java


示例7: close

import org.apache.hadoop.hbase.io.hfile.HFileBlock.BlockWritable; //导入依赖的package包/类
@Override
public void close() throws IOException {
  if (outputStream == null) {
    return;
  }
  // Write out the end of the data blocks, then write meta data blocks.
  // followed by fileinfo, data block index and meta block index.

  finishBlock();
  writeInlineBlocks(true);

  FixedFileTrailer trailer = new FixedFileTrailer(2);

  // Write out the metadata blocks if any.
  if (!metaNames.isEmpty()) {
    for (int i = 0; i < metaNames.size(); ++i) {
      // store the beginning offset
      long offset = outputStream.getPos();
      // write the metadata content
      DataOutputStream dos = fsBlockWriter.startWriting(BlockType.META,
          cacheConf.shouldCacheDataOnWrite());
      metaData.get(i).write(dos);

      fsBlockWriter.writeHeaderAndData(outputStream);
      totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();

      // Add the new meta block to the meta index.
      metaBlockIndexWriter.addEntry(metaNames.get(i), offset,
          fsBlockWriter.getOnDiskSizeWithHeader());
    }
  }

  // Load-on-open section.

  // Data block index.
  //
  // In version 2, this section of the file starts with the root level data
  // block index. We call a function that writes intermediate-level blocks
  // first, then root level, and returns the offset of the root level block
  // index.

  long rootIndexOffset = dataBlockIndexWriter.writeIndexBlocks(outputStream);
  trailer.setLoadOnOpenOffset(rootIndexOffset);

  // Meta block index.
  metaBlockIndexWriter.writeSingleLevelIndex(fsBlockWriter.startWriting(
      BlockType.ROOT_INDEX, false), "meta");
  fsBlockWriter.writeHeaderAndData(outputStream);
  totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();

  if (this.includeMemstoreTS) {
    appendFileInfo(MAX_MEMSTORE_TS_KEY, Bytes.toBytes(maxMemstoreTS));
    appendFileInfo(KEY_VALUE_VERSION, Bytes.toBytes(KEY_VALUE_VER_WITH_MEMSTORE));
  }

  // File info
  writeFileInfo(trailer, fsBlockWriter.startWriting(BlockType.FILE_INFO,
      false));
  fsBlockWriter.writeHeaderAndData(outputStream);
  totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();

  // Load-on-open data supplied by higher levels, e.g. Bloom filters.
  for (BlockWritable w : additionalLoadOnOpenData){
    fsBlockWriter.writeBlock(w, outputStream);
    totalUncompressedBytes += fsBlockWriter.getUncompressedSizeWithHeader();
  }

  // Now finish off the trailer.
  trailer.setNumDataIndexLevels(dataBlockIndexWriter.getNumLevels());
  trailer.setUncompressedDataIndexSize(
      dataBlockIndexWriter.getTotalUncompressedSize());
  trailer.setFirstDataBlockOffset(firstDataBlockOffset);
  trailer.setLastDataBlockOffset(lastDataBlockOffset);
  trailer.setComparatorClass(comparator.getClass());
  trailer.setDataIndexCount(dataBlockIndexWriter.getNumRootEntries());


  finishClose(trailer);

  fsBlockWriter.releaseCompressor();
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:82,代码来源:HFileWriterV2.java


示例8: writeBlock

import org.apache.hadoop.hbase.io.hfile.HFileBlock.BlockWritable; //导入依赖的package包/类
/**
 * Takes the given {@link BlockWritable} instance, creates a new block of
 * its appropriate type, writes the writable into this block, and flushes
 * the block into the output stream. The writer is instructed not to buffer
 * uncompressed bytes for cache-on-write.
 *
 * @param bw the block-writable object to write as a block
 * @param out the file system output stream
 * @throws IOException
 */
public void writeBlock(BlockWritable bw, FSDataOutputStream out)
    throws IOException {
  bw.writeToBlock(startWriting(bw.getBlockType()));
  writeHeaderAndData(out);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:16,代码来源:TestHFileBlockCompatibility.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ButtonBarBuilder类代码示例发布时间:2022-05-21
下一篇:
Java AccessibleStateSet类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap