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

Method run

basex-core/src/main/java/org/basex/core/cmd/AQuery.java:53–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51 }
52
53 @Override
54 protected boolean run() {
55 final boolean queryinfo = options.get(MainOptions.QUERYINFO);
56 String error = null;
57 long hits = 0;
58 if(exception != null) {
59 error = Util.message(exception);
60 } else {
61 try {
62 final boolean runquery = options.get(MainOptions.RUNQUERY);
63 final boolean serialize = options.get(MainOptions.SERIALIZE);
64 final boolean optplan = options.get(MainOptions.OPTPLAN);
65 final int runs = Math.max(1, options.get(MainOptions.RUNS));
66 for(int r = 0; r < runs; ++r) {
67 // reuse existing processor instance
68 if(r != 0) {
69 qp = null;
70 popJob();
71 }
72 init(context);
73
74 queryPlan(!optplan);
75 qp.optimize();
76 queryPlan(optplan);
77 if(!runquery) continue;
78
79 final PrintOutput po = r == 0 && serialize ? out : new NullOutput();
80 try(Serializer ser = qp.serializer(po)) {
81 if(maxResults >= 0) {
82 qp.cache(this, maxResults);
83 hits = result.size();
84 result.serialize(ser);
85 if(exception instanceof final QueryException ex) throw ex;
86 if(exception instanceof final JobException ex) throw ex;
87 } else {
88 hits = 0;
89 final Iter iter = qp.iter();
90 for(Item item; (item = iter.next()) != null;) {
91 ser.serialize(item);
92 ++hits;
93 checkStop();
94 }
95 }
96 }
97 qp.close();
98 }
99 } catch(final QueryException | JobException | IOException ex) {
100 exception = ex;
101 error = Util.message(ex);
102 } catch(final StackOverflowError ex) {
103 Util.debug(ex);
104 error = BASEX_OVERFLOW.message();
105 } catch(final RuntimeException ex) {
106 exception = ex;
107 } finally {
108 // close processor after exceptions
109 if(qp != null) qp.close();
110 }

Callers

nothing calls this directly

Calls 15

messageMethod · 0.95
initMethod · 0.95
queryPlanMethod · 0.95
nextMethod · 0.95
debugMethod · 0.95
popJobMethod · 0.80
serializerMethod · 0.80
jcMethod · 0.80
getMethod · 0.65
cacheMethod · 0.65
sizeMethod · 0.65
iterMethod · 0.65

Tested by

no test coverage detected