Version.LATEST instead of Lucene.VERSION

There was a TODO for it.
This commit is contained in:
Nik Everett 2016-01-06 17:34:44 -05:00
parent cb8d378c2a
commit 9935ae921e
4 changed files with 5 additions and 24 deletions

View File

@ -25,7 +25,6 @@ import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.monitor.jvm.JvmInfo; import org.elasticsearch.monitor.jvm.JvmInfo;
@ -286,7 +285,8 @@ public class Version {
public static final Version CURRENT = V_3_0_0; public static final Version CURRENT = V_3_0_0;
static { static {
assert CURRENT.luceneVersion.equals(Lucene.VERSION) : "Version must be upgraded to [" + Lucene.VERSION + "] is still set to [" + CURRENT.luceneVersion + "]"; assert CURRENT.luceneVersion.equals(org.apache.lucene.util.Version.LATEST) : "Version must be upgraded to ["
+ org.apache.lucene.util.Version.LATEST + "] is still set to [" + CURRENT.luceneVersion + "]";
} }
public static Version readVersion(StreamInput in) throws IOException { public static Version readVersion(StreamInput in) throws IOException {
@ -457,7 +457,6 @@ public class Version {
return V_0_90_0_RC1; return V_0_90_0_RC1;
case V_0_90_0_Beta1_ID: case V_0_90_0_Beta1_ID:
return V_0_90_0_Beta1; return V_0_90_0_Beta1;
case V_0_20_7_ID: case V_0_20_7_ID:
return V_0_20_7; return V_0_20_7;
case V_0_20_6_ID: case V_0_20_6_ID:
@ -476,7 +475,6 @@ public class Version {
return V_0_20_0; return V_0_20_0;
case V_0_20_0_RC1_ID: case V_0_20_0_RC1_ID:
return V_0_20_0_RC1; return V_0_20_0_RC1;
case V_0_19_0_RC1_ID: case V_0_19_0_RC1_ID:
return V_0_19_0_RC1; return V_0_19_0_RC1;
case V_0_19_0_RC2_ID: case V_0_19_0_RC2_ID:
@ -511,7 +509,6 @@ public class Version {
return V_0_19_12; return V_0_19_12;
case V_0_19_13_ID: case V_0_19_13_ID:
return V_0_19_13; return V_0_19_13;
case V_0_18_0_ID: case V_0_18_0_ID:
return V_0_18_0; return V_0_18_0;
case V_0_18_1_ID: case V_0_18_1_ID:
@ -530,9 +527,8 @@ public class Version {
return V_0_18_7; return V_0_18_7;
case V_0_18_8_ID: case V_0_18_8_ID:
return V_0_18_8; return V_0_18_8;
default: default:
return new Version(id, false, Lucene.VERSION); return new Version(id, false, org.apache.lucene.util.Version.LATEST);
} }
} }

View File

@ -86,11 +86,6 @@ import java.util.Objects;
* *
*/ */
public class Lucene { public class Lucene {
// TODO: remove VERSION, and have users use Version.LATEST.
public static final Version VERSION = Version.LATEST;
public static final Version ANALYZER_VERSION = VERSION;
public static final Version QUERYPARSER_VERSION = VERSION;
public static final String LATEST_DOC_VALUES_FORMAT = "Lucene54"; public static final String LATEST_DOC_VALUES_FORMAT = "Lucene54";
public static final String LATEST_POSTINGS_FORMAT = "Lucene50"; public static final String LATEST_POSTINGS_FORMAT = "Lucene50";
public static final String LATEST_CODEC = "Lucene54"; public static final String LATEST_CODEC = "Lucene54";
@ -109,7 +104,6 @@ public class Lucene {
public static final TopDocs EMPTY_TOP_DOCS = new TopDocs(0, EMPTY_SCORE_DOCS, 0.0f); public static final TopDocs EMPTY_TOP_DOCS = new TopDocs(0, EMPTY_SCORE_DOCS, 0.0f);
@SuppressWarnings("deprecation")
public static Version parseVersion(@Nullable String version, Version defaultVersion, ESLogger logger) { public static Version parseVersion(@Nullable String version, Version defaultVersion, ESLogger logger) {
if (version == null) { if (version == null) {
return defaultVersion; return defaultVersion;

View File

@ -89,12 +89,12 @@ public class Analysis {
// check for explicit version on the specific analyzer component // check for explicit version on the specific analyzer component
String sVersion = settings.get("version"); String sVersion = settings.get("version");
if (sVersion != null) { if (sVersion != null) {
return Lucene.parseVersion(sVersion, Lucene.ANALYZER_VERSION, logger); return Lucene.parseVersion(sVersion, Version.LATEST, logger);
} }
// check for explicit version on the index itself as default for all analysis components // check for explicit version on the index itself as default for all analysis components
sVersion = indexSettings.get("index.analysis.version"); sVersion = indexSettings.get("index.analysis.version");
if (sVersion != null) { if (sVersion != null) {
return Lucene.parseVersion(sVersion, Lucene.ANALYZER_VERSION, logger); return Lucene.parseVersion(sVersion, Version.LATEST, logger);
} }
// resolve the analysis version based on the version the index was created with // resolve the analysis version based on the version the index was created with
return org.elasticsearch.Version.indexCreated(indexSettings).luceneVersion; return org.elasticsearch.Version.indexCreated(indexSettings).luceneVersion;

View File

@ -38,7 +38,6 @@ import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory; import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MMapDirectory; import org.apache.lucene.store.MMapDirectory;
import org.apache.lucene.store.MockDirectoryWrapper; import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.Version;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import java.io.IOException; import java.io.IOException;
@ -54,14 +53,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
* *
*/ */
public class LuceneTests extends ESTestCase { public class LuceneTests extends ESTestCase {
/**
* simple test that ensures that we bump the version on Upgrade
*/
public void testVersion() {
// note this is just a silly sanity check, we test it in lucene, and we point to it this way
assertEquals(Lucene.VERSION, Version.LATEST);
}
public void testWaitForIndex() throws Exception { public void testWaitForIndex() throws Exception {
final MockDirectoryWrapper dir = newMockDirectory(); final MockDirectoryWrapper dir = newMockDirectory();