public class IsolatedFusedView extends FusedView
An index (or index partition) that has been isolated by a transaction. Isolation is achieved by the following mechanisms:
BTree
visible only to that transaction.IConflictResolver
.
Note: The timestamp from which the post-commit state of the transaction may
be read IS NOT defined for an IBigdataFederation
. It is not possible
to define this timestamp without requiring concurrent commit processing to be
paused on all data services on which the transaction has written, which is
viewed as too high a cost. Instead, the commit timestamp is the state from
which you can read the data written by the transaction. Reads on tuples NOT
updated by the transaction MAY have been changed by concurrent transactions.
ITx.UNISOLATED
AbstractTask
which handles this process. FusedView.FusedBloomFilter
ERR_RANGE_COUNT_EXCEEDS_MAX_LONG, log
Constructor and Description |
---|
IsolatedFusedView(long timestamp,
AbstractBTree[] sources)
Constructor may be used either for a fully isolated transaction or an
unisolated operation.
|
Modifier and Type | Method and Description |
---|---|
ICounter |
getCounter()
Counters are disallowed for isolated view.
|
BTree |
getWriteSet()
The isolated write set (the place where we record the intention of the
transaction).
|
byte[] |
insert(byte[] key,
byte[] val)
Insert or update a value under the key.
|
boolean |
isEmptyWriteSet()
True iff there are no writes on this isolated index.
|
void |
mergeDown(long revisionTime,
AbstractBTree[] groundStateSources)
Merge the transaction scope index onto the then current unisolated index.
|
byte[] |
putIfAbsent(byte[] key,
byte[] val)
Insert or update a value under the key iff there is no entry for that key
in the index.
|
byte[] |
remove(byte[] key)
Write a deleted entry for the key on the write set.
|
boolean |
validate(AbstractBTree[] groundStateSources)
Validate changes made to the index within a transaction against the last
committed state of the index in the global scope.
|
assertNotReadOnly, contains, contains, getBloomFilter, getCounters, getIndexMetadata, getMutableBTree, getResourceMetadata, getSourceCount, getSources, insert, lookup, lookup, lookup, lookup, rangeCount, rangeCount, rangeCountExact, rangeCountExactWithDeleted, rangeIterator, rangeIterator, rangeIterator, remove, submit, submit, submit, toString
public IsolatedFusedView(long timestamp, AbstractBTree[] sources)
Reads will read through the writeSet and then the resource(s) in the groundState in the order in which they are given. A read is satisfied by the first resource containing an index entry for the search key.
Writes will first read through looking for a @todo javadoc
timestamp
- The timestamp associated with the groundState.sources
- An ordered array of sources comprised of the BTree
that will absorb writes and the historical ground state.public BTree getWriteSet()
BTree
at
index zero(0) of sources in the view.FusedView.getMutableBTree()
public boolean isEmptyWriteSet()
public final ICounter getCounter()
getCounter
in interface IIndexLocalCounter
getCounter
in class FusedView
UnsupportedOperationException
- alwayspublic byte[] insert(byte[] key, byte[] val)
Resolves the old value against the view and then directs the write to the first of the sources specified to the ctor.
Write an entry for the key on the write set.
insert
in interface ISimpleBTree
insert
in class FusedView
key
- The key.val
- The value (may be null).null
if the
key was not found or if the previous entry for that key was
marked as deleted.public byte[] putIfAbsent(byte[] key, byte[] val)
if (!contains(key)) insert(key, value);However, if the index allows
null
values to be stored under
a key and the application in fact stores null
values for
some tuples, then caller is not able to decide using this method whether
or not the mutation was applied based on the return value. For these
cases if the caller needs to know whether or not the conditional mutation
actually took place, the caller CAN use the pattern
if(!contains()) insert(key,value);
to obtain that
information.
This case is a bit tricky. Since it is possible for the value stored under a key to be null, we need to obtain the Tuple for the key from the view. If the tuple is null or deleted, then we can do an unconditional insert. Otherwise there is an entry under the key and we return the value of the entry from the Tuple. Note that the value COULD be a null.
Write an entry for the key on the write set.
putIfAbsent
in interface ISimpleBTree
putIfAbsent
in class FusedView
key
- The key.val
- The value (may be null).null
if the key
was not found or if the previous entry for that key was marked as
deleted. Note that the return value MAY be null
even
if there was an entry under the key. This is because the index is
capable of storing a null
value. In such cases the
conditional mutation WAS NOT applied.(putIfAbsent)
public byte[] remove(byte[] key)
remove
in interface ISimpleBTree
remove
in class FusedView
key
- The key.null
if the key
was not found or if the previous entry under that key was marked
as deleted.public boolean validate(AbstractBTree[] groundStateSources)
Validate changes made to the index within a transaction against the last
committed state of the index in the global scope. In general there are
two kinds of conflicts: read-write conflicts and write-write conflicts.
Read-write conflicts are handled by NEVER overwriting an existing version
(an MVCC style strategy). Write-write conflicts are detected by backward
validation against the last committed state of the journal. A write-write
conflict exists IFF the version counter on the transaction index entry
differs from the version counter in the global index scope. Once
detected, the resolution of a write-write conflict is delegated to a
conflict resolver
. If a write-write conflict
can not be validated, then validation will fail and the transaction must
abort.
Validation occurs as part of the prepare/commit protocol. Concurrent transactions MAY continue to run without limitation. A concurrent commit (if permitted) would force re-validation since the transaction MUST now be validated against the new baseline. (It is possible that this validation could be optimized.)
The version counters used to detect write-write conflicts are incremented
during the commit as part of the #mergeDown()
of the
IsolatedFusedView
onto the corresponding unisolated indices in
the global scope.
groundStateSources
- The ordered view of the unisolated index. This MUST be the
current view of the ground state as of when the transaction is
validated (NOT when it was created). This view WILL NOT the
same as the groundState specified to the constructor if
intervening transactions have committed on the index.public void mergeDown(long revisionTime, AbstractBTree[] groundStateSources)
Merge the transaction scope index onto the then current unisolated index.
Note: This method is invoked by a transaction during commit processing to
merge the write set of an IsolatedFusedView
into the global
scope. This operation does NOT check for conflicts. The pre-condition is
that the transaction has already been validated (hence, there will be no
conflicts).
Note: This method is also responsible for updating the version timestamps that are used to detect write-write conflicts during validation - they are set to the revisionTime.
revisionTime
- The revision timestamp assigned to the commit point of the
transaction.groundStateSources
- The ordered view of the unisolated index. This MUST be the
current view of the ground state as of when the transaction is
validated (NOT when it was created). This view WILL NOT the
same as the groundState specified to the constructor if
intervening transactions have committed on the index.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.