Apache Lucene open-source search software
LUCENE-4055: add some nocommits; remove IndexFileNameFilter; add changes entry
Michael McCandlessf995f57f45cc
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex dce825156f8..02a18e7bcdc 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -1,3 +1,4 @@+Lucene Change LogFor more information on past and future Lucene versions, please see:@@ -271,6 +272,8 @@ Changes in backwards compatibility policythat take two booleans indicating whether hit scores and maxscore should be computed. (Mike McCandless)+* LUCENE-4055: You can't put foreign files into the index dir anymore.+Changes in Runtime Behavior* LUCENE-2846: omitNorms now behaves like omitTermFrequencyAndPositions, if youdiff --git a/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java b/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.javaindex d231bedede3..93c06da9036 100644--- a/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java+++ b/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java@@ -150,7 +150,7 @@ final class IndexFileDeleter {for (String fileName : files) {- if ((IndexFileNameFilter.INSTANCE.accept(null, fileName)) && !fileName.endsWith("write.lock") && !fileName.equals(IndexFileNames.SEGMENTS_GEN)) {+ if (!fileName.endsWith("write.lock") && !fileName.equals(IndexFileNames.SEGMENTS_GEN)) {// Add this file to refCounts with initial count 0:getRefCount(fileName);@@ -331,8 +331,9 @@ final class IndexFileDeleter {for(int i=0;i<files.length;i++) {String fileName = files[i];+ // nocommit nuke this filteringif ((segmentName == null || fileName.startsWith(segmentPrefix1) || fileName.startsWith(segmentPrefix2)) &&- IndexFileNameFilter.INSTANCE.accept(null, fileName) &&+ !fileName.endsWith("write.lock") &&!refCounts.containsKey(fileName) &&!fileName.equals(IndexFileNames.SEGMENTS_GEN)) {// Unreferenced file, so remove itdiff --git a/lucene/core/src/java/org/apache/lucene/index/IndexFileNameFilter.java b/lucene/core/src/java/org/apache/lucene/index/IndexFileNameFilter.javadeleted file mode 100644index 9ceba8b0920..00000000000--- a/lucene/core/src/java/org/apache/lucene/index/IndexFileNameFilter.java+++ /dev/null@@ -1,61 +0,0 @@-package org.apache.lucene.index;--/**- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--import java.io.File;-import java.io.FilenameFilter;-import java.util.regex.Pattern;--/**- * Filename filter that attempts to accept only filenames- * created by Lucene. Note that this is a "best effort"- * process. If a file is used in a Lucene index, it will- * always match the file; but if a file is not used in a- * Lucene index but is named in a similar way to Lucene's- * files then this filter may accept the file.- *- * <p>This does not accept <code>*-write.lock</code> files.- *- * @lucene.internal- */--public class IndexFileNameFilter implements FilenameFilter {-- public static final FilenameFilter INSTANCE = new IndexFileNameFilter();-- private IndexFileNameFilter() {- }-- // Approximate match for files that seem to be Lucene- // index files. This can easily over-match, ie if some- // app names a file _foo_bar.go:- private final Pattern luceneFilePattern = Pattern.compile("^_[a-z0-9]+(_[a-zA-Z0-9]+)?\\.[a-z0-9]+$");-- /* (non-Javadoc)- * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)- */- public boolean accept(File dir, String name) {- if (name.lastIndexOf('.') != -1) {- // Has an extension- return luceneFilePattern.matcher(name).matches();- } else {- // No extension -- only segments_N file;- return name.startsWith(IndexFileNames.SEGMENTS);- }- }-}diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.javaindex 58fe716affd..5787c45f734 100644--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java@@ -1505,10 +1505,16 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {// merge:for(final MergePolicy.OneMerge merge : pendingMerges) {merge.maxNumSegments = maxNumSegments;+ // nocommit: remove this, except it causes+ // TestExternalCodecs.testPerFieldCodec failures:+ segmentsToMerge.put(merge.info, Boolean.TRUE);}for (final MergePolicy.OneMerge merge: runningMerges) {merge.maxNumSegments = maxNumSegments;+ // nocommit: remove this, except it causes+ // TestExternalCodecs.testPerFieldCodec failures:+ segmentsToMerge.put(merge.info, Boolean.TRUE);}}@@ -2813,7 +2819,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {// merge will skip merging it and will then drop// it once it's done:if (!mergingSegments.contains(info)) {- System.out.println("drop all del seg=" + info.name);segmentInfos.remove(info);readerPool.drop(info);}@@ -3310,9 +3315,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {final String mergeSegmentName = newSegmentName();merge.info = new SegmentInfo(directory, Constants.LUCENE_MAIN_VERSION, mergeSegmentName, 0, -1, mergeSegmentName, false, null, false, 0, codec, details);- // nocommit- // merge.info.setBufferedDeletesGen(result.gen);-// Lock order: IW -> BDbufferedDeletesStream.prune(segmentInfos);diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.javaindex 6e0d89c9594..52ef586abdd 100644--- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java+++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java@@ -34,12 +34,23 @@ import org.apache.lucene.store.Directory;import org.apache.lucene.store.TrackingDirectoryWrapper;import org.apache.lucene.util.Constants;+// nocommit fix jdocs for all codec's SI writer impls to+// describe their format++// nocommit fix codec api to pass this around so they can+// store attrs++// nocommit add attrs api like FI++// nocommit fix PFPF to use attrs api instead of its .per file+/*** Information about a segment such as it's name, directory, and files related* to the segment.** @lucene.experimental*/+// nocommit make final again once atts are working herepublic class SegmentInfo implements Cloneable {// TODO: remove these from this class, for now this is the representationdiff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.javaindex 434f3dd479d..63d26126ed6 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java@@ -985,26 +985,6 @@ public class TestIndexWriter extends LuceneTestCase {dir.close();}-- // LUCENE-1468 -- make sure opening an IndexWriter with- // create=true does not remove non-index files-- public void testOtherFiles() throws Throwable {- Directory dir = newDirectory();- try {- // Create my own random file:- IndexOutput out = dir.createOutput("myrandomfile", newIOContext(random()));- out.writeByte((byte) 42);- out.close();-- new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))).close();-- assertTrue(dir.fileExists("myrandomfile"));- } finally {- dir.close();- }- }-public void testDeadlock() throws Exception {Directory dir = newDirectory();IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMaxBufferedDocs(2));