private < R extends OBDAResultSet , Q extends InputQuery < R > > R executeInThread ( Q inputQuery , Evaluator < R , Q > evaluator ) throws OntopReformulationException , OntopQueryEvaluationException { log . debug ( "Executing SPARQL query: \n{}" , inputQuery ) ; CountDownLatch monitor = new CountDownLatch ( 1 ) ; ExecutableQuery executableQuery = engine . reformulateIntoNativeQuery ( inputQuery ) ; QueryExecutionThread < R , Q > executionthread = new QueryExecutionThread <> ( inputQuery , executableQuery , evaluator , monitor ) ; this . executionThread = executionthread ; executionthread . start ( ) ; try { monitor . await ( ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } if ( executionthread . errorStatus ( ) ) { Exception ex = executionthread . getException ( ) ; if ( ex instanceof OntopReformulationException ) { throw ( OntopReformulationException ) ex ; } else if ( ex instanceof OntopQueryEvaluationException ) { throw ( OntopQueryEvaluationException ) ex ; } else { throw new OntopQueryEvaluationException ( ex ) ; } } if ( canceled ) { canceled = false ; throw new OntopQueryEvaluationException ( "Query execution was cancelled" ) ; } return executionthread . getResultSet ( ) ; }
Internal method to start a new query execution thread type defines the query type SELECT ASK CONSTRUCT or DESCRIBE