Package org.apache.accumulo.tserver
Class NativeMap
- java.lang.Object
-
- org.apache.accumulo.tserver.NativeMap
-
public class NativeMap extends Object implements Iterable<Map.Entry<Key,Value>>
This class stores data in a C++ map. Doing this allows us to store more in memory and avoid pauses caused by Java GC. The strategy for dealing with native memory allocated for the native map is that java code using the native map should call delete() as soon as it is finished using the native map. When the NativeMap object is garbage collected its native resources will be released if needed. However waiting for java GC would be a mistake for long lived NativeMaps. Long lived objects are not garbage collected quickly, therefore a process could easily use too much memory.
-
-
Constructor Summary
Constructors Constructor Description NativeMap()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete()
protected void
finalize()
Value
get(Key key)
long
getMemoryUsed()
static boolean
isLoaded()
Check if native libraries are loaded.Iterator<Map.Entry<Key,Value>>
iterator()
Iterator<Map.Entry<Key,Value>>
iterator(Key startKey)
static void
loadNativeLib(List<File> searchPath)
If native libraries are not loaded, the specified search path will be used to attempt to load them.void
put(Key key, Value value)
int
size()
SortedKeyValueIterator<Key,Value>
skvIterator()
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
loadNativeLib
public static void loadNativeLib(List<File> searchPath)
If native libraries are not loaded, the specified search path will be used to attempt to load them. Directories will be searched by using the system-specific library naming conventions. A path directly to a file can also be provided. Loading will continue until the search path is exhausted, or until the native libraries are found and successfully loaded, whichever occurs first.- Parameters:
searchPath
- a list of files and directories to search
-
isLoaded
public static boolean isLoaded()
Check if native libraries are loaded.- Returns:
- true if they are loaded; false otherwise
-
finalize
protected void finalize() throws Throwable
-
size
public int size()
-
getMemoryUsed
public long getMemoryUsed()
-
delete
public void delete()
-
skvIterator
public SortedKeyValueIterator<Key,Value> skvIterator()
-
-