use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class PropertyIndexInfoProvider method computeCountEstimate.
private void computeCountEstimate(PropertyIndexInfo info, NodeState idxState) {
long count = -1;
for (ChildNodeEntry cne : idxState.getChildNodeEntries()) {
//In multiplexing setups there can be multiple index nodes
if (NodeStateUtils.isHidden(cne.getName())) {
NodeState indexData = cne.getNodeState();
long estimate = ApproximateCounter.getCountSync(indexData);
if (estimate > 0) {
if (count < 0) {
count = 0;
}
count += estimate;
} else if (count < 0 && indexData.getChildNodeCount(1) == 0) {
//If we cannot get estimate then at least try to see if any index data is there or not
count = 0;
}
}
}
info.estimatedCount = count;
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class PropertyIndexStats method getStatsForAllIndexes.
@Override
public TabularData getStatsForAllIndexes(String path, int maxValueCount, int maxDepth, int maxPathCount) throws OpenDataException {
String indexRootPath = concat(path, "oak:index");
NodeState idxRoot = NodeStateUtils.getNode(store.getRoot(), indexRootPath);
TabularType tt = new TabularType(PropertyIndexStats.class.getName(), "Property Index Stats", getType(), new String[] { "path" });
TabularDataSupport tds = new TabularDataSupport(tt);
for (ChildNodeEntry cne : idxRoot.getChildNodeEntries()) {
if ("property".equals(cne.getNodeState().getString("type"))) {
CompositeData stats = getStatsForIndex(concat(indexRootPath, cne.getName()), cne.getNodeState(), maxValueCount, maxDepth, maxPathCount);
tds.put(stats);
}
}
return tds;
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class ConcurrentReadAndAddTest method readNodes.
private void readNodes() {
delayQuery = true;
NodeState test = ns.getRoot().getChildNode("test");
for (ChildNodeEntry entry : test.getChildNodeEntries()) {
entry.getNodeState();
}
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class DocumentNodeStoreTest method concurrentChildOperations.
// OAK-3646
@Test
public void concurrentChildOperations() throws Exception {
Clock clock = new Clock.Virtual();
clock.waitUntil(System.currentTimeMillis());
Revision.setClock(clock);
MemoryDocumentStore store = new MemoryDocumentStore();
DocumentNodeStore ns1 = builderProvider.newBuilder().setAsyncDelay(0).clock(clock).setDocumentStore(store).setClusterId(1).getNodeStore();
DocumentNodeStore ns2 = builderProvider.newBuilder().setAsyncDelay(0).clock(clock).setDocumentStore(store).setClusterId(2).getNodeStore();
// create some children under /foo/bar
NodeBuilder b1 = ns1.getRoot().builder();
NodeBuilder node = b1.child("foo").child("bar");
node.child("child-0");
node.child("child-1");
node.child("child-2");
merge(ns1, b1);
// make changes visible on both cluster nodes
ns1.runBackgroundOperations();
ns2.runBackgroundOperations();
// remove child-0 on cluster node 1
b1 = ns1.getRoot().builder();
b1.child("foo").child("bar").getChildNode("child-0").remove();
merge(ns1, b1);
// push _lastRev updates to DocumentStore
ns1.runBackgroundOperations();
// remove child-1 on cluster node 2
NodeBuilder b2 = ns2.getRoot().builder();
b2.child("foo").child("bar").getChildNode("child-1").remove();
merge(ns2, b2);
// on cluster node 2, remove of child-0 is not yet visible
DocumentNodeState bar = asDocumentNodeState(ns2.getRoot().getChildNode("foo").getChildNode("bar"));
List<ChildNodeEntry> children = Lists.newArrayList(bar.getChildNodeEntries());
assertEquals(2, Iterables.size(children));
RevisionVector invalidate = bar.getLastRevision();
assertNotNull(invalidate);
// this will make changes from cluster node 1 visible
ns2.runBackgroundOperations();
// wait two hours
clock.waitUntil(clock.getTime() + TimeUnit.HOURS.toMillis(2));
// collect everything older than one hour
// this will remove child-0 and child-1 doc
ns1.getVersionGarbageCollector().gc(1, TimeUnit.HOURS);
// forget cache entry for deleted node
ns2.invalidateNodeCache("/foo/bar/child-0", invalidate);
children = Lists.newArrayList(ns2.getRoot().getChildNode("foo").getChildNode("bar").getChildNodeEntries());
assertEquals(1, Iterables.size(children));
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class DocumentNodeStoreTest method readChildrenWithDeletedSiblings.
// OAK-1861
@Test
public void readChildrenWithDeletedSiblings() throws Exception {
final AtomicInteger maxLimit = new AtomicInteger(0);
DocumentStore docStore = new MemoryDocumentStore() {
@Nonnull
@Override
public <T extends Document> List<T> query(Collection<T> collection, String fromKey, String toKey, int limit) {
if (collection == NODES) {
maxLimit.set(Math.max(limit, maxLimit.get()));
}
return super.query(collection, fromKey, toKey, limit);
}
};
DocumentNodeStore ns = builderProvider.newBuilder().setDocumentStore(docStore).setAsyncDelay(0).getNodeStore();
NodeBuilder builder = ns.getRoot().builder();
for (int i = 0; i < 1000; i++) {
builder.child("node-" + i);
}
ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
// now remove all except the last one
for (int i = 0; i < 999; i++) {
builder = ns.getRoot().builder();
builder.getChildNode("node-" + i).remove();
ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}
for (ChildNodeEntry entry : ns.getRoot().getChildNodeEntries()) {
entry.getName();
}
// must not read more than DocumentNodeState.INITIAL_FETCH_SIZE + 1
assertTrue(maxLimit.get() + " > " + (DocumentNodeState.INITIAL_FETCH_SIZE + 1), maxLimit.get() <= DocumentNodeState.INITIAL_FETCH_SIZE + 1);
}
Aggregations