Package com.arcadedb.query.sql.executor
Class BasicCommandContext
- java.lang.Object
-
- com.arcadedb.query.sql.executor.BasicCommandContext
-
- All Implemented Interfaces:
CommandContext
public class BasicCommandContext extends Object implements CommandContext
Basic implementation of OCommandContext interface that stores variables in a map. Supports parent/child context to build a tree of contexts. If a variable is not found on current object the search is applied recursively on child contexts.- Author:
- Luca Garulli (l.garulli--(at)--gmail.com)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.arcadedb.query.sql.executor.CommandContext
CommandContext.TIMEOUT_STRATEGY
-
-
Field Summary
Fields Modifier and Type Field Description protected CommandContext
child
protected DatabaseInternal
database
protected Set<String>
declaredScriptVariables
protected Map<String,Object>
inputParameters
protected CommandContext
parent
protected boolean
recordMetrics
protected AtomicLong
resultsProcessed
protected Map<String,Object>
variables
-
Constructor Summary
Constructors Constructor Description BasicCommandContext()
-
Method Summary
-
-
-
Field Detail
-
database
protected DatabaseInternal database
-
recordMetrics
protected boolean recordMetrics
-
parent
protected CommandContext parent
-
child
protected CommandContext child
-
resultsProcessed
protected final AtomicLong resultsProcessed
-
-
Method Detail
-
getVariable
public Object getVariable(String iName)
- Specified by:
getVariable
in interfaceCommandContext
-
getVariable
public Object getVariable(String iName, Object iDefault)
- Specified by:
getVariable
in interfaceCommandContext
-
setVariable
public CommandContext setVariable(String iName, Object iValue)
- Specified by:
setVariable
in interfaceCommandContext
-
incrementVariable
public CommandContext incrementVariable(String iName)
- Specified by:
incrementVariable
in interfaceCommandContext
-
updateMetric
public long updateMetric(String iName, long iValue)
Description copied from interface:CommandContext
Updates a counter. Used to record metrics.- Specified by:
updateMetric
in interfaceCommandContext
- Parameters:
iName
- Metric's nameiValue
- delta to add or subtract- Returns:
-
getVariables
public Map<String,Object> getVariables()
Returns a read-only map with all the variables.- Specified by:
getVariables
in interfaceCommandContext
-
setChild
public CommandContext setChild(CommandContext iContext)
Set the inherited context avoid to copying all the values every time.- Specified by:
setChild
in interfaceCommandContext
-
getParent
public CommandContext getParent()
- Specified by:
getParent
in interfaceCommandContext
-
setParent
public CommandContext setParent(CommandContext iParentContext)
- Specified by:
setParent
in interfaceCommandContext
-
setParentWithoutOverridingChild
public CommandContext setParentWithoutOverridingChild(CommandContext iParentContext)
-
isRecordingMetrics
public boolean isRecordingMetrics()
- Specified by:
isRecordingMetrics
in interfaceCommandContext
-
setRecordingMetrics
public CommandContext setRecordingMetrics(boolean recordMetrics)
- Specified by:
setRecordingMetrics
in interfaceCommandContext
-
beginExecution
public void beginExecution(long iTimeout, CommandContext.TIMEOUT_STRATEGY iStrategy)
- Specified by:
beginExecution
in interfaceCommandContext
-
checkTimeout
public boolean checkTimeout()
Description copied from interface:CommandContext
Check if timeout is elapsed, if defined.- Specified by:
checkTimeout
in interfaceCommandContext
- Returns:
- false if it the timeout is elapsed and strategy is "return" if the strategy is "exception" (default)
-
copy
public CommandContext copy()
Description copied from interface:CommandContext
Creates a copy of execution context.- Specified by:
copy
in interfaceCommandContext
-
getInputParameters
public Map<String,Object> getInputParameters()
- Specified by:
getInputParameters
in interfaceCommandContext
-
setInputParameters
public void setInputParameters(Map<String,Object> inputParameters)
- Specified by:
setInputParameters
in interfaceCommandContext
-
setInputParameters
public void setInputParameters(Object[] args)
-
getResultsProcessed
public AtomicLong getResultsProcessed()
Returns the number of results processed. This is intended to be used with LIMIT in SQL statements
-
getDatabase
public DatabaseInternal getDatabase()
- Specified by:
getDatabase
in interfaceCommandContext
-
setDatabase
public void setDatabase(Database database)
-
getLowerIndexOf
public static int getLowerIndexOf(String iText, int iBeginOffset, String... iToSearch)
-
getHigherIndexOf
public static int getHigherIndexOf(String iText, int iBeginOffset, String... iToSearch)
-
declareScriptVariable
public void declareScriptVariable(String varName)
- Specified by:
declareScriptVariable
in interfaceCommandContext
-
isScriptVariableDeclared
public boolean isScriptVariableDeclared(String varName)
- Specified by:
isScriptVariableDeclared
in interfaceCommandContext
-
-