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

Method dist

basex-core/src/main/java/org/basex/data/Data.java:331–343  ·  view source on GitHub ↗

Returns the distance of the specified node. @param pre PRE value @param kind node kind @return distance

(final int pre, final int kind)

Source from the content-addressed store, hash-verified

329 * @return distance
330 */
331 public final int dist(final int pre, final int kind) {
332 return switch(kind) {
333 case ELEM -> table.read4(pre, 4);
334 case TEXT, COMM, PI -> table.read4(pre, 8);
335 case ATTR -> {
336 int d = table.read1(pre, 0) >> 3 & IO.MAXATTS;
337 // skip additional attributes if value is larger than maximum range
338 if(d == IO.MAXATTS) while(d < pre && kind(pre - d) == ATTR) d++;
339 yield d;
340 }
341 default -> pre + 1;
342 };
343 }
344
345 /**
346 * Returns the size value (number of descendant table entries).

Callers 5

parentMethod · 0.95
updateDistMethod · 0.95
lazyReplaceMethod · 0.95
adjustDistancesMethod · 0.80
calculateNewDistanceMethod · 0.80

Calls 5

kindMethod · 0.95
read4Method · 0.45
read1Method · 0.45
write1Method · 0.45
write4Method · 0.45

Tested by

no test coverage detected