diff --git a/lucene/src/java/org/apache/lucene/index/SegmentMerger.java b/lucene/src/java/org/apache/lucene/index/SegmentMerger.java index 8bd72778a61..e76658302b2 100644 --- a/lucene/src/java/org/apache/lucene/index/SegmentMerger.java +++ b/lucene/src/java/org/apache/lucene/index/SegmentMerger.java @@ -323,9 +323,12 @@ final class SegmentMerger { docBase += docCount; if (mergeState.payloadProcessorProvider != null) { - // nocommit: this does not work anymore as SR/AtomicIndexReader does not know the directory anymore: - // mergeState.dirPayloadProcessor[i] = mergeState.payloadProcessorProvider.getDirProcessor(reader.reader.directory()); - throw new UnsupportedOperationException("PayloadProcessorProvider is not supported at the moment :("); + // TODO: the PayloadProcessorProvider should take AtomicReader as parameter + // and find out by itself if it can provide a processor: + if (!(reader.reader instanceof SegmentReader)) + throw new UnsupportedOperationException("Payload processing currently requires exclusively SegmentReaders to be merged."); + final Directory dir = ((SegmentReader) reader.reader).directory(); + mergeState.dirPayloadProcessor[i] = mergeState.payloadProcessorProvider.getDirProcessor(dir); } i++; diff --git a/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java b/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java index 1c2d8c94fb3..ea8d6dfcd08 100644 --- a/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java +++ b/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java @@ -37,7 +37,6 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.LuceneTestCase; import org.junit.Test; -import org.junit.Ignore; public class TestPayloadProcessorProvider extends LuceneTestCase { @@ -215,8 +214,6 @@ public class TestPayloadProcessorProvider extends LuceneTestCase { dir.close(); } - @Ignore("This test does not work, as PerDirPayloadProcessor is currently broken (see nocommit in SegmentMerger): "+ - "SegmentReader/AtomicReader does not know its directory. This is broken, it should be a PayLoadProcessorProvider per AtomicReader!") @Test public void testAddIndexes() throws Exception { // addIndexes - single commit in each @@ -226,8 +223,6 @@ public class TestPayloadProcessorProvider extends LuceneTestCase { doTest(random, true, 0, true); } - @Ignore("This test does not work, as PerDirPayloadProcessor is currently broken (see nocommit in SegmentMerger): "+ - "SegmentReader/AtomicReader does not know its directory. This is broken, it should be a PayLoadProcessorProvider per AtomicReader!") @Test public void testAddIndexesIntoExisting() throws Exception { // addIndexes - single commit in each @@ -237,8 +232,6 @@ public class TestPayloadProcessorProvider extends LuceneTestCase { doTest(random, false, NUM_DOCS, true); } - @Ignore("This test does not work, as PerDirPayloadProcessor is currently broken (see nocommit in SegmentMerger): "+ - "SegmentReader/AtomicReader does not know its directory. This is broken, it should be a PayLoadProcessorProvider per AtomicReader!") @Test public void testRegularMerges() throws Exception { Directory dir = newDirectory(); diff --git a/modules/facet/src/test/org/apache/lucene/facet/index/FacetsPayloadProcessorProviderTest.java b/modules/facet/src/test/org/apache/lucene/facet/index/FacetsPayloadProcessorProviderTest.java index d978c7ea9d2..ba654ad2008 100644 --- a/modules/facet/src/test/org/apache/lucene/facet/index/FacetsPayloadProcessorProviderTest.java +++ b/modules/facet/src/test/org/apache/lucene/facet/index/FacetsPayloadProcessorProviderTest.java @@ -7,13 +7,12 @@ import java.util.List; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.analysis.MockTokenizer; import org.apache.lucene.document.Document; -import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; -import org.junit.Ignore; import org.junit.Test; import org.apache.lucene.util.LuceneTestCase; @@ -48,8 +47,6 @@ public class FacetsPayloadProcessorProviderTest extends LuceneTestCase { private static final int NUM_DOCS = 100; - @Ignore("This test does not work, as PerDirPayloadProcessor is currently broken (see nocommit in SegmentMerger): "+ - "SegmentReader/AtomicReader does not know its directory. This is broken, it should be a PayLoadProcessorProvider per AtomicReader!") @Test public void testTaxonomyMergeUtils() throws Exception { Directory dir = newDirectory(); @@ -70,7 +67,7 @@ public class FacetsPayloadProcessorProviderTest extends LuceneTestCase { } private void verifyResults(Directory dir, Directory taxDir) throws IOException { - IndexReader reader1 = IndexReader.open(dir); + DirectoryReader reader1 = DirectoryReader.open(dir); DirectoryTaxonomyReader taxReader = new DirectoryTaxonomyReader(taxDir); IndexSearcher searcher = newSearcher(reader1); FacetSearchParams fsp = new FacetSearchParams();