From 188728047511cc32e313a96bcc77dd88adeba287 Mon Sep 17 00:00:00 2001 From: Julie Tibshirani Date: Tue, 26 Jan 2021 10:14:55 -0800 Subject: [PATCH] LUCENE-9322: Move old field infos format to backwards-codecs. (#2245) We introduced a new `Lucene90FieldInfosFormat`, so the old `Lucene60FieldInfosFormat` should live in backwards-codecs. --- .../lucene60/Lucene60FieldInfosFormat.java | 7 +++++- .../lucene70/Lucene70Codec.java | 2 +- .../lucene80/Lucene80Codec.java | 2 +- .../lucene84/Lucene84Codec.java | 2 +- .../lucene86/Lucene86Codec.java | 2 +- .../lucene87/Lucene87Codec.java | 2 +- .../TestLucene60FieldInfosFormat.java} | 10 ++++----- .../lucene/codecs/lucene60/package-info.java | 22 ------------------- .../lucene/codecs/lucene90/package-info.java | 2 +- lucene/facet/build.gradle | 2 +- versions.lock | 2 -- 11 files changed, 17 insertions(+), 38 deletions(-) rename lucene/{core/src/java/org/apache/lucene/codecs => backward-codecs/src/java/org/apache/lucene/backward_codecs}/lucene60/Lucene60FieldInfosFormat.java (97%) rename lucene/{core/src/test/org/apache/lucene/codecs/lucene50/TestLucene60FieldInfoFormat.java => backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene60/TestLucene60FieldInfosFormat.java} (79%) delete mode 100644 lucene/core/src/java/org/apache/lucene/codecs/lucene60/package-info.java diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60FieldInfosFormat.java b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene60/Lucene60FieldInfosFormat.java similarity index 97% rename from lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60FieldInfosFormat.java rename to lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene60/Lucene60FieldInfosFormat.java index dd72965f14d..3eb352e41c0 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60FieldInfosFormat.java +++ b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene60/Lucene60FieldInfosFormat.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.lucene.codecs.lucene60; +package org.apache.lucene.backward_codecs.lucene60; import java.io.IOException; import java.util.Collections; @@ -311,6 +311,11 @@ public final class Lucene60FieldInfosFormat extends FieldInfosFormat { } } + /** + * Note: although this format is only used on older versions, we need to keep the write logic in + * addition to the read logic. It's possible for field infos on older segments to be written to, + * for example as part of in-place doc values updates. + */ @Override public void write( Directory directory, diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene70/Lucene70Codec.java b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene70/Lucene70Codec.java index b1ee4b4afa1..fae33b07f76 100644 --- a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene70/Lucene70Codec.java +++ b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene70/Lucene70Codec.java @@ -18,6 +18,7 @@ package org.apache.lucene.backward_codecs.lucene70; import org.apache.lucene.backward_codecs.lucene50.Lucene50StoredFieldsFormat; import org.apache.lucene.backward_codecs.lucene50.Lucene50StoredFieldsFormat.Mode; +import org.apache.lucene.backward_codecs.lucene60.Lucene60FieldInfosFormat; import org.apache.lucene.backward_codecs.lucene60.Lucene60PointsFormat; import org.apache.lucene.codecs.Codec; import org.apache.lucene.codecs.CompoundFormat; @@ -35,7 +36,6 @@ import org.apache.lucene.codecs.VectorFormat; import org.apache.lucene.codecs.lucene50.Lucene50CompoundFormat; import org.apache.lucene.codecs.lucene50.Lucene50LiveDocsFormat; import org.apache.lucene.codecs.lucene50.Lucene50TermVectorsFormat; -import org.apache.lucene.codecs.lucene60.Lucene60FieldInfosFormat; import org.apache.lucene.codecs.perfield.PerFieldDocValuesFormat; import org.apache.lucene.codecs.perfield.PerFieldPostingsFormat; diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene80/Lucene80Codec.java b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene80/Lucene80Codec.java index cd2eb90fa26..66604612c69 100644 --- a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene80/Lucene80Codec.java +++ b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene80/Lucene80Codec.java @@ -17,6 +17,7 @@ package org.apache.lucene.backward_codecs.lucene80; import org.apache.lucene.backward_codecs.lucene50.Lucene50StoredFieldsFormat; +import org.apache.lucene.backward_codecs.lucene60.Lucene60FieldInfosFormat; import org.apache.lucene.backward_codecs.lucene60.Lucene60PointsFormat; import org.apache.lucene.backward_codecs.lucene70.Lucene70SegmentInfoFormat; import org.apache.lucene.codecs.Codec; @@ -34,7 +35,6 @@ import org.apache.lucene.codecs.VectorFormat; import org.apache.lucene.codecs.lucene50.Lucene50CompoundFormat; import org.apache.lucene.codecs.lucene50.Lucene50LiveDocsFormat; import org.apache.lucene.codecs.lucene50.Lucene50TermVectorsFormat; -import org.apache.lucene.codecs.lucene60.Lucene60FieldInfosFormat; import org.apache.lucene.codecs.lucene80.Lucene80NormsFormat; import org.apache.lucene.codecs.perfield.PerFieldDocValuesFormat; import org.apache.lucene.codecs.perfield.PerFieldPostingsFormat; diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene84/Lucene84Codec.java b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene84/Lucene84Codec.java index f439c3682e3..49383e3cf07 100644 --- a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene84/Lucene84Codec.java +++ b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene84/Lucene84Codec.java @@ -19,6 +19,7 @@ package org.apache.lucene.backward_codecs.lucene84; import java.util.Objects; import org.apache.lucene.backward_codecs.lucene50.Lucene50StoredFieldsFormat; import org.apache.lucene.backward_codecs.lucene50.Lucene50StoredFieldsFormat.Mode; +import org.apache.lucene.backward_codecs.lucene60.Lucene60FieldInfosFormat; import org.apache.lucene.backward_codecs.lucene60.Lucene60PointsFormat; import org.apache.lucene.backward_codecs.lucene70.Lucene70SegmentInfoFormat; import org.apache.lucene.codecs.Codec; @@ -37,7 +38,6 @@ import org.apache.lucene.codecs.VectorFormat; import org.apache.lucene.codecs.lucene50.Lucene50CompoundFormat; import org.apache.lucene.codecs.lucene50.Lucene50LiveDocsFormat; import org.apache.lucene.codecs.lucene50.Lucene50TermVectorsFormat; -import org.apache.lucene.codecs.lucene60.Lucene60FieldInfosFormat; import org.apache.lucene.codecs.lucene80.Lucene80NormsFormat; import org.apache.lucene.codecs.lucene84.Lucene84PostingsFormat; import org.apache.lucene.codecs.perfield.PerFieldDocValuesFormat; diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene86/Lucene86Codec.java b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene86/Lucene86Codec.java index d05b6320071..7d51c67d51a 100644 --- a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene86/Lucene86Codec.java +++ b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene86/Lucene86Codec.java @@ -19,6 +19,7 @@ package org.apache.lucene.backward_codecs.lucene86; import java.util.Objects; import org.apache.lucene.backward_codecs.lucene50.Lucene50StoredFieldsFormat; +import org.apache.lucene.backward_codecs.lucene60.Lucene60FieldInfosFormat; import org.apache.lucene.codecs.Codec; import org.apache.lucene.codecs.CompoundFormat; import org.apache.lucene.codecs.DocValuesFormat; @@ -35,7 +36,6 @@ import org.apache.lucene.codecs.VectorFormat; import org.apache.lucene.codecs.lucene50.Lucene50CompoundFormat; import org.apache.lucene.codecs.lucene50.Lucene50LiveDocsFormat; import org.apache.lucene.codecs.lucene50.Lucene50TermVectorsFormat; -import org.apache.lucene.codecs.lucene60.Lucene60FieldInfosFormat; import org.apache.lucene.codecs.lucene80.Lucene80NormsFormat; import org.apache.lucene.codecs.lucene84.Lucene84PostingsFormat; import org.apache.lucene.codecs.lucene86.Lucene86PointsFormat; diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene87/Lucene87Codec.java b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene87/Lucene87Codec.java index b6925ff1746..b254fa6bcec 100644 --- a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene87/Lucene87Codec.java +++ b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene87/Lucene87Codec.java @@ -18,6 +18,7 @@ package org.apache.lucene.backward_codecs.lucene87; import java.util.Objects; +import org.apache.lucene.backward_codecs.lucene60.Lucene60FieldInfosFormat; import org.apache.lucene.codecs.Codec; import org.apache.lucene.codecs.CompoundFormat; import org.apache.lucene.codecs.DocValuesFormat; @@ -34,7 +35,6 @@ import org.apache.lucene.codecs.VectorFormat; import org.apache.lucene.codecs.lucene50.Lucene50CompoundFormat; import org.apache.lucene.codecs.lucene50.Lucene50LiveDocsFormat; import org.apache.lucene.codecs.lucene50.Lucene50TermVectorsFormat; -import org.apache.lucene.codecs.lucene60.Lucene60FieldInfosFormat; import org.apache.lucene.codecs.lucene80.Lucene80DocValuesFormat; import org.apache.lucene.codecs.lucene80.Lucene80NormsFormat; import org.apache.lucene.codecs.lucene84.Lucene84PostingsFormat; diff --git a/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestLucene60FieldInfoFormat.java b/lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene60/TestLucene60FieldInfosFormat.java similarity index 79% rename from lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestLucene60FieldInfoFormat.java rename to lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene60/TestLucene60FieldInfosFormat.java index ef39a813856..0db5b326175 100644 --- a/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestLucene60FieldInfoFormat.java +++ b/lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene60/TestLucene60FieldInfosFormat.java @@ -14,17 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.lucene.codecs.lucene50; +package org.apache.lucene.backward_codecs.lucene60; +import org.apache.lucene.backward_codecs.lucene84.Lucene84RWCodec; import org.apache.lucene.codecs.Codec; import org.apache.lucene.index.BaseFieldInfoFormatTestCase; -import org.apache.lucene.util.TestUtil; - -/** Tests Lucene60FieldInfoFormat */ -public class TestLucene60FieldInfoFormat extends BaseFieldInfoFormatTestCase { +public class TestLucene60FieldInfosFormat extends BaseFieldInfoFormatTestCase { @Override protected Codec getCodec() { - return TestUtil.getDefaultCodec(); + return new Lucene84RWCodec(); } } diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene60/package-info.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene60/package-info.java deleted file mode 100644 index 7db4fa69924..00000000000 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene60/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Components from the Lucene 6.0 index format. See {@link org.apache.lucene.codecs.lucene90} for an - * overview of the current index format. - */ -package org.apache.lucene.codecs.lucene60; diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/package-info.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/package-info.java index 226da1f8c71..6bc4f5d4801 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/package-info.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/package-info.java @@ -240,7 +240,7 @@ * systems that frequently run out of file handles. * * - * {@link org.apache.lucene.codecs.lucene60.Lucene60FieldInfosFormat Fields} + * {@link org.apache.lucene.codecs.lucene90.Lucene90FieldInfosFormat Fields} * .fnm * Stores information about the fields * diff --git a/lucene/facet/build.gradle b/lucene/facet/build.gradle index e94d8b0815a..b4f3ac588ac 100644 --- a/lucene/facet/build.gradle +++ b/lucene/facet/build.gradle @@ -28,5 +28,5 @@ dependencies { testImplementation project(':lucene:test-framework') testImplementation project(':lucene:queries') // Required for opening older indexes for backward compatibility tests - testCompile group: 'org.apache.lucene', name: 'lucene-codecs', version: '8.6.3' + testImplementation project(':lucene:backward-codecs') } diff --git a/versions.lock b/versions.lock index 572771857e8..b738b791bba 100644 --- a/versions.lock +++ b/versions.lock @@ -204,8 +204,6 @@ org.apache.kerby:kerb-server:1.0.1 (1 constraints: 0405f135) org.apache.kerby:kerb-simplekdc:1.0.1 (1 constraints: 0405f135) org.apache.kerby:kerby-kdc:1.0.1 (1 constraints: 0405f135) org.apache.logging.log4j:log4j-1.2-api:2.13.2 (1 constraints: 3a053a3b) -org.apache.lucene:lucene-codecs:8.6.3 (1 constraints: 13052836) -org.apache.lucene:lucene-core:8.6.3 (1 constraints: 7f0d022f) org.asciidoctor:asciidoctorj:1.6.2 (1 constraints: 0b050436) org.asciidoctor:asciidoctorj-api:1.6.2 (1 constraints: e30cfb0d) org.hsqldb:hsqldb:2.4.0 (1 constraints: 08050136)