diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index a3c27ef6d3f..8c1947daee3 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -227,6 +227,8 @@ Optimizations * LUCENE-9087: Build always trees with full leaves and lower the default value for maxPointsPerLeafNode to 512. (Ignacio Vera) +* LUCENE-9148: Points now write their index in a separate file. (Adrien Grand) + Bug Fixes --------------------- * LUCENE-9259: Fix wrong NGramFilterFactory argument name for preserveOriginal option (Paul Pazderski) diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsFormat.java b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsFormat.java similarity index 96% rename from lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsFormat.java rename to lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsFormat.java index 496dac0191d..343f7beaab8 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsFormat.java +++ b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsFormat.java @@ -73,7 +73,7 @@ import org.apache.lucene.index.SegmentWriteState; * @lucene.experimental */ -public final class Lucene60PointsFormat extends PointsFormat { +public class Lucene60PointsFormat extends PointsFormat { static final String DATA_CODEC_NAME = "Lucene60PointsFormatData"; static final String META_CODEC_NAME = "Lucene60PointsFormatMeta"; @@ -100,7 +100,7 @@ public final class Lucene60PointsFormat extends PointsFormat { @Override public PointsWriter fieldsWriter(SegmentWriteState state) throws IOException { - return new Lucene60PointsWriter(state); + throw new UnsupportedOperationException("Old codecs may only be used for reading"); } @Override diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsReader.java b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsReader.java similarity index 97% rename from lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsReader.java rename to lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsReader.java index 0eecdbbce59..e24a33c7bbc 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsReader.java +++ b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsReader.java @@ -39,7 +39,7 @@ import org.apache.lucene.util.Accountables; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.bkd.BKDReader; -/** Reads point values previously written with {@link Lucene60PointsWriter} */ +/** Reads point values previously written with Lucene60PointsWriter */ public class Lucene60PointsReader extends PointsReader implements Closeable { final IndexInput dataIn; final SegmentReadState readState; @@ -63,7 +63,7 @@ public class Lucene60PointsReader extends PointsReader implements Closeable { CodecUtil.checkIndexHeader(indexIn, Lucene60PointsFormat.META_CODEC_NAME, Lucene60PointsFormat.INDEX_VERSION_START, - Lucene60PointsFormat.INDEX_VERSION_START, + Lucene60PointsFormat.INDEX_VERSION_CURRENT, readState.segmentInfo.getId(), readState.segmentSuffix); int count = indexIn.readVInt(); @@ -103,7 +103,7 @@ public class Lucene60PointsReader extends PointsReader implements Closeable { int fieldNumber = ent.getKey(); long fp = ent.getValue(); dataIn.seek(fp); - BKDReader reader = new BKDReader(dataIn); + BKDReader reader = new BKDReader(dataIn, dataIn, dataIn); readers.put(fieldNumber, reader); } diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene60/package.html b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene60/package.html new file mode 100644 index 00000000000..6b4e234826d --- /dev/null +++ b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene60/package.html @@ -0,0 +1,25 @@ + + + +
+ + + +Lucene 6.0 file format. + + diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene84/Lucene84Codec.java b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene84/Lucene84Codec.java index 579c6a001f7..bef563301ba 100644 --- a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene84/Lucene84Codec.java +++ b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene84/Lucene84Codec.java @@ -117,7 +117,7 @@ public class Lucene84Codec extends Codec { } @Override - public final SegmentInfoFormat segmentInfoFormat() { + public SegmentInfoFormat segmentInfoFormat() { return segmentInfosFormat; } @@ -132,7 +132,7 @@ public class Lucene84Codec extends Codec { } @Override - public final PointsFormat pointsFormat() { + public PointsFormat pointsFormat() { return new Lucene60PointsFormat(); } diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene84/package.html b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene84/package.html new file mode 100644 index 00000000000..d0ba893dfad --- /dev/null +++ b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene84/package.html @@ -0,0 +1,25 @@ + + + + + + + +Lucene 8.4 file format. + + diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsWriter.java b/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene60/Lucene60PointsWriter.java similarity index 94% rename from lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsWriter.java rename to lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene60/Lucene60PointsWriter.java index c73a9b18f59..06e965368d8 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointsWriter.java +++ b/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene60/Lucene60PointsWriter.java @@ -101,9 +101,10 @@ public class Lucene60PointsWriter extends PointsWriter implements Closeable { values.size())) { if (values instanceof MutablePointValues) { - final long fp = writer.writeField(dataOut, fieldInfo.name, (MutablePointValues) values); - if (fp != -1) { - indexFPs.put(fieldInfo.name, fp); + Runnable finalizer = writer.writeField(dataOut, dataOut, dataOut, fieldInfo.name, (MutablePointValues) values); + if (finalizer != null) { + indexFPs.put(fieldInfo.name, dataOut.getFilePointer()); + finalizer.run(); } return; } @@ -125,8 +126,10 @@ public class Lucene60PointsWriter extends PointsWriter implements Closeable { }); // We could have 0 points on merge since all docs with dimensional fields may be deleted: - if (writer.getPointCount() > 0) { - indexFPs.put(fieldInfo.name, writer.finish(dataOut)); + Runnable finalizer = writer.finish(dataOut, dataOut, dataOut); + if (finalizer != null) { + indexFPs.put(fieldInfo.name, dataOut.getFilePointer()); + finalizer.run(); } } } @@ -210,9 +213,10 @@ public class Lucene60PointsWriter extends PointsWriter implements Closeable { } } - long fp = writer.merge(dataOut, docMaps, bkdReaders); - if (fp != -1) { - indexFPs.put(fieldInfo.name, fp); + Runnable finalizer = writer.merge(dataOut, dataOut, dataOut, docMaps, bkdReaders); + if (finalizer != null) { + indexFPs.put(fieldInfo.name, dataOut.getFilePointer()); + finalizer.run(); } } } else { diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene84/package-info.java b/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene60/Lucene60RWPointsFormat.java similarity index 62% rename from lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene84/package-info.java rename to lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene60/Lucene60RWPointsFormat.java index 5940a47dca8..6f5127f070b 100644 --- a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene84/package-info.java +++ b/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene60/Lucene60RWPointsFormat.java @@ -14,9 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package org.apache.lucene.codecs.lucene60; -/** - * Components from the Lucene 8.4 index format. See {@link org.apache.lucene.codecs.lucene86} - * for an overview of the current index format. - */ -package org.apache.lucene.codecs.lucene84; +import java.io.IOException; + +import org.apache.lucene.codecs.PointsWriter; +import org.apache.lucene.index.SegmentWriteState; + +/** RW variant of Lucene60PointsFormat */ +public class Lucene60RWPointsFormat extends Lucene60PointsFormat { + + /** Sole constructor. */ + public Lucene60RWPointsFormat() {} + + @Override + public PointsWriter fieldsWriter(SegmentWriteState state) throws IOException { + return new Lucene60PointsWriter(state); + } + +} diff --git a/lucene/core/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java b/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java similarity index 88% rename from lucene/core/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java rename to lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java index f44a0d387f5..f6130bddff6 100644 --- a/lucene/core/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java +++ b/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java @@ -21,10 +21,7 @@ import java.io.IOException; import java.util.Arrays; import org.apache.lucene.codecs.Codec; -import org.apache.lucene.codecs.FilterCodec; -import org.apache.lucene.codecs.PointsFormat; -import org.apache.lucene.codecs.PointsReader; -import org.apache.lucene.codecs.PointsWriter; +import org.apache.lucene.codecs.lucene84.Lucene84RWCodec; import org.apache.lucene.document.BinaryPoint; import org.apache.lucene.document.Document; import org.apache.lucene.index.BasePointsFormatTestCase; @@ -35,8 +32,6 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.MockRandomMergePolicy; import org.apache.lucene.index.PointValues; -import org.apache.lucene.index.SegmentReadState; -import org.apache.lucene.index.SegmentWriteState; import org.apache.lucene.index.PointValues.IntersectVisitor; import org.apache.lucene.index.PointValues.Relation; import org.apache.lucene.store.Directory; @@ -51,38 +46,8 @@ public class TestLucene60PointsFormat extends BasePointsFormatTestCase { private final int maxPointsInLeafNode; public TestLucene60PointsFormat() { - // standard issue - Codec defaultCodec = TestUtil.getDefaultCodec(); - if (random().nextBoolean()) { - // randomize parameters - maxPointsInLeafNode = TestUtil.nextInt(random(), 50, 500); - double maxMBSortInHeap = 3.0 + (3*random().nextDouble()); - if (VERBOSE) { - System.out.println("TEST: using Lucene60PointsFormat with maxPointsInLeafNode=" + maxPointsInLeafNode + " and maxMBSortInHeap=" + maxMBSortInHeap); - } - - // sneaky impersonation! - codec = new FilterCodec(defaultCodec.getName(), defaultCodec) { - @Override - public PointsFormat pointsFormat() { - return new PointsFormat() { - @Override - public PointsWriter fieldsWriter(SegmentWriteState writeState) throws IOException { - return new Lucene60PointsWriter(writeState, maxPointsInLeafNode, maxMBSortInHeap); - } - - @Override - public PointsReader fieldsReader(SegmentReadState readState) throws IOException { - return new Lucene60PointsReader(readState); - } - }; - } - }; - } else { - // standard issue - codec = defaultCodec; - maxPointsInLeafNode = BKDWriter.DEFAULT_MAX_POINTS_IN_LEAF_NODE; - } + codec = new Lucene84RWCodec(); + maxPointsInLeafNode = BKDWriter.DEFAULT_MAX_POINTS_IN_LEAF_NODE; } @Override @@ -90,12 +55,6 @@ public class TestLucene60PointsFormat extends BasePointsFormatTestCase { return codec; } - @Override - public void testMergeStability() throws Exception { - assumeFalse("TODO: mess with the parameters and test gets angry!", codec instanceof FilterCodec); - super.testMergeStability(); - } - public void testEstimatePointCount() throws IOException { Directory dir = newDirectory(); IndexWriterConfig iwc = newIndexWriterConfig(); diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene84/Lucene84RWCodec.java b/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene84/Lucene84RWCodec.java new file mode 100644 index 00000000000..c1fd4677f92 --- /dev/null +++ b/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene84/Lucene84RWCodec.java @@ -0,0 +1,39 @@ +/* + * 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. + */ +package org.apache.lucene.codecs.lucene84; + +import org.apache.lucene.codecs.PointsFormat; +import org.apache.lucene.codecs.SegmentInfoFormat; +import org.apache.lucene.codecs.lucene60.Lucene60RWPointsFormat; +import org.apache.lucene.codecs.lucene70.Lucene70RWSegmentInfoFormat; + +/** + * RW impersonation of {@link Lucene84Codec}. + */ +public class Lucene84RWCodec extends Lucene84Codec { + + @Override + public PointsFormat pointsFormat() { + return new Lucene60RWPointsFormat(); + } + + @Override + public SegmentInfoFormat segmentInfoFormat() { + return new Lucene70RWSegmentInfoFormat(); + } + +} 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 index b7145ccea94..d807058f646 100644 --- 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 @@ -16,7 +16,7 @@ */ /** - * Components from the Lucene 6.0 index format. See {@link org.apache.lucene.codecs.lucene80} + * Components from the Lucene 6.0 index format. See {@link org.apache.lucene.codecs.lucene86} * 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/lucene86/Lucene86Codec.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene86/Lucene86Codec.java index b9116e4432c..3f69874ef20 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene86/Lucene86Codec.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene86/Lucene86Codec.java @@ -36,7 +36,6 @@ import org.apache.lucene.codecs.lucene50.Lucene50LiveDocsFormat; import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat; import org.apache.lucene.codecs.lucene50.Lucene50TermVectorsFormat; import org.apache.lucene.codecs.lucene60.Lucene60FieldInfosFormat; -import org.apache.lucene.codecs.lucene60.Lucene60PointsFormat; import org.apache.lucene.codecs.lucene80.Lucene80NormsFormat; import org.apache.lucene.codecs.lucene84.Lucene84PostingsFormat; import org.apache.lucene.codecs.perfield.PerFieldDocValuesFormat; @@ -59,6 +58,7 @@ public class Lucene86Codec extends Codec { private final SegmentInfoFormat segmentInfosFormat = new Lucene86SegmentInfoFormat(); private final LiveDocsFormat liveDocsFormat = new Lucene50LiveDocsFormat(); private final CompoundFormat compoundFormat = new Lucene50CompoundFormat(); + private final PointsFormat pointsFormat = new Lucene86PointsFormat(); private final PostingsFormat defaultFormat; private final PostingsFormat postingsFormat = new PerFieldPostingsFormat() { @@ -133,7 +133,7 @@ public class Lucene86Codec extends Codec { @Override public final PointsFormat pointsFormat() { - return new Lucene60PointsFormat(); + return pointsFormat; } /** Returns the postings format that should be used for writing diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene86/Lucene86PointsFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene86/Lucene86PointsFormat.java new file mode 100644 index 00000000000..8cd63a790c4 --- /dev/null +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene86/Lucene86PointsFormat.java @@ -0,0 +1,80 @@ +/* + * 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. + */ +package org.apache.lucene.codecs.lucene86; + + +import java.io.IOException; + +import org.apache.lucene.codecs.PointsFormat; +import org.apache.lucene.codecs.PointsReader; +import org.apache.lucene.codecs.PointsWriter; +import org.apache.lucene.index.SegmentReadState; +import org.apache.lucene.index.SegmentWriteState; + +/** + * Lucene 8.6 point format, which encodes dimensional values in a block KD-tree structure + * for fast 1D range and N dimensional shape intersection filtering. + * See this paper for details. + * + *Data is stored across three files + *
* This is functionally equivalent to running {@link MatchAllDocsQuery} with a {@link LatLonDocValuesField#newDistanceSort}, * but is far more efficient since it takes advantage of properties the indexed BKD tree. Currently this - * only works with {@link Lucene60PointsFormat} (used by the default codec). Multi-valued fields are + * only works with {@link Lucene86PointsFormat} (used by the default codec). Multi-valued fields are * currently not de-duplicated, so if a document had multiple instances of the specified field that * make it into the top n, that document will appear more than once. *
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java index c2389595752..b3ded508d03 100644 --- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java +++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java @@ -32,8 +32,8 @@ import org.apache.lucene.codecs.FilterCodec; import org.apache.lucene.codecs.PointsFormat; import org.apache.lucene.codecs.PointsReader; import org.apache.lucene.codecs.PointsWriter; -import org.apache.lucene.codecs.lucene60.Lucene60PointsReader; -import org.apache.lucene.codecs.lucene60.Lucene60PointsWriter; +import org.apache.lucene.codecs.lucene86.Lucene86PointsReader; +import org.apache.lucene.codecs.lucene86.Lucene86PointsWriter; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.NumericDocValuesField; @@ -104,12 +104,12 @@ public class TestGeo3DPoint extends LuceneTestCase { return new PointsFormat() { @Override public PointsWriter fieldsWriter(SegmentWriteState writeState) throws IOException { - return new Lucene60PointsWriter(writeState, maxPointsInLeafNode, maxMBSortInHeap); + return new Lucene86PointsWriter(writeState, maxPointsInLeafNode, maxMBSortInHeap); } @Override public PointsReader fieldsReader(SegmentReadState readState) throws IOException { - return new Lucene60PointsReader(readState); + return new Lucene86PointsReader(readState); } }; } diff --git a/lucene/test-framework/src/java/org/apache/lucene/geo/BaseGeoPointTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/geo/BaseGeoPointTestCase.java index 135ff38c579..f556c0d55cc 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/geo/BaseGeoPointTestCase.java +++ b/lucene/test-framework/src/java/org/apache/lucene/geo/BaseGeoPointTestCase.java @@ -30,8 +30,8 @@ import org.apache.lucene.codecs.FilterCodec; import org.apache.lucene.codecs.PointsFormat; import org.apache.lucene.codecs.PointsReader; import org.apache.lucene.codecs.PointsWriter; -import org.apache.lucene.codecs.lucene60.Lucene60PointsReader; -import org.apache.lucene.codecs.lucene60.Lucene60PointsWriter; +import org.apache.lucene.codecs.lucene86.Lucene86PointsReader; +import org.apache.lucene.codecs.lucene86.Lucene86PointsWriter; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.NumericDocValuesField; @@ -1282,12 +1282,12 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase { return new PointsFormat() { @Override public PointsWriter fieldsWriter(SegmentWriteState writeState) throws IOException { - return new Lucene60PointsWriter(writeState, pointsInLeaf, BKDWriter.DEFAULT_MAX_MB_SORT_IN_HEAP); + return new Lucene86PointsWriter(writeState, pointsInLeaf, BKDWriter.DEFAULT_MAX_MB_SORT_IN_HEAP); } @Override public PointsReader fieldsReader(SegmentReadState readState) throws IOException { - return new Lucene60PointsReader(readState); + return new Lucene86PointsReader(readState); } }; } diff --git a/lucene/test-framework/src/java/org/apache/lucene/geo/BaseXYPointTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/geo/BaseXYPointTestCase.java index eb7be93114e..f60bd4c07d3 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/geo/BaseXYPointTestCase.java +++ b/lucene/test-framework/src/java/org/apache/lucene/geo/BaseXYPointTestCase.java @@ -30,8 +30,8 @@ import org.apache.lucene.codecs.FilterCodec; import org.apache.lucene.codecs.PointsFormat; import org.apache.lucene.codecs.PointsReader; import org.apache.lucene.codecs.PointsWriter; -import org.apache.lucene.codecs.lucene60.Lucene60PointsReader; -import org.apache.lucene.codecs.lucene60.Lucene60PointsWriter; +import org.apache.lucene.codecs.lucene86.Lucene86PointsReader; +import org.apache.lucene.codecs.lucene86.Lucene86PointsWriter; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.NumericDocValuesField; @@ -1196,12 +1196,12 @@ public abstract class BaseXYPointTestCase extends LuceneTestCase { return new PointsFormat() { @Override public PointsWriter fieldsWriter(SegmentWriteState writeState) throws IOException { - return new Lucene60PointsWriter(writeState, pointsInLeaf, BKDWriter.DEFAULT_MAX_MB_SORT_IN_HEAP); + return new Lucene86PointsWriter(writeState, pointsInLeaf, BKDWriter.DEFAULT_MAX_MB_SORT_IN_HEAP); } @Override public PointsReader fieldsReader(SegmentReadState readState) throws IOException { - return new Lucene60PointsReader(readState); + return new Lucene86PointsReader(readState); } }; } diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/RandomCodec.java b/lucene/test-framework/src/java/org/apache/lucene/index/RandomCodec.java index 7c158a2f28d..0e3f7f3045a 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/index/RandomCodec.java +++ b/lucene/test-framework/src/java/org/apache/lucene/index/RandomCodec.java @@ -40,8 +40,8 @@ import org.apache.lucene.codecs.blockterms.LuceneVarGapDocFreqInterval; import org.apache.lucene.codecs.blockterms.LuceneVarGapFixedInterval; import org.apache.lucene.codecs.blocktreeords.BlockTreeOrdsPostingsFormat; import org.apache.lucene.codecs.bloom.TestBloomFilteredLucenePostings; -import org.apache.lucene.codecs.lucene60.Lucene60PointsReader; -import org.apache.lucene.codecs.lucene60.Lucene60PointsWriter; +import org.apache.lucene.codecs.lucene86.Lucene86PointsReader; +import org.apache.lucene.codecs.lucene86.Lucene86PointsWriter; import org.apache.lucene.codecs.memory.DirectPostingsFormat; import org.apache.lucene.codecs.memory.FSTPostingsFormat; import org.apache.lucene.codecs.mockrandom.MockRandomPostingsFormat; @@ -97,9 +97,9 @@ public class RandomCodec extends AssertingCodec { @Override public PointsWriter fieldsWriter(SegmentWriteState writeState) throws IOException { - // Randomize how BKDWriter chooses its splis: + // Randomize how BKDWriter chooses its splits: - return new Lucene60PointsWriter(writeState, maxPointsInLeafNode, maxMBSortInHeap) { + return new Lucene86PointsWriter(writeState, maxPointsInLeafNode, maxMBSortInHeap) { @Override public void writeField(FieldInfo fieldInfo, PointsReader reader) throws IOException { @@ -132,8 +132,10 @@ public class RandomCodec extends AssertingCodec { }); // We could have 0 points on merge since all docs with dimensional fields may be deleted: - if (writer.getPointCount() > 0) { - indexFPs.put(fieldInfo.name, writer.finish(dataOut)); + Runnable finalizer = writer.finish(metaOut, indexOut, dataOut); + if (finalizer != null) { + metaOut.writeInt(fieldInfo.number); + finalizer.run(); } } } @@ -142,7 +144,7 @@ public class RandomCodec extends AssertingCodec { @Override public PointsReader fieldsReader(SegmentReadState readState) throws IOException { - return new Lucene60PointsReader(readState); + return new Lucene86PointsReader(readState); } }); }