hi!

     In hbase 0.90.2, HFile$Reader readBlock do this:
     synchronized (blockIndex.blockKeys[block]) {
        blockLoads++;
        // Check cache for block.  If found return.
        if (cache != null) {
          ByteBuffer cachedBuf = cache.getBlock(name + block, cacheBlock);
          if (cachedBuf != null) {
            // Return a distinct 'shallow copy' of the block,
            // so pos doesnt get messed by the scanner
            cacheHits++;
            return cachedBuf.duplicate();
          }
          // Carry on, please load.
        }

        // load from file

       // put to cache
    }

    Why check cache code snippets be wrote in synchronized? I think we
can also do the check cache for block code outside the synchronized,so
we can improve performance.

-- 
=============================
|     BlueDavy                                      |
|     http://www.bluedavy.com                |
=============================

Reply via email to