mirror of
https://github.com/apache/lucene.git
synced 2025-02-07 10:38:40 +00:00
LUCENE-4055: add some nocommits; remove IndexFileNameFilter; add changes entry
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4055@1341213 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2ec6fa5d7f
commit
f995f57f45
@ -1,3 +1,4 @@
|
||||
|
||||
Lucene Change Log
|
||||
|
||||
For more information on past and future Lucene versions, please see:
|
||||
@ -271,6 +272,8 @@ Changes in backwards compatibility policy
|
||||
that take two booleans indicating whether hit scores and max
|
||||
score 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 you
|
||||
|
@ -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 filtering
|
||||
if ((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 it
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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 -> BD
|
||||
bufferedDeletesStream.prune(segmentInfos);
|
||||
|
||||
|
@ -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 here
|
||||
public class SegmentInfo implements Cloneable {
|
||||
|
||||
// TODO: remove these from this class, for now this is the representation
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user