Class OCommandExecutorSQLSelect
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
com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect
- All Implemented Interfaces:
OCommandDistributedReplicateRequest,OCommandExecutor,OIterableRecordSource,OTemporaryRidGenerator,Iterable<OIdentifiable>
- Direct Known Subclasses:
OCommandExecutorSQLLiveSelect
public class OCommandExecutorSQLSelect
extends OCommandExecutorSQLResultsetAbstract
implements OTemporaryRidGenerator
Executes the SQL SELECT statement. the parse() method compiles the query and builds the meta
information needed by the execute(). If the query contains the ORDER BY clause, the results are
temporary collected internally, then ordered and finally returned all together to the listener.
- 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 TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class com.orientechnologies.orient.core.sql.OCommandExecutorSQLResultsetAbstract
compiledFilter, KEYWORD_FROM_2FIND, KEYWORD_LET_2FIND, lazyIteration, let, parsedTarget, request, resultCount, serialTempRID, skip, target, tempResultFields 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 booleanaddResult(OIdentifiable iRecord, OCommandContext iContext) protected booleanassignTarget(Map<Object, Object> iArgs) Assign the right TARGET if found.Execute the requested command parsed previously.protected voidexecuteSearch(Map<Object, Object> iArgs) protected booleanexecuteSearchRecord(OIdentifiable id, OCommandContext iContext, boolean callHooks) protected intextractProjectionNameSubstringEndPosition(String projection) Determine clusters that are used in select operationprotected ORuntimeResultgetProjectionGroup(Object fieldValue, OCommandContext iContext) Returns the quorum type for the command: NONE: no quorum READ: configured Read quorum WRITE: configured Write quorum ALL: all nodesintgetTemporaryRIDCounter(OCommandContext iContext) Returns the temporary RID counter assuring it's unique per query tree.protected booleanhandleResult(OIdentifiable iRecord, OCommandContext iContext) Handles the record in result.booleanvoidbooleanprotected booleaniterator()protected booleanparse(OCommandRequest iRequest) Compile the filter conditions only the first time.protected booleanParses the fetchplan keyword if found.protected voidprotected booleanParses the NOCACHE keyword if found.protected voidprotected intprotected voidprotected voidReport the tip to the profiler and collect it in context to be reported by tools like Studioprotected voidrevertProfiler(OCommandContext iContext, OIndex index, List<Object> keyParams, OIndexDefinition indexDefinition) protected voidrevertSubclassesProfiler(OCommandContext iContext, int num) protected voidvoidsetFetchLimit(int fetchLimit) voidsetFetchPlan(String fetchPlan) voidsetGroupByFields(List<String> groupByFields) voidsetNoCache(boolean noCache) voidsetOrderedFields(List<OPair<String, String>> orderedFields) voidsetParallel(boolean parallel) voidsetProjectionDefinition(Map<String, String> projectionDefinition) voidsetProjections(Map<String, Object> projections) Methods inherited from class com.orientechnologies.orient.core.sql.OCommandExecutorSQLResultsetAbstract
applyLimitAndSkip, assignLetClauses, evaluateRecord, filter, getDistributedExecutionMode, getDistributedResultManagement, getRange, getResult, getResultInstance, getTarget, isCacheable, isIdempotent, isLazyIteration, mergeResults, optimize, optimizeBranch, optimizeFunction, parseLet, parseLimit, parseSkip, pushResult, searchInClasses, searchInClasses, searchInClusters, setCompiledFilter, setLazyIteration, setParsedTarget, setRequest, setTargetMethods 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, getLimit, getParameters, getProgressListener, getSecurityOperationType, getUndoCommand, init, involveSchema, isDistributedExecutingOnLocalNodeFirst, isLocalExecution, setContext, setLimit, setProgressListener, toStringMethods inherited from class com.orientechnologies.common.parser.OBaseParser
getLastWordLength, 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, spliteratorMethods inherited from interface com.orientechnologies.orient.core.command.OCommandDistributedReplicateRequest
getDistributedTimeout, getUndoCommand, isDistributedExecutingOnLocalNodeFirst
-
Field Details
-
KEYWORD_SELECT
- See Also:
-
KEYWORD_ASC
- See Also:
-
KEYWORD_DESC
- See Also:
-
KEYWORD_ORDER
- See Also:
-
KEYWORD_BY
- See Also:
-
KEYWORD_GROUP
- See Also:
-
KEYWORD_UNWIND
- See Also:
-
KEYWORD_FETCHPLAN
- See Also:
-
KEYWORD_NOCACHE
- See Also:
-
KEYWORD_FOREACH
- See Also:
-
-
Constructor Details
-
OCommandExecutorSQLSelect
public OCommandExecutorSQLSelect()
-
-
Method Details
-
hasGroupBy
public boolean hasGroupBy() -
isUseCache
protected boolean isUseCache()- Overrides:
isUseCachein classOCommandExecutorSQLResultsetAbstract
-
parse
Compile the filter conditions only the first time.- Specified by:
parsein interfaceOCommandExecutor- Overrides:
parsein classOCommandExecutorSQLResultsetAbstract- Parameters:
iRequest- Command request implementation.- Returns:
- See Also:
-
#execute(Map<Object, Object>...)
-
getInvolvedClusters
Determine clusters that are used in select operation- Specified by:
getInvolvedClustersin interfaceOCommandExecutor- Overrides:
getInvolvedClustersin classOCommandExecutorAbstract- Returns:
- set of involved cluster names
-
isAnyFunctionAggregates
public boolean isAnyFunctionAggregates()- Returns:
tureif any of the sql functions perform aggregation,falseotherwise
-
iterator
- Specified by:
iteratorin interfaceIterable<OIdentifiable>
-
iterator
- Specified by:
iteratorin interfaceOIterableRecordSource
-
execute
Description copied from interface:OCommandExecutorExecute the requested command parsed previously.- Specified by:
executein interfaceOCommandExecutor- Parameters:
iArgs- Optional variable arguments to pass to the command.- Returns:
- See Also:
-
getProjections
-
getSyntax
- Specified by:
getSyntaxin interfaceOCommandExecutor- Overrides:
getSyntaxin classOBaseParser
-
getFetchPlan
- Specified by:
getFetchPlanin interfaceOCommandExecutor- Overrides:
getFetchPlanin classOCommandExecutorAbstract
-
executeSearch
-
assignTarget
Description copied from class:OCommandExecutorSQLResultsetAbstractAssign the right TARGET if found.- Overrides:
assignTargetin classOCommandExecutorSQLResultsetAbstract- Parameters:
iArgs- Parameters to bind- Returns:
- true if the target has been recognized, otherwise false
-
executeSearchRecord
protected boolean executeSearchRecord(OIdentifiable id, OCommandContext iContext, boolean callHooks) -
handleResult
Handles the record in result.- Overrides:
handleResultin classOCommandExecutorSQLResultsetAbstract- Parameters:
iRecord- Record to handle- Returns:
- false if limit has been reached, otherwise true
-
getTemporaryRIDCounter
Returns the temporary RID counter assuring it's unique per query tree.- Specified by:
getTemporaryRIDCounterin interfaceOTemporaryRidGenerator- Returns:
- Serial as integer
-
addResult
-
reportTip
Report the tip to the profiler and collect it in context to be reported by tools like Studio -
getProjectionGroup
-
parseGroupBy
protected void parseGroupBy() -
parseUnwind
protected void parseUnwind() -
parseOrderBy
protected void parseOrderBy() -
searchInClasses
protected void searchInClasses()- Overrides:
searchInClassesin classOCommandExecutorSQLResultsetAbstract
-
parseProjections
protected int parseProjections() -
createProjectionFromDefinition
-
extractProjectionNameSubstringEndPosition
-
parseFetchplan
Parses the fetchplan keyword if found.- Throws:
OCommandSQLParsingException
-
optimizeExecution
protected boolean optimizeExecution() -
revertSubclassesProfiler
-
revertProfiler
protected void revertProfiler(OCommandContext iContext, OIndex index, List<Object> keyParams, OIndexDefinition indexDefinition) -
parseNoCache
Parses the NOCACHE keyword if found.- Throws:
OCommandSQLParsingException
-
initContext
public void initContext() -
setProjections
-
getProjectionDefinition
-
setProjectionDefinition
-
setOrderedFields
-
setGroupByFields
-
setFetchLimit
public void setFetchLimit(int fetchLimit) -
setFetchPlan
-
setParallel
public void setParallel(boolean parallel) -
setNoCache
public void setNoCache(boolean noCache) -
getQuorumType
Description copied from interface:OCommandDistributedReplicateRequestReturns the quorum type for the command:- NONE: no quorum
- READ: configured Read quorum
- WRITE: configured Write quorum
- ALL: all nodes
- Specified by:
getQuorumTypein interfaceOCommandDistributedReplicateRequest
-