Apache Lucene open-source search software
LUCENE-4055: javadocs, file formats docs, clear some nocommits
Robert Muirf330cf65adc5
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/Codec.java b/lucene/core/src/java/org/apache/lucene/codecs/Codec.javaindex 9a8993a9731..c6bea997964 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/Codec.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/Codec.java@@ -70,7 +70,7 @@ public abstract class Codec implements NamedSPILoader.NamedSPI {public abstract FieldInfosFormat fieldInfosFormat();/** Encodes/decodes segments file */- public abstract SegmentInfosFormat segmentInfosFormat();+ public abstract SegmentInfoFormat segmentInfosFormat();/** Encodes/decodes document normalization values */public abstract NormsFormat normsFormat();diff --git a/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfosFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoFormat.javasimilarity index 52%rename from lucene/core/src/java/org/apache/lucene/codecs/SegmentInfosFormat.javarename to lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoFormat.javaindex f0ce464534d..de8b36592d4 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfosFormat.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoFormat.java@@ -17,32 +17,17 @@ package org.apache.lucene.codecs;* limitations under the License.*/-import java.util.Set;-import org.apache.lucene.index.SegmentInfo;-import org.apache.lucene.index.SegmentInfos; // javadocs/*** Expert: Controls the format of the- * {@link SegmentInfos} (segments file).+ * {@link SegmentInfo} (segment metadata file).* <p>- * NOTE: This isn't a per-segment file. If you change the format, other versions- * of lucene won't be able to read it.*- * @see SegmentInfos+ * @see SegmentInfo* @lucene.experimental*/--// nocommit rename (remove the s?)--// TODO: would be great to handle this situation better.-// ideally a custom implementation could implement two-phase commit differently,-// (e.g. atomic rename), and ideally all versions of lucene could still read it.-// but this is just reflecting reality as it is today...-//-// also, perhaps the name should change (to cover all global files like .fnx?)-// then again, maybe we can just remove that file...-public abstract class SegmentInfosFormat {- public abstract SegmentInfosReader getSegmentInfosReader();- public abstract SegmentInfosWriter getSegmentInfosWriter();+public abstract class SegmentInfoFormat {+ public abstract SegmentInfoReader getSegmentInfosReader();+ public abstract SegmentInfoWriter getSegmentInfosWriter();}diff --git a/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfosReader.java b/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoReader.javasimilarity index 74%rename from lucene/core/src/java/org/apache/lucene/codecs/SegmentInfosReader.javarename to lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoReader.javaindex 55a131a61bb..09eeab6a5bc 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfosReader.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoReader.java@@ -20,26 +20,21 @@ package org.apache.lucene.codecs;import java.io.IOException;import org.apache.lucene.index.SegmentInfo;-import org.apache.lucene.index.SegmentInfos;-import org.apache.lucene.store.ChecksumIndexInput;import org.apache.lucene.store.Directory;import org.apache.lucene.store.IOContext;/**- * Specifies an API for classes that can read {@link SegmentInfos} information.+ * Specifies an API for classes that can read {@link SegmentInfo} information.* @lucene.experimental*/-// nocommit rename (remove the s?)--public abstract class SegmentInfosReader {+public abstract class SegmentInfoReader {/**- * Read {@link SegmentInfos} data from a directory.+ * Read {@link SegmentInfo} data from a directory.* @param directory directory to read from- * @param segmentsFileName name of the "segments_N" file- * @param header input of "segments_N" file after reading preamble- * @param infos empty instance to be populated with data+ * @param segmentName name of the segment to read+ * @return infos instance to be populated with data* @throws IOException*/public abstract SegmentInfo read(Directory directory, String segmentName, IOContext context) throws IOException;diff --git a/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfosWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoWriter.javasimilarity index 63%rename from lucene/core/src/java/org/apache/lucene/codecs/SegmentInfosWriter.javarename to lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoWriter.javaindex 5dd7e10fd38..988aca005d7 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfosWriter.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/SegmentInfoWriter.java@@ -21,30 +21,18 @@ import java.io.IOException;import org.apache.lucene.index.FieldInfos;import org.apache.lucene.index.SegmentInfo;-import org.apache.lucene.index.SegmentInfos;import org.apache.lucene.store.Directory;import org.apache.lucene.store.IOContext;-import org.apache.lucene.store.IndexOutput;/**- * Specifies an API for classes that can write out {@link SegmentInfos} data.+ * Specifies an API for classes that can write out {@link SegmentInfo} data.* @lucene.experimental*/-// nocommit rename (remove the s?)--public abstract class SegmentInfosWriter {+public abstract class SegmentInfoWriter {/**- * Write {@link SegmentInfos} data without closing the output. The returned- * output will become finished only after a successful completion of- * "two phase commit" that first calls {@link #prepareCommit(IndexOutput)} and- * then {@link #finishCommit(IndexOutput)}.- * @param dir directory to write data to- * @param segmentsFileName name of the "segments_N" file to create- * @param infos data to write- * @return an instance of {@link IndexOutput} to be used in subsequent "two- * phase commit" operations as described above.+ * Write {@link SegmentInfo} data.* @throws IOException*/public abstract void write(Directory dir, SegmentInfo info, FieldInfos fis, IOContext ioContext) throws IOException;diff --git a/lucene/core/src/java/org/apache/lucene/codecs/appending/AppendingCodec.java b/lucene/core/src/java/org/apache/lucene/codecs/appending/AppendingCodec.javaindex 749d3f6aab3..9a6ccb92076 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/appending/AppendingCodec.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/appending/AppendingCodec.java@@ -23,7 +23,7 @@ import org.apache.lucene.codecs.FieldInfosFormat;import org.apache.lucene.codecs.LiveDocsFormat;import org.apache.lucene.codecs.NormsFormat;import org.apache.lucene.codecs.PostingsFormat;-import org.apache.lucene.codecs.SegmentInfosFormat;+import org.apache.lucene.codecs.SegmentInfoFormat;import org.apache.lucene.codecs.StoredFieldsFormat;import org.apache.lucene.codecs.TermVectorsFormat;import org.apache.lucene.codecs.lucene40.Lucene40Codec;@@ -31,7 +31,7 @@ import org.apache.lucene.codecs.lucene40.Lucene40DocValuesFormat;import org.apache.lucene.codecs.lucene40.Lucene40FieldInfosFormat;import org.apache.lucene.codecs.lucene40.Lucene40LiveDocsFormat;import org.apache.lucene.codecs.lucene40.Lucene40NormsFormat;-import org.apache.lucene.codecs.lucene40.Lucene40SegmentInfosFormat;+import org.apache.lucene.codecs.lucene40.Lucene40SegmentInfoFormat;import org.apache.lucene.codecs.lucene40.Lucene40StoredFieldsFormat;import org.apache.lucene.codecs.lucene40.Lucene40TermVectorsFormat;@@ -47,7 +47,7 @@ public class AppendingCodec extends Codec {}private final PostingsFormat postings = new AppendingPostingsFormat();- private final SegmentInfosFormat infos = new Lucene40SegmentInfosFormat();+ private final SegmentInfoFormat infos = new Lucene40SegmentInfoFormat();private final StoredFieldsFormat fields = new Lucene40StoredFieldsFormat();private final FieldInfosFormat fieldInfos = new Lucene40FieldInfosFormat();private final TermVectorsFormat vectors = new Lucene40TermVectorsFormat();@@ -76,7 +76,7 @@ public class AppendingCodec extends Codec {}@Override- public SegmentInfosFormat segmentInfosFormat() {+ public SegmentInfoFormat segmentInfosFormat() {return infos;}diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xCodec.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xCodec.javaindex 203e972c594..f3e2864bd45 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xCodec.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xCodec.java@@ -28,7 +28,7 @@ import org.apache.lucene.codecs.NormsFormat;import org.apache.lucene.codecs.PerDocConsumer;import org.apache.lucene.codecs.PerDocProducer;import org.apache.lucene.codecs.PostingsFormat;-import org.apache.lucene.codecs.SegmentInfosFormat;+import org.apache.lucene.codecs.SegmentInfoFormat;import org.apache.lucene.codecs.StoredFieldsFormat;import org.apache.lucene.codecs.TermVectorsFormat;import org.apache.lucene.codecs.lucene40.Lucene40LiveDocsFormat;@@ -58,7 +58,7 @@ public class Lucene3xCodec extends Codec {private final FieldInfosFormat fieldInfosFormat = new Lucene3xFieldInfosFormat();- private final SegmentInfosFormat infosFormat = new Lucene3xSegmentInfosFormat();+ private final SegmentInfoFormat infosFormat = new Lucene3xSegmentInfoFormat();private final Lucene3xNormsFormat normsFormat = new Lucene3xNormsFormat();@@ -112,7 +112,7 @@ public class Lucene3xCodec extends Codec {}@Override- public SegmentInfosFormat segmentInfosFormat() {+ public SegmentInfoFormat segmentInfosFormat() {return infosFormat;}diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfosFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfoFormat.javasimilarity index 80%rename from lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfosFormat.javarename to lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfoFormat.javaindex 4aa019dbcb1..dd1da7025a5 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfosFormat.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfoFormat.java@@ -19,21 +19,21 @@ package org.apache.lucene.codecs.lucene3x;import java.util.Set;-import org.apache.lucene.codecs.SegmentInfosFormat;-import org.apache.lucene.codecs.SegmentInfosReader;-import org.apache.lucene.codecs.SegmentInfosWriter;+import org.apache.lucene.codecs.SegmentInfoFormat;+import org.apache.lucene.codecs.SegmentInfoReader;+import org.apache.lucene.codecs.SegmentInfoWriter;import org.apache.lucene.index.IndexFileNames;import org.apache.lucene.index.SegmentInfo;/**- * Lucene3x ReadOnly SegmentInfosFormat implementation+ * Lucene3x ReadOnly SegmentInfoFormat implementation* @deprecated (4.0) This is only used to read indexes created* before 4.0.* @lucene.experimental*/@Deprecated-public class Lucene3xSegmentInfosFormat extends SegmentInfosFormat {- private final SegmentInfosReader reader = new Lucene3xSegmentInfosReader();+public class Lucene3xSegmentInfoFormat extends SegmentInfoFormat {+ private final SegmentInfoReader reader = new Lucene3xSegmentInfoReader();/** This format adds optional per-segment String* diagnostics storage, and switches userData to Map */@@ -54,12 +54,12 @@ public class Lucene3xSegmentInfosFormat extends SegmentInfosFormat {public static final String SI_EXTENSION = "si";@Override- public SegmentInfosReader getSegmentInfosReader() {+ public SegmentInfoReader getSegmentInfosReader() {return reader;}@Override- public SegmentInfosWriter getSegmentInfosWriter() {+ public SegmentInfoWriter getSegmentInfosWriter() {throw new UnsupportedOperationException("this codec can only be used for reading");}}diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfosReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfoReader.javasimilarity index 90%rename from lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfosReader.javarename to lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfoReader.javaindex 13e97d1b948..e1ff7d42e70 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfosReader.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfoReader.java@@ -24,7 +24,7 @@ import java.util.Map;import java.util.Set;import org.apache.lucene.codecs.Codec;-import org.apache.lucene.codecs.SegmentInfosReader;+import org.apache.lucene.codecs.SegmentInfoReader;import org.apache.lucene.index.IndexFileNames;import org.apache.lucene.index.IndexFormatTooNewException;import org.apache.lucene.index.IndexFormatTooOldException;@@ -38,17 +38,17 @@ import org.apache.lucene.store.IndexInput;import org.apache.lucene.util.IOUtils;/**- * Lucene 3x implementation of {@link SegmentInfosReader}.+ * Lucene 3x implementation of {@link SegmentInfoReader}.* @lucene.experimental* @deprecated*/@Deprecated-public class Lucene3xSegmentInfosReader extends SegmentInfosReader {+public class Lucene3xSegmentInfoReader extends SegmentInfoReader {public static void readLegacyInfos(SegmentInfos infos, Directory directory, IndexInput input, int format) throws IOException {infos.version = input.readLong(); // read versioninfos.counter = input.readInt(); // read counter- Lucene3xSegmentInfosReader reader = new Lucene3xSegmentInfosReader();+ Lucene3xSegmentInfoReader reader = new Lucene3xSegmentInfoReader();for (int i = input.readInt(); i > 0; i--) { // read segmentInfosSegmentInfo si = reader.readSegmentInfo(null, directory, format, input);if (si.getVersion() == null) {@@ -92,13 +92,13 @@ public class Lucene3xSegmentInfosReader extends SegmentInfosReader {@Overridepublic SegmentInfo read(Directory directory, String segmentName, IOContext context) throws IOException {- return read(directory, segmentName, Lucene3xSegmentInfosFormat.FORMAT_4X_UPGRADE, context);+ return read(directory, segmentName, Lucene3xSegmentInfoFormat.FORMAT_4X_UPGRADE, context);}public SegmentInfo read(Directory directory, String segmentName, int format, IOContext context) throws IOException {// NOTE: this is NOT how 3.x is really written...- String fileName = IndexFileNames.segmentFileName(segmentName, "", Lucene3xSegmentInfosFormat.SI_EXTENSION);+ String fileName = IndexFileNames.segmentFileName(segmentName, "", Lucene3xSegmentInfoFormat.SI_EXTENSION);boolean success = false;@@ -125,16 +125,16 @@ public class Lucene3xSegmentInfosReader extends SegmentInfosReader {private SegmentInfo readSegmentInfo(String segmentName, Directory dir, int format, IndexInput input) throws IOException {// check that it is a format we can understand- if (format > Lucene3xSegmentInfosFormat.FORMAT_DIAGNOSTICS) {+ if (format > Lucene3xSegmentInfoFormat.FORMAT_DIAGNOSTICS) {throw new IndexFormatTooOldException(input, format,- Lucene3xSegmentInfosFormat.FORMAT_DIAGNOSTICS, Lucene3xSegmentInfosFormat.FORMAT_4X_UPGRADE);+ Lucene3xSegmentInfoFormat.FORMAT_DIAGNOSTICS, Lucene3xSegmentInfoFormat.FORMAT_4X_UPGRADE);}- if (format < Lucene3xSegmentInfosFormat.FORMAT_4X_UPGRADE) {+ if (format < Lucene3xSegmentInfoFormat.FORMAT_4X_UPGRADE) {throw new IndexFormatTooNewException(input, format,- Lucene3xSegmentInfosFormat.FORMAT_DIAGNOSTICS, Lucene3xSegmentInfosFormat.FORMAT_4X_UPGRADE);+ Lucene3xSegmentInfoFormat.FORMAT_DIAGNOSTICS, Lucene3xSegmentInfoFormat.FORMAT_4X_UPGRADE);}final String version;- if (format <= Lucene3xSegmentInfosFormat.FORMAT_3_1) {+ if (format <= Lucene3xSegmentInfoFormat.FORMAT_3_1) {version = input.readString();} else {version = null;@@ -185,13 +185,13 @@ public class Lucene3xSegmentInfosReader extends SegmentInfosReader {final Map<String,String> diagnostics = input.readStringStringMap();- if (format <= Lucene3xSegmentInfosFormat.FORMAT_HAS_VECTORS) {+ if (format <= Lucene3xSegmentInfoFormat.FORMAT_HAS_VECTORS) {// NOTE: unusedfinal int hasVectors = input.readByte();}final Set<String> files;- if (format == Lucene3xSegmentInfosFormat.FORMAT_4X_UPGRADE) {+ if (format == Lucene3xSegmentInfoFormat.FORMAT_4X_UPGRADE) {files = input.readStringSet();} else {// Replicate logic from 3.x's SegmentInfo.files():@@ -232,7 +232,7 @@ public class Lucene3xSegmentInfosReader extends SegmentInfosReader {// Definitely a separate norm file, with generation:files.add(IndexFileNames.fileNameFromGeneration(segmentName, "s" + ent.getKey(), gen));} else if (gen == SegmentInfo.NO) {- // No seaprate norm+ // No separate norm} else {// nocommit -- i thought _X_N.sY files were pre-3.0...????assert false;diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40Codec.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40Codec.javaindex 3b0e65e61c5..2838582d92d 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40Codec.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40Codec.java@@ -23,7 +23,7 @@ import org.apache.lucene.codecs.FieldInfosFormat;import org.apache.lucene.codecs.LiveDocsFormat;import org.apache.lucene.codecs.NormsFormat;import org.apache.lucene.codecs.PostingsFormat;-import org.apache.lucene.codecs.SegmentInfosFormat;+import org.apache.lucene.codecs.SegmentInfoFormat;import org.apache.lucene.codecs.StoredFieldsFormat;import org.apache.lucene.codecs.TermVectorsFormat;import org.apache.lucene.codecs.perfield.PerFieldPostingsFormat;@@ -42,7 +42,7 @@ public class Lucene40Codec extends Codec {private final TermVectorsFormat vectorsFormat = new Lucene40TermVectorsFormat();private final FieldInfosFormat fieldInfosFormat = new Lucene40FieldInfosFormat();private final DocValuesFormat docValuesFormat = new Lucene40DocValuesFormat();- private final SegmentInfosFormat infosFormat = new Lucene40SegmentInfosFormat();+ private final SegmentInfoFormat infosFormat = new Lucene40SegmentInfoFormat();private final NormsFormat normsFormat = new Lucene40NormsFormat();private final LiveDocsFormat liveDocsFormat = new Lucene40LiveDocsFormat();@@ -83,7 +83,7 @@ public class Lucene40Codec extends Codec {}@Override- public SegmentInfosFormat segmentInfosFormat() {+ public SegmentInfoFormat segmentInfosFormat() {return infosFormat;}diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoFormat.javanew file mode 100644index 00000000000..884a0978171--- /dev/null+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoFormat.java@@ -0,0 +1,82 @@+package org.apache.lucene.codecs.lucene40;++/**+ * 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.+ */++import org.apache.lucene.codecs.SegmentInfoFormat;+import org.apache.lucene.codecs.SegmentInfoReader;+import org.apache.lucene.codecs.SegmentInfoWriter;+import org.apache.lucene.index.IndexWriter; // javadocs+import org.apache.lucene.index.SegmentInfos; // javadocs+import org.apache.lucene.store.DataOutput; // javadocs++/**+ * Lucene 4.0 Segment info format.+ * <p>+ * Files:+ * <ul>+ * <li><tt>.si</tt>: SegVersion, SegSize, IsCompoundFile, Diagnostics, Files+ * </ul>+ * </p>+ * Data types:+ * <p>+ * <ul>+ * <li>SegSize --> {@link DataOutput#writeInt Int32}</li>+ * <li>SegVersion --> {@link DataOutput#writeString String}</li>+ * <li>Files --> {@link DataOutput#writeStringSet Set<String>}</li>+ * <li>Diagnostics--> {@link DataOutput#writeStringStringMap Map<String,String>}</li>+ * <li>IsCompoundFile --> {@link DataOutput#writeByte Int8}</li>+ * </ul>+ * </p>+ * Field Descriptions:+ * <p>+ * <ul>+ * <li>SegVersion is the code version that created the segment.</li>+ * <li>SegSize is the number of documents contained in the segment index.</li>+ * <li>IsCompoundFile records whether the segment is written as a compound file or+ * not. If this is -1, the segment is not a compound file. If it is 1, the segment+ * is a compound file.</li>+ * <li>Checksum contains the CRC32 checksum of all bytes in the segments_N file up+ * until the checksum. This is used to verify integrity of the file on opening the+ * index.</li>+ * <li>The Diagnostics Map is privately written by IndexWriter, as a debugging aid,+ * for each segment it creates. It includes metadata like the current Lucene+ * version, OS, Java version, why the segment was created (merge, flush,+ * addIndexes), etc.</li>+ * <li>Files is a list of files referred to by this segment.</li>+ * </ul>+ * </p>+ *+ * @see SegmentInfos+ * @lucene.experimental+ */+public class Lucene40SegmentInfoFormat extends SegmentInfoFormat {+ private final SegmentInfoReader reader = new Lucene40SegmentInfoReader();+ private final SegmentInfoWriter writer = new Lucene40SegmentInfoWriter();++ @Override+ public SegmentInfoReader getSegmentInfosReader() {+ return reader;+ }++ @Override+ public SegmentInfoWriter getSegmentInfosWriter() {+ return writer;+ }++ public final static String SI_EXTENSION = "si";+}diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfosReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoReader.javasimilarity index 84%rename from lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfosReader.javarename to lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoReader.javaindex b03ee5fb275..00f066731cc 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfosReader.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoReader.java@@ -18,33 +18,28 @@ package org.apache.lucene.codecs.lucene40;*/import java.io.IOException;-import java.util.HashMap;-import java.util.HashSet;import java.util.Map;import java.util.Set;-import org.apache.lucene.codecs.Codec;-import org.apache.lucene.codecs.SegmentInfosReader;+import org.apache.lucene.codecs.SegmentInfoReader;import org.apache.lucene.index.IndexFileNames;import org.apache.lucene.index.SegmentInfo;-import org.apache.lucene.index.SegmentInfos;-import org.apache.lucene.store.ChecksumIndexInput;import org.apache.lucene.store.Directory;import org.apache.lucene.store.IOContext;import org.apache.lucene.store.IndexInput;import org.apache.lucene.util.IOUtils;/**- * Lucene 4.0 implementation of {@link SegmentInfosReader}.+ * Lucene 4.0 implementation of {@link SegmentInfoReader}.*- * @see Lucene40SegmentInfosFormat+ * @see Lucene40SegmentInfoFormat* @lucene.experimental*/-public class Lucene40SegmentInfosReader extends SegmentInfosReader {+public class Lucene40SegmentInfoReader extends SegmentInfoReader {@Overridepublic SegmentInfo read(Directory dir, String segment, IOContext context) throws IOException {- final String fileName = IndexFileNames.segmentFileName(segment, "", Lucene40SegmentInfosFormat.SI_EXTENSION);+ final String fileName = IndexFileNames.segmentFileName(segment, "", Lucene40SegmentInfoFormat.SI_EXTENSION);final IndexInput input = dir.openInput(fileName, context);boolean success = false;try {diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfosWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.javasimilarity index 82%rename from lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfosWriter.javarename to lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.javaindex bb74e4919af..6ec1b145684 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfosWriter.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.java@@ -18,36 +18,29 @@ package org.apache.lucene.codecs.lucene40;*/import java.io.IOException;-import java.util.HashSet;-import java.util.Map.Entry;-import java.util.Map;-import java.util.Set;-import org.apache.lucene.codecs.SegmentInfosWriter;+import org.apache.lucene.codecs.SegmentInfoWriter;import org.apache.lucene.index.FieldInfos;import org.apache.lucene.index.IndexFileNames;import org.apache.lucene.index.SegmentInfo;-import org.apache.lucene.index.SegmentInfos;-import org.apache.lucene.store.ChecksumIndexOutput;import org.apache.lucene.store.Directory;-import org.apache.lucene.store.FlushInfo;import org.apache.lucene.store.IOContext;import org.apache.lucene.store.IndexOutput;import org.apache.lucene.util.IOUtils;/**- * Lucene 4.0 implementation of {@link SegmentInfosWriter}.+ * Lucene 4.0 implementation of {@link SegmentInfoWriter}.*- * @see Lucene40SegmentInfosFormat+ * @see Lucene40SegmentInfoFormat* @lucene.experimental*/-public class Lucene40SegmentInfosWriter extends SegmentInfosWriter {+public class Lucene40SegmentInfoWriter extends SegmentInfoWriter {/** Save a single segment's info. */@Overridepublic void write(Directory dir, SegmentInfo si, FieldInfos fis, IOContext ioContext) throws IOException {assert si.getDelCount() <= si.docCount: "delCount=" + si.getDelCount() + " docCount=" + si.docCount + " segment=" + si.name;- final String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene40SegmentInfosFormat.SI_EXTENSION);+ final String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene40SegmentInfoFormat.SI_EXTENSION);assert si.getFiles() != null;si.getFiles().add(fileName);diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfosFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfosFormat.javadeleted file mode 100644index d3568089ce9..00000000000--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfosFormat.java+++ /dev/null@@ -1,139 +0,0 @@-package org.apache.lucene.codecs.lucene40;--/**- * 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.- */--import java.io.IOException;-import java.util.Set;--import org.apache.lucene.codecs.Codec; // javadocs-import org.apache.lucene.codecs.LiveDocsFormat; // javadocs-import org.apache.lucene.codecs.SegmentInfosFormat;-import org.apache.lucene.codecs.SegmentInfosReader;-import org.apache.lucene.codecs.SegmentInfosWriter;-import org.apache.lucene.codecs.StoredFieldsFormat; // javadocs-import org.apache.lucene.codecs.TermVectorsFormat; // javadocs-import org.apache.lucene.index.FieldInfo.IndexOptions; // javadocs-import org.apache.lucene.index.IndexFileNames;-import org.apache.lucene.index.IndexWriter; // javadocs-import org.apache.lucene.index.SegmentInfo;-import org.apache.lucene.index.SegmentInfos; // javadocs-import org.apache.lucene.store.DataOutput; // javadocs--/**- * Lucene 4.0 Segments format.- * <p>- * Files:- * <ul>- * <li><tt>segments.gen</tt>: described in {@link SegmentInfos}- * <li><tt>segments_N</tt>: Format, Codec, Version, NameCounter, SegCount,- * <SegVersion, SegName, SegSize, DelGen, DocStoreOffset, [DocStoreSegment,- * DocStoreIsCompoundFile], NumField, NormGen<sup>NumField</sup>,- * IsCompoundFile, DeletionCount, HasProx, SegCodec Diagnostics,- * HasVectors><sup>SegCount</sup>, CommitUserData, Checksum- * </ul>- * </p>- * Data types:- * <p>- * <ul>- * <li>Format, NameCounter, SegCount, SegSize, NumField, DocStoreOffset,- * DeletionCount --> {@link DataOutput#writeInt Int32}</li>- * <li>Version, DelGen, NormGen, Checksum -->- * {@link DataOutput#writeLong Int64}</li>- * <li>SegVersion, SegName, DocStoreSegment, Codec, SegCodec -->- * {@link DataOutput#writeString String}</li>- * <li>Diagnostics, CommitUserData -->- * {@link DataOutput#writeStringStringMap Map<String,String>}</li>- * <li>IsCompoundFile, DocStoreIsCompoundFile, HasProx,- * HasVectors --> {@link DataOutput#writeByte Int8}</li>- * </ul>- * </p>- * Field Descriptions:- * <p>- * <ul>- * <li>Format is {@link SegmentInfos#FORMAT_4_0}.</li>- * <li>Codec is "Lucene40", its the {@link Codec} that wrote this particular segments file.</li>- * <li>Version counts how often the index has been changed by adding or deleting- * documents.</li>- * <li>NameCounter is used to generate names for new segment files.</li>- * <li>SegVersion is the code version that created the segment.</li>- * <li>SegName is the name of the segment, and is used as the file name prefix for- * all of the files that compose the segment's index.</li>- * <li>SegSize is the number of documents contained in the segment index.</li>- * <li>DelGen is the generation count of the deletes file. If this is -1,- * there are no deletes. Anything above zero means there are deletes- * stored by {@link LiveDocsFormat}.</li>- * <li>NumField is the size of the array for NormGen, or -1 if there are no- * NormGens stored.</li>- * <li>NormGen records the generation of the separate norms files. If NumField is- * -1, there are no normGens stored and all assumed to be -1. The generation- * then has the same meaning as delGen (above).</li>- * <li>IsCompoundFile records whether the segment is written as a compound file or- * not. If this is -1, the segment is not a compound file. If it is 1, the segment- * is a compound file. Else it is 0, which means we check filesystem to see if- * _X.cfs exists.</li>- * <li>DocStoreOffset, DocStoreSegment, DocStoreIsCompoundFile: If DocStoreOffset- * is -1, this segment has its own doc store (stored fields values and term- * vectors) files and DocStoreSegment and DocStoreIsCompoundFile are not stored.- * In this case all files for {@link StoredFieldsFormat stored field values} and- * {@link TermVectorsFormat term vectors} will be stored with this segment.- * Otherwise, DocStoreSegment is the name of the segment that has the shared doc- * store files; DocStoreIsCompoundFile is 1 if that segment is stored in compound- * file format (as a <tt>.cfx</tt> file); and DocStoreOffset is the starting document- * in the shared doc store files where this segment's documents begin. In this case,- * this segment does not store its own doc store files but instead shares a single- * set of these files with other segments.</li>- * <li>Checksum contains the CRC32 checksum of all bytes in the segments_N file up- * until the checksum. This is used to verify integrity of the file on opening the- * index.</li>- * <li>DeletionCount records the number of deleted documents in this segment.</li>- * <li>HasProx is 1 if any fields in this segment have position data- * ({@link IndexOptions#DOCS_AND_FREQS_AND_POSITIONS DOCS_AND_FREQS_AND_POSITIONS} or- * {@link IndexOptions#DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS});- * else, it's 0.</li>- * <li>SegCodec is the {@link Codec#getName() name} of the Codec that encoded- * this segment.</li>- * <li>CommitUserData stores an optional user-supplied opaque- * Map<String,String> that was passed to {@link IndexWriter#commit(java.util.Map)}- * or {@link IndexWriter#prepareCommit(java.util.Map)}.</li>- * <li>The Diagnostics Map is privately written by IndexWriter, as a debugging aid,- * for each segment it creates. It includes metadata like the current Lucene- * version, OS, Java version, why the segment was created (merge, flush,- * addIndexes), etc.</li>- * <li>HasVectors is 1 if this segment stores term vectors, else it's 0.</li>- * </ul>- * </p>- *- * @see SegmentInfos- * @lucene.experimental- */-public class Lucene40SegmentInfosFormat extends SegmentInfosFormat {- private final SegmentInfosReader reader = new Lucene40SegmentInfosReader();- private final SegmentInfosWriter writer = new Lucene40SegmentInfosWriter();-- @Override- public SegmentInfosReader getSegmentInfosReader() {- return reader;- }-- @Override- public SegmentInfosWriter getSegmentInfosWriter() {- return writer;- }-- public final static String SI_EXTENSION = "si";-}diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/package.html b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/package.htmlindex f1413e1aafd..ffbd770174d 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/package.html+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/package.html@@ -137,6 +137,11 @@ its numbering.</p><p>Each segment index maintains the following:</p><ul><li>+{@link org.apache.lucene.codecs.lucene40.Lucene40SegmentInfoFormat Segment info}.+ This contains metadata about a segment, such as the number of documents,+ what files it uses,+</li>+<li>{@link org.apache.lucene.codecs.lucene40.Lucene40FieldInfosFormat Field names}.This contains the set of field names used in the index.</li>@@ -197,8 +202,9 @@ An optional file indicating which documents are deleted.<div><p>All files belonging to a segment have the same name with varying extensions.The extensions correspond to the different file formats described below. When-using the Compound File format (default in 1.4 and greater) these files are-collapsed into a single .cfs file (see below for details)</p>+using the Compound File format (default in 1.4 and greater) these files (except+for the Segment info file, the Lock file, and Deleted documents file) are collapsed+into a single .cfs file (see below for details)</p><p>Typically, all segments in an index are stored in a single directory,although this is not required.</p><p>As of version 2.1 (lock-less commits), file names are never re-used (there@@ -220,9 +226,9 @@ Lucene:</p><th>Brief Description</th></tr><tr>-<td>{@link org.apache.lucene.codecs.lucene40.Lucene40SegmentInfosFormat Segments File}</td>+<td>{@link org.apache.lucene.index.SegmentInfos Segments File}</td><td>segments.gen, segments_N</td>-<td>Stores information about segments</td>+<td>Stores information about a commit point</td></tr><tr><td><a href="#Lock_File">Lock File</a></td>@@ -231,6 +237,11 @@ Lucene:</p>file.</td></tr><tr>+<td>{@link org.apache.lucene.codecs.lucene40.Lucene40SegmentInfoFormat Segment Info}</td>+<td>.si</td>+<td>Stores metadata about a segment</td>+</tr>+<tr><td>{@link org.apache.lucene.store.CompoundFileDirectory Compound File}</td><td>.cfs, .cfe</td><td>An optional "virtual" file consisting of all the other index files fordiff --git a/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.javaindex 7a851f2561f..c65c4c44b0a 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.java@@ -206,8 +206,6 @@ public abstract class PerFieldPostingsFormat extends PostingsFormat {return new FieldsReader(state);}- // nocommit simplify now that we don't have files()...?-// NOTE: only called during writing; for reading we read// all we need from the index (ie we save the field ->// format mapping)diff --git a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCodec.java b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCodec.javaindex 23defd7b9bc..1003bde9e3f 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCodec.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCodec.java@@ -23,7 +23,7 @@ import org.apache.lucene.codecs.FieldInfosFormat;import org.apache.lucene.codecs.LiveDocsFormat;import org.apache.lucene.codecs.NormsFormat;import org.apache.lucene.codecs.PostingsFormat;-import org.apache.lucene.codecs.SegmentInfosFormat;+import org.apache.lucene.codecs.SegmentInfoFormat;import org.apache.lucene.codecs.StoredFieldsFormat;import org.apache.lucene.codecs.TermVectorsFormat;@@ -36,7 +36,7 @@ import org.apache.lucene.codecs.TermVectorsFormat;public final class SimpleTextCodec extends Codec {private final PostingsFormat postings = new SimpleTextPostingsFormat();private final StoredFieldsFormat storedFields = new SimpleTextStoredFieldsFormat();- private final SegmentInfosFormat segmentInfos = new SimpleTextSegmentInfosFormat();+ private final SegmentInfoFormat segmentInfos = new SimpleTextSegmentInfosFormat();private final FieldInfosFormat fieldInfosFormat = new SimpleTextFieldInfosFormat();private final TermVectorsFormat vectorsFormat = new SimpleTextTermVectorsFormat();// TODO: need a plain-text impl@@ -75,7 +75,7 @@ public final class SimpleTextCodec extends Codec {}@Override- public SegmentInfosFormat segmentInfosFormat() {+ public SegmentInfoFormat segmentInfosFormat() {return segmentInfos;}diff --git a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosFormat.javaindex 0a0490d5484..08d88f9ac8d 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosFormat.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosFormat.java@@ -19,9 +19,9 @@ package org.apache.lucene.codecs.simpletext;import java.util.Set;-import org.apache.lucene.codecs.SegmentInfosFormat;-import org.apache.lucene.codecs.SegmentInfosReader;-import org.apache.lucene.codecs.SegmentInfosWriter;+import org.apache.lucene.codecs.SegmentInfoFormat;+import org.apache.lucene.codecs.SegmentInfoReader;+import org.apache.lucene.codecs.SegmentInfoWriter;import org.apache.lucene.index.IndexFileNames;import org.apache.lucene.index.SegmentInfo;@@ -31,19 +31,19 @@ import org.apache.lucene.index.SegmentInfo;* <b><font color="red">FOR RECREATIONAL USE ONLY</font></B>* @lucene.experimental*/-public class SimpleTextSegmentInfosFormat extends SegmentInfosFormat {- private final SegmentInfosReader reader = new SimpleTextSegmentInfosReader();- private final SegmentInfosWriter writer = new SimpleTextSegmentInfosWriter();+public class SimpleTextSegmentInfosFormat extends SegmentInfoFormat {+ private final SegmentInfoReader reader = new SimpleTextSegmentInfosReader();+ private final SegmentInfoWriter writer = new SimpleTextSegmentInfosWriter();public static final String SI_EXTENSION = "si";@Override- public SegmentInfosReader getSegmentInfosReader() {+ public SegmentInfoReader getSegmentInfosReader() {return reader;}@Override- public SegmentInfosWriter getSegmentInfosWriter() {+ public SegmentInfoWriter getSegmentInfosWriter() {return writer;}}diff --git a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosReader.java b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosReader.javaindex d4cddde5419..f81ee38a41d 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosReader.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosReader.java@@ -24,7 +24,7 @@ import java.util.Map;import java.util.Set;import org.apache.lucene.codecs.Codec;-import org.apache.lucene.codecs.SegmentInfosReader;+import org.apache.lucene.codecs.SegmentInfoReader;import org.apache.lucene.index.CorruptIndexException;import org.apache.lucene.index.IndexFileNames;import org.apache.lucene.index.SegmentInfo;@@ -46,7 +46,7 @@ import static org.apache.lucene.codecs.simpletext.SimpleTextSegmentInfosWriter.** <b><font color="red">FOR RECREATIONAL USE ONLY</font></B>* @lucene.experimental*/-public class SimpleTextSegmentInfosReader extends SegmentInfosReader {+public class SimpleTextSegmentInfosReader extends SegmentInfoReader {@Overridepublic SegmentInfo read(Directory directory, String segmentName, IOContext context) throws IOException {diff --git a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosWriter.javaindex b51c0c7a035..4d476f953b5 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosWriter.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosWriter.java@@ -22,7 +22,7 @@ import java.util.Map.Entry;import java.util.Map;import java.util.Set;-import org.apache.lucene.codecs.SegmentInfosWriter;+import org.apache.lucene.codecs.SegmentInfoWriter;import org.apache.lucene.index.FieldInfos;import org.apache.lucene.index.IndexFileNames;import org.apache.lucene.index.SegmentInfo;@@ -41,7 +41,7 @@ import org.apache.lucene.util.IOUtils;* <b><font color="red">FOR RECREATIONAL USE ONLY</font></B>* @lucene.experimental*/-public class SimpleTextSegmentInfosWriter extends SegmentInfosWriter {+public class SimpleTextSegmentInfosWriter extends SegmentInfoWriter {final static BytesRef SI_VERSION = new BytesRef(" version ");final static BytesRef SI_DOCCOUNT = new BytesRef(" number of documents ");diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.javaindex 5787c45f734..8fc60f52257 100644--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java@@ -33,7 +33,7 @@ import java.util.concurrent.atomic.AtomicInteger;import org.apache.lucene.analysis.Analyzer;import org.apache.lucene.codecs.Codec;-import org.apache.lucene.codecs.lucene3x.Lucene3xSegmentInfosFormat;+import org.apache.lucene.codecs.lucene3x.Lucene3xSegmentInfoFormat;import org.apache.lucene.index.DocumentsWriterPerThread.FlushedSegment;import org.apache.lucene.index.FieldInfos.FieldNumberBiMap;import org.apache.lucene.index.IndexWriterConfig.OpenMode;@@ -2372,7 +2372,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {final boolean hasSharedDocStore = info.getDocStoreOffset() != -1;final String segmentInfoFileName3X = IndexFileNames.segmentFileName(info.name,"",- Lucene3xSegmentInfosFormat.SI_EXTENSION);+ Lucene3xSegmentInfoFormat.SI_EXTENSION);if (hasSharedDocStore) {// only violate the codec this way if it's preflex &diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.javaindex 52ef586abdd..cffc38bf0c8 100644--- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java+++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java@@ -34,16 +34,11 @@ import org.apache.lucene.store.Directory;import org.apache.lucene.store.TrackingDirectoryWrapper;import org.apache.lucene.util.Constants;-// nocommit fix jdocs for all codec's SI writer impls to-// describe their format-// nocommit fix codec api to pass this around so they can// store attrs// nocommit add attrs api like FI-// nocommit fix PFPF to use attrs api instead of its .per file-/*** Information about a segment such as it's name, directory, and files related* to the segment.diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.javaindex 32a93dd4a26..8ff077c88d0 100644--- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java+++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java@@ -32,16 +32,14 @@ import java.util.Map;import java.util.Set;import org.apache.lucene.codecs.Codec;-import org.apache.lucene.codecs.SegmentInfosReader;-import org.apache.lucene.codecs.SegmentInfosWriter;+import org.apache.lucene.codecs.LiveDocsFormat;import org.apache.lucene.codecs.lucene3x.Lucene3xCodec;-import org.apache.lucene.codecs.lucene3x.Lucene3xSegmentInfosFormat;-import org.apache.lucene.codecs.lucene3x.Lucene3xSegmentInfosReader;+import org.apache.lucene.codecs.lucene3x.Lucene3xSegmentInfoFormat;+import org.apache.lucene.codecs.lucene3x.Lucene3xSegmentInfoReader;import org.apache.lucene.store.ChecksumIndexInput;import org.apache.lucene.store.ChecksumIndexOutput;import org.apache.lucene.store.DataOutput; // javadocsimport org.apache.lucene.store.Directory;-import org.apache.lucene.store.FlushInfo;import org.apache.lucene.store.IOContext;import org.apache.lucene.store.IndexInput;import org.apache.lucene.store.IndexOutput;@@ -60,9 +58,8 @@ import org.apache.lucene.util.ThreadInterruptedException;* older segments_N files are present it's because they temporarily cannot be* deleted, or, a writer is in the process of committing, or a custom* {@link org.apache.lucene.index.IndexDeletionPolicy IndexDeletionPolicy}- * is in use). This file lists each segment by name, has details about the- * separate norms and deletion files, and also contains the size of each- * segment.+ * is in use). This file lists each segment by name and has details about the+ * codec and generation of deletes.* </p>* <p>There is also a file <tt>segments.gen</tt>. This file contains* the current generation (the <tt>_N</tt> in <tt>segments_N</tt>) of the index.@@ -72,27 +69,55 @@ import org.apache.lucene.util.ThreadInterruptedException;* an {@link DataOutput#writeInt Int32} version header* ({@link #FORMAT_SEGMENTS_GEN_CURRENT}), followed by the* generation recorded as {@link DataOutput#writeLong Int64}, written twice.</p>+ * <p>+ * Files:+ * <ul>+ * <li><tt>segments.gen</tt>: GenHeader, Generation, Generation+ * <li><tt>segments_N</tt>: Header, Version, NameCounter, SegCount,+ * <SegName, SegCodec, DelGen, DeletionCount><sup>SegCount</sup>,+ * CommitUserData, Checksum+ * </ul>+ * </p>+ * Data types:+ * <p>+ * <ul>+ * <li>Header --> {@link CodecUtil#writeHeader CodecHeader}</li>+ * <li>GenHeader, NameCounter, SegCount, DeletionCount --> {@link DataOutput#writeInt Int32}</li>+ * <li>Generation, Version, DelGen, Checksum --> {@link DataOutput#writeLong Int64}</li>+ * <li>SegName, SegCodec --> {@link DataOutput#writeString String}</li>+ * <li>CommitUserData --> {@link DataOutput#writeStringStringMap Map<String,String>}</li>+ * </ul>+ * </p>+ * Field Descriptions:+ * <p>+ * <ul>+ * <li>Version counts how often the index has been changed by adding or deleting+ * documents.</li>+ * <li>NameCounter is used to generate names for new segment files.</li>+ * <li>SegName is the name of the segment, and is used as the file name prefix for+ * all of the files that compose the segment's index.</li>+ * <li>DelGen is the generation count of the deletes file. If this is -1,+ * there are no deletes. Anything above zero means there are deletes+ * stored by {@link LiveDocsFormat}.</li>+ * <li>DeletionCount records the number of deleted documents in this segment.</li>+ * <li>Checksum contains the CRC32 checksum of all bytes in the segments_N file up+ * until the checksum. This is used to verify integrity of the file on opening the+ * index.</li>+ * <li>SegCodec is the {@link Codec#getName() name} of the Codec that encoded+ * this segment.</li>+ * <li>CommitUserData stores an optional user-supplied opaque+ * Map<String,String> that was passed to {@link IndexWriter#commit(java.util.Map)}+ * or {@link IndexWriter#prepareCommit(java.util.Map)}.</li>+ * </ul>+ * </p>** @lucene.experimental*/public final class SegmentInfos implements Cloneable, Iterable<SegmentInfo> {- /*- * The file format version, a negative number.- *- * NOTE: future format numbers must always be one smaller- * than the latest. With time, support for old formats will- * be removed, however the numbers should continue to decrease.+ /**+ * The file format version for the segments_N codec header*/-- // TODO: i don't think we need *all* these version numbers here?- // most codecs only need FORMAT_CURRENT? and we should rename it- // to FORMAT_FLEX? because the 'preamble' is just FORMAT_CURRENT + codecname- // after that the codec takes over.-- // also i think this class should write this, somehow we let- // preflexrw hackishly override this (like seek backwards and overwrite it)-public static final int VERSION_40 = 0;/** Used for the segments.gen file only!@@ -248,13 +273,9 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentInfo> {lastGeneration = generation;- // TODO: scary to have default impl reopen the file... but to make it a bit more flexible,- // maybe we could use a plain indexinput here... could default impl rewind/wrap with checksumII,- // and any checksumming is then up to implementation?ChecksumIndexInput input = new ChecksumIndexInput(directory.openInput(segmentFileName, IOContext.READ));try {final int format = input.readInt();- final boolean checkCheckSum;if (format == CodecUtil.CODEC_MAGIC) {// 4.0+CodecUtil.checkHeaderNoMagic(input, "segments", VERSION_40, VERSION_40);@@ -274,7 +295,7 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentInfo> {}userData = input.readStringStringMap();} else {- Lucene3xSegmentInfosReader.readLegacyInfos(this, directory, input, format);+ Lucene3xSegmentInfoReader.readLegacyInfos(this, directory, input, format);Codec codec = Codec.forName("Lucene3x");for (SegmentInfo info : this) {info.setCodec(codec);@@ -331,7 +352,7 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentInfo> {ChecksumIndexOutput segnOutput = null;boolean success = false;- // nocommit document somewhere taht we store this+ // nocommit document somewhere that we store this// list-of-segs plus delGen plus other stuff// "generically" and then codec gets to write SI@@ -343,7 +364,6 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentInfo> {segnOutput.writeLong(version);segnOutput.writeInt(counter); // write countersegnOutput.writeInt(size()); // write infos- Codec codec3X = Codec.forName("Lucene3x");for (SegmentInfo si : this) {segnOutput.writeString(si.name);segnOutput.writeString(si.getCodec().getName());@@ -355,7 +375,7 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentInfo> {// "ugprade" to write the .si file for it:String version = si.getVersion();if (version == null || version.startsWith("3.")) {- String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene3xSegmentInfosFormat.SI_EXTENSION);+ String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene3xSegmentInfoFormat.SI_EXTENSION);if (!directory.fileExists(fileName)) {upgradedSIFiles.add(write3xInfo(directory, si, IOContext.DEFAULT));}@@ -393,7 +413,7 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentInfo> {public static String write3xInfo(Directory dir, SegmentInfo si, IOContext context) throws IOException {// NOTE: this is NOT how 3.x is really written...- String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene3xSegmentInfosFormat.SI_EXTENSION);+ String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene3xSegmentInfoFormat.SI_EXTENSION);si.getFiles().add(fileName);//System.out.println("UPGRADE write " + fileName);diff --git a/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.java b/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.javaindex e01df64d3eb..eb4f742a51f 100644--- a/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.java+++ b/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.java@@ -71,7 +71,7 @@ public class ChecksumIndexOutput extends IndexOutput {throw new UnsupportedOperationException();}- /** See {@link #prepareCommit} */+ /** writes the checksum */public void finishCommit() throws IOException {main.writeLong(getChecksum());}diff --git a/lucene/core/src/java/org/apache/lucene/util/CodecUtil.java b/lucene/core/src/java/org/apache/lucene/util/CodecUtil.javaindex 7d7d01adbf0..5e1998842ea 100644--- a/lucene/core/src/java/org/apache/lucene/util/CodecUtil.java+++ b/lucene/core/src/java/org/apache/lucene/util/CodecUtil.java@@ -130,7 +130,7 @@ public final class CodecUtil {}/** Like {@link- * checkHeader(DataInput,String,int,int)} except this+ * #checkHeader(DataInput,String,int,int)} except this* version assumes the first int has already been read* and validated from the input. */public static int checkHeaderNoMagic(DataInput in, String codec, int minVersion, int maxVersion) throws IOException {diff --git a/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java b/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.javaindex a7634f9c87d..cbfe795329a 100755--- a/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java@@ -30,7 +30,7 @@ import org.apache.lucene.codecs.FieldInfosFormat;import org.apache.lucene.codecs.LiveDocsFormat;import org.apache.lucene.codecs.NormsFormat;import org.apache.lucene.codecs.PostingsFormat;-import org.apache.lucene.codecs.SegmentInfosFormat;+import org.apache.lucene.codecs.SegmentInfoFormat;import org.apache.lucene.codecs.StoredFieldsFormat;import org.apache.lucene.codecs.TermVectorsFormat;import org.apache.lucene.codecs.lucene40.Lucene40Codec;@@ -38,7 +38,7 @@ import org.apache.lucene.codecs.lucene40.Lucene40DocValuesFormat;import org.apache.lucene.codecs.lucene40.Lucene40FieldInfosFormat;import org.apache.lucene.codecs.lucene40.Lucene40LiveDocsFormat;import org.apache.lucene.codecs.lucene40.Lucene40NormsFormat;-import org.apache.lucene.codecs.lucene40.Lucene40SegmentInfosFormat;+import org.apache.lucene.codecs.lucene40.Lucene40SegmentInfoFormat;import org.apache.lucene.codecs.lucene40.Lucene40StoredFieldsFormat;import org.apache.lucene.codecs.lucene40.Lucene40TermVectorsFormat;import org.apache.lucene.codecs.pulsing.Pulsing40PostingsFormat;@@ -1150,8 +1150,8 @@ public class TestAddIndexes extends LuceneTestCase {}@Override- public SegmentInfosFormat segmentInfosFormat() {- return new Lucene40SegmentInfosFormat();+ public SegmentInfoFormat segmentInfosFormat() {+ return new Lucene40SegmentInfoFormat();}@Overridediff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWCodec.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWCodec.javaindex 921c5830fdc..296042510bd 100644--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWCodec.java+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWCodec.java@@ -24,7 +24,7 @@ import org.apache.lucene.codecs.FieldInfosFormat;import org.apache.lucene.codecs.LiveDocsFormat;import org.apache.lucene.codecs.NormsFormat;import org.apache.lucene.codecs.PostingsFormat;-import org.apache.lucene.codecs.SegmentInfosFormat;+import org.apache.lucene.codecs.SegmentInfoFormat;import org.apache.lucene.codecs.StoredFieldsFormat;import org.apache.lucene.codecs.TermVectorsFormat;import org.apache.lucene.codecs.lucene40.Lucene40LiveDocsFormat;@@ -42,7 +42,7 @@ public class PreFlexRWCodec extends Lucene3xCodec {private final Lucene3xNormsFormat norms = new PreFlexRWNormsFormat();private final FieldInfosFormat fieldInfos = new PreFlexRWFieldInfosFormat();private final TermVectorsFormat termVectors = new PreFlexRWTermVectorsFormat();- private final SegmentInfosFormat segmentInfos = new PreFlexRWSegmentInfosFormat();+ private final SegmentInfoFormat segmentInfos = new PreFlexRWSegmentInfosFormat();private final StoredFieldsFormat storedFields = new PreFlexRWStoredFieldsFormat();// TODO: this should really be a different implprivate final LiveDocsFormat liveDocs = new Lucene40LiveDocsFormat();@@ -66,7 +66,7 @@ public class PreFlexRWCodec extends Lucene3xCodec {}@Override- public SegmentInfosFormat segmentInfosFormat() {+ public SegmentInfoFormat segmentInfosFormat() {if (LuceneTestCase.PREFLEX_IMPERSONATION_IS_ACTIVE) {return segmentInfos ;} else {diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWSegmentInfosFormat.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWSegmentInfosFormat.javaindex d49c01eea8d..d9cf0a9afd7 100644--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWSegmentInfosFormat.java+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWSegmentInfosFormat.java@@ -1,6 +1,6 @@package org.apache.lucene.codecs.lucene3x;-import org.apache.lucene.codecs.SegmentInfosWriter;+import org.apache.lucene.codecs.SegmentInfoWriter;/*** Licensed to the Apache Software Foundation (ASF) under one or more@@ -22,11 +22,11 @@ import org.apache.lucene.codecs.SegmentInfosWriter;/*** @lucene.experimental*/-class PreFlexRWSegmentInfosFormat extends Lucene3xSegmentInfosFormat {- private final SegmentInfosWriter writer = new PreFlexRWSegmentInfosWriter();+class PreFlexRWSegmentInfosFormat extends Lucene3xSegmentInfoFormat {+ private final SegmentInfoWriter writer = new PreFlexRWSegmentInfosWriter();@Override- public SegmentInfosWriter getSegmentInfosWriter() {+ public SegmentInfoWriter getSegmentInfosWriter() {return writer;}}diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWSegmentInfosWriter.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWSegmentInfosWriter.javaindex 89c11f518d1..85397526d16 100644--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWSegmentInfosWriter.java+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWSegmentInfosWriter.java@@ -21,7 +21,7 @@ import java.io.IOException;import java.util.Map.Entry;import java.util.Map;-import org.apache.lucene.codecs.SegmentInfosWriter;+import org.apache.lucene.codecs.SegmentInfoWriter;import org.apache.lucene.index.FieldInfos;import org.apache.lucene.index.IndexFileNames;import org.apache.lucene.index.SegmentInfo;@@ -34,10 +34,10 @@ import org.apache.lucene.store.IndexOutput;import org.apache.lucene.util.IOUtils;/**- * PreFlex implementation of {@link SegmentInfosWriter}.+ * PreFlex implementation of {@link SegmentInfoWriter}.* @lucene.experimental*/-class PreFlexRWSegmentInfosWriter extends SegmentInfosWriter {+class PreFlexRWSegmentInfosWriter extends SegmentInfoWriter {// NOTE: this is not "really" 3.x format, because we are// writing each SI to its own file, vs 3.x where the list