use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReader in project jackrabbit-oak by apache.
the class IndexNode method createReader.
private IndexReader createReader(List<LuceneIndexReader> nrtReaders) {
if (readers.size() == 1 && nrtReaders.isEmpty()) {
return readers.get(0).getReader();
}
if (nrtReaders.size() == 1 && readers.isEmpty()) {
return nrtReaders.get(0).getReader();
}
IndexReader[] readerArr = new IndexReader[readers.size() + nrtReaders.size()];
int i = 0;
for (LuceneIndexReader r : Iterables.concat(readers, nrtReaders)) {
readerArr[i++] = r.getReader();
}
return new MultiReader(readerArr, true);
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReader in project jackrabbit-oak by apache.
the class NRTIndexTest method getReaderWithoutWriter.
@Test
public void getReaderWithoutWriter() throws Exception {
IndexDefinition idxDefn = getSyncIndexDefinition("/foo");
NRTIndex idx1 = indexFactory.createIndex(idxDefn);
List<LuceneIndexReader> readers = idx1.getReaders();
assertNotNull(readers);
assertTrue(readers.isEmpty());
idx1.close();
assertTrue(idx1.isClosed());
//Closing multiple times should not raise exception
idx1.close();
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReader in project jackrabbit-oak by apache.
the class IndexNode method open.
static IndexNode open(String indexPath, NodeState root, NodeState defnNodeState, LuceneIndexReaderFactory readerFactory, @Nullable NRTIndexFactory nrtFactory) throws IOException {
IndexDefinition definition = new IndexDefinition(root, defnNodeState, indexPath);
List<LuceneIndexReader> readers = readerFactory.createReaders(definition, defnNodeState, indexPath);
NRTIndex nrtIndex = nrtFactory != null ? nrtFactory.createIndex(definition) : null;
if (!readers.isEmpty() || (nrtIndex != null && !hasAsyncIndexerRun(root))) {
return new IndexNode(PathUtils.getName(indexPath), definition, readers, nrtIndex);
}
return null;
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReader in project jackrabbit-oak by apache.
the class IndexNode method refreshReaders.
private void refreshReaders() {
long start = PERF_LOGGER.start();
List<LuceneIndexReader> newNRTReaders = getNRTReaders();
//so if they are same no need to reinitialize the searcher
if (newNRTReaders != nrtReaders) {
nrtReaders = newNRTReaders;
indexSearcher = new IndexSearcher(createReader(nrtReaders));
PERF_LOGGER.end(start, 0, "Refreshed reader for index [{}]", definition);
}
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReader in project jackrabbit-oak by apache.
the class IndexNode method close.
void close() throws IOException {
lock.writeLock().lock();
try {
checkState(!closed);
closed = true;
} finally {
lock.writeLock().unlock();
}
//them
for (LuceneIndexReader reader : Iterables.concat(readers, nrtReaders)) {
reader.close();
}
}
Aggregations