Guest User

lucent-solr-7.0-upgrade

a guest
Jun 27th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.43 KB | None | 0 0
  1. diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
  2. index e463259f9d..7123e7040a 100644
  3. --- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
  4. +++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
  5. @@ -127,7 +127,9 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentCommitInfo
  6. /** The version that added information about the Lucene version at the time when the index has been created. */
  7. public static final int VERSION_70 = 7;
  8.  
  9. - static final int VERSION_CURRENT = VERSION_70;
  10. + public static final int VERSION_80 = 8;
  11. +
  12. + static final int VERSION_CURRENT = VERSION_80;
  13.  
  14. /** Used to name new segments. */
  15. // TODO: should this be a long ...?
  16. @@ -165,13 +167,13 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentCommitInfo
  17. private final int indexCreatedVersionMajor;
  18.  
  19. /** Sole constructor.
  20. - * @param indexCreatedVersionMajor the Lucene version major at index creation time, or 6 if the index was created before 7.0 */
  21. + * @param indexCreatedVersionMajor the Lucene version major at index creation time, or 7 if the index was created before 8.0 */
  22. public SegmentInfos(int indexCreatedVersionMajor) {
  23. if (indexCreatedVersionMajor > Version.LATEST.major) {
  24. throw new IllegalArgumentException("indexCreatedVersionMajor is in the future: " + indexCreatedVersionMajor);
  25. }
  26. - if (indexCreatedVersionMajor < 6) {
  27. - throw new IllegalArgumentException("indexCreatedVersionMajor must be >= 6, got: " + indexCreatedVersionMajor);
  28. + if (indexCreatedVersionMajor < 7) {
  29. + throw new IllegalArgumentException("indexCreatedVersionMajor must be >= 7, got: " + indexCreatedVersionMajor);
  30. }
  31. this.indexCreatedVersionMajor = indexCreatedVersionMajor;
  32. }
  33. @@ -312,12 +314,12 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentCommitInfo
  34. CodecUtil.checkIndexHeaderSuffix(input, Long.toString(generation, Character.MAX_RADIX));
  35.  
  36. Version luceneVersion = Version.fromBits(input.readVInt(), input.readVInt(), input.readVInt());
  37. - if (luceneVersion.onOrAfter(Version.LUCENE_6_0_0) == false) {
  38. + if (luceneVersion.onOrAfter(Version.LUCENE_7_0_0) == false) {
  39. // TODO: should we check indexCreatedVersion instead?
  40. throw new IndexFormatTooOldException(input, "this index is too old (version: " + luceneVersion + ")");
  41. }
  42.  
  43. - int indexCreatedVersion = 6;
  44. + int indexCreatedVersion = 7;
  45. if (format >= VERSION_70) {
  46. indexCreatedVersion = input.readVInt();
  47. }
  48. diff --git a/lucene/core/src/test/org/apache/lucene/index/TestSegmentInfos.java b/lucene/core/src/test/org/apache/lucene/index/TestSegmentInfos.java
  49. index 128601e4e1..5576bc9fcd 100644
  50. --- a/lucene/core/src/test/org/apache/lucene/index/TestSegmentInfos.java
  51. +++ b/lucene/core/src/test/org/apache/lucene/index/TestSegmentInfos.java
  52. @@ -30,9 +30,9 @@ import java.util.Collections;
  53. public class TestSegmentInfos extends LuceneTestCase {
  54.  
  55. public void testIllegalCreatedVersion() {
  56. - IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new SegmentInfos(5));
  57. - assertEquals("indexCreatedVersionMajor must be >= 6, got: 5", e.getMessage());
  58. - e = expectThrows(IllegalArgumentException.class, () -> new SegmentInfos(8));
  59. + IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new SegmentInfos(6));
  60. + assertEquals("indexCreatedVersionMajor must be >= 7, got: 6", e.getMessage());
  61. + e = expectThrows(IllegalArgumentException.class, () -> new SegmentInfos(9));
  62. assertEquals("indexCreatedVersionMajor is in the future: 8", e.getMessage());
  63. }
  64.  
  65. @@ -56,7 +56,7 @@ public class TestSegmentInfos extends LuceneTestCase {
  66. Codec codec = Codec.getDefault();
  67.  
  68. SegmentInfos sis = new SegmentInfos(Version.LATEST.major);
  69. - SegmentInfo info = new SegmentInfo(dir, Version.LUCENE_7_0_0, Version.LUCENE_7_0_0, "_0", 1, false, Codec.getDefault(),
  70. + SegmentInfo info = new SegmentInfo(dir, Version.LUCENE_8_0_0, Version.LUCENE_8_0_0, "_0", 1, false, Codec.getDefault(),
  71. Collections.<String,String>emptyMap(), id, Collections.<String,String>emptyMap(), null);
  72. info.setFiles(Collections.<String>emptySet());
  73. codec.segmentInfoFormat().write(dir, info, IOContext.DEFAULT);
  74. @@ -65,7 +65,7 @@ public class TestSegmentInfos extends LuceneTestCase {
  75. sis.add(commitInfo);
  76. sis.commit(dir);
  77. sis = SegmentInfos.readLatestCommit(dir);
  78. - assertEquals(Version.LUCENE_7_0_0, sis.getMinSegmentLuceneVersion());
  79. + assertEquals(Version.LUCENE_8_0_0, sis.getMinSegmentLuceneVersion());
  80. assertEquals(Version.LATEST, sis.getCommitLuceneVersion());
  81. dir.close();
  82. }
  83. @@ -78,14 +78,14 @@ public class TestSegmentInfos extends LuceneTestCase {
  84. Codec codec = Codec.getDefault();
  85.  
  86. SegmentInfos sis = new SegmentInfos(Version.LATEST.major);
  87. - SegmentInfo info = new SegmentInfo(dir, Version.LUCENE_7_0_0, Version.LUCENE_7_0_0, "_0", 1, false, Codec.getDefault(),
  88. + SegmentInfo info = new SegmentInfo(dir, Version.LUCENE_8_0_0, Version.LUCENE_8_0_0, "_0", 1, false, Codec.getDefault(),
  89. Collections.<String,String>emptyMap(), id, Collections.<String,String>emptyMap(), null);
  90. info.setFiles(Collections.<String>emptySet());
  91. codec.segmentInfoFormat().write(dir, info, IOContext.DEFAULT);
  92. SegmentCommitInfo commitInfo = new SegmentCommitInfo(info, 0, -1, -1, -1);
  93. sis.add(commitInfo);
  94.  
  95. - info = new SegmentInfo(dir, Version.LUCENE_7_0_0, Version.LUCENE_7_0_0, "_1", 1, false, Codec.getDefault(),
  96. + info = new SegmentInfo(dir, Version.LUCENE_8_0_0, Version.LUCENE_8_0_0, "_1", 1, false, Codec.getDefault(),
  97. Collections.<String,String>emptyMap(), id, Collections.<String,String>emptyMap(), null);
  98. info.setFiles(Collections.<String>emptySet());
  99. codec.segmentInfoFormat().write(dir, info, IOContext.DEFAULT);
  100. @@ -94,7 +94,7 @@ public class TestSegmentInfos extends LuceneTestCase {
  101.  
  102. sis.commit(dir);
  103. sis = SegmentInfos.readLatestCommit(dir);
  104. - assertEquals(Version.LUCENE_7_0_0, sis.getMinSegmentLuceneVersion());
  105. + assertEquals(Version.LUCENE_8_0_0, sis.getMinSegmentLuceneVersion());
  106. assertEquals(Version.LATEST, sis.getCommitLuceneVersion());
  107. dir.close();
  108. }
Advertisement
Add Comment
Please, Sign In to add comment