mirror of https://github.com/apache/lucene.git
LUCENE-3661: remove .del from IndexFileNames
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3661@1233726 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2dee41b88e
commit
6117558c44
|
@ -30,5 +30,5 @@ public abstract class LiveDocsFormat {
|
||||||
public abstract MutableBits newLiveDocs(int size) throws IOException;
|
public abstract MutableBits newLiveDocs(int size) throws IOException;
|
||||||
public abstract Bits readLiveDocs(Directory dir, SegmentInfo info, IOContext context) throws IOException;
|
public abstract Bits readLiveDocs(Directory dir, SegmentInfo info, IOContext context) throws IOException;
|
||||||
public abstract void writeLiveDocs(MutableBits bits, Directory dir, SegmentInfo info, IOContext context) throws IOException;
|
public abstract void writeLiveDocs(MutableBits bits, Directory dir, SegmentInfo info, IOContext context) throws IOException;
|
||||||
public abstract void files(Directory dir, SegmentInfo info, Set<String> files) throws IOException;
|
public abstract void separateFiles(Directory dir, SegmentInfo info, Set<String> files) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,9 @@ import org.apache.lucene.util.MutableBits;
|
||||||
|
|
||||||
public class Lucene40LiveDocsFormat extends LiveDocsFormat {
|
public class Lucene40LiveDocsFormat extends LiveDocsFormat {
|
||||||
|
|
||||||
|
/** Extension of deletes */
|
||||||
|
static final String DELETES_EXTENSION = "del";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MutableBits newLiveDocs(int size) throws IOException {
|
public MutableBits newLiveDocs(int size) throws IOException {
|
||||||
BitVector bitVector = new BitVector(size);
|
BitVector bitVector = new BitVector(size);
|
||||||
|
@ -22,14 +25,14 @@ public class Lucene40LiveDocsFormat extends LiveDocsFormat {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Bits readLiveDocs(Directory dir, SegmentInfo info, IOContext context) throws IOException {
|
public Bits readLiveDocs(Directory dir, SegmentInfo info, IOContext context) throws IOException {
|
||||||
String filename = IndexFileNames.fileNameFromGeneration(info.name, IndexFileNames.DELETES_EXTENSION, info.getDelGen());
|
String filename = IndexFileNames.fileNameFromGeneration(info.name, DELETES_EXTENSION, info.getDelGen());
|
||||||
return new BitVector(dir, filename, context);
|
return new BitVector(dir, filename, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeLiveDocs(MutableBits bits, Directory dir, SegmentInfo info, IOContext context) throws IOException {
|
public void writeLiveDocs(MutableBits bits, Directory dir, SegmentInfo info, IOContext context) throws IOException {
|
||||||
// nocommit: this api is ugly...
|
// nocommit: this api is ugly...
|
||||||
String filename = IndexFileNames.fileNameFromGeneration(info.name, IndexFileNames.DELETES_EXTENSION, info.getDelGen());
|
String filename = IndexFileNames.fileNameFromGeneration(info.name, DELETES_EXTENSION, info.getDelGen());
|
||||||
|
|
||||||
// nocommit: is it somehow cleaner to still have IW do this try/finally/delete stuff and add abort() instead?
|
// nocommit: is it somehow cleaner to still have IW do this try/finally/delete stuff and add abort() instead?
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
@ -49,9 +52,9 @@ public class Lucene40LiveDocsFormat extends LiveDocsFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void files(Directory dir, SegmentInfo info, Set<String> files) throws IOException {
|
public void separateFiles(Directory dir, SegmentInfo info, Set<String> files) throws IOException {
|
||||||
if (info.hasDeletions()) {
|
if (info.hasDeletions()) {
|
||||||
files.add(IndexFileNames.fileNameFromGeneration(info.name, IndexFileNames.DELETES_EXTENSION, info.getDelGen()));
|
files.add(IndexFileNames.fileNameFromGeneration(info.name, DELETES_EXTENSION, info.getDelGen()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,6 @@ public final class IndexFileNames {
|
||||||
/** Extension of compound file for doc store files*/
|
/** Extension of compound file for doc store files*/
|
||||||
public static final String COMPOUND_FILE_STORE_EXTENSION = "cfx";
|
public static final String COMPOUND_FILE_STORE_EXTENSION = "cfx";
|
||||||
|
|
||||||
/** Extension of deletes */
|
|
||||||
public static final String DELETES_EXTENSION = "del";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This array contains all filename extensions used by
|
* This array contains all filename extensions used by
|
||||||
* Lucene's index files, with one exception, namely the
|
* Lucene's index files, with one exception, namely the
|
||||||
|
@ -70,7 +67,6 @@ public final class IndexFileNames {
|
||||||
public static final String INDEX_EXTENSIONS[] = new String[] {
|
public static final String INDEX_EXTENSIONS[] = new String[] {
|
||||||
COMPOUND_FILE_EXTENSION,
|
COMPOUND_FILE_EXTENSION,
|
||||||
COMPOUND_FILE_ENTRIES_EXTENSION,
|
COMPOUND_FILE_ENTRIES_EXTENSION,
|
||||||
DELETES_EXTENSION,
|
|
||||||
GEN_EXTENSION,
|
GEN_EXTENSION,
|
||||||
COMPOUND_FILE_STORE_EXTENSION,
|
COMPOUND_FILE_STORE_EXTENSION,
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import org.apache.lucene.analysis.Analyzer;
|
import org.apache.lucene.analysis.Analyzer;
|
||||||
import org.apache.lucene.codecs.Codec;
|
import org.apache.lucene.codecs.Codec;
|
||||||
|
@ -4071,11 +4070,8 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
|
||||||
Collection<String> files = info.files();
|
Collection<String> files = info.files();
|
||||||
CompoundFileDirectory cfsDir = new CompoundFileDirectory(directory, fileName, context, true);
|
CompoundFileDirectory cfsDir = new CompoundFileDirectory(directory, fileName, context, true);
|
||||||
try {
|
try {
|
||||||
|
assert assertNoSeparateFiles(files, directory, info);
|
||||||
for (String file : files) {
|
for (String file : files) {
|
||||||
assert !IndexFileNames.matchesExtension(file, IndexFileNames.DELETES_EXTENSION)
|
|
||||||
: ".del file is not allowed in .cfs: " + file;
|
|
||||||
assert !isSeparateNormsFile(file)
|
|
||||||
: "separate norms file (.s[0-9]+) is not allowed in .cfs: " + file;
|
|
||||||
directory.copy(cfsDir, file, file, context);
|
directory.copy(cfsDir, file, file, context);
|
||||||
checkAbort.work(directory.fileLength(file));
|
checkAbort.work(directory.fileLength(file));
|
||||||
}
|
}
|
||||||
|
@ -4088,15 +4084,19 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the given filename ends with the separate norms file
|
* used only by assert: checks that filenames about to be put in cfs belong.
|
||||||
* pattern: {@code SEPARATE_NORMS_EXTENSION + "[0-9]+"}.
|
|
||||||
* @deprecated only for asserting
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
private static boolean assertNoSeparateFiles(Collection<String> files,
|
||||||
private static boolean isSeparateNormsFile(String filename) {
|
Directory dir, SegmentInfo info) throws IOException {
|
||||||
int idx = filename.lastIndexOf('.');
|
// maybe this is overkill, but codec naming clashes would be bad.
|
||||||
if (idx == -1) return false;
|
Set<String> separateFiles = new HashSet<String>();
|
||||||
String ext = filename.substring(idx + 1);
|
Codec codec = info.getCodec();
|
||||||
return Pattern.matches("s[0-9]+", ext);
|
codec.normsFormat().separateFiles(dir, info, separateFiles);
|
||||||
|
codec.liveDocsFormat().separateFiles(dir, info, separateFiles);
|
||||||
|
|
||||||
|
for (String file : files) {
|
||||||
|
assert !separateFiles.contains(file) : file + " should not go in CFS!";
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -495,9 +495,10 @@ public final class SegmentInfo implements Cloneable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String delFileName = IndexFileNames.fileNameFromGeneration(name, IndexFileNames.DELETES_EXTENSION, delGen);
|
// because deletions are stored outside CFS, we must check deletes here
|
||||||
if (delFileName != null && (delGen >= YES || dir.fileExists(delFileName))) {
|
// note: before the WTF logic was: delFileName != null && (hasDeletions() || fileExists(delFileName))...
|
||||||
fileSet.add(delFileName);
|
if (hasDeletions()) {
|
||||||
|
codec.liveDocsFormat().separateFiles(dir, this, fileSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
// because separate norm files are unconditionally stored outside cfs,
|
// because separate norm files are unconditionally stored outside cfs,
|
||||||
|
|
Loading…
Reference in New Issue