lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r771260 - in /lucene/java/trunk/src: java/org/apache/lucene/store/FileSwitchDirectory.java test/org/apache/lucene/store/TestFileSwitchDirectory.java
Date Mon, 04 May 2009 10:16:22 GMT
Author: mikemccand
Date: Mon May  4 10:16:21 2009
New Revision: 771260

URL: http://svn.apache.org/viewvc?rev=771260&view=rev
Log:
add getters to FSD; change listAll to directly create String[]

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/store/FileSwitchDirectory.java
    lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/store/FileSwitchDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/store/FileSwitchDirectory.java?rev=771260&r1=771259&r2=771260&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/store/FileSwitchDirectory.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/store/FileSwitchDirectory.java Mon May  4
10:16:21 2009
@@ -44,6 +44,14 @@
     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 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 {

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java?rev=771260&r1=771259&r2=771260&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java Mon May
 4 10:16:21 2009
@@ -64,8 +64,11 @@
     }
     reader.close();
     writer.close();
-    
-    primaryDir.close();
-    secondaryDir.close();
+
+    files = fsd.listAll();
+    for(int i=0;i<files.length;i++) {
+      assertNotNull(files[i]);
+    }
+    fsd.close();
   }
 }



Mime
View raw message