mirror of https://github.com/apache/lucene.git
add getters to FSD; change listAll to directly create String[]
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@771260 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6bcd89a916
commit
703f1d794b
|
@ -44,6 +44,14 @@ public class FileSwitchDirectory extends Directory {
|
|||
this.lockFactory = primaryDir.getLockFactory();
|
||||
}
|
||||
|
||||
public Directory getPrimaryDir() {
|
||||
return primaryDir;
|
||||
}
|
||||
|
||||
public Directory getSecondaryDir() {
|
||||
return secondaryDir;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
if (doClose) {
|
||||
try {
|
||||
|
@ -56,16 +64,12 @@ public class FileSwitchDirectory extends Directory {
|
|||
}
|
||||
|
||||
public String[] listAll() throws IOException {
|
||||
List list = new ArrayList();
|
||||
String[] ramFiles = secondaryDir.listAll();
|
||||
for (int x = 0; x < ramFiles.length; x++) {
|
||||
list.add(ramFiles[x]);
|
||||
}
|
||||
String[] fsFiles = primaryDir.listAll();
|
||||
for (int x = 0; x < fsFiles.length; x++) {
|
||||
list.add(fsFiles[x]);
|
||||
}
|
||||
return (String[]) list.toArray(new String[0]);
|
||||
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;
|
||||
}
|
||||
|
||||
public String[] list() throws IOException {
|
||||
|
|
|
@ -65,7 +65,10 @@ public class TestFileSwitchDirectory extends LuceneTestCase {
|
|||
reader.close();
|
||||
writer.close();
|
||||
|
||||
primaryDir.close();
|
||||
secondaryDir.close();
|
||||
files = fsd.listAll();
|
||||
for(int i=0;i<files.length;i++) {
|
||||
assertNotNull(files[i]);
|
||||
}
|
||||
fsd.close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue