org.exist.xquery.update
Class Modification

java.lang.Object
  extended by org.exist.xquery.AbstractExpression
      extended by org.exist.xquery.update.Modification
All Implemented Interfaces:
Expression
Direct Known Subclasses:
Delete, Insert, Rename, Replace, Update

public abstract class Modification
extends AbstractExpression


Field Summary
protected  DocumentSet lockedDocuments
           
protected static org.apache.log4j.Logger LOG
           
protected  MutableDocumentSet modifiedDocuments
           
protected  Expression select
           
protected  Int2ObjectHashMap<DocumentTrigger> triggers
           
protected  Expression value
           
 
Fields inherited from class org.exist.xquery.AbstractExpression
column, context, contextDocSet, contextId, line, unordered
 
Fields inherited from interface org.exist.xquery.Expression
DOT_TEST, EXPRESSION_ID_INVALID, IGNORE_CONTEXT, IN_NODE_CONSTRUCTOR, IN_PREDICATE, IN_UPDATE, IN_WHERE_CLAUSE, NEED_INDEX_INFO, NO_CONTEXT_ID, NON_STREAMABLE, POSITIONAL_PREDICATE, SINGLE_STEP_EXECUTION, UNORDERED, USE_TREE_TRAVERSAL
 
Constructor Summary
Modification(XQueryContext context, Expression select, Expression value)
           
 
Method Summary
 void analyze(AnalyzeContextInfo contextInfo)
          Statically analyze the expression and its subexpressions.
static void checkFragmentation(XQueryContext context, DocumentSet docs)
           
static void checkFragmentation(XQueryContext context, DocumentSet docs, int splitCount)
          Check if any of the modified documents needs defragmentation.
 void commitTransaction(Txn transaction)
          Commit's the transaction for the update unless it is a batch update and then the commit is defered
protected  Sequence deepCopy(Sequence inSeq)
           
protected  void finishTriggers(Txn transaction)
           
 int getCardinality()
          The default cardinality is Cardinality.EXACTLY_ONE.
 Txn getTransaction()
          Gets the Transaction to use for the update (can be batch or individual)
 void resetState(boolean postOptimization)
          Called to inform an expression that it should reset to its initial state.
 int returnsType()
          The static return type of the expression.
protected  StoredNode[] selectAndLock(Txn transaction, Sequence nodes)
          Acquire a lock on all documents processed by this modification.
protected  void unlockDocuments()
          Release all acquired document locks.
 
Methods inherited from class org.exist.xquery.AbstractExpression
accept, allowMixNodesInReturn, eval, eval, getColumn, getContext, getContextDocSet, getContextId, getDependencies, getExpressionId, getLine, getParent, getPrimaryAxis, getSource, getSubExpression, getSubExpressionCount, match, needsReset, setASTNode, setContextDocSet, setContextId, setLocation, setPrimaryAxis, simplify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.exist.xquery.Expression
dump
 

Field Detail

LOG

protected static final org.apache.log4j.Logger LOG

select

protected final Expression select

value

protected final Expression value

lockedDocuments

protected DocumentSet lockedDocuments

modifiedDocuments

protected MutableDocumentSet modifiedDocuments

triggers

protected Int2ObjectHashMap<DocumentTrigger> triggers
Constructor Detail

Modification

public Modification(XQueryContext context,
                    Expression select,
                    Expression value)
Parameters:
context -
Method Detail

getCardinality

public int getCardinality()
Description copied from class: AbstractExpression
The default cardinality is Cardinality.EXACTLY_ONE.

Specified by:
getCardinality in interface Expression
Overrides:
getCardinality in class AbstractExpression

returnsType

public int returnsType()
Description copied from interface: Expression
The static return type of the expression. This method should return one of the type constants defined in class Type. If the return type cannot be determined statically, return Type.ITEM.

Specified by:
returnsType in interface Expression
Specified by:
returnsType in class AbstractExpression

resetState

public void resetState(boolean postOptimization)
Description copied from interface: Expression
Called to inform an expression that it should reset to its initial state. All cached data in the expression object should be dropped. For example, the xmldb:document() function calls this method whenever the input document set has changed.

Specified by:
resetState in interface Expression
Overrides:
resetState in class AbstractExpression

analyze

public void analyze(AnalyzeContextInfo contextInfo)
             throws XPathException
Description copied from interface: Expression
Statically analyze the expression and its subexpressions. During the static analysis phase, the query engine can detect unknown variables and some type errors.

Throws:
XPathException

selectAndLock

protected StoredNode[] selectAndLock(Txn transaction,
                                     Sequence nodes)
                              throws LockException,
                                     PermissionDeniedException,
                                     XPathException,
                                     TriggerException
Acquire a lock on all documents processed by this modification. We have to avoid that node positions change during the operation.

Parameters:
nodes -
Throws:
LockException
TriggerException
PermissionDeniedException
XPathException

deepCopy

protected Sequence deepCopy(Sequence inSeq)
                     throws XPathException
Throws:
XPathException

finishTriggers

protected void finishTriggers(Txn transaction)
                       throws TriggerException
Throws:
TriggerException

unlockDocuments

protected void unlockDocuments()
Release all acquired document locks.


checkFragmentation

public static void checkFragmentation(XQueryContext context,
                                      DocumentSet docs)
                               throws EXistException
Throws:
EXistException

checkFragmentation

public static void checkFragmentation(XQueryContext context,
                                      DocumentSet docs,
                                      int splitCount)
                               throws EXistException
Check if any of the modified documents needs defragmentation. Defragmentation will take place if the number of split pages in the document exceeds the limit defined in the configuration file.

Parameters:
docs -
Throws:
EXistException

getTransaction

public Txn getTransaction()
Gets the Transaction to use for the update (can be batch or individual)

Returns:
The transaction

commitTransaction

public void commitTransaction(Txn transaction)
                       throws TransactionException
Commit's the transaction for the update unless it is a batch update and then the commit is defered

Parameters:
transaction - The Transaction to commit
Throws:
TransactionException