MCPcopy Create free account
hub / github.com/BaseXdb/basex / eval

Method eval

basex-core/src/main/java/org/basex/query/func/job/JobEval.java:37–70  ·  view source on GitHub ↗

Evaluates a query as job. @param query query @param options job options @param qc query context @return resulting value @throws QueryException query exception

(final IOContent query, final JobOptions options, final QueryContext qc)

Source from the content-addressed store, hash-verified

35 * @throws QueryException query exception
36 */
37 final Str eval(final IOContent query, final JobOptions options, final QueryContext qc)
38 throws QueryException {
39
40 final HashMap<String, Value> bindings = toBindings(arg(1), qc);
41 options.set(JobOptions.BASE_URI, toBaseUri(query.url(), options, JobOptions.BASE_URI));
42
43 final boolean service = Boolean.TRUE.equals(options.get(JobOptions.SERVICE));
44 if(service) {
45 if(!bindings.isEmpty()) throw JOBS_SERVICE.get(info);
46 // invalidate option (not relevant for next steps, i.e., if services are written to disk)
47 options.put(JobOptions.SERVICE, null);
48 }
49
50 // copy variable values
51 for(final Entry<String, Value> it : bindings.entrySet()) {
52 bindings.put(it.getKey(), it.getValue().materialize(n -> false, info, qc));
53 }
54
55 final QueryJobSpec spec = new QueryJobSpec(options, bindings, query);
56 final QueryJob job = new QueryJob(spec, qc.context, info, null);
57
58 // add service
59 if(service) {
60 if(!bindings.isEmpty()) throw JOBS_SERVICE.get(info);
61 try {
62 final Jobs jobs = new Jobs(qc.context);
63 jobs.add(spec);
64 jobs.write();
65 } catch(final IOException ex) {
66 throw JOBS_SERVICE_X_X.get(info, ex);
67 }
68 }
69 return Str.get(job.jc().id());
70 }
71}

Callers 1

itemMethod · 0.95

Calls 15

addMethod · 0.95
writeMethod · 0.95
getMethod · 0.95
toBindingsMethod · 0.80
toBaseUriMethod · 0.80
getKeyMethod · 0.80
jcMethod · 0.80
setMethod · 0.65
getMethod · 0.65
idMethod · 0.65
argMethod · 0.45
urlMethod · 0.45

Tested by

no test coverage detected