Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java
- ===================================================================
- --- lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java (revision 1341590)
- +++ lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java (working copy)
- @@ -145,8 +145,8 @@
- SegmentInfoPerCommit infoPerCommit = getInfo(n);
- SegmentInfo info = infoPerCommit.info;
- // Same info just changing the dir:
- - SegmentInfo newInfo = new SegmentInfo(destFSDir, info.getVersion(), info.name, info.docCount, info.getDocStoreOffset(),
- - info.getDocStoreSegment(), info.getDocStoreIsCompoundFile(), info.getNormGen(), info.getUseCompoundFile(),
- + SegmentInfo newInfo = new SegmentInfo(destFSDir, info.getVersion(), info.name, info.docCount,
- + info.getNormGen(), info.getUseCompoundFile(),
- info.getCodec(), info.getDiagnostics(), info.attributes());
- destInfos.add(new SegmentInfoPerCommit(newInfo, infoPerCommit.getDelCount(), infoPerCommit.getDelGen()));
- // nocommit is this right...?
- Index: lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java
- ===================================================================
- --- lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java (revision 1341584)
- +++ lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java (working copy)
- @@ -35,6 +35,8 @@
- import org.apache.lucene.codecs.Codec;
- import org.apache.lucene.codecs.PostingsFormat;
- +import org.apache.lucene.codecs.lucene3x.Lucene3xCodec;
- +import org.apache.lucene.codecs.lucene3x.Lucene3xSegmentInfoFormat;
- import org.apache.lucene.codecs.lucene40.Lucene40Codec;
- import org.apache.lucene.codecs.perfield.PerFieldPostingsFormat;
- import org.apache.lucene.document.ByteDocValuesField;
- @@ -918,4 +920,23 @@
- }
- }
- }
- +
- + // method for crazy tests that make segmentinfos directly. if its lucene3x codec,
- + // then these attributes are expected to be in the SI
- + //
- + // nocommit: maybe i'm being too picky here?
- + // we could make preflex-reader more tolerant instead, at the risk of bugs.
- + // personally i prefer to find the bugs instead and make the tests hairier...
- + // its really their fault for doing this!!!!!!
- + public static Map<String,String> newSegmentInfoAttributes(final String segmentName) {
- + if (Codec.getDefault() instanceof Lucene3xCodec) {
- + return new HashMap<String,String>() {{
- + put(Lucene3xSegmentInfoFormat.DOCSTOREOFFSET_KEY, "-1");
- + put(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY, segmentName);
- + put(Lucene3xSegmentInfoFormat.DOCSTOREISCOMPOUND_KEY, "false");
- + }};
- + } else {
- + return null;
- + }
- + }
- }
- Index: lucene/core/src/test/org/apache/lucene/index/TestCodecs.java
- ===================================================================
- --- lucene/core/src/test/org/apache/lucene/index/TestCodecs.java (revision 1341590)
- +++ lucene/core/src/test/org/apache/lucene/index/TestCodecs.java (working copy)
- @@ -256,8 +256,8 @@
- final Directory dir = newDirectory();
- this.write(fieldInfos, dir, fields, true);
- Codec codec = Codec.getDefault();
- - final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, -1, SEGMENT, false, null, false,
- - codec, null, null);
- + final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, null, false,
- + codec, null, _TestUtil.newSegmentInfoAttributes(SEGMENT));
- final FieldsProducer reader = codec.postingsFormat().fieldsProducer(new SegmentReadState(dir, si, fieldInfos, newIOContext(random()), DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR));
- @@ -313,9 +313,8 @@
- this.write(fieldInfos, dir, fields, false);
- Codec codec = Codec.getDefault();
- - final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, -1,
- - SEGMENT, false, null, false,
- - codec, null, null);
- + final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, null, false,
- + codec, null, _TestUtil.newSegmentInfoAttributes(SEGMENT));
- if (VERBOSE) {
- System.out.println("TEST: now read postings");
- Index: lucene/core/src/test/org/apache/lucene/index/TestDoc.java
- ===================================================================
- --- lucene/core/src/test/org/apache/lucene/index/TestDoc.java (revision 1341590)
- +++ lucene/core/src/test/org/apache/lucene/index/TestDoc.java (working copy)
- @@ -205,8 +205,7 @@
- r1.close();
- r2.close();
- final SegmentInfo info = new SegmentInfo(si1.info.dir, Constants.LUCENE_MAIN_VERSION, merged,
- - si1.info.docCount + si2.info.docCount, -1, merged,
- - false, null, false, codec, null, null);
- + si1.info.docCount + si2.info.docCount, null, false, codec, null, _TestUtil.newSegmentInfoAttributes(merged));
- info.setFiles(new HashSet<String>(trackingDir.getCreatedFiles()));
- if (useCompoundFile) {
- Index: lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
- ===================================================================
- --- lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (revision 1341584)
- +++ lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (working copy)
- @@ -55,6 +55,7 @@
- import org.apache.lucene.util._TestUtil;
- import org.junit.AfterClass;
- import org.junit.BeforeClass;
- +import org.junit.Ignore;
- /*
- Verify we can read the pre-4.0 file format, do searches
- @@ -63,6 +64,7 @@
- // don't use 3.x codec, its unrealistic since it means
- // we won't even be running the actual code, only the impostor
- @SuppressCodecs("Lucene3x")
- +@Ignore("nocommit")
- public class TestBackwardsCompatibility extends LuceneTestCase {
- // Uncomment these cases & run them on an older Lucene
- Index: lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java
- ===================================================================
- --- lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java (revision 1341590)
- +++ lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java (working copy)
- @@ -85,8 +85,8 @@
- assertTrue(docsMerged == 2);
- //Should be able to open a new SegmentReader against the new directory
- SegmentReader mergedReader = new SegmentReader(new SegmentInfoPerCommit(
- - new SegmentInfo(mergedDir, Constants.LUCENE_MAIN_VERSION, mergedSegment, docsMerged, -1, mergedSegment,
- - false, null, false, codec, null, null),
- + new SegmentInfo(mergedDir, Constants.LUCENE_MAIN_VERSION, mergedSegment, docsMerged,
- + null, false, codec, null, _TestUtil.newSegmentInfoAttributes(mergedSegment)),
- 0, -1L),
- DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random()));
- assertTrue(mergedReader != null);
- Index: lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java (revision 1341590)
- +++ lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java (working copy)
- @@ -485,9 +485,7 @@
- consumer.flush(flushState);
- pendingDeletes.terms.clear();
- final SegmentInfo newSegment = new SegmentInfo(directoryOrig, Constants.LUCENE_MAIN_VERSION, segment, flushState.numDocs,
- - -1, segment, false, null, false,
- - flushState.codec,
- - null, null);
- + null, false, flushState.codec, null, null);
- newSegment.setFiles(new HashSet<String>(directory.getCreatedFiles()));
- if (infoStream.isEnabled("DWPT")) {
- Index: lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java (revision 1341584)
- +++ lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java (working copy)
- @@ -431,12 +431,17 @@
- // NOTE: a lie
- output.writeLong(0L);
- -
- - output.writeInt(si.getDocStoreOffset());
- - if (si.getDocStoreOffset() != -1) {
- - output.writeString(si.getDocStoreSegment());
- - output.writeByte((byte) (si.getDocStoreIsCompoundFile() ? 1:0));
- + // TODO: this sucks. if preflex-rw storefieldswriter had the si we could do this in test code...
- + if (si.getAttribute(Lucene3xSegmentInfoFormat.DOCSTOREOFFSET_KEY) == null) {
- + // preflex-rw case
- + String previous = si.putAttribute(Lucene3xSegmentInfoFormat.DOCSTOREOFFSET_KEY, "-1");
- + assert previous == null;
- + previous = si.putAttribute(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY, si.name);
- + assert previous == null;
- + previous = si.putAttribute(Lucene3xSegmentInfoFormat.DOCSTOREISCOMPOUND_KEY, "false");
- + assert previous == null;
- }
- + output.writeStringStringMap(si.attributes());
- // pre-4.0 indexes write a byte if there is a single norms file
- output.writeByte((byte) 1);
- Index: lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/index/IndexWriter.java (revision 1341590)
- +++ lucene/core/src/java/org/apache/lucene/index/IndexWriter.java (working copy)
- @@ -2223,7 +2223,9 @@
- assert !infos.contains(info): "dup info dir=" + info.info.dir + " name=" + info.info.name;
- String newSegName = newSegmentName();
- - String dsName = info.info.getDocStoreSegment();
- + // TODO: should we really do this just for the infostream? or just print the atts?
- + final String sharedDsSegment = info.info.getAttribute(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY);
- + String dsName = sharedDsSegment == null ? info.info.name : sharedDsSegment;
- if (infoStream.isEnabled("IW")) {
- infoStream.message("IW", "addIndexes: process segment origName=" + info.info.name + " newName=" + newSegName + " dsName=" + dsName + " info=" + info);
- @@ -2298,8 +2300,7 @@
- MergeState mergeState = merger.merge(); // merge 'em
- SegmentInfo info = new SegmentInfo(directory, Constants.LUCENE_MAIN_VERSION, mergedName, mergeState.mergedDocCount,
- - -1, mergedName, false, null, false,
- - codec, null, null);
- + null, false, codec, null, null);
- SegmentInfoPerCommit infoPerCommit = new SegmentInfoPerCommit(info, 0, -1L);
- info.setFiles(new HashSet<String>(trackingDir.getCreatedFiles()));
- @@ -2361,7 +2362,8 @@
- // only relevant for segments that share doc store with others,
- // because the DS might have been copied already, in which case we
- // just want to update the DS name of this SegmentInfo.
- - String dsName = info.info.getDocStoreSegment();
- + final String sharedDsSegment = info.info.getAttribute(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY);
- + final String dsName = sharedDsSegment == null ? info.info.name : sharedDsSegment;
- assert dsName != null;
- final String newDsName;
- if (dsNames.containsKey(dsName)) {
- @@ -2372,7 +2374,9 @@
- }
- Set<String> codecDocStoreFiles = new HashSet<String>();
- - final boolean hasSharedDocStore = info.info.getDocStoreOffset() != -1;
- + final String sharedDsOffsetValue = info.info.getAttribute(Lucene3xSegmentInfoFormat.DOCSTOREOFFSET_KEY);
- + final int docStoreOffset = sharedDsOffsetValue == null ? -1 : Integer.parseInt(sharedDsOffsetValue);
- + final boolean hasSharedDocStore = docStoreOffset != -1;
- final String segmentInfoFileName3X = IndexFileNames.segmentFileName(info.info.name,
- "",
- Lucene3xSegmentInfoFormat.SI_EXTENSION);
- @@ -2380,24 +2384,25 @@
- if (hasSharedDocStore) {
- // only violate the codec this way if it's preflex &
- // shares doc stores
- - assert info.info.getDocStoreSegment() != null;
- + assert sharedDsSegment != null;
- // nocommit what to do....
- - if (info.info.getDocStoreIsCompoundFile()) {
- - codecDocStoreFiles.add(IndexFileNames.segmentFileName(info.info.getDocStoreSegment(), "", "cfx"));
- + if (Boolean.parseBoolean(info.info.getAttribute(Lucene3xSegmentInfoFormat.DOCSTOREISCOMPOUND_KEY))) {
- + codecDocStoreFiles.add(IndexFileNames.segmentFileName(dsName, "", "cfx"));
- } else {
- - codecDocStoreFiles.add(IndexFileNames.segmentFileName(info.info.getDocStoreSegment(), "", "fdt"));
- - codecDocStoreFiles.add(IndexFileNames.segmentFileName(info.info.getDocStoreSegment(), "", "fdx"));
- - codecDocStoreFiles.add(IndexFileNames.segmentFileName(info.info.getDocStoreSegment(), "", "tvx"));
- - codecDocStoreFiles.add(IndexFileNames.segmentFileName(info.info.getDocStoreSegment(), "", "tvf"));
- - codecDocStoreFiles.add(IndexFileNames.segmentFileName(info.info.getDocStoreSegment(), "", "tvd"));
- + codecDocStoreFiles.add(IndexFileNames.segmentFileName(dsName, "", "fdt"));
- + codecDocStoreFiles.add(IndexFileNames.segmentFileName(dsName, "", "fdx"));
- + codecDocStoreFiles.add(IndexFileNames.segmentFileName(dsName, "", "tvx"));
- + codecDocStoreFiles.add(IndexFileNames.segmentFileName(dsName, "", "tvf"));
- + codecDocStoreFiles.add(IndexFileNames.segmentFileName(dsName, "", "tvd"));
- }
- + info.info.putAttribute(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY, newDsName);
- }
- //System.out.println("copy seg=" + info.info.name + " version=" + info.info.getVersion());
- // Same SI as before but we change directory, name and docStoreSegment:
- - SegmentInfo newInfo = new SegmentInfo(directory, info.info.getVersion(), segName, info.info.docCount, info.info.getDocStoreOffset(),
- - newDsName, info.info.getDocStoreIsCompoundFile(), info.info.getNormGen(), info.info.getUseCompoundFile(),
- + SegmentInfo newInfo = new SegmentInfo(directory, info.info.getVersion(), segName, info.info.docCount,
- + info.info.getNormGen(), info.info.getUseCompoundFile(),
- info.info.getCodec(), info.info.getDiagnostics(), info.info.attributes());
- SegmentInfoPerCommit newInfoPerCommit = new SegmentInfoPerCommit(newInfo, info.getDelCount(), info.getDelGen());
- @@ -3316,7 +3321,7 @@
- // ConcurrentMergePolicy we keep deterministic segment
- // names.
- final String mergeSegmentName = newSegmentName();
- - SegmentInfo si = new SegmentInfo(directory, Constants.LUCENE_MAIN_VERSION, mergeSegmentName, 0, -1, mergeSegmentName, false, null, false, codec, details, null);
- + SegmentInfo si = new SegmentInfo(directory, Constants.LUCENE_MAIN_VERSION, mergeSegmentName, 0, null, false, codec, details, null);
- merge.info = new SegmentInfoPerCommit(si, 0, -1L);
- // Lock order: IW -> BD
- @@ -4006,7 +4011,8 @@
- if (infoStream.isEnabled("IW")) {
- infoStream.message("IW", "create compound file " + fileName);
- }
- - assert info.getDocStoreOffset() == -1;
- + String docStoreOffset = info.getAttribute(Lucene3xSegmentInfoFormat.DOCSTOREOFFSET_KEY);
- + assert docStoreOffset == null || "-1".equals(docStoreOffset);
- // Now merge all added files
- Collection<String> files = info.files();
- CompoundFileDirectory cfsDir = new CompoundFileDirectory(directory, fileName, context, true);
- Index: lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/index/CheckIndex.java (revision 1341584)
- +++ lucene/core/src/java/org/apache/lucene/index/CheckIndex.java (working copy)
- @@ -489,15 +489,8 @@
- msg(" diagnostics = " + diagnostics);
- }
- - final int docStoreOffset = info.info.getDocStoreOffset();
- - if (docStoreOffset != -1) {
- - msg(" docStoreOffset=" + docStoreOffset);
- - segInfoStat.docStoreOffset = docStoreOffset;
- - msg(" docStoreSegment=" + info.info.getDocStoreSegment());
- - segInfoStat.docStoreSegment = info.info.getDocStoreSegment();
- - msg(" docStoreIsCompoundFile=" + info.info.getDocStoreIsCompoundFile());
- - segInfoStat.docStoreCompoundFile = info.info.getDocStoreIsCompoundFile();
- - }
- + // TODO: we could just dump the attributes here?
- + // then you would see info on any shared doc stores or anything like that
- if (info.hasDeletions()) {
- msg(" no deletions");
- Index: lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java (revision 1341590)
- +++ lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java (working copy)
- @@ -62,15 +62,6 @@
- private volatile long sizeInBytes = -1; // total byte size of all files (computed on demand)
- - //TODO: LUCENE-2555: remove once we don't need to support shared doc stores (pre 4.0)
- - private final int docStoreOffset; // if this segment shares stored fields & vectors, this
- - // offset is where in that file this segment's docs begin
- - //TODO: LUCENE-2555: remove once we don't need to support shared doc stores (pre 4.0)
- - private final String docStoreSegment; // name used to derive fields/vectors file we share with
- - // other segments
- - //TODO: LUCENE-2555: remove once we don't need to support shared doc stores (pre 4.0)
- - private final boolean docStoreIsCompoundFile; // whether doc store files are stored in compound file (*.cfx)
- -
- private Codec codec;
- private Map<String,String> diagnostics;
- @@ -98,17 +89,14 @@
- * <p>Note: this is public only to allow access from
- * the codecs package.</p>
- */
- - public SegmentInfo(Directory dir, String version, String name, int docCount, int docStoreOffset,
- - String docStoreSegment, boolean docStoreIsCompoundFile, Map<Integer,Long> normGen, boolean isCompoundFile,
- + public SegmentInfo(Directory dir, String version, String name, int docCount,
- + Map<Integer,Long> normGen, boolean isCompoundFile,
- Codec codec, Map<String,String> diagnostics, Map<String,String> attributes) {
- assert !(dir instanceof TrackingDirectoryWrapper);
- this.dir = dir;
- this.version = version;
- this.name = name;
- this.docCount = docCount;
- - this.docStoreOffset = docStoreOffset;
- - this.docStoreSegment = docStoreSegment;
- - this.docStoreIsCompoundFile = docStoreIsCompoundFile;
- this.normGen = normGen;
- this.isCompoundFile = isCompoundFile;
- this.codec = codec;
- @@ -171,33 +159,6 @@
- return isCompoundFile;
- }
- - /**
- - * @deprecated shared doc stores are not supported in >= 4.0
- - */
- - @Deprecated
- - public int getDocStoreOffset() {
- - // TODO: LUCENE-2555: remove once we don't need to support shared doc stores (pre 4.0)
- - return docStoreOffset;
- - }
- -
- - /**
- - * @deprecated shared doc stores are not supported in >= 4.0
- - */
- - @Deprecated
- - public boolean getDocStoreIsCompoundFile() {
- - // TODO: LUCENE-2555: remove once we don't need to support shared doc stores (pre 4.0)
- - return docStoreIsCompoundFile;
- - }
- -
- - /**
- - * @deprecated shared doc stores are not supported in >= 4.0
- - */
- - @Deprecated
- - public String getDocStoreSegment() {
- - // TODO: LUCENE-2555: remove once we don't need to support shared doc stores (pre 4.0)
- - return docStoreSegment;
- - }
- -
- /** Can only be called once. */
- public void setCodec(Codec codec) {
- assert this.codec == null;
- @@ -237,14 +198,12 @@
- /** Used for debugging. Format may suddenly change.
- *
- * <p>Current format looks like
- - * <code>_a(3.1):c45/4->_1</code>, which means the segment's
- + * <code>_a(3.1):c45/4</code>, which means the segment's
- * name is <code>_a</code>; it was created with Lucene 3.1 (or
- * '?' if it's unknown); it's using compound file
- * format (would be <code>C</code> if not compound); it
- * has 45 documents; it has 4 deletions (this part is
- - * left off when there are no deletions); it's using the
- - * shared doc stores named <code>_1</code> (this part is
- - * left off if doc stores are private).</p>
- + * left off when there are no deletions);</p>
- */
- public String toString(Directory dir, int delCount) {
- @@ -261,17 +220,10 @@
- if (delCount != 0) {
- s.append('/').append(delCount);
- }
- +
- + // TODO: we could add attributes.toString() here? might be nice if its only for debugging?
- + // then you could see the shared doc stores etc again... (or whatever else). could be verbose though
- - if (docStoreOffset != -1) {
- - s.append("->").append(docStoreSegment);
- - if (docStoreIsCompoundFile) {
- - s.append('c');
- - } else {
- - s.append('C');
- - }
- - s.append('+').append(docStoreOffset);
- - }
- -
- return s.toString();
- }
- Index: lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xTermVectorsFormat.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xTermVectorsFormat.java (revision 1341584)
- +++ lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xTermVectorsFormat.java (working copy)
- @@ -41,7 +41,10 @@
- @Override
- public TermVectorsReader vectorsReader(Directory directory, SegmentInfo segmentInfo, FieldInfos fieldInfos, IOContext context) throws IOException {
- - final String fileName = IndexFileNames.segmentFileName(segmentInfo.getDocStoreSegment(), "", Lucene3xTermVectorsReader.VECTORS_FIELDS_EXTENSION);
- + final String segment = segmentInfo.getAttribute(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY);
- + final int docStoreOffset = Integer.parseInt(segmentInfo.getAttribute(Lucene3xSegmentInfoFormat.DOCSTOREOFFSET_KEY));
- + final boolean docStoreIsCompoundFile = Boolean.parseBoolean(segmentInfo.getAttribute(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY));
- + final String fileName = IndexFileNames.segmentFileName(segment, "", Lucene3xTermVectorsReader.VECTORS_FIELDS_EXTENSION);
- // Unfortunately, for 3.x indices, each segment's
- // FieldInfos can lie about hasVectors (claim it's true
- @@ -49,8 +52,8 @@
- // check if the files really exist before trying to open
- // them (4.x has fixed this):
- final boolean exists;
- - if (segmentInfo.getDocStoreOffset() != -1 && segmentInfo.getDocStoreIsCompoundFile()) {
- - String cfxFileName = IndexFileNames.segmentFileName(segmentInfo.getDocStoreSegment(), "", Lucene3xCodec.COMPOUND_FILE_STORE_EXTENSION);
- + if (docStoreOffset != -1 && docStoreIsCompoundFile) {
- + String cfxFileName = IndexFileNames.segmentFileName(segment, "", Lucene3xCodec.COMPOUND_FILE_STORE_EXTENSION);
- if (segmentInfo.dir.fileExists(cfxFileName)) {
- Directory cfsDir = new CompoundFileDirectory(segmentInfo.dir, cfxFileName, context, false);
- try {
- Index: lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfoFormat.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfoFormat.java (revision 1341584)
- +++ lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfoFormat.java (working copy)
- @@ -17,13 +17,9 @@
- * limitations under the License.
- */
- -import java.util.Set;
- -
- 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 SegmentInfoFormat implementation
- @@ -53,6 +49,10 @@
- * index is first committed to with 4.0. */
- public static final String SI_EXTENSION = "si";
- + public static final String DOCSTOREOFFSET_KEY = Lucene3xSegmentInfoFormat.class.getSimpleName() + ".dsoffset";
- + public static final String DOCSTORESEGMENT_KEY = Lucene3xSegmentInfoFormat.class.getSimpleName() + ".dsname";
- + public static final String DOCSTOREISCOMPOUND_KEY = Lucene3xSegmentInfoFormat.class.getSimpleName() + ".dscompound";
- +
- @Override
- public SegmentInfoReader getSegmentInfosReader() {
- return reader;
- Index: lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xTermVectorsReader.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xTermVectorsReader.java (revision 1341584)
- +++ lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xTermVectorsReader.java (working copy)
- @@ -114,14 +114,15 @@
- public Lucene3xTermVectorsReader(Directory d, SegmentInfo si, FieldInfos fieldInfos, IOContext context)
- throws CorruptIndexException, IOException {
- - final String segment = si.getDocStoreSegment();
- - final int docStoreOffset = si.getDocStoreOffset();
- + final String segment = si.getAttribute(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY);
- + final int docStoreOffset = Integer.parseInt(si.getAttribute(Lucene3xSegmentInfoFormat.DOCSTOREOFFSET_KEY));
- + final boolean docStoreIsCompoundFile = Boolean.parseBoolean(si.getAttribute(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY));
- final int size = si.docCount;
- boolean success = false;
- try {
- - if (docStoreOffset != -1 && si.getDocStoreIsCompoundFile()) {
- + if (docStoreOffset != -1 && docStoreIsCompoundFile) {
- d = storeCFSReader = new CompoundFileDirectory(si.dir,
- IndexFileNames.segmentFileName(segment, "", Lucene3xCodec.COMPOUND_FILE_STORE_EXTENSION), context, false);
- } else {
- Index: lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfoReader.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfoReader.java (revision 1341590)
- +++ lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xSegmentInfoReader.java (working copy)
- @@ -59,10 +59,13 @@
- // 2.x segment, and an IndexFormatTooOldException will be thrown,
- // which is what we want.
- Directory dir = directory;
- - if (si.getDocStoreOffset() != -1) {
- - if (si.getDocStoreIsCompoundFile()) {
- + final int docStoreOffset = Integer.parseInt(si.getAttribute(Lucene3xSegmentInfoFormat.DOCSTOREOFFSET_KEY));
- + final String docStoreSegment = si.getAttribute(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY);
- + final boolean docStoreIsCompoundFile = Boolean.parseBoolean(si.getAttribute(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY));
- + if (docStoreOffset != -1) {
- + if (docStoreIsCompoundFile) {
- dir = new CompoundFileDirectory(dir, IndexFileNames.segmentFileName(
- - si.getDocStoreSegment(), "",
- + docStoreSegment, "",
- Lucene3xCodec.COMPOUND_FILE_STORE_EXTENSION), IOContext.READONCE, false);
- }
- } else if (si.getUseCompoundFile()) {
- @@ -71,7 +74,7 @@
- }
- try {
- - Lucene3xStoredFieldsReader.checkCodeVersion(dir, si.getDocStoreSegment());
- + Lucene3xStoredFieldsReader.checkCodeVersion(dir, si.getAttribute(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY));
- } finally {
- // If we opened the directory, close it
- if (dir != directory) dir.close();
- @@ -152,15 +155,31 @@
- final int docCount = input.readInt();
- final long delGen = input.readLong();
- - final int docStoreOffset = input.readInt();
- +
- + final Map<String,String> attributes;
- + final int docStoreOffset;
- final String docStoreSegment;
- final boolean docStoreIsCompoundFile;
- - if (docStoreOffset != -1) {
- - docStoreSegment = input.readString();
- - docStoreIsCompoundFile = input.readByte() == SegmentInfo.YES;
- + if (format == Lucene3xSegmentInfoFormat.FORMAT_4X_UPGRADE) {
- + // if we have an upgraded format, we write this as codec attributes
- + attributes = input.readStringStringMap();
- + docStoreOffset = Integer.parseInt(attributes.get(Lucene3xSegmentInfoFormat.DOCSTOREOFFSET_KEY));
- + docStoreSegment = attributes.get(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY);
- + docStoreIsCompoundFile = Boolean.parseBoolean(attributes.get(Lucene3xSegmentInfoFormat.DOCSTOREISCOMPOUND_KEY));
- } else {
- - docStoreSegment = name;
- - docStoreIsCompoundFile = false;
- + docStoreOffset = input.readInt();
- + if (docStoreOffset != -1) {
- + docStoreSegment = input.readString();
- + docStoreIsCompoundFile = input.readByte() == SegmentInfo.YES;
- + } else {
- + docStoreSegment = name;
- + docStoreIsCompoundFile = false;
- + }
- + // now put the attributes, to be accessible
- + attributes = new HashMap<String,String>();
- + attributes.put(Lucene3xSegmentInfoFormat.DOCSTOREOFFSET_KEY, Integer.toString(docStoreOffset));
- + attributes.put(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY, docStoreSegment);
- + attributes.put(Lucene3xSegmentInfoFormat.DOCSTOREISCOMPOUND_KEY, Boolean.toString(docStoreIsCompoundFile));
- }
- // pre-4.0 indexes write a byte if there is a single norms file
- @@ -244,10 +263,9 @@
- }
- }
- - // nocommit: convert 3.x specific stuff (shared docstores, normgen, etc) into attributes
- - SegmentInfo info = new SegmentInfo(dir, version, segmentName, docCount, docStoreOffset,
- - docStoreSegment, docStoreIsCompoundFile, normGen, isCompoundFile,
- - null, diagnostics, null);
- + // nocommit: convert 3.x normgen into attributes
- + SegmentInfo info = new SegmentInfo(dir, version, segmentName, docCount, normGen, isCompoundFile,
- + null, diagnostics, attributes);
- info.setFiles(files);
- SegmentInfoPerCommit infoPerCommit = new SegmentInfoPerCommit(info, delCount, delGen);
- Index: lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xStoredFieldsReader.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xStoredFieldsReader.java (revision 1341584)
- +++ lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xStoredFieldsReader.java (working copy)
- @@ -139,13 +139,14 @@
- }
- public Lucene3xStoredFieldsReader(Directory d, SegmentInfo si, FieldInfos fn, IOContext context) throws IOException {
- - final String segment = si.getDocStoreSegment();
- - final int docStoreOffset = si.getDocStoreOffset();
- + final String segment = si.getAttribute(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY);
- + final int docStoreOffset = Integer.parseInt(si.getAttribute(Lucene3xSegmentInfoFormat.DOCSTOREOFFSET_KEY));
- + final boolean docStoreIsCompoundFile = Boolean.parseBoolean(si.getAttribute(Lucene3xSegmentInfoFormat.DOCSTORESEGMENT_KEY));
- final int size = si.docCount;
- boolean success = false;
- fieldInfos = fn;
- try {
- - if (docStoreOffset != -1 && si.getDocStoreIsCompoundFile()) {
- + if (docStoreOffset != -1 && docStoreIsCompoundFile) {
- d = storeCFSReader = new CompoundFileDirectory(si.dir,
- IndexFileNames.segmentFileName(segment, "", Lucene3xCodec.COMPOUND_FILE_STORE_EXTENSION), context, false);
- } else {
- Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoReader.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoReader.java (revision 1341590)
- +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoReader.java (working copy)
- @@ -45,17 +45,13 @@
- try {
- final String version = input.readString();
- final int docCount = input.readInt();
- - final int docStoreOffset = -1;
- - final String docStoreSegment = segment;
- - final boolean docStoreIsCompoundFile = false;
- final Map<Integer,Long> normGen = null;
- final boolean isCompoundFile = input.readByte() == SegmentInfo.YES;
- final Map<String,String> diagnostics = input.readStringStringMap();
- final Map<String,String> attributes = input.readStringStringMap();
- final Set<String> files = input.readStringSet();
- - final SegmentInfo si = new SegmentInfo(dir, version, segment, docCount, docStoreOffset,
- - docStoreSegment, docStoreIsCompoundFile, normGen, isCompoundFile,
- + final SegmentInfo si = new SegmentInfo(dir, version, segment, docCount, normGen, isCompoundFile,
- null, diagnostics, attributes);
- si.setFiles(files);
- Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.java (revision 1341590)
- +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.java (working copy)
- @@ -51,7 +51,6 @@
- output.writeString(si.getVersion());
- output.writeInt(si.docCount);
- - assert si.getDocStoreOffset() == -1;
- assert si.getNormGen() == null;
- output.writeByte((byte) (si.getUseCompoundFile() ? SegmentInfo.YES : SegmentInfo.NO));
- Index: lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosReader.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosReader.java (revision 1341590)
- +++ lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfosReader.java (working copy)
- @@ -113,9 +113,8 @@
- files.add(fileName);
- }
- - SegmentInfo info = new SegmentInfo(directory, version, segmentName, docCount, -1,
- - segmentName, false, null, isCompoundFile,
- - null, diagnostics, attributes);
- + SegmentInfo info = new SegmentInfo(directory, version, segmentName, docCount,
- + null, isCompoundFile, null, diagnostics, attributes);
- info.setFiles(files);
- success = true;
- return info;
Add Comment
Please, Sign In to add comment