Package org.apache.hadoop.hbase.io.util
Class LRUDictionary
java.lang.Object
org.apache.hadoop.hbase.io.util.LRUDictionary
- All Implemented Interfaces:
Dictionary
WALDictionary using an LRU eviction algorithm. Uses a linked list running through a hashtable.
Currently has max of 2^15 entries. Will start evicting if exceeds this number The maximum memory
we expect this dictionary to take in the worst case is about:
(2 ^ 15) * 5 (Regionname, Row key, CF, Column qual, table) * 100 bytes
(these are some big names) = ~16MB. If you want to get silly, even at 1kb entries, it
maxes out at 160 megabytes.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class -
Field Summary
FieldsFields inherited from interface org.apache.hadoop.hbase.io.util.Dictionary
NOT_IN_DICTIONARY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionshortaddEntry(byte[] data, int offset, int length) Adds an entry to the dictionary.private shortaddEntryInternal(byte[] data, int offset, int length, boolean copy) voidclear()Flushes the dictionary, empties all values.shortfindEntry(byte[] data, int offset, int length) Finds the index of an entry.shortfindEntry(ByteBuffer data, int offset, int length) Finds the index of an entry.byte[]getEntry(short idx) Gets an entry from the dictionary.voidinit(int initialSize)
-
Field Details
-
backingStore
-
-
Constructor Details
-
LRUDictionary
public LRUDictionary()
-
-
Method Details
-
getEntry
Description copied from interface:DictionaryGets an entry from the dictionary.- Specified by:
getEntryin interfaceDictionary- Parameters:
idx- index of the entry- Returns:
- the entry, or null if non existent
-
init
- Specified by:
initin interfaceDictionary
-
findEntry
Description copied from interface:DictionaryFinds the index of an entry. If no entry found, we add it.- Specified by:
findEntryin interfaceDictionary- Parameters:
data- the byte array that we're looking upoffset- Offset intodatato add to Dictionary.length- Length beyondoffsetthat comprises entry; must be > 0.- Returns:
- the index of the entry, or
Dictionary.NOT_IN_DICTIONARYif not found
-
addEntry
Description copied from interface:DictionaryAdds an entry to the dictionary. Be careful using this method. It will add an entry to the dictionary even if it already has an entry for the same data. Call {Dictionary.findEntry(byte[], int, int)} to add without duplicating dictionary entries.- Specified by:
addEntryin interfaceDictionary- Parameters:
data- the entry to addoffset- Offset intodatato add to Dictionary.length- Length beyondoffsetthat comprises entry; must be > 0.- Returns:
- the index of the entry
-
addEntryInternal
-
clear
Description copied from interface:DictionaryFlushes the dictionary, empties all values.- Specified by:
clearin interfaceDictionary
-
findEntry
Description copied from interface:DictionaryFinds the index of an entry. If no entry found, we add it.- Specified by:
findEntryin interfaceDictionary- Parameters:
data- the ByteBuffer that we're looking upoffset- Offset intodatato add to Dictionary.length- Length beyondoffsetthat comprises entry; must be > 0.- Returns:
- the index of the entry, or
Dictionary.NOT_IN_DICTIONARYif not found
-