lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r1239084 - in /lucene/dev/branches/branch_3x: ./ lucene/ lucene/contrib/facet/src/java/org/apache/lucene/facet/index/ lucene/src/java/org/apache/lucene/index/ lucene/src/test/org/apache/lucene/index/ solr/ solr/core/
Date Wed, 01 Feb 2012 11:34:44 GMT
Author: uschindler
Date: Wed Feb  1 11:34:44 2012
New Revision: 1239084

URL: http://svn.apache.org/viewvc?rev=1239084&view=rev
Log:
Merged revision(s) 1239052-1239056 from lucene/dev/trunk:
LUCENE-3735: Fix PayloadProcessorProvider to no longer use Directory for lookup, instead IndexReader

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/lucene/CHANGES.txt
    lucene/dev/branches/branch_3x/lucene/contrib/facet/src/java/org/apache/lucene/facet/index/FacetsPayloadProcessorProvider.java
    lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/PayloadProcessorProvider.java
    lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMergeInfo.java
    lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java
    lucene/dev/branches/branch_3x/solr/   (props changed)
    lucene/dev/branches/branch_3x/solr/core/   (props changed)

Modified: lucene/dev/branches/branch_3x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/CHANGES.txt?rev=1239084&r1=1239083&r2=1239084&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/lucene/CHANGES.txt Wed Feb  1 11:34:44 2012
@@ -89,6 +89,12 @@ API Changes
   In Lucene 4.0, SimilarityProvider will allow you to customize scoring
   using external norms, too.  (Uwe Schindler, Robert Muir)
 
+* LUCENE-3735: PayloadProcessorProvider was changed to return a
+  ReaderPayloadProcessor instead of DirPayloadProcessor. The selction
+  of the provider to return for the factory is now based on the IndexReader
+  to be merged. To mimic the old behaviour, just use IndexReader.directory()
+  for choosing the provider by Directory.  (Uwe Schindler)
+
 New Features
 
 * LUCENE-3593: Added a FieldValueFilter that accepts all documents that either

Modified: lucene/dev/branches/branch_3x/lucene/contrib/facet/src/java/org/apache/lucene/facet/index/FacetsPayloadProcessorProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/facet/src/java/org/apache/lucene/facet/index/FacetsPayloadProcessorProvider.java?rev=1239084&r1=1239083&r2=1239084&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/facet/src/java/org/apache/lucene/facet/index/FacetsPayloadProcessorProvider.java
(original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/facet/src/java/org/apache/lucene/facet/index/FacetsPayloadProcessorProvider.java
Wed Feb  1 11:34:44 2012
@@ -7,6 +7,7 @@ import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.PayloadProcessorProvider;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.store.Directory;
@@ -93,7 +94,7 @@ public class FacetsPayloadProcessorProvi
   
   private final Directory workDir;
   
-  private final DirPayloadProcessor dirProcessor;
+  private final ReaderPayloadProcessor dirProcessor;
 
   /**
    * Construct FacetsPayloadProcessorProvider with FacetIndexingParams
@@ -109,14 +110,11 @@ public class FacetsPayloadProcessorProvi
   }
   
   @Override
-  public DirPayloadProcessor getDirProcessor(Directory dir) throws IOException {
-    if (workDir != dir) {
-      return null;
-    }
-    return dirProcessor;
+  public ReaderPayloadProcessor getReaderProcessor(IndexReader reader) throws IOException
{
+    return (workDir == reader.directory()) ? dirProcessor : null;
   }
   
-  public static class FacetsDirPayloadProcessor extends DirPayloadProcessor {
+  public static class FacetsDirPayloadProcessor extends ReaderPayloadProcessor {
     
     private final Map<Term, CategoryListParams> termMap = new HashMap<Term, CategoryListParams>(1);
     

Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexWriter.java?rev=1239084&r1=1239083&r2=1239084&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexWriter.java
(original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexWriter.java
Wed Feb  1 11:34:44 2012
@@ -37,7 +37,6 @@ import org.apache.lucene.analysis.Analyz
 import org.apache.lucene.analysis.LimitTokenCountAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.index.PayloadProcessorProvider.DirPayloadProcessor;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Similarity;
 import org.apache.lucene.store.AlreadyClosedException;
@@ -4778,7 +4777,7 @@ public class IndexWriter implements Clos
    * is merged, not only external ones that are given through
    * {@link #addIndexes}. If you want only the payloads of the external segments
    * to be processed, you can return <code>null</code> whenever a
-   * {@link DirPayloadProcessor} is requested for the {@link Directory} of the
+   * {@link PayloadProcessorProvider.ReaderPayloadProcessor} is requested for the {@link
Directory} of the
    * {@link IndexWriter}.
    * <p>
    * The default is <code>null</code> which means payloads are processed

Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/PayloadProcessorProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/PayloadProcessorProvider.java?rev=1239084&r1=1239083&r2=1239084&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/PayloadProcessorProvider.java
(original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/PayloadProcessorProvider.java
Wed Feb  1 11:34:44 2012
@@ -22,20 +22,20 @@ import java.io.IOException;
 import org.apache.lucene.store.Directory;
 
 /**
- * Provides a {@link DirPayloadProcessor} to be used for a {@link Directory}.
- * This allows using different {@link DirPayloadProcessor}s for different
- * directories, for e.g. to perform different processing of payloads of
+ * Provides a {@link ReaderPayloadProcessor} to be used for a {@link Directory}.
+ * This allows using different {@link ReaderPayloadProcessor}s for different
+ * source {@link IndexReader}, for e.g. to perform different processing of payloads of
  * different directories.
  * <p>
  * <b>NOTE:</b> to avoid processing payloads of certain directories, you can
- * return <code>null</code> in {@link #getDirProcessor}.
+ * return <code>null</code> in {@link #getReaderProcessor}.
  * <p>
- * <b>NOTE:</b> it is possible that the same {@link DirPayloadProcessor} will
be
+ * <b>NOTE:</b> it is possible that the same {@link ReaderPayloadProcessor} will
be
  * requested for the same {@link Directory} concurrently. Therefore, to avoid
  * concurrency issues you should return different instances for different
- * threads. Usually, if your {@link DirPayloadProcessor} does not maintain state
+ * threads. Usually, if your {@link ReaderPayloadProcessor} does not maintain state
  * this is not a problem. The merge code ensures that the
- * {@link DirPayloadProcessor} instance you return will be accessed by one
+ * {@link ReaderPayloadProcessor} instance you return will be accessed by one
  * thread to obtain the {@link PayloadProcessor}s for different terms.
  * 
  * @lucene.experimental
@@ -47,11 +47,11 @@ public abstract class PayloadProcessorPr
    * processing the payloads of different terms differently. If you intent to
    * process all your payloads the same way, then you can ignore the given term.
    * <p>
-   * <b>NOTE:</b> if you protect your {@link DirPayloadProcessor} from
+   * <b>NOTE:</b> if you protect your {@link ReaderPayloadProcessor} from
    * concurrency issues, then you shouldn't worry about any such issues when
    * {@link PayloadProcessor}s are requested for different terms.
    */
-  public static abstract class DirPayloadProcessor {
+  public static abstract class ReaderPayloadProcessor {
 
     /** Returns a {@link PayloadProcessor} for the given term. */
     public abstract PayloadProcessor getProcessor(Term term) throws IOException;
@@ -59,6 +59,12 @@ public abstract class PayloadProcessorPr
   }
 
   /**
+   * @deprecated Use {@link ReaderPayloadProcessor} instead.
+   */
+  @Deprecated
+  public static abstract class DirPayloadProcessor extends ReaderPayloadProcessor {}
+
+  /**
    * Processes the given payload. One should call {@link #payloadLength()} to
    * get the length of the processed payload.
    * 
@@ -80,10 +86,25 @@ public abstract class PayloadProcessorPr
   }
 
   /**
-   * Returns a {@link DirPayloadProcessor} for the given {@link Directory},
+   * Returns a {@link ReaderPayloadProcessor} for the given {@link Directory},
    * through which {@link PayloadProcessor}s can be obtained for each
    * {@link Term}, or <code>null</code> if none should be used.
+   * You should override this method, not {@link #getDirProcessor}.
    */
-  public abstract DirPayloadProcessor getDirProcessor(Directory dir) throws IOException;
+  public ReaderPayloadProcessor getReaderProcessor(IndexReader reader) throws IOException
{
+    return this.getDirProcessor(reader.directory());
+  }
 
+  /**
+   * Returns a {@link DirPayloadProcessor} for the given {@link Directory},
+   * through which {@link PayloadProcessor}s can be obtained for each
+   * {@link Term}, or <code>null</code> if none should be used.
+   * @deprecated Use {@link #getReaderProcessor} instead. You can still select by {@link
Directory},
+   * if you retrieve the underlying directory from {@link IndexReader#directory()}.
+   */
+  @Deprecated
+  public DirPayloadProcessor getDirProcessor(Directory dir) throws IOException {
+    throw new UnsupportedOperationException("You must either implement getReaderProcessor()
or getDirProcessor().");
+  }
+  
 }

Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMergeInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMergeInfo.java?rev=1239084&r1=1239083&r2=1239084&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMergeInfo.java
(original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMergeInfo.java
Wed Feb  1 11:34:44 2012
@@ -19,7 +19,7 @@ package org.apache.lucene.index;
 
 import java.io.IOException;
 
-import org.apache.lucene.index.PayloadProcessorProvider.DirPayloadProcessor;
+import org.apache.lucene.index.PayloadProcessorProvider.ReaderPayloadProcessor;
 
 final class SegmentMergeInfo {
   Term term;
@@ -30,7 +30,7 @@ final class SegmentMergeInfo {
   int delCount;
   private TermPositions postings;  // use getPositions()
   private int[] docMap;  // use getDocMap()
-  DirPayloadProcessor dirPayloadProcessor;
+  ReaderPayloadProcessor readerPayloadProcessor;
   
   SegmentMergeInfo(int b, TermEnum te, IndexReader r)
     throws IOException {

Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMerger.java?rev=1239084&r1=1239083&r2=1239084&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
(original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
Wed Feb  1 11:34:44 2012
@@ -448,7 +448,7 @@ final class SegmentMerger {
       TermEnum termEnum = reader.terms();
       SegmentMergeInfo smi = new SegmentMergeInfo(base, termEnum, reader);
       if (payloadProcessorProvider != null) {
-        smi.dirPayloadProcessor = payloadProcessorProvider.getDirProcessor(reader.directory());
+        smi.readerPayloadProcessor = payloadProcessorProvider.getReaderProcessor(reader);
       }
       int[] docMap  = smi.getDocMap();
       if (docMap != null) {
@@ -533,8 +533,8 @@ final class SegmentMerger {
       postings.seek(smi.termEnum);
 
       PayloadProcessor payloadProcessor = null;
-      if (smi.dirPayloadProcessor != null) {
-        payloadProcessor = smi.dirPayloadProcessor.getProcessor(smi.term);
+      if (smi.readerPayloadProcessor != null) {
+        payloadProcessor = smi.readerPayloadProcessor.getProcessor(smi.term);
       }
 
       while (postings.next()) {

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java?rev=1239084&r1=1239083&r2=1239084&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java
(original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java
Wed Feb  1 11:34:44 2012
@@ -32,7 +32,7 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.Field.Index;
 import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.index.PayloadProcessorProvider.DirPayloadProcessor;
+import org.apache.lucene.index.PayloadProcessorProvider.ReaderPayloadProcessor;
 import org.apache.lucene.index.PayloadProcessorProvider.PayloadProcessor;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
@@ -42,20 +42,20 @@ public class TestPayloadProcessorProvide
 
   private static final class PerDirPayloadProcessor extends PayloadProcessorProvider {
 
-    private Map<Directory, DirPayloadProcessor> processors;
+    private final Map<Directory, ReaderPayloadProcessor> processors;
 
-    public PerDirPayloadProcessor(Map<Directory, DirPayloadProcessor> processors) {
+    public PerDirPayloadProcessor(Map<Directory, ReaderPayloadProcessor> processors)
{
       this.processors = processors;
     }
 
     @Override
-    public DirPayloadProcessor getDirProcessor(Directory dir) throws IOException {
-      return processors.get(dir);
+    public ReaderPayloadProcessor getReaderProcessor(IndexReader reader) throws IOException
{
+      return processors.get(reader.directory());
     }
 
   }
 
-  private static final class PerTermPayloadProcessor extends DirPayloadProcessor {
+  private static final class PerTermPayloadProcessor extends ReaderPayloadProcessor {
 
     @Override
     public PayloadProcessor getProcessor(Term term) throws IOException {
@@ -194,7 +194,7 @@ public class TestPayloadProcessorProvide
 
     // Add two source dirs. By not adding the dest dir, we ensure its payloads
     // won't get processed.
-    Map<Directory, DirPayloadProcessor> processors = new HashMap<Directory, DirPayloadProcessor>();
+    Map<Directory, ReaderPayloadProcessor> processors = new HashMap<Directory, ReaderPayloadProcessor>();
     for (Directory d : dirs) {
       processors.put(d, new PerTermPayloadProcessor());
     }
@@ -250,7 +250,7 @@ public class TestPayloadProcessorProvide
 
     // Add two source dirs. By not adding the dest dir, we ensure its payloads
     // won't get processed.
-    Map<Directory, DirPayloadProcessor> processors = new HashMap<Directory, DirPayloadProcessor>();
+    Map<Directory, ReaderPayloadProcessor> processors = new HashMap<Directory, ReaderPayloadProcessor>();
     processors.put(dir, new PerTermPayloadProcessor());
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)));
     writer.setPayloadProcessorProvider(new PerDirPayloadProcessor(processors));



Mime
View raw message