|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.aitools.aq.bighashmap.core.BigHashMap<V>
V
- the value type of this hash mappublic class BigHashMap<V extends Value>
A simple hash map so store a large set of key/value pairs. This
representation is backed by an external hash table, which is implemented
in native code for best access performance. For simplicity this hash map
takes String
as its key type and some derivative of Value
(only these in this project) as its value type.
Unlike most other Map
implementations, this hash map will be
constructed from a text representation of key/value pairs, which has to be
provided by the user. Please take a look at the documentation for the exact
Specification of this text format.
Once constructed the hash map is completely read-only. Hence the majority
of Map
's interface, which would modify the hash map data, is not
supported. Keep in mind that the purpose of this hash map is efficient
lookup behavior on very large key sets that do not fit into memory.
This hash map has no build-in thread-safety. The use of this class in
multi-threaded applications requires to enclose each method invocation in a
separate synchronized
block.
Furthermore, due to the underlying C/C++ implementation, there is no Unicode support for the input files. Non-ASCII characters may be truncated, which could create key duplicates, which could cause the CMPH library to crash. We are working on this limitation.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Method Summary | ||
---|---|---|
static
|
build(java.lang.Class<V> clazz,
java.io.File inputDir,
java.io.File outputDir)
Function to build a BigHashMap instance. |
|
void |
clear()
Not supported. |
|
void |
close()
Closes the hash map and deletes the underlying native object. |
|
boolean |
containsKey(java.lang.Object key)
|
|
boolean |
containsValue(java.lang.Object value)
Not supported. |
|
java.util.Set<java.util.Map.Entry<java.lang.String,V>> |
entrySet()
Not supported. |
|
V |
get(java.lang.Object key)
|
|
boolean |
get(java.lang.String key,
V value)
Lookup a value with object reuse. |
|
boolean |
isEmpty()
|
|
java.util.Set<java.lang.String> |
keySet()
Not supported. |
|
static
|
open(java.lang.Class<V> clazz,
java.io.File indexFile,
Memory memory)
Opens and initializes the hash map represented by indexFile . |
|
V |
put(java.lang.String key,
V value)
Not supported. |
|
void |
putAll(java.util.Map<? extends java.lang.String,? extends V> m)
Not supported. |
|
V |
remove(java.lang.Object key)
Not supported. |
|
int |
size()
Note that for big hash maps the actual size does not fit into Integer.MAX_VALUE . |
|
long |
sizeLong()
Returns the size of this hash map as long value, since it is not guaranteed that the actual size as int provided by size() fits into Integer.MAX_VALUE . |
|
java.util.Collection<V> |
values()
Not supported. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
Method Detail |
---|
public static <V extends Value> java.io.File build(java.lang.Class<V> clazz, java.io.File inputDir, java.io.File outputDir)
BigHashMap
instance.
clazz
- the class object of the value type. If the value type is
not supported an UnsupportedOperationException
will be
thrown. Otherwise, if this value type is supported, but does not
match the type serialized in the input files, will cause
parsing errors or undefined behavior.inputDir
- the directory that contains one or more input files, and
nothing more. For the format specification take a look at the
documentation.outputDir
- the already existing, but empty directory, where the
external hash map will be stored.
java.lang.UnsupportedOperationException
public static <V extends Value> BigHashMap<V> open(java.lang.Class<V> clazz, java.io.File indexFile, Memory memory)
indexFile
.
clazz
- the class object of the value type. If the value type is
not supported some exception will be thrown. Otherwise, if this
value type is supported, but does not match the native type
indeed, it will cause undefined behavior.indexFile
- the path to the initialization file, which was returned
by build(Class, File, File)
prior.memory
- A hint how many memory can be used by that instance at
runtime. Currently if you can provide enough memory, the entire
table data is mapped into memory to avoid disk I/O at runtime.public void close()
public long sizeLong()
size()
fits into Integer.MAX_VALUE
.
size()
public int size()
Integer.MAX_VALUE
. Use sizeLong()
instead.
size
in interface java.util.Map<java.lang.String,V extends Value>
sizeLong()
public boolean isEmpty()
isEmpty
in interface java.util.Map<java.lang.String,V extends Value>
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<java.lang.String,V extends Value>
public V get(java.lang.Object key)
get
in interface java.util.Map<java.lang.String,V extends Value>
public boolean get(java.lang.String key, V value)
get(Object)
instead, which seems to be more stable.
key
- value
-
key
was found, false otherwisepublic boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<java.lang.String,V extends Value>
public V put(java.lang.String key, V value)
put
in interface java.util.Map<java.lang.String,V extends Value>
public V remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.String,V extends Value>
public void putAll(java.util.Map<? extends java.lang.String,? extends V> m)
putAll
in interface java.util.Map<java.lang.String,V extends Value>
public void clear()
clear
in interface java.util.Map<java.lang.String,V extends Value>
public java.util.Set<java.lang.String> keySet()
keySet
in interface java.util.Map<java.lang.String,V extends Value>
public java.util.Collection<V> values()
values
in interface java.util.Map<java.lang.String,V extends Value>
public java.util.Set<java.util.Map.Entry<java.lang.String,V>> entrySet()
entrySet
in interface java.util.Map<java.lang.String,V extends Value>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |