LUCENE-5992: encode version using 3 ints, not String, for Lucene 5.x indices

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1629769 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-10-06 21:37:11 +00:00
parent d308344af8
commit a922e89191
3 changed files with 12 additions and 7 deletions

View File

@ -55,12 +55,7 @@ public class Lucene50SegmentInfoReader extends SegmentInfoReader {
CodecUtil.checkHeader(input, Lucene50SegmentInfoFormat.CODEC_NAME,
Lucene50SegmentInfoFormat.VERSION_START,
Lucene50SegmentInfoFormat.VERSION_CURRENT);
final Version version;
try {
version = Version.parse(input.readString());
} catch (ParseException pe) {
throw new CorruptIndexException("unable to parse version string: " + pe.getMessage(), input, pe);
}
final Version version = Version.fromBits(input.readInt(), input.readInt(), input.readInt());
final int docCount = input.readInt();
if (docCount < 0) {

View File

@ -58,7 +58,10 @@ public class Lucene50SegmentInfoWriter extends SegmentInfoWriter {
throw new IllegalArgumentException("invalid major version: should be >= 5 but got: " + version.major + " segment=" + si);
}
// Write the Lucene version that created this segment, since 3.1
output.writeString(version.toString());
output.writeInt(version.major);
output.writeInt(version.minor);
output.writeInt(version.bugfix);
assert version.prerelease == 0;
output.writeInt(si.getDocCount());
output.writeByte((byte) (si.getUseCompoundFile() ? SegmentInfo.YES : SegmentInfo.NO));

View File

@ -370,6 +370,13 @@ public final class Version {
}
}
}
/** Returns a new version based on raw numbers
*
* @lucene.internal */
public static final Version fromBits(int major, int minor, int bugfix) {
return new Version(major, minor, bugfix);
}
/** Major version, the difference between stable and trunk */
public final int major;