Interface OSQLFunction
- All Known Subinterfaces:
OIndexableSQLFunction,OSQLFunctionFiltered
- All Known Implementing Classes:
KillQueryFunction,KillSessionFunction,ListQueriesFunction,ListSessionsFunction,ODatabaseFunction,OLuceneCrossClassSearchFunction,OLuceneSearchFunctionTemplate,OLuceneSearchMoreLikeThisFunction,OLuceneSearchOnClassFunction,OLuceneSearchOnFieldsFunction,OLuceneSearchOnIndexFunction,OSpatialFunctionAbstract,OSpatialFunctionAbstractIndexable,OSQLEnterpriseFunction,OSQLFunctionAbsoluteValue,OSQLFunctionAbstract,OSQLFunctionAstar,OSQLFunctionAverage,OSQLFunctionBoth,OSQLFunctionBothE,OSQLFunctionBothV,OSQLFunctionCoalesce,OSQLFunctionConcat,OSQLFunctionConfigurableAbstract,OSQLFunctionCount,OSQLFunctionDate,OSQLFunctionDecimal,OSQLFunctionDecode,OSQLFunctionDifference,OSQLFunctionDijkstra,OSQLFunctionDistance,OSQLFunctionDistinct,OSQLFunctionDocument,OSQLFunctionEncode,OSQLFunctionEval,OSQLFunctionFirst,OSQLFunctionFormat,OSQLFunctionFormat,OSQLFunctionHeuristicPathFinderAbstract,OSQLFunctionIf,OSQLFunctionIfNull,OSQLFunctionIn,OSQLFunctionIndexKeySize,OSQLFunctionInE,OSQLFunctionIntersect,OSQLFunctionInterval,OSQLFunctionInV,OSQLFunctionLast,OSQLFunctionList,OSQLFunctionMap,OSQLFunctionMathAbstract,OSQLFunctionMax,OSQLFunctionMedian,OSQLFunctionMin,OSQLFunctionMode,OSQLFunctionMove,OSQLFunctionMoveFiltered,OSQLFunctionMultiValueAbstract,OSQLFunctionOut,OSQLFunctionOutE,OSQLFunctionOutV,OSQLFunctionPathFinder,OSQLFunctionPercentile,OSQLFunctionSequence,OSQLFunctionSet,OSQLFunctionShortestPath,OSQLFunctionStandardDeviation,OSQLFunctionStrcmpci,OSQLFunctionSum,OSQLFunctionSymmetricDifference,OSQLFunctionSysdate,OSQLFunctionThrowCME,OSQLFunctionTraversedEdge,OSQLFunctionTraversedElement,OSQLFunctionTraversedVertex,OSQLFunctionUnionAll,OSQLFunctionUUID,OSQLFunctionVariance,OSQLStaticReflectiveFunction,OSTAsBinaryFunction,OSTAsGeoJSONFunction,OSTAsTextFunction,OSTBufferFunction,OSTContainsFunction,OSTDisjointFunction,OSTDistanceFunction,OSTDistanceSphereFunction,OSTDWithinFunction,OSTEnvelopFunction,OSTEqualsFunction,OSTGeomFromGeoJSONFunction,OSTGeomFromTextFunction,OSTIntersectsFunction,OSTSrid,OSTWithinFunction
public interface OSQLFunction
Interface that defines a SQL Function. Functions can be state-less if registered as instance, or
state-full when registered as class. State-less function are reused across queries, so don't keep
any run-time information inside of it. State-full function, instead, stores Implement it and
register it with:
OSQLParser.getInstance().registerFunction() to being used by the
SQL engine.
??? could it be possible to have a small piece of code here showing where to register a function using services ???
- Author:
- Luca Garulli (l.garulli--(at)--orientdb.com)
-
Method Summary
Modifier and TypeMethodDescriptionbooleanA function can make calculation on several records before returning a result.voidConfigure the function.execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] iParams, OCommandContext iContext) Process a record.booleanA function can act both as transformation or filtering records.intMaximum number of parameter this function can handle.intMinimum number of parameter this function must have.getName()Function name, the name is used by the sql parser to identify a call this function.getResult(OCommandContext ctx) Only called when function aggregates results after all records have been passed to the function.Returns a convenient SQL String representation of the function.mergeDistributedResult(List<Object> resultsToMerge) This method correspond to distributed query executionvoidCalled by OCommandExecutor, given parameter is the number of results. ???booleanThis method correspond to distributed query execution
-
Method Details
-
execute
Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] iParams, OCommandContext iContext) Process a record.- Parameters:
iThis-iCurrentRecord- : current recordiCurrentResult- TODOiParams- : function parameters, number is ensured to be within minParams and maxParams.iContext- : object calling this function- Returns:
- function result, can be null. Special cases : can be null if function aggregate results, can be null if function filter results : this mean result is excluded
-
config
Configure the function.- Parameters:
configuredParameters-
-
aggregateResults
boolean aggregateResults()A function can make calculation on several records before returning a result.Example of such function : sum, count, max, min ...
The final result of the aggregation is obtain by calling
getResult(OCommandContext)- Returns:
- true if function aggregate results
-
filterResult
boolean filterResult()A function can act both as transformation or filtering records. If the function may reduce the number final records than it must return true.Function should return null for the execute method if the record must be excluded.
- Returns:
- true if the function acts as a record filter.
-
getName
String getName()Function name, the name is used by the sql parser to identify a call this function.- Returns:
- String , function name, never null or empty.
-
getMinParams
int getMinParams()Minimum number of parameter this function must have.- Returns:
- minimum number of parameters
-
getMaxParams
int getMaxParams()Maximum number of parameter this function can handle.- Returns:
- maximum number of parameters ??? -1 , negative or Integer.MAX_VALUE for unlimited ???
-
getSyntax
String getSyntax()Returns a convenient SQL String representation of the function.Example :
myFunction( param1, param2, [optionalParam3])
This text will be used in exception messages.
- Returns:
- String , never null.
-
getResult
Only called when function aggregates results after all records have been passed to the function.- Parameters:
ctx- TODOctx-- Returns:
- Aggregation result
-
setResult
Called by OCommandExecutor, given parameter is the number of results. ??? strange ???- Parameters:
iResult-
-
shouldMergeDistributedResult
boolean shouldMergeDistributedResult()This method correspond to distributed query execution- Returns:
trueif results that comes from different nodes need to be merged to obtain valid one,falseotherwise
-
mergeDistributedResult
This method correspond to distributed query execution- Parameters:
resultsToMerge- is the results that comes from different nodes- Returns:
- is the valid merged result
-