forked from apache/jackrabbit-oak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OAK-2621: Too many reads for child nodes
git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/oak/trunk@1813171 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
Showing
4 changed files
with
164 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...ument/src/test/java/org/apache/jackrabbit/oak/plugins/document/GetChildNodeCountTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.jackrabbit.oak.plugins.document; | ||
|
||
import javax.jcr.SimpleCredentials; | ||
|
||
import org.apache.jackrabbit.oak.Oak; | ||
import org.apache.jackrabbit.oak.api.ContentRepository; | ||
import org.apache.jackrabbit.oak.api.ContentSession; | ||
import org.apache.jackrabbit.oak.api.Root; | ||
import org.apache.jackrabbit.oak.api.Tree; | ||
import org.apache.jackrabbit.oak.api.Type; | ||
import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore; | ||
import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider; | ||
import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import static com.google.common.collect.Lists.newArrayList; | ||
import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES; | ||
import static org.apache.jackrabbit.oak.plugins.document.util.Utils.closeIfCloseable; | ||
import static org.hamcrest.Matchers.lessThan; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class GetChildNodeCountTest { | ||
|
||
@Rule | ||
public DocumentMKBuilderProvider builderProvider = new DocumentMKBuilderProvider(); | ||
|
||
private CountingDocumentStore store = new CountingDocumentStore(new MemoryDocumentStore()); | ||
|
||
private DocumentNodeStore ns; | ||
|
||
private ContentRepository repository; | ||
|
||
private ContentSession session; | ||
|
||
@Before | ||
public void before() throws Exception { | ||
ns = builderProvider.newBuilder().setAsyncDelay(0) | ||
.setDocumentStore(store).getNodeStore(); | ||
repository = new Oak(ns) | ||
.with(new PropertyIndexEditorProvider()) | ||
.with(new OpenSecurityProvider()) | ||
.createContentRepository(); | ||
session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()), null); | ||
Root root = session.getLatestRoot(); | ||
Tree idx = root.getTree("/").addChild("oak:index").addChild("p"); | ||
idx.setProperty("type", "property"); | ||
idx.setProperty("propertyNames", newArrayList("p"), Type.NAMES); | ||
root.commit(); | ||
} | ||
|
||
@After | ||
public void after() throws Exception { | ||
session.close(); | ||
closeIfCloseable(repository); | ||
ns.dispose(); | ||
} | ||
|
||
@Test | ||
public void removeIndexedNodes() throws Exception { | ||
Root root = session.getLatestRoot(); | ||
Tree t = root.getTree("/").addChild("test"); | ||
for (int i = 0; i < 200; i ++) { | ||
t.addChild("node-" + i).setProperty("p", "v"); | ||
} | ||
root.commit(); | ||
ns.getNodeChildrenCache().invalidateAll(); | ||
store.resetCounters(); | ||
// remove nodes | ||
root = session.getLatestRoot(); | ||
root.getTree("/test").remove(); | ||
root.commit(); | ||
assertThat(store.getNumQueryCalls(NODES), lessThan(13)); | ||
} | ||
} |