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


Java BlockCacheKey.hashCode方法代码示例

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


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

示例1: cacheBlockWithWait

import org.apache.hadoop.hbase.io.hfile.BlockCacheKey; //导入方法依赖的package包/类
/**
 * Cache the block to ramCache
 * @param cacheKey block's cache key
 * @param cachedItem block buffer
 * @param inMemory if block is in-memory
 * @param wait if true, blocking wait when queue is full
 */
public void cacheBlockWithWait(BlockCacheKey cacheKey, Cacheable cachedItem, boolean inMemory,
    boolean wait) {
  if (!cacheEnabled) {
    return;
  }

  if (backingMap.containsKey(cacheKey)) {
    return;
  }

  /*
   * Stuff the entry into the RAM cache so it can get drained to the persistent store
   */
  RAMQueueEntry re =
      new RAMQueueEntry(cacheKey, cachedItem, accessCount.incrementAndGet(), inMemory);
  if (ramCache.putIfAbsent(cacheKey, re) != null) {
    return;
  }
  int queueNum = (cacheKey.hashCode() & 0x7FFFFFFF) % writerQueues.size();
  BlockingQueue<RAMQueueEntry> bq = writerQueues.get(queueNum);
  boolean successfulAddition = false;
  if (wait) {
    try {
      successfulAddition = bq.offer(re, DEFAULT_CACHE_WAIT_TIME, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  } else {
    successfulAddition = bq.offer(re);
  }
  if (!successfulAddition) {
    ramCache.remove(cacheKey);
    cacheStats.failInsert();
  } else {
    this.blockNumber.incrementAndGet();
    this.heapSize.addAndGet(cachedItem.heapSize());
    blocksByHFile.put(cacheKey.getHfileName(), cacheKey);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:47,代码来源:BucketCache.java

示例2: cacheBlockWithWait

import org.apache.hadoop.hbase.io.hfile.BlockCacheKey; //导入方法依赖的package包/类
/**
 * Cache the block to ramCache
 * @param cacheKey block's cache key
 * @param cachedItem block buffer
 * @param inMemory if block is in-memory
 * @param wait if true, blocking wait when queue is full
 */
public void cacheBlockWithWait(BlockCacheKey cacheKey, Cacheable cachedItem,
    boolean inMemory, boolean wait) {
  if (!cacheEnabled)
    return;

  if (backingMap.containsKey(cacheKey) || ramCache.containsKey(cacheKey))
    return;

  /*
   * Stuff the entry into the RAM cache so it can get drained to the
   * persistent store
   */
  RAMQueueEntry re = new RAMQueueEntry(cacheKey, cachedItem,
      accessCount.incrementAndGet(), inMemory);
  ramCache.put(cacheKey, re);
  int queueNum = (cacheKey.hashCode() & 0x7FFFFFFF) % writerQueues.size();
  BlockingQueue<RAMQueueEntry> bq = writerQueues.get(queueNum);
  boolean successfulAddition = bq.offer(re);
  if (!successfulAddition && wait) {
    synchronized (cacheWaitSignals[queueNum]) {
      try {
        successfulAddition = bq.offer(re);
        if (!successfulAddition) cacheWaitSignals[queueNum].wait(DEFAULT_CACHE_WAIT_TIME);
      } catch (InterruptedException ie) {
        Thread.currentThread().interrupt();
      }
    }
    successfulAddition = bq.offer(re);
  }
  if (!successfulAddition) {
      ramCache.remove(cacheKey);
      failedBlockAdditions.incrementAndGet();
  } else {
    this.blockNumber.incrementAndGet();
    this.heapSize.addAndGet(cachedItem.heapSize());
    blocksByHFile.put(cacheKey.getHfileName(), cacheKey);
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:46,代码来源:BucketCache.java

示例3: cacheBlockWithWait

import org.apache.hadoop.hbase.io.hfile.BlockCacheKey; //导入方法依赖的package包/类
/**
 * Cache the block to ramCache
 * @param cacheKey block's cache key
 * @param cachedItem block buffer
 * @param inMemory if block is in-memory
 * @param wait if true, blocking wait when queue is full
 */
public void cacheBlockWithWait(BlockCacheKey cacheKey, Cacheable cachedItem,
    boolean inMemory, boolean wait) {
  if (!cacheEnabled)
    return;

  if (backingMap.containsKey(cacheKey) || ramCache.containsKey(cacheKey))
    return;

  /*
   * Stuff the entry into the RAM cache so it can get drained to the
   * persistent store
   */
  RAMQueueEntry re = new RAMQueueEntry(cacheKey, cachedItem,
      accessCount.incrementAndGet(), inMemory);
  ramCache.put(cacheKey, re);
  int queueNum = (cacheKey.hashCode() & 0x7FFFFFFF) % writerQueues.size();
  BlockingQueue<RAMQueueEntry> bq = writerQueues.get(queueNum);
  boolean successfulAddition = bq.offer(re);
  if (!successfulAddition && wait) {
    synchronized (cacheWaitSignals[queueNum]) {
      try {
        cacheWaitSignals[queueNum].wait(DEFAULT_CACHE_WAIT_TIME);
      } catch (InterruptedException ie) {
        Thread.currentThread().interrupt();
      }
    }
    successfulAddition = bq.offer(re);
  }
  if (!successfulAddition) {
      ramCache.remove(cacheKey);
      failedBlockAdditions.incrementAndGet();
  } else {
    this.blockNumber.incrementAndGet();
    this.heapSize.addAndGet(cachedItem.heapSize());
    blocksByHFile.put(cacheKey.getHfileName(), cacheKey);
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:45,代码来源:BucketCache.java

示例4: cacheBlockWithWait

import org.apache.hadoop.hbase.io.hfile.BlockCacheKey; //导入方法依赖的package包/类
/**
 * Cache the block to ramCache
 * @param cacheKey block's cache key
 * @param cachedItem block buffer
 * @param inMemory if block is in-memory
 * @param wait if true, blocking wait when queue is full
 */
public void cacheBlockWithWait(BlockCacheKey cacheKey, Cacheable cachedItem, boolean inMemory,
    boolean wait) {
  if (LOG.isTraceEnabled()) LOG.trace("Caching key=" + cacheKey + ", item=" + cachedItem);
  if (!cacheEnabled) {
    return;
  }

  if (backingMap.containsKey(cacheKey)) {
    Cacheable existingBlock = getBlock(cacheKey, false, false, false);
    try {
      if (BlockCacheUtil.compareCacheBlock(cachedItem, existingBlock) != 0) {
        throw new RuntimeException("Cached block contents differ, which should not have happened."
            + "cacheKey:" + cacheKey);
      }
      String msg = "Caching an already cached block: " + cacheKey;
      msg += ". This is harmless and can happen in rare cases (see HBASE-8547)";
      LOG.warn(msg);
    } finally {
      // return the block since we need to decrement the count
      returnBlock(cacheKey, existingBlock);
    }
    return;
  }

  /*
   * Stuff the entry into the RAM cache so it can get drained to the persistent store
   */
  RAMQueueEntry re =
      new RAMQueueEntry(cacheKey, cachedItem, accessCount.incrementAndGet(), inMemory);
  if (ramCache.putIfAbsent(cacheKey, re) != null) {
    return;
  }
  int queueNum = (cacheKey.hashCode() & 0x7FFFFFFF) % writerQueues.size();
  BlockingQueue<RAMQueueEntry> bq = writerQueues.get(queueNum);
  boolean successfulAddition = false;
  if (wait) {
    try {
      successfulAddition = bq.offer(re, DEFAULT_CACHE_WAIT_TIME, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  } else {
    successfulAddition = bq.offer(re);
  }
  if (!successfulAddition) {
    ramCache.remove(cacheKey);
    cacheStats.failInsert();
  } else {
    this.blockNumber.increment();
    this.heapSize.add(cachedItem.heapSize());
    blocksByHFile.add(cacheKey);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:61,代码来源:BucketCache.java


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