Package org.basex.query.up
Class Updates
java.lang.Object
org.basex.query.up.Updates
Implementation of the W3C XQUERY UPDATE FACILITY 1.0.
Holds all update operations and primitives a snapshot contains, checks constraints and finally executes the updates.
Fragment updates are treated like database updates. An artificial data instance is created for each fragment. Ultimately the updating process for a fragment is the same as for a database node.
The complete updating process is custom-tailored to the sequential table encoding of BaseX. As a general rule, all updates are collected and applied for each database from bottom to top, regarding the PRE values of the corresponding target nodes. Updates on the highest PRE values are applied first.
Updates work like the following:
- Each call of an updating expression creates an
NodeUpdate. - All update primitives for a snapshot/query are collected here.
- Primitives are kept separately for each database that is addressed. This
way we can operate on PRE values instead of node IDs, skip mapping
overhead and further optimize the process.
DataUpdates - Primitives are further kept separately for each database node - each
individual target PRE value. There's a specific container for this:
NodeUpdates - Transform expressions are executed in an 'isolated' updating environment,
see
TransformModifier. All the other updates are executed by aDatabaseModifier. - After the query has been parsed and all update primitives have been added to the list, constraints, which cannot be taken care of on the fly, are checked. If no problems occur, updates are TO BE carried out.
- Before applying the updates the
NodeUpdateComparatorhelps to orderNodeUpdatefor execution. Each primitive then creates a sequence ofBasicUpdatewhich are passed to theDatalayer via anAtomicUpdateCache. This list takes care of optimization and also text node merging.
- Author:
- BaseX Team 2005-21, BSD License, Lukas Kircher
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Update up, QueryContext qc) Adds an update primitive to the current context modifier.voidAdds a data reference to list which keeps track of the nodes copied within a transform expression.voidaddOutput(Value value, QueryContext qc) Adds output.voidapply(QueryContext qc) Executes all updates.Returns the names of all databases that will be updated.determineDataRef(ANode target, QueryContext qc) Determines the data reference and pre value for an update primitive which has a fragment as a target node.output(boolean reset) Returns value to be output.prepare(QueryContext qc) Prepares update operations.intsize()Number of updates on the pending update list.
-
Field Details
-
mod
public final org.basex.query.up.ContextModifier modCurrent context modifier. -
putPaths
All file paths that are targeted during a snapshot by an fn:put expression.
-
-
Constructor Details
-
Updates
public Updates(boolean transform) Constructor.- Parameters:
transform- transform flag
-
-
Method Details
-
addData
Adds a data reference to list which keeps track of the nodes copied within a transform expression.- Parameters:
data- reference
-
add
Adds an update primitive to the current context modifier.- Parameters:
up- update primitiveqc- query context- Throws:
QueryException- query exception
-
addOutput
Adds output.- Parameters:
value- value to be addedqc- query context
-
output
Returns value to be output.- Parameters:
reset- reset cache- Returns:
- value
-
determineDataRef
Determines the data reference and pre value for an update primitive which has a fragment as a target node. If an ancestor of the given target node has already been added to the pending update list, the corresponding data reference and the pre value of the given target node within this database table are calculated. Otherwise a new data instance is created. This function is called during query evaluation.- Parameters:
target- target fragmentqc- query context- Returns:
- database node created from input fragment
-
prepare
Prepares update operations. Called after query evaluation.- Parameters:
qc- query context- Returns:
- updated data references
- Throws:
QueryException- query exception
-
apply
Executes all updates. Called after query evaluation.- Parameters:
qc- query context- Throws:
QueryException- query exception
-
databases
Returns the names of all databases that will be updated. Called after query evaluation.- Returns:
- databases
-
size
public int size()Number of updates on the pending update list.- Returns:
- #updates
-