mirror of https://github.com/apache/lucene.git
LUCENE-3226: revert
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1138331 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8ce0a65494
commit
8d61139abb
|
@ -371,10 +371,10 @@ public class CheckIndex {
|
||||||
sFormat = "FORMAT_DIAGNOSTICS [Lucene 2.9]";
|
sFormat = "FORMAT_DIAGNOSTICS [Lucene 2.9]";
|
||||||
} else if (format == DefaultSegmentInfosWriter.FORMAT_HAS_VECTORS) {
|
} else if (format == DefaultSegmentInfosWriter.FORMAT_HAS_VECTORS) {
|
||||||
sFormat = "FORMAT_HAS_VECTORS [Lucene 3.1]";
|
sFormat = "FORMAT_HAS_VECTORS [Lucene 3.1]";
|
||||||
} else if (format == DefaultSegmentInfosWriter.FORMAT_SEGMENT_RECORDS_VERSION) {
|
} else if (format == DefaultSegmentInfosWriter.FORMAT_3_1) {
|
||||||
sFormat = "FORMAT_SEGMENT_RECORDS_VERSION [Lucene 3.1+]";
|
sFormat = "FORMAT_3_1 [Lucene 3.1]";
|
||||||
} else if (format == DefaultSegmentInfosWriter.FORMAT_FLEX) {
|
} else if (format == DefaultSegmentInfosWriter.FORMAT_4_0) {
|
||||||
sFormat = "FORMAT_FLEX [Lucene 4.0+]";
|
sFormat = "FORMAT_4_0 [Lucene 4.0]";
|
||||||
} else if (format == DefaultSegmentInfosWriter.FORMAT_CURRENT) {
|
} else if (format == DefaultSegmentInfosWriter.FORMAT_CURRENT) {
|
||||||
throw new RuntimeException("BUG: You should update this tool!");
|
throw new RuntimeException("BUG: You should update this tool!");
|
||||||
} else if (format < DefaultSegmentInfosWriter.FORMAT_CURRENT) {
|
} else if (format < DefaultSegmentInfosWriter.FORMAT_CURRENT) {
|
||||||
|
|
|
@ -178,7 +178,7 @@ public final class SegmentInfo implements Cloneable {
|
||||||
*/
|
*/
|
||||||
public SegmentInfo(Directory dir, int format, IndexInput input, CodecProvider codecs) throws IOException {
|
public SegmentInfo(Directory dir, int format, IndexInput input, CodecProvider codecs) throws IOException {
|
||||||
this.dir = dir;
|
this.dir = dir;
|
||||||
if (format <= DefaultSegmentInfosWriter.FORMAT_SEGMENT_RECORDS_VERSION) {
|
if (format <= DefaultSegmentInfosWriter.FORMAT_3_1) {
|
||||||
version = input.readString();
|
version = input.readString();
|
||||||
}
|
}
|
||||||
name = input.readString();
|
name = input.readString();
|
||||||
|
@ -193,7 +193,7 @@ public final class SegmentInfo implements Cloneable {
|
||||||
docStoreIsCompoundFile = false;
|
docStoreIsCompoundFile = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format > DefaultSegmentInfosWriter.FORMAT_FLEX) {
|
if (format > DefaultSegmentInfosWriter.FORMAT_4_0) {
|
||||||
// pre-4.0 indexes write a byte if there is a single norms file
|
// pre-4.0 indexes write a byte if there is a single norms file
|
||||||
byte b = input.readByte();
|
byte b = input.readByte();
|
||||||
assert 1 == b;
|
assert 1 == b;
|
||||||
|
@ -206,7 +206,7 @@ public final class SegmentInfo implements Cloneable {
|
||||||
normGen = new HashMap<Integer, Long>();
|
normGen = new HashMap<Integer, Long>();
|
||||||
for(int j=0;j<numNormGen;j++) {
|
for(int j=0;j<numNormGen;j++) {
|
||||||
int fieldNumber = j;
|
int fieldNumber = j;
|
||||||
if (format <= DefaultSegmentInfosWriter.FORMAT_FLEX) {
|
if (format <= DefaultSegmentInfosWriter.FORMAT_4_0) {
|
||||||
fieldNumber = input.readInt();
|
fieldNumber = input.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ public final class SegmentInfo implements Cloneable {
|
||||||
hasProx = input.readByte();
|
hasProx = input.readByte();
|
||||||
|
|
||||||
// System.out.println(Thread.currentThread().getName() + ": si.read hasProx=" + hasProx + " seg=" + name);
|
// System.out.println(Thread.currentThread().getName() + ": si.read hasProx=" + hasProx + " seg=" + name);
|
||||||
if (format <= DefaultSegmentInfosWriter.FORMAT_FLEX) {
|
if (format <= DefaultSegmentInfosWriter.FORMAT_4_0) {
|
||||||
segmentCodecs = new SegmentCodecs(codecs, input);
|
segmentCodecs = new SegmentCodecs(codecs, input);
|
||||||
} else {
|
} else {
|
||||||
// codec ID on FieldInfo is 0 so it will simply use the first codec available
|
// codec ID on FieldInfo is 0 so it will simply use the first codec available
|
||||||
|
|
|
@ -289,7 +289,7 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentInfo> {
|
||||||
}
|
}
|
||||||
}.run();
|
}.run();
|
||||||
// either we are on 4.0 or we don't have a lastGlobalFieldMapVersion i.e. its still set to 0
|
// either we are on 4.0 or we don't have a lastGlobalFieldMapVersion i.e. its still set to 0
|
||||||
assert DefaultSegmentInfosWriter.FORMAT_FLEX <= format || (DefaultSegmentInfosWriter.FORMAT_FLEX > format && lastGlobalFieldMapVersion == 0);
|
assert DefaultSegmentInfosWriter.FORMAT_4_0 <= format || (DefaultSegmentInfosWriter.FORMAT_4_0 > format && lastGlobalFieldMapVersion == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only non-null after prepareCommit has been called and
|
// Only non-null after prepareCommit has been called and
|
||||||
|
@ -1030,7 +1030,7 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentInfo> {
|
||||||
readGlobalFieldMap(map, dir);
|
readGlobalFieldMap(map, dir);
|
||||||
}
|
}
|
||||||
if (size() > 0) {
|
if (size() > 0) {
|
||||||
if (format > DefaultSegmentInfosWriter.FORMAT_FLEX) {
|
if (format > DefaultSegmentInfosWriter.FORMAT_4_0) {
|
||||||
assert lastGlobalFieldMapVersion == 0;
|
assert lastGlobalFieldMapVersion == 0;
|
||||||
// build the map up if we open a pre 4.0 index
|
// build the map up if we open a pre 4.0 index
|
||||||
for (SegmentInfo info : this) {
|
for (SegmentInfo info : this) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class DefaultSegmentInfosReader extends SegmentInfosReader {
|
||||||
|
|
||||||
infos.version = input.readLong(); // read version
|
infos.version = input.readLong(); // read version
|
||||||
infos.counter = input.readInt(); // read counter
|
infos.counter = input.readInt(); // read counter
|
||||||
if (infos.getFormat() <= DefaultSegmentInfosWriter.FORMAT_FLEX) {
|
if (infos.getFormat() <= DefaultSegmentInfosWriter.FORMAT_4_0) {
|
||||||
infos.setGlobalFieldMapVersion(input.readLong());
|
infos.setGlobalFieldMapVersion(input.readLong());
|
||||||
}
|
}
|
||||||
for (int i = input.readInt(); i > 0; i--) { // read segmentInfos
|
for (int i = input.readInt(); i > 0; i--) { // read segmentInfos
|
||||||
|
|
|
@ -40,15 +40,15 @@ public class DefaultSegmentInfosWriter extends SegmentInfosWriter {
|
||||||
public static final int FORMAT_HAS_VECTORS = -10;
|
public static final int FORMAT_HAS_VECTORS = -10;
|
||||||
|
|
||||||
/** Each segment records the Lucene version that created it. */
|
/** Each segment records the Lucene version that created it. */
|
||||||
public static final int FORMAT_SEGMENT_RECORDS_VERSION = -11;
|
public static final int FORMAT_3_1 = -11;
|
||||||
|
|
||||||
/** Each segment records whether its postings are written
|
/** Each segment records whether its postings are written
|
||||||
* in the new flex format */
|
* in the new flex format */
|
||||||
public static final int FORMAT_FLEX = -12;
|
public static final int FORMAT_4_0 = -12;
|
||||||
|
|
||||||
/** This must always point to the most recent file format.
|
/** This must always point to the most recent file format.
|
||||||
* whenever you add a new format, make it 1 smaller (negative version logic)! */
|
* whenever you add a new format, make it 1 smaller (negative version logic)! */
|
||||||
public static final int FORMAT_CURRENT = FORMAT_FLEX;
|
public static final int FORMAT_CURRENT = FORMAT_4_0;
|
||||||
|
|
||||||
/** This must always point to the first supported file format. */
|
/** This must always point to the first supported file format. */
|
||||||
public static final int FORMAT_MINIMUM = FORMAT_DIAGNOSTICS;
|
public static final int FORMAT_MINIMUM = FORMAT_DIAGNOSTICS;
|
||||||
|
|
|
@ -465,14 +465,14 @@ public class TestGlobalFieldNumbers extends LuceneTestCase {
|
||||||
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
|
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
|
||||||
TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(policy));
|
TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(policy));
|
||||||
SegmentInfos segmentInfos = writer.segmentInfos;
|
SegmentInfos segmentInfos = writer.segmentInfos;
|
||||||
assertTrue(DefaultSegmentInfosWriter.FORMAT_FLEX < segmentInfos.getFormat());
|
assertTrue(DefaultSegmentInfosWriter.FORMAT_4_0 < segmentInfos.getFormat());
|
||||||
assertEquals(0, segmentInfos.getGlobalFieldMapVersion());
|
assertEquals(0, segmentInfos.getGlobalFieldMapVersion());
|
||||||
for (String string : writer.getIndexFileNames()) {
|
for (String string : writer.getIndexFileNames()) {
|
||||||
assertFalse(string.endsWith(".fnx"));
|
assertFalse(string.endsWith(".fnx"));
|
||||||
}
|
}
|
||||||
writer.commit();
|
writer.commit();
|
||||||
|
|
||||||
assertTrue(DefaultSegmentInfosWriter.FORMAT_FLEX < segmentInfos.getFormat());
|
assertTrue(DefaultSegmentInfosWriter.FORMAT_4_0 < segmentInfos.getFormat());
|
||||||
assertEquals(0, segmentInfos.getGlobalFieldMapVersion());
|
assertEquals(0, segmentInfos.getGlobalFieldMapVersion());
|
||||||
Collection<String> files = writer.getIndexFileNames();
|
Collection<String> files = writer.getIndexFileNames();
|
||||||
for (String string : files) {
|
for (String string : files) {
|
||||||
|
@ -485,7 +485,7 @@ public class TestGlobalFieldNumbers extends LuceneTestCase {
|
||||||
writer.addDocument(d);
|
writer.addDocument(d);
|
||||||
writer.prepareCommit();
|
writer.prepareCommit();
|
||||||
// the fnx file should still be under control of the SIS
|
// the fnx file should still be under control of the SIS
|
||||||
assertTrue(DefaultSegmentInfosWriter.FORMAT_FLEX < segmentInfos.getFormat());
|
assertTrue(DefaultSegmentInfosWriter.FORMAT_4_0 < segmentInfos.getFormat());
|
||||||
assertEquals(0, segmentInfos.getLastGlobalFieldMapVersion());
|
assertEquals(0, segmentInfos.getLastGlobalFieldMapVersion());
|
||||||
assertEquals(1, segmentInfos.getGlobalFieldMapVersion());
|
assertEquals(1, segmentInfos.getGlobalFieldMapVersion());
|
||||||
files = writer.getIndexFileNames();
|
files = writer.getIndexFileNames();
|
||||||
|
@ -496,7 +496,7 @@ public class TestGlobalFieldNumbers extends LuceneTestCase {
|
||||||
writer.commit();
|
writer.commit();
|
||||||
|
|
||||||
// now we should see the fnx file even if this is a 3.x segment
|
// now we should see the fnx file even if this is a 3.x segment
|
||||||
assertTrue(DefaultSegmentInfosWriter.FORMAT_FLEX < segmentInfos.getFormat());
|
assertTrue(DefaultSegmentInfosWriter.FORMAT_4_0 < segmentInfos.getFormat());
|
||||||
assertEquals(1, segmentInfos.getGlobalFieldMapVersion());
|
assertEquals(1, segmentInfos.getGlobalFieldMapVersion());
|
||||||
assertEquals(1, segmentInfos.getLastGlobalFieldMapVersion());
|
assertEquals(1, segmentInfos.getLastGlobalFieldMapVersion());
|
||||||
files = writer.getIndexFileNames();
|
files = writer.getIndexFileNames();
|
||||||
|
|
Loading…
Reference in New Issue