@ Override @ SuppressWarnings ( { "ThrowableInstanceNeverThrown" , "unchecked" } ) public void execute ( FunctionContext functionContext ) { ResultSender < Serializable > resultSender = functionContext . getResultSender ( ) ; RegionFunctionContext regionFunctionContext = ( RegionFunctionContext ) functionContext ; if ( functionContext . getArguments ( ) == null ) { handleException ( new FunctionException ( "You must specify function argument for query execution." ) , resultSender , null ) ; return ; } if ( ! ( functionContext . getArguments ( ) instanceof BucketOrientedQueryFunctionArgument ) ) { handleException ( new FunctionException ( "Function arguments must be of type " + BucketOrientedQueryFunctionArgument . class . getName ( ) + "." ) , resultSender , null ) ; return ; } BucketOrientedQueryFunctionArgument argument = ( BucketOrientedQueryFunctionArgument ) functionContext . getArguments ( ) ; LocalDataSet localData = ( LocalDataSet ) PartitionRegionHelper . getLocalDataForContext ( regionFunctionContext ) ; QueryService queryService = localData . getCache ( ) . getQueryService ( ) ; String queryStr = argument . getQueryString ( ) ; try { Query query = queryService . newQuery ( queryStr ) ; SelectResults < ? > result = ( SelectResults < ? > ) localData . executeQuery ( ( DefaultQuery ) query , argument . getQueryParameters ( ) , localData . getBucketSet ( ) ) ; resultSender . lastResult ( ( Serializable ) formatResults ( result ) ) ; } catch ( Exception e ) { handleException ( e , resultSender , queryStr ) ; } }
Executes query using arguments query string and query parameters .