@Override public boolean hasNoChildren() { //Passing max as 1 so as to minimize any overhead. return delegate.getChildNodeCount(1) == 0; }
@Override public boolean hasNoChildren() { //Passing max as 1 so as to minimize any overhead. return delegate.getChildNodeCount(1) == 0; }
@Override public long getChildNodeCount(long max) { return delegate.getChildNodeCount(max); }
@Override public long getChildNodeCount(long max) { return state.getChildNodeCount(max); }
private byte cost(NodeState node) { long childCount = node.getChildNodeCount(Long.MAX_VALUE); return (byte) (Byte.MIN_VALUE + 64 - numberOfLeadingZeros(childCount)); }
public boolean equals(Object object) { if (object == EMPTY_NODE || object == MISSING_NODE) { return exists == (object == EMPTY_NODE); } else if (object instanceof NodeState) { NodeState that = (NodeState) object; return that.getPropertyCount() == 0 && that.getChildNodeCount(1) == 0 && (exists == that.exists()); } else { return false; } }
public boolean equals(Object object) { if (object == EMPTY_NODE || object == MISSING_NODE) { return exists == (object == EMPTY_NODE); } else if (object instanceof NodeState) { NodeState that = (NodeState) object; return that.getPropertyCount() == 0 && that.getChildNodeCount(1) == 0 && (exists == that.exists()); } else { return false; } }
@Override public long getChildNodeCount(long max) { return head().getCurrentNodeState().getChildNodeCount(max); }
@Override public long getChildNodeCount(long max) { return head().getCurrentNodeState().getChildNodeCount(max); }
@Test public void testGetChildNodeCount() { assertEquals(3, state.getChildNodeCount(4)); }
@Test public void testGetChildNodeCount() { assertEquals(N + 1, state.getChildNodeCount(N + 2)); }
private NodeState randomStep(NodeState parent, NodeState node) { int count = (int) node.getChildNodeCount(Long.MAX_VALUE); int k = rnd.nextInt(count + 1); if (k == 0) { return parent; } else { String name = get(node.getChildNodeNames(), k - 1); return node.getChildNode(name); } }
@Test public void mixedMountsChildNodes() { assertThat("root(childCount)", store.getRoot().getChildNodeCount(100), equalTo(4l)); }
@Test public void childNodeEntryForMountIsComposite() { ChildNodeEntry libsNode = Iterables.find(store.getRoot().getChildNodeEntries(), new Predicate<ChildNodeEntry>() { @Override public boolean apply(ChildNodeEntry input) { return input.getName().equals("libs"); } }); assertThat("root.libs(childCount)", libsNode.getNodeState().getChildNodeCount(10), equalTo(3l)); }
@Test public void nestedMountNodeIsVisible() { assertThat("root.libs(childCount)", store.getRoot().getChildNode("libs").getChildNodeCount(10), equalTo(3l)); }
@Test public void getRoot() { NodeState root = store.getRoot(); assertEquals(0, root.getChildNodeCount(1)); }
@Test public void childrenUnderMountAreFound() { assertThat("root.tmp(childCount)", store.getRoot().getChildNode("tmp").getChildNodeCount(10), equalTo(2l)); }
@Test public void noVersionStoragePrePopulated() throws Exception { // default initial content does not have intermediate nodes // pre-populated NodeState system = INITIAL_CONTENT.getChildNode(JCR_SYSTEM); assertTrue(system.exists()); NodeState vs = system.getChildNode(JCR_VERSIONSTORAGE); assertTrue(vs.exists()); assertTrue(vs.getChildNodeCount(Integer.MAX_VALUE) == 0); }
@Test public void mergeExisting_Aggregates() throws Exception{ builder.aggregateRule("foo").include("/path1"); builder.aggregateRule("foo").include("/path2"); nodeBuilder = builder.build().builder(); builder = new IndexDefinitionBuilder(nodeBuilder); builder.aggregateRule("foo").include("/path1"); builder.aggregateRule("foo").include("/path3"); NodeState state = builder.build(); assertEquals(3, state.getChildNode(AGGREGATES).getChildNode("foo").getChildNodeCount(100)); }
@Test public void mergeExisting_Aggregates() throws Exception{ builder.aggregateRule("foo").include("/path1"); builder.aggregateRule("foo").include("/path2"); nodeBuilder = builder.build().builder(); builder = new IndexDefinitionBuilder(nodeBuilder); builder.aggregateRule("foo").include("/path1"); builder.aggregateRule("foo").include("/path3"); NodeState state = builder.build(); assertEquals(3, state.getChildNode(AGGREGATES).getChildNode("foo").getChildNodeCount(100)); }