LUCENE-3661: clean up how we handle the case of files outside of CFS

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3661@1234051 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2012-01-20 18:10:22 +00:00
parent aadd4725cc
commit 7a3542f16a
4 changed files with 12 additions and 17 deletions

View File

@ -54,6 +54,11 @@ public abstract class Codec implements NamedSPILoader.NamedSPI {
normsFormat().files(dir, info, files);
}
public void separateFiles(Directory dir, SegmentInfo info, Set<String> files) throws IOException {
liveDocsFormat().separateFiles(dir, info, files);
normsFormat().separateFiles(dir, info, files);
}
/** Encodes/decodes postings */
public abstract PostingsFormat postingsFormat();

View File

@ -39,7 +39,9 @@ import org.apache.lucene.util.MutableBits;
*
* @lucene.internal
*/
public final class BitVector implements Cloneable, MutableBits {
// pkg-private: if this thing is generally useful then it can go back in .util,
// but the serialization must be here underneath the codec.
final class BitVector implements Cloneable, MutableBits {
private byte[] bits;
private int size;

View File

@ -4082,9 +4082,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
Directory dir, SegmentInfo info) throws IOException {
// maybe this is overkill, but codec naming clashes would be bad.
Set<String> separateFiles = new HashSet<String>();
Codec codec = info.getCodec();
codec.normsFormat().separateFiles(dir, info, separateFiles);
codec.liveDocsFormat().separateFiles(dir, info, separateFiles);
info.getCodec().separateFiles(dir, info, separateFiles);
for (String file : files) {
assert !separateFiles.contains(file) : file + " should not go in CFS!";

View File

@ -484,6 +484,9 @@ public final class SegmentInfo implements Cloneable {
} else {
codec.files(dir, this, fileSet);
}
// regardless of compound file setting: these files are always in the directory
codec.separateFiles(dir, this, fileSet);
if (docStoreOffset != -1) {
// We are sharing doc stores (stored fields, term
@ -495,19 +498,6 @@ public final class SegmentInfo implements Cloneable {
}
}
// because deletions are stored outside CFS, we must check deletes here
// note: before the WTF logic was: delFileName != null && (hasDeletions() || fileExists(delFileName))...
if (hasDeletions()) {
codec.liveDocsFormat().separateFiles(dir, this, fileSet);
}
// because separate norm files are unconditionally stored outside cfs,
// we must explicitly ask for their filenames if we might have separate norms:
// remove this when 3.x indexes are no longer supported
if (normGen != null) {
codec.normsFormat().separateFiles(dir, this, fileSet);
}
files = new ArrayList<String>(fileSet);
return files;