use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class ReportingNodeStateTest method getChildNodeEntriesReportsNode.
@Test
public void getChildNodeEntriesReportsNode() {
final NodeBuilder builder = EmptyNodeState.EMPTY_NODE.builder();
for (int i = 1; i < 20; i++) {
builder.child("a" + i);
}
final AssertingPeriodicReporter reporter = new AssertingPeriodicReporter(10, 10);
final NodeState nodeState = ReportingNodeState.wrap(builder.getNodeState(), reporter);
reporter.reset();
int counter = 0;
String name = "<none>";
for (final ChildNodeEntry child : nodeState.getChildNodeEntries()) {
if (++counter == 10) {
name = child.getName();
break;
}
}
assertThat(reporter, hasReportedNode(10, "/" + name));
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class CompositeNodeStoreTest method childNodeEntryForMountIsComposite.
@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));
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class AggregateTest method noOfChildNodeRead.
@Test
public void noOfChildNodeRead() throws Exception {
Aggregate ag = new Aggregate("nt:base", of(ni("a")));
NodeBuilder nb = newNode("nt:base");
nb.child("a");
for (int i = 0; i < 10; i++) {
nb.child("a" + i);
}
NodeState state = nb.getNodeState();
final AtomicInteger counter = new AtomicInteger();
Iterable<? extends ChildNodeEntry> countingIterator = Iterables.transform(state.getChildNodeEntries(), new Function<ChildNodeEntry, ChildNodeEntry>() {
@Override
public ChildNodeEntry apply(ChildNodeEntry input) {
counter.incrementAndGet();
return input;
}
});
NodeState mocked = spy(state);
doReturn(countingIterator).when(mocked).getChildNodeEntries();
ag.collectAggregates(mocked, col);
//Here at max a single call should happen for reading child nodes
assertThat(counter.get(), is(lessThanOrEqualTo(1)));
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class SameNameSiblingsEditor method parseNamedChildNodeDefs.
private static List<ChildTypeDef> parseNamedChildNodeDefs(NodeState root, NodeState parentType, TypePredicate parentTypePredicate) {
List<ChildTypeDef> defs = new ArrayList<ChildTypeDef>();
NodeState namedChildNodeDefinitions = parentType.getChildNode(REP_NAMED_CHILD_NODE_DEFINITIONS);
for (ChildNodeEntry childName : namedChildNodeDefinitions.getChildNodeEntries()) {
for (String childType : filterChildren(childName.getNodeState(), NO_SNS_PROPERTY)) {
TypePredicate childTypePredicate = new TypePredicate(root, childType);
defs.add(new ChildTypeDef(parentTypePredicate, childName.getName(), childTypePredicate));
}
}
return defs;
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class VersionCopier method getVersionHistoryLastModified.
private Calendar getVersionHistoryLastModified(final NodeState versionHistory) {
Calendar youngest = Calendar.getInstance();
youngest.setTimeInMillis(0);
for (final ChildNodeEntry entry : versionHistory.getChildNodeEntries()) {
final NodeState version = entry.getNodeState();
if (!isVersion.apply(version)) {
continue;
}
if (version.hasProperty(JCR_CREATED)) {
final Calendar created = ISO8601.parse(version.getProperty(JCR_CREATED).getValue(Type.DATE));
if (created.after(youngest)) {
youngest = created;
}
}
}
return youngest;
}
Aggregations