Package org.dizitart.no2.store
Interface NitriteMap<Key,Value>
-
- Type Parameters:
Key
- the type of keyValue
- the type of value
- All Superinterfaces:
org.dizitart.no2.common.meta.AttributesAware
,AutoCloseable
public interface NitriteMap<Key,Value> extends org.dizitart.no2.common.meta.AttributesAware, AutoCloseable
Represents a Nitrite key-value pair map. Every piece of data in a Nitrite database is stored inNitriteMap
.- Since:
- 1.0
- Author:
- Anindya Chatterjee.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Key
ceilingKey(Key key)
Get the least key that is greater than or equal to this key.void
clear()
Removes all entries in the map.void
close()
Closes thisNitriteMap
.boolean
containsKey(Key key)
Determines if the map contains a mapping for the specified key.void
drop()
Deletes the map from the store.RecordStream<Pair<Key,Value>>
entries()
Gets aRecordStream
view of the mappings contained in this map.Key
floorKey(Key key)
Get the largest key that is smaller or equal to this key.Value
get(Key key)
Gets the value mapped with the specified key ornull
otherwise.default Attributes
getAttributes()
Gets the attributes of this map.String
getName()
Gets name of this map.NitriteStore<?>
getStore()
Gets the parentNitriteStore
where this map is stored.Key
higherKey(Key key)
Get the lest key that is greater than the given key, or null if no such key exists.boolean
isClosed()
Indicates if the map already is closed.boolean
isDropped()
Indicates if this map is dropped already.boolean
isEmpty()
Indicates whether the map is empty.Iterable<Key>
keys()
Gets aRecordStream
view of the keys contained in this map.Key
lowerKey(Key key)
Get the largest key that is smaller than the given key, or null if no such key exists.void
put(Key key, Value value)
Associates the specified value with the specified key in this map.Value
putIfAbsent(Key key, Value value)
Add a key-value pair if it does not yet exist.Value
remove(Key key)
Removes the mapping for a key from this map if it is present.RecordStream<Pair<Key,Value>>
reversedEntries()
Gets a reversedRecordStream
view of the mappings contained in this map.default void
setAttributes(Attributes attributes)
Sets the attributes for this map.long
size()
Get the number of entries, as an integer.default void
updateLastModifiedTime()
Update last modified time of the map.Iterable<Value>
values()
Gets aRecordStream
view of the values contained in this map.
-
-
-
Method Detail
-
containsKey
boolean containsKey(Key key)
Determines if the map contains a mapping for the specified key.- Parameters:
key
- key whose presence in this map is to be tested- Returns:
- `true` if this map contains a mapping for the specified key.
-
get
Value get(Key key)
Gets the value mapped with the specified key ornull
otherwise.- Parameters:
key
- the key- Returns:
- the value, or null if the key not found.
-
clear
void clear()
Removes all entries in the map.
-
isClosed
boolean isClosed()
Indicates if the map already is closed.- Returns:
- the boolean
-
close
void close()
Closes thisNitriteMap
.- Specified by:
close
in interfaceAutoCloseable
-
values
Iterable<Value> values()
Gets aRecordStream
view of the values contained in this map.- Returns:
- the collection view of all values in this map.
-
keys
Iterable<Key> keys()
Gets aRecordStream
view of the keys contained in this map.- Returns:
- a set view of the keys contained in this map.
-
remove
Value remove(Key key)
Removes the mapping for a key from this map if it is present.- Parameters:
key
- the key whose mapping is to be removed from this map.- Returns:
- the value that has been removed.
-
put
void put(Key key, Value value)
Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced by the specified value.- Parameters:
key
- key with which the specified value is to be associated (may not be null).value
- value to be associated with the specified key (may not be null).
-
size
long size()
Get the number of entries, as an integer. Integer.MAX_VALUE is returned if there are more than these entries.- Returns:
- the number of entries, as an integer.
-
putIfAbsent
Value putIfAbsent(Key key, Value value)
Add a key-value pair if it does not yet exist.- Parameters:
key
- the key (may not be null)value
- the new value- Returns:
- the old value if the key existed, or `null` otherwise.
-
higherKey
Key higherKey(Key key)
Get the lest key that is greater than the given key, or null if no such key exists.- Parameters:
key
- the key- Returns:
- the result.
-
ceilingKey
Key ceilingKey(Key key)
Get the least key that is greater than or equal to this key.- Parameters:
key
- the key- Returns:
- the result.
-
lowerKey
Key lowerKey(Key key)
Get the largest key that is smaller than the given key, or null if no such key exists.- Parameters:
key
- the key- Returns:
- the result.
-
floorKey
Key floorKey(Key key)
Get the largest key that is smaller or equal to this key.- Parameters:
key
- the key- Returns:
- the result.
-
isEmpty
boolean isEmpty()
Indicates whether the map is empty.- Returns:
- `true` if the map is empty; `false` otherwise.
-
getStore
NitriteStore<?> getStore()
Gets the parentNitriteStore
where this map is stored.- Returns:
- the store where this map is stored.
-
getName
String getName()
Gets name of this map.- Returns:
- the name of this map.
-
entries
RecordStream<Pair<Key,Value>> entries()
Gets aRecordStream
view of the mappings contained in this map.- Returns:
- a set view of the mappings contained in this map.
-
reversedEntries
RecordStream<Pair<Key,Value>> reversedEntries()
Gets a reversedRecordStream
view of the mappings contained in this map.- Returns:
- the record stream
-
drop
void drop()
Deletes the map from the store.
-
isDropped
boolean isDropped()
Indicates if this map is dropped already.- Returns:
- the boolean result
-
getAttributes
default Attributes getAttributes()
Gets the attributes of this map.- Specified by:
getAttributes
in interfaceorg.dizitart.no2.common.meta.AttributesAware
-
setAttributes
default void setAttributes(Attributes attributes)
Sets the attributes for this map.- Specified by:
setAttributes
in interfaceorg.dizitart.no2.common.meta.AttributesAware
-
updateLastModifiedTime
default void updateLastModifiedTime()
Update last modified time of the map.
-
-