You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/01/20 03:18:59 UTC
svn commit: r1233726 - in
/lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene:
codecs/LiveDocsFormat.java codecs/lucene40/Lucene40LiveDocsFormat.java
index/IndexFileNames.java index/IndexWriter.java index/SegmentInfo.java
Author: rmuir
Date: Fri Jan 20 02:18:59 2012
New Revision: 1233726
URL: http://svn.apache.org/viewvc?rev=1233726&view=rev
Log:
LUCENE-3661: remove .del from IndexFileNames
Modified:
lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/LiveDocsFormat.java
lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.java
lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexFileNames.java
lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexWriter.java
lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
Modified: lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/LiveDocsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/LiveDocsFormat.java?rev=1233726&r1=1233725&r2=1233726&view=diff
==============================================================================
--- lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/LiveDocsFormat.java (original)
+++ lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/LiveDocsFormat.java Fri Jan 20 02:18:59 2012
@@ -30,5 +30,5 @@ public abstract class LiveDocsFormat {
public abstract MutableBits newLiveDocs(int size) 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 files(Directory dir, SegmentInfo info, Set<String> files) throws IOException;
+ public abstract void separateFiles(Directory dir, SegmentInfo info, Set<String> files) throws IOException;
}
Modified: lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.java?rev=1233726&r1=1233725&r2=1233726&view=diff
==============================================================================
--- lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.java (original)
+++ lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.java Fri Jan 20 02:18:59 2012
@@ -13,6 +13,9 @@ import org.apache.lucene.util.MutableBit
public class Lucene40LiveDocsFormat extends LiveDocsFormat {
+ /** Extension of deletes */
+ static final String DELETES_EXTENSION = "del";
+
@Override
public MutableBits newLiveDocs(int size) throws IOException {
BitVector bitVector = new BitVector(size);
@@ -22,14 +25,14 @@ public class Lucene40LiveDocsFormat exte
@Override
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);
}
@Override
public void writeLiveDocs(MutableBits bits, Directory dir, SegmentInfo info, IOContext context) throws IOException {
// 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?
boolean success = false;
@@ -49,9 +52,9 @@ public class Lucene40LiveDocsFormat exte
}
@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()) {
- files.add(IndexFileNames.fileNameFromGeneration(info.name, IndexFileNames.DELETES_EXTENSION, info.getDelGen()));
+ files.add(IndexFileNames.fileNameFromGeneration(info.name, DELETES_EXTENSION, info.getDelGen()));
}
}
}
Modified: lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexFileNames.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexFileNames.java?rev=1233726&r1=1233725&r2=1233726&view=diff
==============================================================================
--- lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexFileNames.java (original)
+++ lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexFileNames.java Fri Jan 20 02:18:59 2012
@@ -57,9 +57,6 @@ public final class IndexFileNames {
/** Extension of compound file for doc store files*/
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
* 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[] {
COMPOUND_FILE_EXTENSION,
COMPOUND_FILE_ENTRIES_EXTENSION,
- DELETES_EXTENSION,
GEN_EXTENSION,
COMPOUND_FILE_STORE_EXTENSION,
};
Modified: lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexWriter.java?rev=1233726&r1=1233725&r2=1233726&view=diff
==============================================================================
--- lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexWriter.java Fri Jan 20 02:18:59 2012
@@ -30,7 +30,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.regex.Pattern;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.codecs.Codec;
@@ -4071,11 +4070,8 @@ public class IndexWriter implements Clos
Collection<String> files = info.files();
CompoundFileDirectory cfsDir = new CompoundFileDirectory(directory, fileName, context, true);
try {
+ assert assertNoSeparateFiles(files, directory, info);
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);
checkAbort.work(directory.fileLength(file));
}
@@ -4088,15 +4084,19 @@ public class IndexWriter implements Clos
/**
- * Returns true if the given filename ends with the separate norms file
- * pattern: {@code SEPARATE_NORMS_EXTENSION + "[0-9]+"}.
- * @deprecated only for asserting
- */
- @Deprecated
- private static boolean isSeparateNormsFile(String filename) {
- int idx = filename.lastIndexOf('.');
- if (idx == -1) return false;
- String ext = filename.substring(idx + 1);
- return Pattern.matches("s[0-9]+", ext);
+ * used only by assert: checks that filenames about to be put in cfs belong.
+ */
+ private static boolean assertNoSeparateFiles(Collection<String> files,
+ 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);
+
+ for (String file : files) {
+ assert !separateFiles.contains(file) : file + " should not go in CFS!";
+ }
+ return true;
}
}
Modified: lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/SegmentInfo.java?rev=1233726&r1=1233725&r2=1233726&view=diff
==============================================================================
--- lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/SegmentInfo.java (original)
+++ lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/SegmentInfo.java Fri Jan 20 02:18:59 2012
@@ -495,9 +495,10 @@ public final class SegmentInfo implement
}
}
- String delFileName = IndexFileNames.fileNameFromGeneration(name, IndexFileNames.DELETES_EXTENSION, delGen);
- if (delFileName != null && (delGen >= YES || dir.fileExists(delFileName))) {
- fileSet.add(delFileName);
+ // 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,