lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1139797 - in /lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src: java/org/apache/lucene/store/NRTCachingDirectory.java test/org/apache/lucene/index/TestNRTManager.java test/org/apache/lucene/store/TestNRTCachingDirectory.java
Date Sun, 26 Jun 2011 14:17:28 GMT
Author: mikemccand
Date: Sun Jun 26 14:17:27 2011
New Revision: 1139797

URL: http://svn.apache.org/viewvc?rev=1139797&view=rev
Log:
NRTCachingDir doesn't need the MergeScheduler anymore

Modified:
    lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java
    lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/index/TestNRTManager.java
    lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java

Modified: lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java?rev=1139797&r1=1139796&r2=1139797&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java
(original)
+++ lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java
Sun Jun 26 14:17:27 2011
@@ -40,11 +40,7 @@ import org.apache.lucene.util.IOUtils;
 /**
  * Wraps a {@link RAMDirectory}
  * around any provided delegate directory, to
- * be used during NRT search.  Make sure you pull the merge
- * scheduler using {@link #getMergeScheduler} and pass that to your
- * {@link IndexWriter}; this class uses that to keep track of which
- * merges are being done by which threads, to decide when to
- * cache each written file.
+ * be used during NRT search.
  *
  * <p>This class is likely only useful in a near-real-time
  * context, where indexing rate is lowish but reopen
@@ -56,20 +52,12 @@ import org.apache.lucene.util.IOUtils;
  * <p>This is safe to use: when your app calls {IndexWriter#commit},
  * all cached files will be flushed from the cached and sync'd.</p>
  *
- * <p><b>NOTE</b>: this class is somewhat sneaky in its
- * approach for spying on merges to determine the size of a
- * merge: it records which threads are running which merges
- * by watching ConcurrentMergeScheduler's doMerge method.
- * While this works correctly, likely future versions of
- * this class will take a more general approach.
- *
  * <p>Here's a simple example usage:
  *
  * <pre>
  *   Directory fsDir = FSDirectory.open(new File("/path/to/index"));
  *   NRTCachingDirectory cachedFSDir = new NRTCachingDirectory(fsDir, 5.0, 60.0);
  *   IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_32, analyzer);
- *   conf.setMergeScheduler(cachedFSDir.getMergeScheduler());
  *   IndexWriter writer = new IndexWriter(cachedFSDir, conf);
  * </pre>
  *
@@ -246,22 +234,6 @@ public class NRTCachingDirectory extends
     delegate.close();
   }
 
-  private final ConcurrentHashMap<Thread,MergePolicy.OneMerge> merges = new ConcurrentHashMap<Thread,MergePolicy.OneMerge>();
-
-  public MergeScheduler getMergeScheduler() {
-    return new ConcurrentMergeScheduler() {
-      @Override
-      protected void doMerge(MergePolicy.OneMerge merge) throws IOException {
-        try {
-          merges.put(Thread.currentThread(), merge);
-          super.doMerge(merge);
-        } finally {
-          merges.remove(Thread.currentThread());
-        }
-      }
-    };
-  }
-
   /** Subclass can override this to customize logic; return
    *  true if this file should be written to the RAMDirectory. */
   protected boolean doCacheWrite(String name, IOContext context) {

Modified: lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/index/TestNRTManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/index/TestNRTManager.java?rev=1139797&r1=1139796&r2=1139797&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/index/TestNRTManager.java
(original)
+++ lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/index/TestNRTManager.java
Sun Jun 26 14:17:27 2011
@@ -159,9 +159,7 @@ public class TestNRTManager extends Luce
         System.out.println("TEST: wrap NRTCachingDir");
       }
 
-      NRTCachingDirectory nrtDir = new NRTCachingDirectory(dir, 5.0, 60.0);
-      conf.setMergeScheduler(nrtDir.getMergeScheduler());
-      dir = nrtDir;
+      dir = new NRTCachingDirectory(dir, 5.0, 60.0);
     }
     
     final IndexWriter writer = new IndexWriter(dir, conf);

Modified: lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java?rev=1139797&r1=1139796&r2=1139797&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java
(original)
+++ lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java
Sun Jun 26 14:17:27 2011
@@ -45,7 +45,6 @@ public class TestNRTCachingDirectory ext
     Directory dir = newDirectory();
     NRTCachingDirectory cachedDir = new NRTCachingDirectory(dir, 2.0, 25.0);
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random));
-    conf.setMergeScheduler(cachedDir.getMergeScheduler());
     RandomIndexWriter w = new RandomIndexWriter(random, cachedDir, conf);
     w.w.setInfoStream(VERBOSE ? System.out : null);
     final LineFileDocs docs = new LineFileDocs(random);    
@@ -109,7 +108,6 @@ public class TestNRTCachingDirectory ext
     Directory fsDir = FSDirectory.open(new File("/path/to/index"));
     NRTCachingDirectory cachedFSDir = new NRTCachingDirectory(fsDir, 2.0, 25.0);
     IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_32, analyzer);
-    conf.setMergeScheduler(cachedFSDir.getMergeScheduler());
     IndexWriter writer = new IndexWriter(cachedFSDir, conf);
   }
 



Mime
View raw message