LUCENE-2533: don't return dup Strings from FileSwitchDir.listAll

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@963372 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2010-07-12 17:28:34 +00:00
parent 9cfb3be57f
commit 7dc191922c
2 changed files with 13 additions and 6 deletions

View File

@ -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

View File

@ -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 Directory {
@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. */