Package org.apache.hadoop.hbase.io.util
Interface Dictionary
- All Known Implementing Classes:
LRUDictionary
Dictionary interface Dictionary indexes should be either bytes or shorts, only positive. (The
first bit is reserved for detecting whether something is compressed or not).
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionshort
addEntry
(byte[] data, int offset, int length) Adds an entry to the dictionary.void
clear()
Flushes the dictionary, empties all values.short
findEntry
(byte[] data, int offset, int length) Finds the index of an entry.short
findEntry
(ByteBuffer data, int offset, int length) Finds the index of an entry.byte[]
getEntry
(short idx) Gets an entry from the dictionary.void
init
(int initialSize) static void
write
(OutputStream out, byte[] data, int offset, int length, Dictionary dict) Helper methods to write the dictionary data to the OutputStreamstatic void
write
(OutputStream out, ByteBuffer data, int offset, int length, Dictionary dict) Helper methods to write the dictionary data to the OutputStream
-
Field Details
-
NOT_IN_DICTIONARY
- See Also:
-
-
Method Details
-
init
-
getEntry
Gets an entry from the dictionary.- Parameters:
idx
- index of the entry- Returns:
- the entry, or null if non existent
-
findEntry
Finds the index of an entry. If no entry found, we add it.- Parameters:
data
- the byte array that we're looking upoffset
- Offset intodata
to add to Dictionary.length
- Length beyondoffset
that comprises entry; must be > 0.- Returns:
- the index of the entry, or
NOT_IN_DICTIONARY
if not found
-
findEntry
Finds the index of an entry. If no entry found, we add it.- Parameters:
data
- the ByteBuffer that we're looking upoffset
- Offset intodata
to add to Dictionary.length
- Length beyondoffset
that comprises entry; must be > 0.- Returns:
- the index of the entry, or
NOT_IN_DICTIONARY
if not found
-
addEntry
Adds 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 {findEntry(byte[], int, int)
} to add without duplicating dictionary entries.- Parameters:
data
- the entry to addoffset
- Offset intodata
to add to Dictionary.length
- Length beyondoffset
that comprises entry; must be > 0.- Returns:
- the index of the entry
-
clear
void clear()Flushes the dictionary, empties all values. -
write
static void write(OutputStream out, byte[] data, int offset, int length, Dictionary dict) throws IOException Helper methods to write the dictionary data to the OutputStream- Parameters:
out
- the outputstream to which data needs to be writtendata
- the data to be written in byte[]offset
- the offsetlength
- length to be writtendict
- the dictionary whose contents are to written- Throws:
IOException
-
write
static void write(OutputStream out, ByteBuffer data, int offset, int length, Dictionary dict) throws IOException Helper methods to write the dictionary data to the OutputStream- Parameters:
out
- the outputstream to which data needs to be writtendata
- the data to be written in ByteBufferoffset
- the offsetlength
- length to be writtendict
- the dictionary whose contents are to written- Throws:
IOException
-