@Override public void setTimeout(long timeout1, TimeUnit timeUnit1, long timeout2, TimeUnit timeUnit2) { // Two timeouts. long x1 = asMillis(timeout1, timeUnit1) ; long x2 = asMillis(timeout2, timeUnit2) ; this.timeout1 = x1 ; if ( timeout2 < 0 ) this.timeout2 = TIMEOUT_UNSET ; else this.timeout2 = x2 ; }
private ResultSet execResultSet() { startQueryIterator() ; return asResultSet(queryIterator) ; }
public boolean execAsk() { if ( ! query.isAskType() ) throw new QueryExecException("Attempt to have boolean from a "+labelForQuery(query)+" query") ; startQueryIterator() ; boolean r = queryIterator.hasNext() ; this.close() ; return r ; }
private void startQueryIterator() { execInit() ; if ( queryIterator != null ) Log.warn(this, "Query iterator has already been started") ; initTimeout1() ; // We don't know if getPlan().iterator() does a lot of work or not // (ideally it shouldn't start executing the query but in some sub-systems // it might be necessary) queryIterator = getPlan().iterator() ; // Add the second timeout wrapper. queryIterator = initTimeout2(queryIterator) ; if ( cancel ) queryIterator.cancel() ; }
public Model execDescribe(Model model) throw new QueryExecException("Attempt to get a DESCRIBE result from a "+labelForQuery(query)+" query") ; ResultSet qRes = execResultSet() ; insertPrefixesInto(model) ; if ( qRes != null ) this.close() ; getContext().put(ARQConstants.sysCurrentDataset, getDataset()) ; dh.start(model, getContext()) ; dh.finish() ; this.close() ; return model ;
public Model execConstruct(Model model) throw new QueryExecException("Attempt to get a CONSTRUCT model from a "+labelForQuery(query)+" query") ; startQueryIterator() ; insertPrefixesInto(model) ; Template template = query.getConstructTemplate() ; this.close() ; return model ;
protected static QueryExecution make(Query query, Dataset dataset, Context context) { query.setResultVars() ; if ( context == null ) context = ARQ.getContext(); // .copy done in QueryExecutionBase -> Context.setupContext. DatasetGraph dsg = null ; if ( dataset != null ) dsg = dataset.asDatasetGraph() ; QueryEngineFactory f = findFactory(query, dsg, context); if ( f == null ) { Log.warn(QueryExecutionFactory.class, "Failed to find a QueryEngineFactory for query: "+query) ; return null ; } return new QueryExecutionBase(query, dataset, context, f) ; }
@Override public Model execConstruct(Model model) { try { Iterator<Triple> it = execConstructTriples(); // Prefixes for result insertPrefixesInto(model); while (it.hasNext()) { Triple t = it.next(); Statement stmt = ModelUtils.tripleToStatement(model, t); if ( stmt != null ) model.add(stmt); } } finally { this.close(); } return model; }
execInit() ; if ( queryIterator != null ) Log.warn(this, "Query iterator has already been started") ; if ( ! isTimeoutSet(timeout1) && ! isTimeoutSet(timeout2) ) queryIterator = getPlan().iterator() ; return ; if ( ! isTimeoutSet(timeout1) && isTimeoutSet(timeout2) ) alarmClock.add(timeout2Callback, timeout2) ; queryIterator = getPlan().iterator() ; queryIterator = getPlan().iterator() ;
public ResultSet execSelect() { if ( ! query.isSelectType() ) throw new QueryExecException("Attempt to have ResultSet from a "+labelForQuery(query)+" query") ; return execResultSet() ; }
public Plan getPlan() { if ( plan == null ) { DatasetGraph dsg = prepareDataset(dataset, query, fileManager) ; Binding inputBinding = null ; if ( initialBinding != null ) inputBinding = BindingUtils.asBinding(initialBinding) ; if ( inputBinding == null ) inputBinding = BindingRoot.create() ; plan = qeFactory.create(query, dsg, inputBinding, getContext()) ; } return plan ; }
@Override public Model execDescribe() { return execDescribe(GraphFactory.makeJenaDefaultModel()) ; }
@Override public Model execConstruct() { return execConstruct(GraphFactory.makeJenaDefaultModel()) ; }
throw new QueryExecException("Attempt to get a DESCRIBE result from a "+labelForQuery(query)+" query") ; ResultSet qRes = execResultSet() ; insertPrefixesInto(model) ; if ( qRes != null ) getContext().put(ARQConstants.sysCurrentDataset, getDataset()) ; dh.start(model, getContext()) ; dh.finish() ; this.close() ; return model ;
static private QueryExecution make(Query query, Dataset dataset, Context context) { query.setResultVars() ; if ( context == null ) context = ARQ.getContext().copy(); // .copy probably not necessary but safe. DatasetGraph dsg = null ; if ( dataset != null ) dsg = dataset.asDatasetGraph() ; QueryEngineFactory f = findFactory(query, dsg, context); if ( f == null ) { Log.warn(QueryExecutionFactory.class, "Failed to find a QueryEngineFactory for query: "+query) ; return null ; } return new QueryExecutionBase(query, dataset, context, f) ; }
@Override public ResultSet execSelect() { if ( ! query.isSelectType() ) throw new QueryExecException("Attempt to have ResultSet from a "+labelForQuery(query)+" query") ; return execResultSet() ; }
public Plan getPlan() { if ( plan == null ) { DatasetGraph dsg = prepareDataset(dataset, query, fileManager) ; Binding inputBinding = null ; if ( initialBinding != null ) { inputBinding = new BindingMap() ; BindingUtils.addToBinding(inputBinding, initialBinding) ; } if ( inputBinding == null ) inputBinding = BindingRoot.create() ; plan = qeFactory.create(query, dsg, inputBinding, getContext()) ; } return plan ; }
public Model execDescribe() { return execDescribe(GraphFactory.makeJenaDefaultModel()) ; }
public Model execConstruct() { return execConstruct(GraphFactory.makeJenaDefaultModel()) ; }
@Override public boolean execAsk() { if ( ! query.isAskType() ) throw new QueryExecException("Attempt to have boolean from a "+labelForQuery(query)+" query") ; startQueryIterator() ; boolean r = queryIterator.hasNext() ; this.close() ; return r ; }