lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r963372 - in /lucene/dev/trunk/lucene: CHANGES.txt src/java/org/apache/lucene/store/FileSwitchDirectory.java
Date Mon, 12 Jul 2010 17:28:34 GMT
Author: mikemccand
Date: Mon Jul 12 17:28:34 2010
New Revision: 963372

URL: http://svn.apache.org/viewvc?rev=963372&view=rev
Log:
LUCENE-2533: don't return dup Strings from FileSwitchDir.listAll

Modified:
    lucene/dev/trunk/lucene/CHANGES.txt
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/FileSwitchDirectory.java

Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=963372&r1=963371&r2=963372&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Mon Jul 12 17:28:34 2010
@@ -407,6 +407,10 @@ Bug fixes
 * LUCENE-2513: when opening writable IndexReader on a not-current
   commit, do not overwrite "future" commits.  (Mike McCandless)
 
+* LUCENE-2533: fix FileSwitchDirectory.listAll to not return dups when
+  primary & secondary dirs share the same underlying directory.
+  (Michael McCandless)
+
 New features
 
 * LUCENE-2128: Parallelized fetching document frequencies during weight

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/FileSwitchDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/FileSwitchDirectory.java?rev=963372&r1=963371&r2=963372&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/FileSwitchDirectory.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/FileSwitchDirectory.java Mon
Jul 12 17:28:34 2010
@@ -24,6 +24,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
+import java.util.HashSet;
 
 /**
  * Expert: A Directory instance that switches files between
@@ -76,12 +77,14 @@ public class FileSwitchDirectory extends
   
   @Override
   public String[] listAll() throws IOException {
-    String[] primaryFiles = primaryDir.listAll();
-    String[] secondaryFiles = secondaryDir.listAll();
-    String[] files = new String[primaryFiles.length + secondaryFiles.length];
-    System.arraycopy(primaryFiles, 0, files, 0, primaryFiles.length);
-    System.arraycopy(secondaryFiles, 0, files, primaryFiles.length, secondaryFiles.length);
-    return files;
+    Set<String> files = new HashSet<String>();
+    for(String f : primaryDir.listAll()) {
+      files.add(f);
+    }
+    for(String f : secondaryDir.listAll()) {
+      files.add(f);
+    }
+    return files.toArray(new String[files.size()]);
   }
 
   /** Utility method to return a file's extension. */



Mime
View raw message