public final class AtomicUpdateCache extends Object
A container/list for atomic updates. Updates must be added from the lowest to the highest PRE value (regarding the location of the update). Updates are finally applied by this container from the highest to the lowest PRE value (reverse document order) to support efficient structural bulk updates etc.
If a collection of updates is carried out via the AUC there are several benefits:
To avoid ambiguity it is not allowed to add:
Delete
or Replace
operating
on the same node.Rename
or UpdateValue
operating
on the same node.Updates are added in a streaming fashion where the most recently added update is remembered. This avoids additional traversals of the AUC during consistency checks and further optimizations.
Constructor and Description |
---|
AtomicUpdateCache(Data data)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addDelete(int pre)
Adds a delete atomic to the list.
|
void |
addInsert(int pre,
int par,
DataClip clip)
Adds an insert atomic to the list.
|
void |
addRename(int pre,
byte[] name,
byte[] uri)
Adds a rename atomic to the list.
|
void |
addReplace(int pre,
DataClip clip)
Adds a replace atomic to the list.
|
void |
addUpdateValue(int pre,
byte[] value)
Adds an updateValue atomic to the list.
|
void |
applyUpdates()
Carries out structural updates.
|
int |
calculatePreValue(int pre,
boolean beforeUpdates)
Calculates the PRE value of a given node before/after updates.
|
void |
clear()
Resets the list.
|
void |
execute(boolean mergeTexts)
Executes the updates.
|
int |
updatesSize()
Returns the number of structural updates.
|
public final Data data
public AtomicUpdateCache(Data data)
data
- target data referencepublic void addDelete(int pre)
pre
- PRE value of the target node/update locationpublic void addInsert(int pre, int par, DataClip clip)
pre
- PRE value of the target node/update locationpar
- new parent of the inserted nodesclip
- insertion sequence data clippublic void addReplace(int pre, DataClip clip)
pre
- PRE value of the target node/update locationclip
- insertion sequence data clippublic void addRename(int pre, byte[] name, byte[] uri)
pre
- PRE value of the target node/update locationname
- new name for the target nodeuri
- new uri for the target nodepublic void addUpdateValue(int pre, byte[] value)
pre
- PRE value of the target node/update locationvalue
- new value for the target nodepublic void clear()
public int updatesSize()
public void execute(boolean mergeTexts)
mergeTexts
- adjacent text nodes are to be expected and must be mergedpublic void applyUpdates()
public int calculatePreValue(int pre, boolean beforeUpdates)
pre
- PRE valuebeforeUpdates
- calculate PRE value before shifts/updates have been appliedCopyright © 2005–2015 BaseX Team. All rights reserved.