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


Java DataBlockEncoding.equals方法代码示例

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


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

示例1: getCachedBlock

import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding; //导入方法依赖的package包/类
/**
* Retrieve block from cache. Validates the retrieved block's type vs {@code expectedBlockType}
* and its encoding vs. {@code expectedDataBlockEncoding}. Unpacks the block as necessary.
*/
private HFileBlock getCachedBlock(BlockCacheKey cacheKey, boolean cacheBlock, boolean useLock,
    boolean isCompaction, boolean updateCacheMetrics, BlockType expectedBlockType,
    DataBlockEncoding expectedDataBlockEncoding) throws IOException {
  // Check cache for block. If found return.
  if (cacheConf.isBlockCacheEnabled()) {
    BlockCache cache = cacheConf.getBlockCache();
    HFileBlock cachedBlock = (HFileBlock) cache.getBlock(cacheKey, cacheBlock, useLock,
      updateCacheMetrics);
    if (cachedBlock != null) {
      if (cacheConf.shouldCacheCompressed(cachedBlock.getBlockType().getCategory())) {
        cachedBlock = cachedBlock.unpack(hfileContext, fsBlockReader);
      }
      validateBlockType(cachedBlock, expectedBlockType);

      if (expectedDataBlockEncoding == null) {
        return cachedBlock;
      }
      DataBlockEncoding actualDataBlockEncoding =
              cachedBlock.getDataBlockEncoding();
      // Block types other than data blocks always have
      // DataBlockEncoding.NONE. To avoid false negative cache misses, only
      // perform this check if cached block is a data block.
      if (cachedBlock.getBlockType().isData() &&
              !actualDataBlockEncoding.equals(expectedDataBlockEncoding)) {
        // This mismatch may happen if a ScannerV2, which is used for say a
        // compaction, tries to read an encoded block from the block cache.
        // The reverse might happen when an EncodedScannerV2 tries to read
        // un-encoded blocks which were cached earlier.
        //
        // Because returning a data block with an implicit BlockType mismatch
        // will cause the requesting scanner to throw a disk read should be
        // forced here. This will potentially cause a significant number of
        // cache misses, so update so we should keep track of this as it might
        // justify the work on a CompoundScannerV2.
        if (!expectedDataBlockEncoding.equals(DataBlockEncoding.NONE) &&
                !actualDataBlockEncoding.equals(DataBlockEncoding.NONE)) {
          // If the block is encoded but the encoding does not match the
          // expected encoding it is likely the encoding was changed but the
          // block was not yet evicted. Evictions on file close happen async
          // so blocks with the old encoding still linger in cache for some
          // period of time. This event should be rare as it only happens on
          // schema definition change.
          LOG.info("Evicting cached block with key " + cacheKey +
                  " because of a data block encoding mismatch" +
                  "; expected: " + expectedDataBlockEncoding +
                  ", actual: " + actualDataBlockEncoding);
          cache.evictBlock(cacheKey);
        }
        return null;
      }
      return cachedBlock;
    }
  }
  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:60,代码来源:HFileReaderV2.java


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