Class OCommandExecutorSQLResultsetAbstract
java.lang.Object
com.orientechnologies.common.parser.OBaseParser
com.orientechnologies.orient.core.command.OCommandExecutorAbstract
com.orientechnologies.orient.core.sql.OCommandExecutorSQLAbstract
com.orientechnologies.orient.core.sql.OCommandExecutorSQLResultsetAbstract
- All Implemented Interfaces:
OCommandDistributedReplicateRequest,OCommandExecutor,OIterableRecordSource,Iterable<OIdentifiable>
- Direct Known Subclasses:
OCommandExecutorSQLEarlyResultsetAbstract,OCommandExecutorSQLSelect,OCommandExecutorSQLTraverse
public abstract class OCommandExecutorSQLResultsetAbstract
extends OCommandExecutorSQLAbstract
implements OCommandDistributedReplicateRequest, Iterable<OIdentifiable>, OIterableRecordSource
Executes a TRAVERSE crossing records. Returns a List containing all the traversed
records that match the WHERE condition.
SYNTAX: TRAVERSE
In the command context you've access to the variable $depth containing the depth level from
the root node. This is useful to limit the traverse up to a level. For example to consider from
the first depth level (0 is root node) to the third use:
TRAVERSE children FROM #5:23 WHERE $depth BETWEEN 1 AND 3. To filter traversed records use
it combined with a SELECT statement:
SELECT FROM (TRAVERSE children FROM #5:23 WHERE $depth BETWEEN 1 AND 3) WHERE city.name = 'Rome'
- Author:
- Luca Garulli (l.garulli--(at)--orientdb.com)
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.orientechnologies.orient.core.command.OCommandDistributedReplicateRequest
OCommandDistributedReplicateRequest.DISTRIBUTED_EXECUTION_MODE, OCommandDistributedReplicateRequest.DISTRIBUTED_RESULT_MGMT, OCommandDistributedReplicateRequest.QUORUM_TYPE -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected OSQLFilterprotected static final Stringprotected static final Stringprotected booleanprotected OSQLTargetprotected OSQLAsynchQuery<ODocument>protected intprotected AtomicIntegerprotected intprotected Iterator<? extends OIdentifiable>protected Iterable<OIdentifiable>Fields inherited from class com.orientechnologies.orient.core.sql.OCommandExecutorSQLAbstract
CLASS_PREFIX, CLUSTER_PREFIX, DEFAULT_PARAM_USER, DICTIONARY_PREFIX, INDEX_PREFIX, INDEX_VALUES_ASC_PREFIX, INDEX_VALUES_DESC_PREFIX, INDEX_VALUES_PREFIX, KEYWORD_FROM, KEYWORD_KEY, KEYWORD_LET, KEYWORD_LIMIT, KEYWORD_LOCK, KEYWORD_OFFSET, KEYWORD_RETURN, KEYWORD_RID, KEYWORD_SKIP, KEYWORD_TIMEOUT, KEYWORD_UNSAFE, KEYWORD_WHERE, METADATA_DATABASE, METADATA_DISTRIBUTED, METADATA_INDEXMGR, METADATA_PREFIX, METADATA_SCHEMA, METADATA_STORAGE, preParsedStatement, timeoutMs, timeoutStrategyFields inherited from class com.orientechnologies.orient.core.command.OCommandExecutorAbstract
context, limit, parameters, progressListenerFields inherited from class com.orientechnologies.common.parser.OBaseParser
parserText, parserTextUpperCase -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidassignLetClauses(ORecord iRecord) protected booleanassignTarget(Map<Object, Object> iArgs) Assign the right TARGET if found.protected booleanevaluateRecord(ORecord iRecord, OCommandContext iContext) protected booleanfilter(ORecord iRecord, OCommandContext iContext) The command is replicatedReturns how to manage the distributed result between: CHECK_FOR_EQUALS: all results must be the same MERGE: merges results.protected ORID[]getRange()protected Objectprotected ObjectIterator<? extends OIdentifiable>protected booleanhandleResult(OIdentifiable iRecord, OCommandContext iContext) booleanReturns true if the command results can be cached.booleanReturns true if the command doesn't change the database, otherwise false.booleanprotected booleanmergeResults(Map<String, Object> results) protected voidoptimize()Optimizes the condition tree.protected voidoptimizeBranch(OSQLFilterCondition iParentCondition, OSQLFilterCondition iCondition) protected ObjectoptimizeFunction(OSQLFunctionRuntime function) Check function arguments and pre calculate it if possibleparse(OCommandRequest iRequest) Compile the filter conditions only the first time.protected voidparseLet()protected intparseLimit(String w) Parses the limit keyword if found.protected intParses the skip keyword if found.protected booleanpushResult(Object rec) protected voidprotected voidsearchInClasses(boolean iAscendentOrder) protected Iterator<? extends OIdentifiable>searchInClasses(OClass iCls, boolean iPolymorphic, boolean iAscendentOrder) protected voidvoidsetCompiledFilter(OSQLFilter compiledFilter) voidsetLazyIteration(boolean lazyIteration) voidsetParsedTarget(OSQLTarget parsedTarget) voidsetRequest(OSQLAsynchQuery<ODocument> request) voidsetTarget(Iterator<? extends OIdentifiable> target) Methods inherited from class com.orientechnologies.orient.core.sql.OCommandExecutorSQLAbstract
bindDefaultContextVariables, checkClusterAccess, decodeClassName, getInvolvedClustersOfClasses, getInvolvedClustersOfClusters, getInvolvedClustersOfIndex, parseLock, parseTimeout, preParse, throwParsingException, throwParsingException, throwSyntaxErrorExceptionMethods inherited from class com.orientechnologies.orient.core.command.OCommandExecutorAbstract
checkInterruption, checkInterruption, getContext, getDatabase, getDistributedTimeout, getFetchPlan, getInvolvedClusters, getLimit, getParameters, getProgressListener, getSecurityOperationType, getUndoCommand, init, involveSchema, isDistributedExecutingOnLocalNodeFirst, isLocalExecution, setContext, setLimit, setProgressListener, toStringMethods inherited from class com.orientechnologies.common.parser.OBaseParser
getLastWordLength, getSyntax, getWordStatic, nextWord, nextWord, parseOptionalWord, parserGetCurrentChar, parserGetCurrentPosition, parserGetLastSeparator, parserGetLastWord, parserGetPreviousPosition, parserGoBack, parserIsEnded, parserMoveCurrentPosition, parserNextChars, parserNextWord, parserNextWord, parserNextWord, parserOptionalKeyword, parserOptionalWord, parserRequiredKeyword, parserRequiredWord, parserRequiredWord, parserRequiredWord, parserSetCurrentPosition, parserSetEndOfText, parserSetLastSeparator, parserSkipWhiteSpacesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface com.orientechnologies.orient.core.command.OCommandDistributedReplicateRequest
getDistributedTimeout, getQuorumType, getUndoCommand, isDistributedExecutingOnLocalNodeFirstMethods inherited from interface com.orientechnologies.orient.core.command.OCommandExecutor
execute, getSyntaxMethods inherited from interface com.orientechnologies.orient.core.sql.OIterableRecordSource
iterator
-
Field Details
-
KEYWORD_FROM_2FIND
- See Also:
-
KEYWORD_LET_2FIND
- See Also:
-
request
-
parsedTarget
-
compiledFilter
-
let
-
target
-
tempResult
-
resultCount
protected int resultCount -
serialTempRID
-
skip
protected int skip -
lazyIteration
protected boolean lazyIteration
-
-
Constructor Details
-
OCommandExecutorSQLResultsetAbstract
public OCommandExecutorSQLResultsetAbstract()
-
-
Method Details
-
parse
Compile the filter conditions only the first time.- Specified by:
parsein interfaceOCommandExecutor- Parameters:
iRequest- Command request implementation.- Returns:
- See Also:
-
#execute(Map<Object, Object>...)
-
isIdempotent
public boolean isIdempotent()Description copied from interface:OCommandExecutorReturns true if the command doesn't change the database, otherwise false.- Specified by:
isIdempotentin interfaceOCommandExecutor- Overrides:
isIdempotentin classOCommandExecutorSQLAbstract
-
isLazyIteration
public boolean isLazyIteration() -
setLazyIteration
public void setLazyIteration(boolean lazyIteration) -
getDistributedExecutionMode
Description copied from class:OCommandExecutorSQLAbstractThe command is replicated- Specified by:
getDistributedExecutionModein interfaceOCommandDistributedReplicateRequest- Overrides:
getDistributedExecutionModein classOCommandExecutorSQLAbstract
-
getDistributedResultManagement
Description copied from interface:OCommandDistributedReplicateRequestReturns how to manage the distributed result between:- CHECK_FOR_EQUALS: all results must be the same
- MERGE: merges results. This is typically used on sharding
- Specified by:
getDistributedResultManagementin interfaceOCommandDistributedReplicateRequest- Overrides:
getDistributedResultManagementin classOCommandExecutorAbstract
-
assignTarget
Assign the right TARGET if found.- Parameters:
iArgs- Parameters to bind- Returns:
- true if the target has been recognized, otherwise false
-
getResultInstance
-
getResult
-
pushResult
-
handleResult
-
parseLet
protected void parseLet() -
parseLimit
Parses the limit keyword if found.- Parameters:
w-- Returns:
- the limit found as integer, or -1 if no limit is found. -1 means no limits.
- Throws:
OCommandSQLParsingException- if no valid limit has been found
-
parseSkip
Parses the skip keyword if found.- Parameters:
w-- Returns:
- the skip found as integer, or -1 if no skip is found. -1 means no skip.
- Throws:
OCommandSQLParsingException- if no valid skip has been found
-
filter
-
evaluateRecord
-
assignLetClauses
-
searchInClasses
protected void searchInClasses() -
searchInClasses
protected void searchInClasses(boolean iAscendentOrder) -
searchInClasses
protected Iterator<? extends OIdentifiable> searchInClasses(OClass iCls, boolean iPolymorphic, boolean iAscendentOrder) -
isUseCache
protected boolean isUseCache() -
searchInClusters
protected void searchInClusters() -
applyLimitAndSkip
protected void applyLimitAndSkip() -
optimize
protected void optimize()Optimizes the condition tree. -
optimizeFunction
Check function arguments and pre calculate it if possible- Parameters:
function-- Returns:
- optimized function, same function if no change
-
optimizeBranch
-
getRange
-
getTarget
-
setTarget
-
setRequest
-
setParsedTarget
-
setCompiledFilter
-
isCacheable
public boolean isCacheable()Description copied from interface:OCommandExecutorReturns true if the command results can be cached.- Specified by:
isCacheablein interfaceOCommandExecutor- Overrides:
isCacheablein classOCommandExecutorAbstract
-
mergeResults
- Specified by:
mergeResultsin interfaceOCommandExecutor- Overrides:
mergeResultsin classOCommandExecutorAbstract- Throws:
Exception
-