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

Method key

basex-core/src/main/java/org/basex/query/expr/CmpR.java:259–282  ·  view source on GitHub ↗

Retrieves the statistics key for the element/attribute name. @param ii index info @param type index type @return key, or null if statistics are not available

(final IndexInfo ii, final IndexType type)

Source from the content-addressed store, hash-verified

257 * @return key, or {@code null} if statistics are not available
258 */
259 private Stats key(final IndexInfo ii, final IndexType type) {
260 // statistics are not up-to-date
261 final Data data = ii.db.data();
262 if(data == null || !data.meta.uptodate || !data.nspaces.isEmpty() ||
263 !(expr instanceof final AxisPath path)) return null;
264
265 NameTest test = ii.test;
266 if(test == null) {
267 final Step step;
268 final int st = path.steps.length - 1;
269 if(type == IndexType.TEXT) {
270 step = st == 0 ? ii.step : path.step(st - 1);
271 } else {
272 step = path.step(st);
273 if(step.axis != Axis.ATTRIBUTE || step.exprs.length > 0) return null;
274 }
275 if(!(step.test instanceof final NameTest nt) || nt.name == null) return null;
276 test = nt;
277 }
278
279 final Names names = type == IndexType.TEXT ? data.elemNames : data.attrNames;
280 final Stats stats = names.stats(names.index(test.qname.local()));
281 return stats != null && StatsType.isNumeric(stats.type) ? stats : null;
282 }
283
284 @Override
285 public Expr copy(final CompileContext cc, final IntObjectMap<Var> vm) {

Callers 6

indexAccessibleMethod · 0.95
toStringMethod · 0.45
optimizeMethod · 0.45
toStringMethod · 0.45
flattenMethod · 0.45
childrenMethod · 0.45

Calls 7

statsMethod · 0.95
isNumericMethod · 0.95
indexMethod · 0.65
dataMethod · 0.45
isEmptyMethod · 0.45
stepMethod · 0.45
localMethod · 0.45

Tested by

no test coverage detected