org.apache.hadoop.hive.ql.exec.persistence
Class HashMapWrapper<K,V>
java.lang.Object
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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOG
protected org.apache.commons.logging.Log LOG
console
protected transient SessionState.LogHelper console
memoryMXBean
public static MemoryMXBean memoryMXBean
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()
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