com.sleepycat.je.incomp
Class INCompressor

java.lang.Object
  extended by com.sleepycat.je.utilint.DaemonThread
      extended by com.sleepycat.je.incomp.INCompressor
All Implemented Interfaces:
Runnable

public class INCompressor
extends DaemonThread

The IN Compressor. JE compression consist of removing delete entries from BINs, and pruning empty IN/BINs from the tree. Compression is carried out by either a daemon thread or lazily by operations (namely checkpointing and eviction) that are writing INS.


Field Summary
 
Fields inherited from class com.sleepycat.je.utilint.DaemonThread
name, nWakeupRequests, workQueue, workQueueLatch
 
Constructor Summary
INCompressor(EnvironmentImpl env, long waitTime, String name)
           
 
Method Summary
 void addBinKeyToQueue(BIN bin, Key deletedKey, boolean doWakeup)
          Adds the BIN and deleted Key to the queue if the BIN is not already in the queue, or adds the deleted key to an existing entry if one exists.
 void addBinRefToQueue(BINReference binRef, boolean doWakeup)
          Adds the BINReference to the queue if the BIN is not already in the queue, or adds the deleted keys to an existing entry if one exists.
 void addMultipleBinRefsToQueue(Collection binRefs, boolean doWakeup)
          Adds an entire collection of BINReferences to the queue at once.
 void addToQueue(Object o)
          The default daemon work queue is not used because we need a map, not a set.
 void clearEnv()
           
 void doCompress()
          The real work to doing a compress.
 boolean exists(long nodeId)
           
 int getBinRefQueueSize()
           
 void lazyCompress(IN in)
          Lazily compress a single BIN.
 void loadStats(StatsConfig config, EnvironmentStats stat)
          Return stats
protected  int nDeadlockRetries()
          Return the number of retries when a deadlock exception occurs.
 void onWakeup()
          onWakeup is synchronized to ensure that multiple invocations of the DaemonThread aren't made.
 BIN searchForBIN(DatabaseImpl db, BINReference binRef)
          Search the tree for the BIN or DBIN that corresponds to this BINReference.
 String toString()
           
 void verifyCursors()
           
 
Methods inherited from class com.sleepycat.je.utilint.DaemonThread
addToQueueAlreadyLatched, getNWakeupRequests, getQueueSize, getThread, isRunning, isShutdownRequested, requestShutdown, run, runOrPause, shutdown, wakeup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

INCompressor

public INCompressor(EnvironmentImpl env,
                    long waitTime,
                    String name)
             throws DatabaseException
Throws:
DatabaseException
Method Detail

toString

public String toString()
Overrides:
toString in class DaemonThread

clearEnv

public void clearEnv()

verifyCursors

public void verifyCursors()
                   throws DatabaseException
Throws:
DatabaseException

addToQueue

public void addToQueue(Object o)
                throws DatabaseException
The default daemon work queue is not used because we need a map, not a set.

Overrides:
addToQueue in class DaemonThread
Throws:
DatabaseException

getBinRefQueueSize

public int getBinRefQueueSize()
                       throws DatabaseException
Throws:
DatabaseException

addBinKeyToQueue

public void addBinKeyToQueue(BIN bin,
                             Key deletedKey,
                             boolean doWakeup)
                      throws DatabaseException
Adds the BIN and deleted Key to the queue if the BIN is not already in the queue, or adds the deleted key to an existing entry if one exists.

Throws:
DatabaseException

addBinRefToQueue

public void addBinRefToQueue(BINReference binRef,
                             boolean doWakeup)
                      throws DatabaseException
Adds the BINReference to the queue if the BIN is not already in the queue, or adds the deleted keys to an existing entry if one exists.

Throws:
DatabaseException

addMultipleBinRefsToQueue

public void addMultipleBinRefsToQueue(Collection binRefs,
                                      boolean doWakeup)
                               throws DatabaseException
Adds an entire collection of BINReferences to the queue at once. Use this to avoid latching for each add.

Throws:
DatabaseException

exists

public boolean exists(long nodeId)

loadStats

public void loadStats(StatsConfig config,
                      EnvironmentStats stat)
               throws DatabaseException
Return stats

Throws:
DatabaseException

nDeadlockRetries

protected int nDeadlockRetries()
                        throws DatabaseException
Return the number of retries when a deadlock exception occurs.

Overrides:
nDeadlockRetries in class DaemonThread
Throws:
DatabaseException

onWakeup

public void onWakeup()
              throws DatabaseException
Description copied from class: DaemonThread
onWakeup is synchronized to ensure that multiple invocations of the DaemonThread aren't made. isRunnable must be called from within onWakeup to avoid having the following sequence: Thread A: isRunnable() => true, Thread B: isRunnable() => true, Thread A: onWakeup() starts Thread B: waits for monitor on thread to call onWakeup() Thread A: onWakeup() completes rendering isRunnable() predicate false Thread B: onWakeup() starts, but isRunnable predicate is now false

Specified by:
onWakeup in class DaemonThread
Throws:
DatabaseException

doCompress

public void doCompress()
                throws DatabaseException
The real work to doing a compress. This may be called by the compressor thread or programatically.

Throws:
DatabaseException

searchForBIN

public BIN searchForBIN(DatabaseImpl db,
                        BINReference binRef)
                 throws DatabaseException
Search the tree for the BIN or DBIN that corresponds to this BINReference.

Parameters:
binRef - the BINReference that indicates the bin we want.
Returns:
the BIN or DBIN that corresponds to this BINReference. The node is latched upon return. Returns null if the BIN can't be found.
Throws:
DatabaseException

lazyCompress

public void lazyCompress(IN in)
                  throws DatabaseException
Lazily compress a single BIN. Do not do any pruning. The target IN should be latched when we enter, and it will be remain latched.

Throws:
DatabaseException


Copyright 2004-2005 Sleepycat, Inc. All Rights Reserved.