LUCENE-3226: rename SegmentInfos.FORMAT_3_1 and improve description in CheckIndex

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1138257 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-06-22 00:05:27 +00:00
parent 6b41b73894
commit 0056b966bf
6 changed files with 18 additions and 18 deletions

View File

@ -371,10 +371,10 @@ public class CheckIndex {
sFormat = "FORMAT_DIAGNOSTICS [Lucene 2.9]";
} else if (format == DefaultSegmentInfosWriter.FORMAT_HAS_VECTORS) {
sFormat = "FORMAT_HAS_VECTORS [Lucene 3.1]";
} else if (format == DefaultSegmentInfosWriter.FORMAT_3_1) {
sFormat = "FORMAT_3_1 [Lucene 3.1]";
} else if (format == DefaultSegmentInfosWriter.FORMAT_4_0) {
sFormat = "FORMAT_4_0 [Lucene 4.0]";
} else if (format == DefaultSegmentInfosWriter.FORMAT_SEGMENT_RECORDS_VERSION) {
sFormat = "FORMAT_SEGMENT_RECORDS_VERSION [Lucene 3.1+]";
} else if (format == DefaultSegmentInfosWriter.FORMAT_FLEX) {
sFormat = "FORMAT_FLEX [Lucene 4.0+]";
} else if (format == DefaultSegmentInfosWriter.FORMAT_CURRENT) {
throw new RuntimeException("BUG: You should update this tool!");
} else if (format < DefaultSegmentInfosWriter.FORMAT_CURRENT) {

View File

@ -178,7 +178,7 @@ public final class SegmentInfo implements Cloneable {
*/
public SegmentInfo(Directory dir, int format, IndexInput input, CodecProvider codecs) throws IOException {
this.dir = dir;
if (format <= DefaultSegmentInfosWriter.FORMAT_3_1) {
if (format <= DefaultSegmentInfosWriter.FORMAT_SEGMENT_RECORDS_VERSION) {
version = input.readString();
}
name = input.readString();
@ -193,7 +193,7 @@ public final class SegmentInfo implements Cloneable {
docStoreIsCompoundFile = false;
}
if (format > DefaultSegmentInfosWriter.FORMAT_4_0) {
if (format > DefaultSegmentInfosWriter.FORMAT_FLEX) {
// pre-4.0 indexes write a byte if there is a single norms file
byte b = input.readByte();
assert 1 == b;
@ -206,7 +206,7 @@ public final class SegmentInfo implements Cloneable {
normGen = new HashMap<Integer, Long>();
for(int j=0;j<numNormGen;j++) {
int fieldNumber = j;
if (format <= DefaultSegmentInfosWriter.FORMAT_4_0) {
if (format <= DefaultSegmentInfosWriter.FORMAT_FLEX) {
fieldNumber = input.readInt();
}
@ -221,7 +221,7 @@ public final class SegmentInfo implements Cloneable {
hasProx = input.readByte();
// System.out.println(Thread.currentThread().getName() + ": si.read hasProx=" + hasProx + " seg=" + name);
if (format <= DefaultSegmentInfosWriter.FORMAT_4_0) {
if (format <= DefaultSegmentInfosWriter.FORMAT_FLEX) {
segmentCodecs = new SegmentCodecs(codecs, input);
} else {
// codec ID on FieldInfo is 0 so it will simply use the first codec available

View File

@ -289,7 +289,7 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentInfo> {
}
}.run();
// either we are on 4.0 or we don't have a lastGlobalFieldMapVersion i.e. its still set to 0
assert DefaultSegmentInfosWriter.FORMAT_4_0 <= format || (DefaultSegmentInfosWriter.FORMAT_4_0 > format && lastGlobalFieldMapVersion == 0);
assert DefaultSegmentInfosWriter.FORMAT_FLEX <= format || (DefaultSegmentInfosWriter.FORMAT_FLEX > format && lastGlobalFieldMapVersion == 0);
}
// Only non-null after prepareCommit has been called and
@ -1030,7 +1030,7 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentInfo> {
readGlobalFieldMap(map, dir);
}
if (size() > 0) {
if (format > DefaultSegmentInfosWriter.FORMAT_4_0) {
if (format > DefaultSegmentInfosWriter.FORMAT_FLEX) {
assert lastGlobalFieldMapVersion == 0;
// build the map up if we open a pre 4.0 index
for (SegmentInfo info : this) {

View File

@ -55,7 +55,7 @@ public class DefaultSegmentInfosReader extends SegmentInfosReader {
infos.version = input.readLong(); // read version
infos.counter = input.readInt(); // read counter
if (infos.getFormat() <= DefaultSegmentInfosWriter.FORMAT_4_0) {
if (infos.getFormat() <= DefaultSegmentInfosWriter.FORMAT_FLEX) {
infos.setGlobalFieldMapVersion(input.readLong());
}
for (int i = input.readInt(); i > 0; i--) { // read segmentInfos

View File

@ -40,15 +40,15 @@ public class DefaultSegmentInfosWriter extends SegmentInfosWriter {
public static final int FORMAT_HAS_VECTORS = -10;
/** Each segment records the Lucene version that created it. */
public static final int FORMAT_3_1 = -11;
public static final int FORMAT_SEGMENT_RECORDS_VERSION = -11;
/** Each segment records whether its postings are written
* in the new flex format */
public static final int FORMAT_4_0 = -12;
public static final int FORMAT_FLEX = -12;
/** This must always point to the most recent file format.
* whenever you add a new format, make it 1 smaller (negative version logic)! */
public static final int FORMAT_CURRENT = FORMAT_4_0;
public static final int FORMAT_CURRENT = FORMAT_FLEX;
/** This must always point to the first supported file format. */
public static final int FORMAT_MINIMUM = FORMAT_DIAGNOSTICS;

View File

@ -465,14 +465,14 @@ public class TestGlobalFieldNumbers extends LuceneTestCase {
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(policy));
SegmentInfos segmentInfos = writer.segmentInfos;
assertTrue(DefaultSegmentInfosWriter.FORMAT_4_0 < segmentInfos.getFormat());
assertTrue(DefaultSegmentInfosWriter.FORMAT_FLEX < segmentInfos.getFormat());
assertEquals(0, segmentInfos.getGlobalFieldMapVersion());
for (String string : writer.getIndexFileNames()) {
assertFalse(string.endsWith(".fnx"));
}
writer.commit();
assertTrue(DefaultSegmentInfosWriter.FORMAT_4_0 < segmentInfos.getFormat());
assertTrue(DefaultSegmentInfosWriter.FORMAT_FLEX < segmentInfos.getFormat());
assertEquals(0, segmentInfos.getGlobalFieldMapVersion());
Collection<String> files = writer.getIndexFileNames();
for (String string : files) {
@ -485,7 +485,7 @@ public class TestGlobalFieldNumbers extends LuceneTestCase {
writer.addDocument(d);
writer.prepareCommit();
// the fnx file should still be under control of the SIS
assertTrue(DefaultSegmentInfosWriter.FORMAT_4_0 < segmentInfos.getFormat());
assertTrue(DefaultSegmentInfosWriter.FORMAT_FLEX < segmentInfos.getFormat());
assertEquals(0, segmentInfos.getLastGlobalFieldMapVersion());
assertEquals(1, segmentInfos.getGlobalFieldMapVersion());
files = writer.getIndexFileNames();
@ -496,7 +496,7 @@ public class TestGlobalFieldNumbers extends LuceneTestCase {
writer.commit();
// now we should see the fnx file even if this is a 3.x segment
assertTrue(DefaultSegmentInfosWriter.FORMAT_4_0 < segmentInfos.getFormat());
assertTrue(DefaultSegmentInfosWriter.FORMAT_FLEX < segmentInfos.getFormat());
assertEquals(1, segmentInfos.getGlobalFieldMapVersion());
assertEquals(1, segmentInfos.getLastGlobalFieldMapVersion());
files = writer.getIndexFileNames();