Search in sources :

Example 11 with IndexUpdateProvider

use of org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider in project jackrabbit-oak by apache.

the class IndexTrackerTest method setUp.

@Before
public void setUp() {
    IndexUpdateProvider updateProvider = new IndexUpdateProvider(new LuceneIndexEditorProvider(), "async", false);
    updateProvider.setCorruptIndexHandler(corruptIndexHandler);
    hook = new EditorHook(updateProvider);
}
Also used : IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) Before(org.junit.Before)

Example 12 with IndexUpdateProvider

use of org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider in project jackrabbit-oak by apache.

the class SolrBaseTest method setUp.

@Before
public void setUp() throws Exception {
    store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    provider = new TestUtils();
    server = provider.getSolrServer();
    configuration = provider.getConfiguration();
    hook = new EditorHook(new IndexUpdateProvider(new SolrIndexEditorProvider(provider, provider)));
    Oak oak = new Oak().with(new InitialContent()).with(new OpenSecurityProvider()).with(// synchronous
    new SolrIndexInitializer(false)).with(new SolrQueryIndexProvider(provider, provider)).with(new NodeStateSolrServersObserver()).with(new SolrIndexEditorProvider(provider, provider));
    repository = oak.createContentRepository();
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) SolrQueryIndexProvider(org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider) NodeStateSolrServersObserver(org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServersObserver) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) Oak(org.apache.jackrabbit.oak.Oak) SolrIndexInitializer(org.apache.jackrabbit.oak.plugins.index.solr.util.SolrIndexInitializer) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) SolrIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider) Before(org.junit.Before)

Example 13 with IndexUpdateProvider

use of org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider in project jackrabbit-oak by apache.

the class LocalIndexWriterFactoryTest method setUp.

@Before
public void setUp() throws IOException {
    tracker = new IndexTracker();
    DocumentQueue queue = new DocumentQueue(100, tracker, sameThreadExecutor());
    editorProvider = new LuceneIndexEditorProvider(null, null, null, Mounts.defaultMountInfoProvider());
    editorProvider.setIndexingQueue(queue);
    syncHook = new EditorHook(new IndexUpdateProvider(editorProvider));
    asyncHook = new EditorHook(new IndexUpdateProvider(editorProvider, "async", false));
}
Also used : IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) Before(org.junit.Before)

Example 14 with IndexUpdateProvider

use of org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider in project jackrabbit-oak by apache.

the class NodeTypeIndexTest method nodeType.

@Test
public void nodeType() throws Exception {
    NodeBuilder root = store.getRoot().builder();
    // remove "rep:security" as it interferes with tests
    root.getChildNode("rep:security").remove();
    // set "entryCount", so the node type index counts the nodes
    // and the approximation is not used
    root.getChildNode("oak:index").getChildNode("nodetype").setProperty("entryCount", -1);
    addFolder(root, "folder-1");
    addFolder(root, "folder-2");
    addFile(root, "file-1");
    store.merge(root, new EditorHook(new IndexUpdateProvider(new PropertyIndexEditorProvider())), CommitInfo.EMPTY);
    NodeState rootState = store.getRoot();
    NodeTypeIndex index = new NodeTypeIndex(Mounts.defaultMountInfoProvider());
    FilterImpl filter;
    filter = createFilter(rootState, JcrConstants.NT_FOLDER);
    assertEquals(6.0, index.getCost(filter, rootState), 0.0);
    checkCursor(index.query(filter, rootState), "/folder-1", "/folder-2");
    filter = createFilter(rootState, JcrConstants.NT_FILE);
    assertEquals(5.0, index.getCost(filter, rootState), 0.0);
    checkCursor(index.query(filter, rootState), "/file-1");
    filter = createFilter(rootState, JcrConstants.NT_HIERARCHYNODE);
    assertEquals(7.0, index.getCost(filter, rootState), 0.0);
    checkCursor(index.query(filter, rootState), "/folder-1", "/folder-2", "/file-1");
}
Also used : IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 15 with IndexUpdateProvider

use of org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider in project jackrabbit-oak by apache.

the class ReferenceIndexTest method referenceHandlingWithMounts.

@Test
public void referenceHandlingWithMounts() throws Exception {
    NodeState root = INITIAL_CONTENT;
    NodeBuilder builder = root.builder();
    NodeState before = builder.getNodeState();
    builder.child("a").child("x").setProperty(createProperty("foo", "u1", Type.REFERENCE));
    builder.child("b").setProperty(createProperty("foo", "u1", Type.REFERENCE));
    builder.child("c").setProperty(createProperty("foo", "u1", Type.WEAKREFERENCE));
    builder.child("d").setProperty(createProperty("foo", "u2", Type.WEAKREFERENCE));
    builder.child("a").child("y").setProperty(createProperty("foo", "u1", Type.WEAKREFERENCE));
    NodeState after = builder.getNodeState();
    MountInfoProvider mip = Mounts.newBuilder().mount("foo", "/a").build();
    EditorHook hook = new EditorHook(new IndexUpdateProvider(new ReferenceEditorProvider().with(mip)));
    ReferenceIndex referenceIndex = new ReferenceIndex(mip);
    NodeState indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
    FilterImpl f = createFilter(indexed, NT_BASE);
    f.restrictProperty("*", Operator.EQUAL, newReference("u1"), PropertyType.REFERENCE);
    // System.out.println(NodeStateUtils.toString(NodeStateUtils.getNode(indexed, "/oak:index/reference")));
    assertFilter(f, referenceIndex, indexed, of("/a/x", "/b"));
    FilterImpl f2 = createFilter(indexed, NT_BASE);
    f2.restrictProperty("*", Operator.EQUAL, newReference("u1"), PropertyType.WEAKREFERENCE);
    assertFilter(f2, referenceIndex, indexed, of("/c", "/a/y"));
}
Also used : IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) Test(org.junit.Test)

Aggregations

IndexUpdateProvider (org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider)24 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)24 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)14 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)14 Test (org.junit.Test)13 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)6 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)6 Before (org.junit.Before)6 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)4 CompositeIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.CompositeIndexEditorProvider)3 IndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider)3 LuceneIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider)3 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)2 CommitHook (org.apache.jackrabbit.oak.spi.commit.CommitHook)2 CompositeHook (org.apache.jackrabbit.oak.spi.commit.CompositeHook)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1 Executor (java.util.concurrent.Executor)1 ExecutorService (java.util.concurrent.ExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1