Refine search
public static void set(Symbol symbol, boolean value) { getContext().set(symbol, value) ; } public static void setTrue(Symbol symbol) { getContext().setTrue(symbol) ; }
/** Set strict mode, including expression evaluation */ public static void setStrictMode() { setStrictMode(ARQ.getContext()) ; }
@Override public void start() { ARQ.init(); }
/** Set normal mode, including expression evaluation */ public static void setNormalMode() { SystemARQ.StrictDateTimeFO = false ; SystemARQ.ValueExtensions = true ; SystemARQ.EnableRomanNumerals = false ; setNormalMode(ARQ.getContext()) ; }
/** * Globally switch the default optimizer on and off : * Note that storage subsystems may also be applying * separately controlled optimizations. */ public static void enableOptimizer(boolean state) { enableOptimizer(ARQ.getContext(), state) ; }
@Test public void timeout_22() { String qs = prefix + "SELECT * { ?s ?p ?o }" ; ARQ.getContext().set(ARQ.queryTimeout, "-1") ; try(QueryExecution qExec = QueryExecutionFactory.create(qs, ds)) { ResultSet rs = qExec.execSelect() ; ResultSetFormatter.consume(rs) ; } }
public static NodeValue eval(Expr expr, Binding binding) { Context context = ARQ.getContext().copy() ; context.set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime()) ; FunctionEnv env = new ExecutionContext(context, null, null, null) ; NodeValue r = expr.eval(binding, env) ; return r ; }
@SuppressWarnings("unchecked") @Test public void query_service_context_application_05() { // This test requires us to set that GZip and Deflate are permitted Map<String, Context> serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext); if (serviceContextMap == null) { ARQ.getContext().put(Service.serviceContext, new HashMap<String, Context>()); serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext); } if (serviceContextMap.get(SERVICE) == null) { serviceContextMap.put(SERVICE, new Context(ARQ.getContext())); } Context serviceContext = serviceContextMap.get(SERVICE); try { serviceContext.put(Service.queryCompression, false); Query q = QueryFactory.create("ASK { }"); QueryEngineHTTP engine = QueryExecutionFactory.createServiceRequest(SERVICE, q); Assert.assertNotNull(engine); // Check that no settings were changed Assert.assertEquals(-1, engine.getTimeout1()); Assert.assertEquals(-1, engine.getTimeout2()); Assert.assertFalse(engine.getAllowCompression()); Assert.assertNull(engine.getClient()); } finally { serviceContext.remove(Service.queryCompression); } }
/** * Get server global {@link org.apache.jena.sparql.util.Context}. * * @return {@link org.apache.jena.query.ARQ#getContext()} */ public static Context getContext() { return ARQ.getContext() ; }
@Override public void processArgs(CmdArgModule cmdLine) { if ( cmdLine.getValues(setDecl) == null || cmdLine.getValues(setDecl).size() == 0 ) return; for ( String arg : cmdLine.getValues(setDecl) ) { String[] frags = arg.split("=", 2); if ( frags.length != 2 ) { throw new RuntimeException("Can't split '" + arg + "' -- looking for '=' to separate name and value"); } String symbolName = frags[0]; String value = frags[1]; // Make it a long name. symbolName = MappingRegistry.mapPrefixName(symbolName); Symbol symbol = Symbol.create(symbolName); context.set(symbol, value); } ARQ.getContext().putAll(context); }
ARQ.setStrictMode() ; ARQ.getContext().set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime()) ; FunctionEnv env = new ExecutionContext(ARQ.getContext(), null, null, null) ; NodeValue r = expr.eval(null, env) ;
public static DescribeHandlerRegistry get(Context context) { if ( context == null ) return null ; return (DescribeHandlerRegistry)ARQ.getContext().get(ARQConstants.registryDescribeHandlers) ; }
private static Context setupContext(Context context, DatasetGraph dataset) { // To many copies? if ( context == null ) // Copy of global context to protect against change. context = ARQ.getContext() ; context = context.copy() ; if ( dataset.getContext() != null ) context.putAll(dataset.getContext()) ; context.set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime()) ; return context ; } }
/** Set execution logging - logging is to logger "org.apache.jena.arq.exec" at level INFO. * An appropriate logging configuration is also required. */ public static void setExecutionLogging(Explain.InfoLevel infoLevel) { if ( InfoLevel.NONE.equals(infoLevel) ) { ARQ.getContext().unset(ARQ.symLogExec) ; return ; } ARQ.getContext().set(ARQ.symLogExec, infoLevel) ; // if ( ! getExecLogger().isInfoEnabled() ) // getExecLogger().warn("Attempt to enable execution logging but the logger '"+logExecName+"' is not logging at level INFO") ; }
/** Setup a context using another context and a dataset. * This adds the current time. */ public static Context setupContextExec(Context globalContext, DatasetGraph dataset) { if ( globalContext == null ) globalContext = ARQ.getContext(); // Copy per-dataset settings. Context dsgCxt = ( dataset != null && dataset.getContext() != null ) ? dataset.getContext() : null; Context context = mergeCopy(globalContext, dsgCxt); context.set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime()) ; // Allocators. // context.set(ARQConstants.sysVarAllocNamed, new VarAlloc(ARQConstants.allocVarMarkerExec)) ; // context.set(ARQConstants.sysVarAllocAnon, new VarAlloc(ARQConstants.allocVarAnonMarkerExec)) ; // Add VarAlloc for variables and bNodes (this is not the parse name). // More added later e.g. query (if there is a query), algebra form (in setOp) return context; }
@Test public void uniontxn_global_r() { ARQ.getContext().setTrue(TDB.symUnionDefaultGraph) ; test(ReadWrite.READ) ; ARQ.getContext().unset(TDB.symUnionDefaultGraph) ; }
/** Merge an outer (global) and local context to produce a new context * The new context is always a separate copy. */ public static Context mergeCopy(Context contextGlobal, Context contextLocal) { if ( contextGlobal == null ) contextGlobal = ARQ.getContext(); Context context = contextGlobal.copy(); if ( contextLocal != null ) // Copy per-dataset settings. context.putAll(contextLocal); return context ; }
/** * Create a new generator * @param context Context */ public AlgebraGenerator(Context context) { this (context != null ? context : ARQ.getContext().copy(), 0) ; }
/** * Gets the HTTP client that is being used, may be null if no request has yet been made * @return HTTP Client or null */ public HttpClient getClient() { Context arqContext = ARQ.getContext(); if (arqContext.isDefined(Service.serviceContext)) { @SuppressWarnings("unchecked") Map<String, Context> context = (Map<String, Context>) arqContext.get(Service.serviceContext); if (context.containsKey(serviceURL)) { Context serviceContext = context.get(serviceURL); if (serviceContext.isDefined(Service.queryClient)) return serviceContext.get(Service.queryClient); } } return client; }
@Test public void query_service_context_application_01() { // This test requires no service context to be set @SuppressWarnings("unchecked") Map<String, Context> serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext); if (serviceContextMap != null) { serviceContextMap.remove(SERVICE); } Query q = QueryFactory.create("ASK { }"); QueryEngineHTTP engine = QueryExecutionFactory.createServiceRequest(SERVICE, q); Assert.assertNotNull(engine); // Check that no settings were changed Assert.assertEquals(-1, engine.getTimeout1()); Assert.assertEquals(-1, engine.getTimeout2()); Assert.assertTrue(engine.getAllowCompression()); Assert.assertNull(engine.getClient()); }