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

Method pathStats

basex-core/src/main/java/org/basex/query/expr/path/Path.java:399–420  ·  view source on GitHub ↗

Returns database statistics for the path nodes that will result from this path. @return statistics or null

()

Source from the content-addressed store, hash-verified

397 * @return statistics or {@code null}
398 */
399 public ArrayList<Stats> pathStats() {
400 final ArrayList<PathNode> nodes = pathNodes(root, true);
401 if(nodes == null) return null;
402
403 // loop through all nodes
404 final ArrayList<Stats> stats = new ArrayList<>();
405 for(PathNode node : nodes) {
406 // retrieve text child if addressed node is an element
407 if(node.kind == Data.ELEM) {
408 if(!node.stats.isLeaf()) return null;
409 for(final PathNode nd : node.children) {
410 if(nd.kind == Data.TEXT) node = nd;
411 }
412 }
413 // skip nodes others than texts and attributes
414 // check if distinct values are available
415 final int kind = node.kind;
416 if(kind != Data.TEXT && kind != Data.ATTR) return null;
417 stats.add(node.stats);
418 }
419 return stats;
420 }
421
422 /**
423 * Checks if the path contains empty steps.

Callers 3

optMethod · 0.80
optStatsMethod · 0.80
optMethod · 0.80

Calls 3

pathNodesMethod · 0.95
addMethod · 0.65
isLeafMethod · 0.45

Tested by

no test coverage detected