org.apache.hadoop.hive.ql.exec.persistence
Class HashMapWrapper<K,V>

java.lang.Object
  extended by org.apache.hadoop.hive.ql.exec.persistence.HashMapWrapper<K,V>
All Implemented Interfaces:
Serializable

public class HashMapWrapper<K,V>
extends Object
implements Serializable

Simple wrapper for persistent Hashmap implementing only the put/get/remove/clear interface. The main memory hash table acts as a cache and all put/get will operate on it first. If the size of the main memory hash table exceeds a certain threshold, new elements will go into the persistent hash table.

See Also:
Serialized Form

Field Summary
protected  SessionState.LogHelper console
           
protected  org.apache.commons.logging.Log LOG
           
static MemoryMXBean memoryMXBean
           
 
Constructor Summary
HashMapWrapper()
           
HashMapWrapper(int threshold)
           
HashMapWrapper(int threshold, float loadFactor, float memoryUsage)
          Constructor.
 
Method Summary
 void clear()
           
 void close()
          Close the persistent hash table and clean it up.
 long flushMemoryCacheToPersistent(File file)
          Flush the main memory hash table into the persistent cache file
 V get(K key)
           
 SessionState.LogHelper getConsole()
           
 long getCurrentMemory()
           
 File getDumpFile()
           
 int getKeySize()
           
 long getMaxMemory()
           
static MemoryMXBean getMemoryMXBean()
           
 HashMap<K,V> getMHash()
           
 NumberFormat getNum()
           
static int getTHRESHOLD()
           
 void initilizePersistentHash(String fileName)
           
 boolean isAbort(long numRows, SessionState.LogHelper console)
           
 Set<K> keySet()
           
 boolean put(K key, V value)
           
 void remove(K key)
           
 void setConsole(SessionState.LogHelper console)
           
 void setCurrentMemory(long currentMemory)
           
 void setDumpFile(File dumpFile)
           
 void setLOG(org.apache.commons.logging.Log log)
           
 void setMaxMemory(long maxMemory)
           
static void setMemoryMXBean(MemoryMXBean memoryMXBean)
           
 void setMHash(HashMap<K,V> hash)
           
 void setNum(NumberFormat num)
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected org.apache.commons.logging.Log LOG

console

protected transient SessionState.LogHelper console

memoryMXBean

public static MemoryMXBean memoryMXBean
Constructor Detail

HashMapWrapper

public HashMapWrapper(int threshold,
                      float loadFactor,
                      float memoryUsage)
Constructor.

Parameters:
threshold - User specified threshold to store new values into persistent storage.

HashMapWrapper

public HashMapWrapper(int threshold)

HashMapWrapper

public HashMapWrapper()
Method Detail

get

public V get(K key)

put

public boolean put(K key,
                   V value)
            throws HiveException
Throws:
HiveException

remove

public void remove(K key)

flushMemoryCacheToPersistent

public long flushMemoryCacheToPersistent(File file)
                                  throws IOException
Flush the main memory hash table into the persistent cache file

Returns:
persistent cache file
Throws:
IOException

initilizePersistentHash

public void initilizePersistentHash(String fileName)
                             throws IOException,
                                    ClassNotFoundException
Throws:
IOException
ClassNotFoundException

size

public int size()

keySet

public Set<K> keySet()

close

public void close()
           throws HiveException
Close the persistent hash table and clean it up.

Throws:
HiveException

clear

public void clear()
           throws HiveException
Throws:
HiveException

getKeySize

public int getKeySize()

isAbort

public boolean isAbort(long numRows,
                       SessionState.LogHelper console)

setLOG

public void setLOG(org.apache.commons.logging.Log log)

getMHash

public HashMap<K,V> getMHash()

setMHash

public void setMHash(HashMap<K,V> hash)

getConsole

public SessionState.LogHelper getConsole()

setConsole

public void setConsole(SessionState.LogHelper console)

getDumpFile

public File getDumpFile()

setDumpFile

public void setDumpFile(File dumpFile)

getMemoryMXBean

public static MemoryMXBean getMemoryMXBean()

setMemoryMXBean

public static void setMemoryMXBean(MemoryMXBean memoryMXBean)

getMaxMemory

public long getMaxMemory()

setMaxMemory

public void setMaxMemory(long maxMemory)

getCurrentMemory

public long getCurrentMemory()

setCurrentMemory

public void setCurrentMemory(long currentMemory)

getNum

public NumberFormat getNum()

setNum

public void setNum(NumberFormat num)

getTHRESHOLD

public static int getTHRESHOLD()


Copyright © 2011 The Apache Software Foundation