E
- public class TxSet<E> extends Object implements HGSortedSet<E>
A transactional HGSortedSet
that implements MVCC for concurrency instead of
locking. It uses an underlying implementation that is copied-on-write: when a transaction
attempts to modify the set, it is cloned into a local copy and that copy receives all
the writes. In addition, each write operation is recorded in a write log. At commit time,
if there's no conflict, the write log is replayed on the latest committed version of the
set (which may be different from the copy the transaction started from). This may sound
a bit counter-intuitive: if the set is only being written to during a transaction, there won't
be a conflict, even if another transaction modified and committed in the meantime. A conflict
will occur only if the set has been read, but somebody else in the meantime modified it.
Assuming the underlying set implementation is only accessed in the context of HGDB transactions, it doesn't need to be thread-safe, it doesn't need any locks.
Modifier and Type | Class and Description |
---|---|
static class |
TxSet.SetTxBox<E> |
Modifier | Constructor and Description |
---|---|
protected |
TxSet() |
|
TxSet(HGTransactionManager txManager,
HGSortedSet<E> backingSet) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e) |
boolean |
addAll(Collection<? extends E> c) |
void |
clear() |
Comparator<? super E> |
comparator() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
E |
first() |
HGRandomAccessResult<E> |
getSearchResult() |
SortedSet<E> |
headSet(E toElement) |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
E |
last() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
SortedSet<E> |
subSet(E fromElement,
E toElement) |
SortedSet<E> |
tailSet(E fromElement) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
protected TxSet()
public TxSet(HGTransactionManager txManager, HGSortedSet<E> backingSet)
public HGRandomAccessResult<E> getSearchResult()
getSearchResult
in interface HGSortedSet<E>
public Comparator<? super E> comparator()
comparator
in interface SortedSet<E>
public boolean add(E e)
public boolean addAll(Collection<? extends E> c)
public void clear()
public boolean contains(Object o)
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E>
containsAll
in interface Set<E>
public boolean isEmpty()
public boolean remove(Object o)
public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public int size()
public Object[] toArray()
Copyright © 2015. All rights reserved.