You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2015/01/01 11:45:52 UTC

svn commit: r1648813 - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/CHANGES.txt lucene/core/ lucene/core/src/java/org/apache/lucene/store/FSDirectory.java

Author: uschindler
Date: Thu Jan  1 10:45:51 2015
New Revision: 1648813

URL: http://svn.apache.org/r1648813
Log:
Merged revision(s) 1648812 from lucene/dev/trunk:
LUCENE-6150: Remove staleFiles set and onIndexOutputClosed() from FSDirectory

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/lucene/   (props changed)
    lucene/dev/branches/branch_5x/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/lucene/core/   (props changed)
    lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java

Modified: lucene/dev/branches/branch_5x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/CHANGES.txt?rev=1648813&r1=1648812&r2=1648813&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/lucene/CHANGES.txt Thu Jan  1 10:45:51 2015
@@ -297,6 +297,9 @@ API Changes
 * LUCENE-6147: Make the core Accountables.namedAccountable function public
   (Ryan Ernst)
 
+* LUCENE-6150: Remove staleFiles set and onIndexOutputClosed() from FSDirectory.
+  (Uwe Schindler, Robert Muir, Mike McCandless)
+
 Bug Fixes
 
 * LUCENE-5650: Enforce read-only access to any path outside the temporary

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java?rev=1648813&r1=1648812&r2=1648813&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java Thu Jan  1 10:45:51 2015
@@ -17,9 +17,6 @@ package org.apache.lucene.store;
  * limitations under the License.
  */
 
-import org.apache.lucene.util.Constants;
-import org.apache.lucene.util.IOUtils;
-
 import java.io.FileOutputStream;
 import java.io.FilterOutputStream;
 import java.io.IOException;
@@ -29,12 +26,11 @@ import java.nio.file.Path;
 import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 import java.util.concurrent.Future;
 
-import static java.util.Collections.synchronizedSet;
+import org.apache.lucene.util.Constants;
+import org.apache.lucene.util.IOUtils;
 
 /**
  * Base class for Directory implementations that store index
@@ -116,7 +112,6 @@ import static java.util.Collections.sync
 public abstract class FSDirectory extends BaseDirectory {
 
   protected final Path directory; // The underlying filesystem directory
-  protected final Set<String> staleFiles = synchronizedSet(new HashSet<String>()); // Files written, but not yet sync'ed
 
   /** Create a new FSDirectory for the named location (ctor for subclasses).
    * @param path the path of the directory
@@ -208,7 +203,6 @@ public abstract class FSDirectory extend
   public void deleteFile(String name) throws IOException {
     ensureOpen();
     Files.delete(directory.resolve(name));
-    staleFiles.remove(name);
   }
 
   /** Creates an IndexOutput for the file with the given name. */
@@ -224,25 +218,13 @@ public abstract class FSDirectory extend
     Files.deleteIfExists(directory.resolve(name)); // delete existing, if any
   }
 
-  /**
-   * Sub classes should call this method on closing an open {@link IndexOutput}, reporting the name of the file
-   * that was closed. {@code FSDirectory} needs this information to take care of syncing stale files.
-   */
-  protected void onIndexOutputClosed(String name) {
-    staleFiles.add(name);
-  }
-
   @Override
   public void sync(Collection<String> names) throws IOException {
     ensureOpen();
-    Set<String> toSync = new HashSet<>(names);
-    toSync.retainAll(staleFiles);
 
-    for (String name : toSync) {
+    for (String name : names) {
       fsync(name);
     }
-    
-    staleFiles.removeAll(toSync);
   }
   
   @Override
@@ -279,8 +261,6 @@ public abstract class FSDirectory extend
      */
     static final int CHUNK_SIZE = 8192;
     
-    private final String name;
-
     public FSIndexOutput(String name) throws IOException {
       super("FSIndexOutput(path=\"" + directory.resolve(name) + "\")", new FilterOutputStream(Files.newOutputStream(directory.resolve(name))) {
         // This implementation ensures, that we never write more than CHUNK_SIZE bytes:
@@ -294,16 +274,6 @@ public abstract class FSDirectory extend
           }
         }
       }, CHUNK_SIZE);
-      this.name = name;
-    }
-    
-    @Override
-    public void close() throws IOException {
-      try {
-        onIndexOutputClosed(name);
-      } finally {
-        super.close();
-      }
     }
   }