public class BigdataMap<K,V> extends AbstractMap<K,V> implements SortedMap<K,V>
SortedMap
wrapping an IIndex
.
Note: The BigdataMap
has the same concurrency constraints as the
BTree
- it is single-threaded for writes and allows concurrent
readers. When wrapping a scale-out index, the ConcurrencyManager
will
automatically provide appropriate concurrency controls. When wrapping a local
index, you can use an UnisolatedReadWriteIndex
to impose Map
operation level concurrency control if your application does not otherwise
handle this constraint. Also, note that point tests for the scale-out indices
are VERY expensive when compared to ordered reads and writes.
Note: The total order of the BigdataMap
is completely determined by
ITupleSerializer.serializeKey(Object)
. There is NO concept of a
Comparator
. The ITupleSerializer
is responsible for coercing
application keys into variable length unsigned byte[]s which
are the keys for the underlying B+Tree. The order for the B+Tree is the
natural order for the unsigned byte[]s. KeyBuilder
supports the generation of unsigned byte[]s from various kinds of Java
primitives and Unicode String
s and is typically used to write the
ITupleSerializer.serializeKey(Object)
method.
Note: The coercion of the application keys into unsigned byte[]s is not type
safe unless you either consistently use a strongly typed instance of this
class or specify an ITupleSerializer
for the backing B+Tree that only
allows application keys that are instances of acceptable classes. This issue
is more critical for keys than for values since the keys define the total
index order and the default coercion rules for keys are provided by
KeyBuilder.append(Object)
which does not attempt to partition the key
space by the application key type (keys are not safely polymorphic by
default).
Note: When storing Java objects in the tuple value, the value MUST be treated
as if it is immutable since it will be serialized on insert or update and
deserialized on read. In particular, the pattern of updating the value stored
in the map without put(Object, Object)
ting the value back into the
map WILL NOT cause the value associated with the tuple to be updated.
Note: Both Map.equals(Object)
and Map.hashCode()
are VERY
expensive, but that is how they are defined.
Modifier and Type | Class and Description |
---|---|
protected class |
BigdataMap.Entry
Note: Since the same
ITuple instance is returned for each tuple
by many ITupleIterator s there is a side-effect that invalidates
the last visited Map.Entry object. |
protected class |
BigdataMap.EntrySet
Implementation supporting
entrySet() . |
protected class |
BigdataMap.EntrySetIterator
Iterator visiting
Map.Entry objects in support of BigdataMap.EntrySet . |
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
BigdataMap(IIndex ndx)
Wrap an index as a
SortedMap . |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
Comparator<? super K> |
comparator()
There is no means available to specify a
Comparator for the
SortedMap . |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value)
Note: This performs an index scan (since the values of the map are
unordered) but stops as soon as a match is found.
|
Set<Map.Entry<K,V>> |
entrySet()
Note:
AbstractMap.keySet() and AbstractMap.values() both depend on this method. |
K |
firstKey() |
V |
get(Object key) |
IIndex |
getIndex()
The backing index.
|
SortedMap<K,V> |
headMap(K toKey)
A
SortedMap view onto the backing B+Tree which imposes the
specified key-range restriction. |
boolean |
isEmpty() |
K |
lastKey() |
V |
put(K key,
V val) |
void |
putAll(Map<? extends K,? extends V> t) |
long |
rangeCount(boolean exactCount)
The #of non-deleted entries in the map.
|
V |
remove(Object key) |
int |
size()
The #of index entries.
|
SortedMap<K,V> |
subMap(K fromKey,
K toKey)
A
SortedMap view onto the backing B+Tree which imposes the
specified key-range restriction. |
SortedMap<K,V> |
tailMap(K fromKey)
A
SortedMap view onto the backing B+Tree which imposes the
specified key-range restriction. |
clone, equals, hashCode, keySet, toString, values
public IIndex getIndex()
public void clear()
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
containsKey
in class AbstractMap<K,V>
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
containsValue
in class AbstractMap<K,V>
public int size()
Integer.MAX_VALUE
entries then this method will report Integer.MAX_VALUE
entries.
If the backing index supports delete markers then an index scan will be
performed in order to count the #of non-deleted index entries.public boolean isEmpty()
public long rangeCount(boolean exactCount)
exactCount
- When true
the result will be an exact count,
which will require a full key-range scan if delete markers are
enabled for the index.false
and delete markers are being used, then this
will be an upper bound.IRangeQuery.rangeCount(byte[], byte[])
public final Comparator<? super K> comparator()
Comparator
for the
SortedMap
. Application keys are first converted into
unsigned byte[] keys using the configured
ITupleSerializer
for the backing B+Tree. The index order is
directly determined by those keys.comparator
in interface SortedMap<K,V>
null
.public K firstKey()
firstKey
in interface SortedMap<K,V>
UnsupportedOperationException
- if the ITupleSerializer
does not implement the
optional ITupleSerializer.deserializeKey(ITuple)
method.public K lastKey()
lastKey
in interface SortedMap<K,V>
UnsupportedOperationException
- if the ITupleSerializer
does not implement the
optional ITupleSerializer.deserializeKey(ITuple)
method.public SortedMap<K,V> headMap(K toKey)
SortedMap
view onto the backing B+Tree which imposes the
specified key-range restriction.public SortedMap<K,V> subMap(K fromKey, K toKey)
SortedMap
view onto the backing B+Tree which imposes the
specified key-range restriction.public SortedMap<K,V> tailMap(K fromKey)
SortedMap
view onto the backing B+Tree which imposes the
specified key-range restriction.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.