org.apache.hadoop.hive.ql.exec.persistence
Class MRU<T extends DCLLItem>

java.lang.Object
  extended by org.apache.hadoop.hive.ql.exec.persistence.MRU<T>

public class MRU<T extends DCLLItem>
extends Object

An MRU (Most Recently Used) cache implementation. This implementation maintains a doubly circular linked list and it can be used with an auxiliary data structure such as a HashMap to locate the item quickly.


Constructor Summary
MRU()
           
 
Method Summary
 void clear()
          Clear all elements in the MRU list.
 T head()
          Get the most recently used.
 void moveToHead(T v)
          Move an existing item to the head.
 T put(T item)
          Insert a value into the MRU.
 void remove(T v)
          Remove a item from the MRU list.
 T tail()
          Get the least recently used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MRU

public MRU()
Method Detail

put

public T put(T item)
Insert a value into the MRU. It will appear as the head.


remove

public void remove(T v)
Remove a item from the MRU list.

Parameters:
v - linked list item.

head

public T head()
Get the most recently used.

Returns:
the most recently used item.

tail

public T tail()
Get the least recently used.

Returns:
the least recently used item.

moveToHead

public void moveToHead(T v)
Move an existing item to the head.

Parameters:
v - the linked list item to be moved to the head.

clear

public void clear()
Clear all elements in the MRU list. This is not very efficient (linear) since it will call remove() to every item in the list.



Copyright © 2011 The Apache Software Foundation