You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2016/03/02 15:05:30 UTC
[2/7] lucene-solr git commit: SegmentInfos now throws
IndexFormatTooOld if index is before 6.0.0
SegmentInfos now throws IndexFormatTooOld if index is before 6.0.0
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/2ba48030
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/2ba48030
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/2ba48030
Branch: refs/heads/master
Commit: 2ba48030f391efc963a9de8a13e6d2cf13e954d2
Parents: ddbeb2a
Author: Mike McCandless <mi...@apache.org>
Authored: Wed Mar 2 06:10:53 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Wed Mar 2 06:10:53 2016 -0500
----------------------------------------------------------------------
.../org/apache/lucene/index/SegmentInfos.java | 28 +++++++-------------
1 file changed, 9 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2ba48030/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
index 642b320..d8fd0c9 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
@@ -304,11 +304,12 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentCommitInfo
infos.generation = generation;
infos.lastGeneration = generation;
if (format >= VERSION_53) {
- // TODO: in the future (7.0? sigh) we can use this to throw IndexFormatTooOldException ... or just rely on the
- // minSegmentLuceneVersion check instead:
infos.luceneVersion = Version.fromBits(input.readVInt(), input.readVInt(), input.readVInt());
+ if (infos.luceneVersion.onOrAfter(Version.LUCENE_6_0_0) == false) {
+ throw new IndexFormatTooOldException(input, "this index is too old (version: " + infos.luceneVersion + ")");
+ }
} else {
- // else compute the min version down below in the for loop
+ throw new IndexFormatTooOldException(input, "this index segments file is too old (segment infos format: " + format + ")");
}
infos.version = input.readLong();
@@ -319,18 +320,10 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentCommitInfo
throw new CorruptIndexException("invalid segment count: " + numSegments, input);
}
- if (format >= VERSION_53) {
- if (numSegments > 0) {
- infos.minSegmentLuceneVersion = Version.fromBits(input.readVInt(), input.readVInt(), input.readVInt());
- if (infos.minSegmentLuceneVersion.onOrAfter(Version.LUCENE_5_0_0) == false) {
- throw new IndexFormatTooOldException(input, "this index contains a too-old segment (version: " + infos.minSegmentLuceneVersion + ")");
- }
- } else {
- // else leave as null: no segments
- }
+ if (numSegments > 0) {
+ infos.minSegmentLuceneVersion = Version.fromBits(input.readVInt(), input.readVInt(), input.readVInt());
} else {
- // else we recompute it below as we visit segments; it can't be used for throwing IndexFormatTooOldExc, but consumers of
- // SegmentInfos can maybe still use it for other reasons
+ // else leave as null: no segments
}
long totalDocs = 0;
@@ -382,11 +375,8 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentCommitInfo
infos.add(siPerCommit);
Version segmentVersion = info.getVersion();
- if (format < VERSION_53) {
- if (infos.minSegmentLuceneVersion == null || segmentVersion.onOrAfter(infos.minSegmentLuceneVersion) == false) {
- infos.minSegmentLuceneVersion = segmentVersion;
- }
- } else if (segmentVersion.onOrAfter(infos.minSegmentLuceneVersion) == false) {
+
+ if (segmentVersion.onOrAfter(infos.minSegmentLuceneVersion) == false) {
throw new CorruptIndexException("segments file recorded minSegmentLuceneVersion=" + infos.minSegmentLuceneVersion + " but segment=" + info + " has older version=" + segmentVersion, input);
}
}