Package com.gengoai.collection.disk
Class NavigableDiskMap<K,V>
- java.lang.Object
-
- com.gengoai.collection.disk.NavigableDiskMap<K,V>
-
- Type Parameters:
K
- the key type parameterV
- the value type parameter
- All Implemented Interfaces:
Serializable
,AutoCloseable
,Map<K,V>
,NavigableMap<K,V>
,SortedMap<K,V>
public final class NavigableDiskMap<K,V> extends Object implements NavigableMap<K,V>, Serializable, AutoCloseable
A NavigableMap implementation that stores its data in a file. NavigableDiskMap are monitored to ensure that their file handle is properly closed if the it is no longer in use. However, one can use the
commit
andclose
methods to explicitly commit changes and close the map.NavigableDiskMap are created using a builder in the following way:
var map = NavigableDiskMap.builder() .file(Resources.from("/data/map.db") .namespace("people") .compressed(true) .build();
Once an NavigableDiskMap instance is constructed it acts like regular Java NavigableMap.
- See Also:
- Serialized Form
-
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
ceilingEntry
public Map.Entry<K,V> ceilingEntry(K k)
- Specified by:
ceilingEntry
in interfaceNavigableMap<K,V>
-
ceilingKey
public K ceilingKey(K k)
- Specified by:
ceilingKey
in interfaceNavigableMap<K,V>
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
commit
public void commit()
Commit.
-
comparator
public Comparator<? super K> comparator()
- Specified by:
comparator
in interfaceSortedMap<K,V>
-
containsKey
public boolean containsKey(Object o)
- Specified by:
containsKey
in interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object o)
- Specified by:
containsValue
in interfaceMap<K,V>
-
descendingKeySet
public NavigableSet<K> descendingKeySet()
- Specified by:
descendingKeySet
in interfaceNavigableMap<K,V>
-
descendingMap
public NavigableMap<K,V> descendingMap()
- Specified by:
descendingMap
in interfaceNavigableMap<K,V>
-
equals
public boolean equals(Object o)
-
firstEntry
public Map.Entry<K,V> firstEntry()
- Specified by:
firstEntry
in interfaceNavigableMap<K,V>
-
floorEntry
public Map.Entry<K,V> floorEntry(K k)
- Specified by:
floorEntry
in interfaceNavigableMap<K,V>
-
getHandle
public MapDBHandle getHandle()
-
hashCode
public int hashCode()
-
headMap
public NavigableMap<K,V> headMap(K k, boolean b)
- Specified by:
headMap
in interfaceNavigableMap<K,V>
-
higherEntry
public Map.Entry<K,V> higherEntry(K k)
- Specified by:
higherEntry
in interfaceNavigableMap<K,V>
-
lastEntry
public Map.Entry<K,V> lastEntry()
- Specified by:
lastEntry
in interfaceNavigableMap<K,V>
-
lowerEntry
public Map.Entry<K,V> lowerEntry(K k)
- Specified by:
lowerEntry
in interfaceNavigableMap<K,V>
-
navigableKeySet
public NavigableSet<K> navigableKeySet()
- Specified by:
navigableKeySet
in interfaceNavigableMap<K,V>
-
pollFirstEntry
public Map.Entry<K,V> pollFirstEntry()
- Specified by:
pollFirstEntry
in interfaceNavigableMap<K,V>
-
pollLastEntry
public Map.Entry<K,V> pollLastEntry()
- Specified by:
pollLastEntry
in interfaceNavigableMap<K,V>
-
subMap
public NavigableMap<K,V> subMap(K k, boolean b, K k1, boolean b1)
- Specified by:
subMap
in interfaceNavigableMap<K,V>
-
tailMap
public NavigableMap<K,V> tailMap(K k, boolean b)
- Specified by:
tailMap
in interfaceNavigableMap<K,V>
-
-