You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/10/15 11:58:19 UTC

svn commit: r1708760 [4/4] - in /lucene/dev/trunk: lucene/ lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/ lucene/analysis/common/src/test/org/apache/lucene/analysis/core/ lucene/analysis/common/src/test/org/apache/lucene/analysis/...

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/ThrottledIndexOutput.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/ThrottledIndexOutput.java?rev=1708760&r1=1708759&r2=1708760&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/ThrottledIndexOutput.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/ThrottledIndexOutput.java Thu Oct 15 09:58:18 2015
@@ -16,6 +16,7 @@ package org.apache.lucene.util;
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 import java.io.IOException;
 
 import org.apache.lucene.store.DataInput;
@@ -59,7 +60,7 @@ public class ThrottledIndexOutput extend
   public ThrottledIndexOutput(int bytesPerSecond, long flushDelayMillis,
       long closeDelayMillis, long seekDelayMillis, long minBytesWritten,
       IndexOutput delegate) {
-    super("ThrottledIndexOutput(" + delegate + ")");
+    super("ThrottledIndexOutput(" + delegate + ")", delegate == null ? "n/a" : delegate.getName());
     assert bytesPerSecond > 0;
     this.delegate = delegate;
     this.bytesPerSecond = bytesPerSecond;
@@ -117,8 +118,9 @@ public class ThrottledIndexOutput extend
   }
 
   private static final void sleep(long ms) {
-    if (ms <= 0)
+    if (ms <= 0) {
       return;
+    }
     try {
       Thread.sleep(ms);
     } catch (InterruptedException e) {

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/LookupFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/LookupFactory.java?rev=1708760&r1=1708759&r2=1708760&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/LookupFactory.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/LookupFactory.java Thu Oct 15 09:58:18 2015
@@ -17,7 +17,11 @@ package org.apache.solr.spelling.suggest
  * limitations under the License.
  */
 
+import java.io.IOException;
+import java.nio.file.Paths;
+
 import org.apache.lucene.search.suggest.Lookup;
+import org.apache.lucene.store.FSDirectory;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.spelling.suggest.jaspell.JaspellLookupFactory;
@@ -41,4 +45,23 @@ public abstract class LookupFactory {
    * <b>NOTE:</b> not all {@link Lookup} implementations store in-memory data structures
    * */
   public abstract String storeFileName();
+
+  /** Non-null if this sugggester created a temp dir, needed only during build */
+  private static FSDirectory tmpBuildDir;
+
+  protected static synchronized FSDirectory getTempDir() {
+    if (tmpBuildDir == null) {
+      // Lazy init
+      String tempDirPath = System.getProperty("java.io.tmpdir");
+      if (tempDirPath == null)  {
+        throw new RuntimeException("Java has no temporary folder property (java.io.tmpdir)?");
+      }
+      try {
+        tmpBuildDir = FSDirectory.open(Paths.get(tempDirPath));
+      } catch (IOException ioe) {
+        throw new RuntimeException(ioe);
+      }
+    }
+    return tmpBuildDir;
+  }
 }

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/AnalyzingLookupFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/AnalyzingLookupFactory.java?rev=1708760&r1=1708759&r2=1708760&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/AnalyzingLookupFactory.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/AnalyzingLookupFactory.java Thu Oct 15 09:58:18 2015
@@ -120,8 +120,7 @@ public class AnalyzingLookupFactory exte
     ? Boolean.valueOf(params.get(PRESERVE_POSITION_INCREMENTS).toString())
     : false;
 
-    
-    return new AnalyzingSuggester(indexAnalyzer, queryAnalyzer, flags, maxSurfaceFormsPerAnalyzedForm,
+    return new AnalyzingSuggester(getTempDir(), "suggester", indexAnalyzer, queryAnalyzer, flags, maxSurfaceFormsPerAnalyzedForm,
         maxGraphExpansions, preservePositionIncrements);
   }
 

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/FSTLookupFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/FSTLookupFactory.java?rev=1708760&r1=1708759&r2=1708760&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/FSTLookupFactory.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/FSTLookupFactory.java Thu Oct 15 09:58:18 2015
@@ -60,7 +60,7 @@ public class FSTLookupFactory extends Lo
     ? Boolean.valueOf(params.get(EXACT_MATCH_FIRST).toString())
     : true;
 
-    return new FSTCompletionLookup(buckets, exactMatchFirst);
+    return new FSTCompletionLookup(getTempDir(), "suggester", buckets, exactMatchFirst);
   }
 
   @Override

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/FuzzyLookupFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/FuzzyLookupFactory.java?rev=1708760&r1=1708759&r2=1708760&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/FuzzyLookupFactory.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/FuzzyLookupFactory.java Thu Oct 15 09:58:18 2015
@@ -134,7 +134,7 @@ public class FuzzyLookupFactory extends
     ? Boolean.valueOf(params.get(UNICODE_AWARE).toString())
     : FuzzySuggester.DEFAULT_UNICODE_AWARE;
     
-    return new FuzzySuggester(indexAnalyzer, queryAnalyzer, options, maxSurfaceFormsPerAnalyzedForm,
+    return new FuzzySuggester(getTempDir(), "suggester", indexAnalyzer, queryAnalyzer, options, maxSurfaceFormsPerAnalyzedForm,
         maxGraphExpansions, preservePositionIncrements, maxEdits, transpositions, nonFuzzyPrefix,
         minFuzzyLength, unicodeAware);
   }

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/WFSTLookupFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/WFSTLookupFactory.java?rev=1708760&r1=1708759&r2=1708760&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/WFSTLookupFactory.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/fst/WFSTLookupFactory.java Thu Oct 15 09:58:18 2015
@@ -17,8 +17,6 @@ package org.apache.solr.spelling.suggest
  * limitations under the License.
  */
 
-import java.io.File;
-
 import org.apache.lucene.search.suggest.Lookup;
 import org.apache.lucene.search.suggest.fst.*;
 import org.apache.solr.common.util.NamedList;
@@ -48,7 +46,7 @@ public class WFSTLookupFactory extends L
     ? Boolean.valueOf(params.get(EXACT_MATCH_FIRST).toString())
     : true;
 
-    return new WFSTCompletionLookup(exactMatchFirst);
+    return new WFSTCompletionLookup(getTempDir(), "suggester", exactMatchFirst);
   }
 
   @Override

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/tst/TSTLookupFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/tst/TSTLookupFactory.java?rev=1708760&r1=1708759&r2=1708760&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/tst/TSTLookupFactory.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/suggest/tst/TSTLookupFactory.java Thu Oct 15 09:58:18 2015
@@ -31,7 +31,7 @@ public class TSTLookupFactory extends Lo
 
   @Override
   public Lookup create(NamedList params, SolrCore core) {
-    return new TSTLookup();
+    return new TSTLookup(getTempDir(), "suggester");
   }
 
   @Override

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/blockcache/CachedIndexOutput.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/blockcache/CachedIndexOutput.java?rev=1708760&r1=1708759&r2=1708760&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/blockcache/CachedIndexOutput.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/blockcache/CachedIndexOutput.java Thu Oct 15 09:58:18 2015
@@ -37,7 +37,7 @@ public class CachedIndexOutput extends R
   
   public CachedIndexOutput(BlockDirectory directory, IndexOutput dest,
       int blockSize, String name, Cache cache, int bufferSize) {
-    super("dest=" + dest + " name=" + name, bufferSize);
+    super("dest=" + dest + " name=" + name, name, bufferSize);
     this.directory = directory;
     this.dest = dest;
     this.blockSize = blockSize;

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/blockcache/ReusedBufferedIndexOutput.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/blockcache/ReusedBufferedIndexOutput.java?rev=1708760&r1=1708759&r2=1708760&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/blockcache/ReusedBufferedIndexOutput.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/blockcache/ReusedBufferedIndexOutput.java Thu Oct 15 09:58:18 2015
@@ -43,12 +43,12 @@ public abstract class ReusedBufferedInde
   
   private final Store store;
   
-  public ReusedBufferedIndexOutput(String resourceDescription) {
-    this(resourceDescription, BUFFER_SIZE);
+  public ReusedBufferedIndexOutput(String resourceDescription, String name) {
+    this(resourceDescription, name, BUFFER_SIZE);
   }
   
-  public ReusedBufferedIndexOutput(String resourceDescription, int bufferSize) {
-    super(resourceDescription);
+  public ReusedBufferedIndexOutput(String resourceDescription, String name, int bufferSize) {
+    super(resourceDescription, name);
     checkBufferSize(bufferSize);
     this.bufferSize = bufferSize;
     store = BufferStore.instance(bufferSize);

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java?rev=1708760&r1=1708759&r2=1708760&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java Thu Oct 15 09:58:18 2015
@@ -107,7 +107,12 @@ public class HdfsDirectory extends BaseD
   
   @Override
   public IndexOutput createOutput(String name, IOContext context) throws IOException {
-    return new HdfsFileWriter(getFileSystem(), new Path(hdfsDirPath, name));
+    return new HdfsFileWriter(getFileSystem(), new Path(hdfsDirPath, name), name);
+  }
+
+  @Override
+  public IndexOutput createTempOutput(String prefix, String suffix, IOContext context) throws IOException {
+    throw new UnsupportedOperationException();
   }
   
   private String[] getNormalNames(List<String> files) {

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/hdfs/HdfsFileWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/hdfs/HdfsFileWriter.java?rev=1708760&r1=1708759&r2=1708760&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/hdfs/HdfsFileWriter.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/store/hdfs/HdfsFileWriter.java Thu Oct 15 09:58:18 2015
@@ -37,8 +37,8 @@ public class HdfsFileWriter extends Outp
   public static final String HDFS_SYNC_BLOCK = "solr.hdfs.sync.block";
   public static final int BUFFER_SIZE = 16384;
   
-  public HdfsFileWriter(FileSystem fileSystem, Path path) throws IOException {
-    super("fileSystem=" + fileSystem + " path=" + path, getOutputStream(fileSystem, path), BUFFER_SIZE);
+  public HdfsFileWriter(FileSystem fileSystem, Path path, String name) throws IOException {
+    super("fileSystem=" + fileSystem + " path=" + path, name, getOutputStream(fileSystem, path), BUFFER_SIZE);
   }
   
   private static final OutputStream getOutputStream(FileSystem fileSystem, Path path) throws IOException {