Search in sources :

Example 6 with DefaultIndexReaderFactory

use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory in project jackrabbit-oak by apache.

the class MultiplexingLucenePropertyIndexTest method numDocsIsSumOfAllReaders.

@Test
public void numDocsIsSumOfAllReaders() throws Exception {
    NodeBuilder defnBuilder = newLucenePropertyIndexDefinition(builder, "test", ImmutableSet.of("foo"), "async");
    IndexDefinition defn = new IndexDefinition(initialContent, defnBuilder.getNodeState(), "/foo");
    //1. Have 2 reader created by writes in 2 diff mounts
    LuceneIndexWriterFactory factory = new DefaultIndexWriterFactory(mip, null, null);
    LuceneIndexWriter writer = factory.newInstance(defn, builder, true);
    writer.updateDocument("/content/en", newDoc("/content/en"));
    writer.updateDocument("/libs/config", newDoc("/libs/config"));
    writer.close(0);
    //2. Construct the readers
    LuceneIndexReaderFactory readerFactory = new DefaultIndexReaderFactory(mip, null);
    List<LuceneIndexReader> readers = readerFactory.createReaders(defn, builder.getNodeState(), "/foo");
    IndexNode node = new IndexNode("foo", defn, readers, null);
    //3 Obtain the plan
    FilterImpl filter = createFilter("nt:base");
    filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
    IndexPlanner planner = new IndexPlanner(node, "/foo", filter, Collections.<QueryIndex.OrderEntry>emptyList());
    QueryIndex.IndexPlan plan = planner.getPlan();
    //Count should be sum of both readers
    assertEquals(2, plan.getEstimatedEntryCount());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) LuceneIndexWriter(org.apache.jackrabbit.oak.plugins.index.lucene.writer.LuceneIndexWriter) LuceneIndexWriterFactory(org.apache.jackrabbit.oak.plugins.index.lucene.writer.LuceneIndexWriterFactory) LuceneIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) LuceneIndexReader(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReader) LuceneIndexHelper.newLucenePropertyIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) DefaultIndexWriterFactory(org.apache.jackrabbit.oak.plugins.index.lucene.writer.DefaultIndexWriterFactory) Test(org.junit.Test) AbstractQueryTest(org.apache.jackrabbit.oak.query.AbstractQueryTest)

Example 7 with DefaultIndexReaderFactory

use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory in project jackrabbit-oak by apache.

the class IndexNodeTest method setUp.

@Before
public void setUp() throws IOException {
    indexCopier = new IndexCopier(sameThreadExecutor(), temporaryFolder.getRoot());
    nrtFactory = new NRTIndexFactory(indexCopier, StatisticsProvider.NOOP);
    readerFactory = new DefaultIndexReaderFactory(Mounts.defaultMountInfoProvider(), indexCopier);
    LuceneIndexEditorContext.configureUniqueId(builder);
}
Also used : NRTIndexFactory(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) Before(org.junit.Before)

Example 8 with DefaultIndexReaderFactory

use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory in project jackrabbit-oak by apache.

the class HybridIndexTest method createRepository.

@Override
protected ContentRepository createRepository() {
    IndexCopier copier;
    try {
        copier = new IndexCopier(executorService, temporaryFolder.getRoot());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    MountInfoProvider mip = defaultMountInfoProvider();
    NRTIndexFactory nrtIndexFactory = new NRTIndexFactory(copier, clock, TimeUnit.MILLISECONDS.toSeconds(refreshDelta), StatisticsProvider.NOOP);
    LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
    IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
    LuceneIndexProvider provider = new LuceneIndexProvider(tracker);
    queue = new DocumentQueue(100, tracker, sameThreadExecutor());
    LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider(copier, tracker, null, null, mip);
    editorProvider.setIndexingQueue(queue);
    LocalIndexObserver localIndexObserver = new LocalIndexObserver(queue, StatisticsProvider.NOOP);
    nodeStore = new MemoryNodeStore();
    Oak oak = new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with((QueryIndexProvider) provider).with((Observer) provider).with(localIndexObserver).with(editorProvider).with(new PropertyIndexEditorProvider()).with(new NodeTypeIndexProvider()).with(optionalEditorProvider).with(new NodeCounterEditorProvider()).withAsyncIndexing("async", TimeUnit.DAYS.toSeconds(1));
    wb = oak.getWhiteboard();
    return oak.createContentRepository();
}
Also used : NodeTypeIndexProvider(org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) IOException(java.io.IOException) LuceneIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) InitialContent(org.apache.jackrabbit.oak.InitialContent) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) Oak(org.apache.jackrabbit.oak.Oak) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) Mounts.defaultMountInfoProvider(org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) NodeCounterEditorProvider(org.apache.jackrabbit.oak.plugins.index.counter.NodeCounterEditorProvider)

Example 9 with DefaultIndexReaderFactory

use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory in project jackrabbit-oak by apache.

the class DocumentQueueTest method benchMarkIndexWriter.

//@Test
public void benchMarkIndexWriter() throws Exception {
    Executor executor = Executors.newFixedThreadPool(5);
    IndexCopier indexCopier = new IndexCopier(executor, temporaryFolder.getRoot());
    indexFactory = new NRTIndexFactory(indexCopier, clock, TimeUnit.MILLISECONDS.toSeconds(refreshDelta), StatisticsProvider.NOOP);
    tracker = new IndexTracker(new DefaultIndexReaderFactory(defaultMountInfoProvider(), indexCopier), indexFactory);
    NodeState indexed = createAndPopulateAsyncIndex(IndexingMode.NRT);
    tracker.update(indexed);
    DocumentQueue queue = new DocumentQueue(1000, tracker, executor);
    /*
            Sample output
            [nrt] Time taken for 10000 is 639.3 ms with waits 1
            [sync] Time taken for 10000 is 30.34 s

            Refreshing reader after every commit would slow down things
         */
    LuceneDoc doc = createDoc("/a/b", "a");
    int numDocs = 10000;
    Stopwatch w = Stopwatch.createStarted();
    int waitCount = 0;
    for (int i = 0; i < numDocs; i++) {
        while (!queue.add(doc)) {
            waitCount++;
        }
    }
    System.out.printf("%n[nrt] Time taken for %d is %s with waits %d%n", numDocs, w, waitCount);
    indexed = createAndPopulateAsyncIndex(IndexingMode.SYNC);
    tracker.update(indexed);
    queue = new DocumentQueue(1000, tracker, executor);
    w = Stopwatch.createStarted();
    for (int i = 0; i < numDocs; i++) {
        ListMultimap<String, LuceneDoc> docs = ArrayListMultimap.create();
        docs.get("/oak:index/fooIndex").add(doc);
        queue.addAllSynchronously(docs.asMap());
    }
    System.out.printf("%n[sync] Time taken for %d is %s%n", numDocs, w);
}
Also used : MoreExecutors.sameThreadExecutor(com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor) Executor(java.util.concurrent.Executor) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) Stopwatch(com.google.common.base.Stopwatch) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier)

Aggregations

DefaultIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory)9 IndexCopier (org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier)5 IndexTracker (org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker)5 IOException (java.io.IOException)4 LuceneIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory)4 LuceneIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider)3 LuceneIndexProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider)3 NRTIndexFactory (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory)3 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)3 InitialContent (org.apache.jackrabbit.oak.InitialContent)2 Oak (org.apache.jackrabbit.oak.Oak)2 NodeTypeIndexProvider (org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider)2 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)2 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)2 Observer (org.apache.jackrabbit.oak.spi.commit.Observer)2 Mounts.defaultMountInfoProvider (org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider)2 OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)2 Stopwatch (com.google.common.base.Stopwatch)1 MoreExecutors.sameThreadExecutor (com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor)1 Executor (java.util.concurrent.Executor)1