diagnostics) {
assert !(dir instanceof TrackingDirectoryWrapper);
this.dir = dir;
this.version = version;
@@ -94,7 +91,6 @@
this.isCompoundFile = isCompoundFile;
this.codec = codec;
this.diagnostics = diagnostics;
- this.attributes = attributes;
}
/**
@@ -259,40 +255,4 @@
}
}
- /**
- * Get a codec attribute value, or null if it does not exist
- */
- public String getAttribute(String key) {
- if (attributes == null) {
- return null;
- } else {
- return attributes.get(key);
- }
- }
-
- /**
- * Puts a codec attribute value.
- *
- * This is a key-value mapping for the field that the codec can use
- * to store additional metadata, and will be available to the codec
- * when reading the segment via {@link #getAttribute(String)}
- *
- * If a value already exists for the field, it will be replaced with
- * the new value.
- */
- public String putAttribute(String key, String value) {
- if (attributes == null) {
- attributes = new HashMap();
- }
- return attributes.put(key, value);
- }
-
- /**
- * Returns the internal codec attributes map.
- *
- * @return internal codec attributes map. May be null if no mappings exist.
- */
- public Map attributes() {
- return attributes;
- }
}
Index: lucene/core/src/test/org/apache/lucene/index/TestCodecs.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestCodecs.java (revision 1527180)
+++ lucene/core/src/test/org/apache/lucene/index/TestCodecs.java (working copy)
@@ -254,7 +254,7 @@
final Directory dir = newDirectory();
this.write(fieldInfos, dir, fields);
Codec codec = Codec.getDefault();
- final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, false, codec, null, null);
+ final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, false, codec, null);
final FieldsProducer reader = codec.postingsFormat().fieldsProducer(new SegmentReadState(dir, si, fieldInfos, newIOContext(random())));
@@ -311,8 +311,7 @@
this.write(fieldInfos, dir, fields);
Codec codec = Codec.getDefault();
- final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000,
- false, codec, null, null);
+ final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, false, codec, null);
if (VERBOSE) {
System.out.println("TEST: now read postings");
@@ -850,7 +849,7 @@
private void write(final FieldInfos fieldInfos, final Directory dir, final FieldData[] fields) throws Throwable {
final Codec codec = Codec.getDefault();
- final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, false, codec, null, null);
+ final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, false, codec, null);
final SegmentWriteState state = new SegmentWriteState(InfoStream.getDefault(), dir, si, fieldInfos, null, newIOContext(random()));
Arrays.sort(fields);
Index: lucene/core/src/test/org/apache/lucene/index/TestDoc.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDoc.java (revision 1527180)
+++ lucene/core/src/test/org/apache/lucene/index/TestDoc.java (working copy)
@@ -217,7 +217,7 @@
final Codec codec = Codec.getDefault();
TrackingDirectoryWrapper trackingDir = new TrackingDirectoryWrapper(si1.info.dir);
- final SegmentInfo si = new SegmentInfo(si1.info.dir, Constants.LUCENE_MAIN_VERSION, merged, -1, false, codec, null, null);
+ final SegmentInfo si = new SegmentInfo(si1.info.dir, Constants.LUCENE_MAIN_VERSION, merged, -1, false, codec, null);
SegmentMerger merger = new SegmentMerger(Arrays.asList(r1, r2),
si, InfoStream.getDefault(), trackingDir,
@@ -228,7 +228,7 @@
r2.close();
final SegmentInfo info = new SegmentInfo(si1.info.dir, Constants.LUCENE_MAIN_VERSION, merged,
si1.info.getDocCount() + si2.info.getDocCount(),
- false, codec, null, null);
+ false, codec, null);
info.setFiles(new HashSet(trackingDir.getCreatedFiles()));
if (useCompoundFile) {
Index: lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java (revision 1527180)
+++ lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java (working copy)
@@ -78,7 +78,7 @@
public void testMerge() throws IOException {
final Codec codec = Codec.getDefault();
- final SegmentInfo si = new SegmentInfo(mergedDir, Constants.LUCENE_MAIN_VERSION, mergedSegment, -1, false, codec, null, null);
+ final SegmentInfo si = new SegmentInfo(mergedDir, Constants.LUCENE_MAIN_VERSION, mergedSegment, -1, false, codec, null);
SegmentMerger merger = new SegmentMerger(Arrays.asList(reader1, reader2),
si, InfoStream.getDefault(), mergedDir,
@@ -89,7 +89,7 @@
//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,
- false, codec, null, null),
+ false, codec, null),
0, -1L, -1L),
newIOContext(random()));
assertTrue(mergedReader != null);
Index: lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java
===================================================================
--- lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java (revision 1527180)
+++ lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java (working copy)
@@ -139,8 +139,7 @@
SegmentInfo info = infoPerCommit.info;
// Same info just changing the dir:
SegmentInfo newInfo = new SegmentInfo(destFSDir, info.getVersion(), info.name, info.getDocCount(),
- info.getUseCompoundFile(),
- info.getCodec(), info.getDiagnostics(), info.attributes());
+ info.getUseCompoundFile(), info.getCodec(), info.getDiagnostics());
destInfos.add(new SegmentInfoPerCommit(newInfo, infoPerCommit.getDelCount(), infoPerCommit.getDelGen(), infoPerCommit.getFieldInfosGen()));
// now copy files over
Collection files = infoPerCommit.files();
Index: lucene/test-framework/src/java/org/apache/lucene/codecs/lucene40/Lucene40RWCodec.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/codecs/lucene40/Lucene40RWCodec.java (revision 1527180)
+++ lucene/test-framework/src/java/org/apache/lucene/codecs/lucene40/Lucene40RWCodec.java (working copy)
@@ -6,6 +6,7 @@
import org.apache.lucene.codecs.FieldInfosFormat;
import org.apache.lucene.codecs.FieldInfosWriter;
import org.apache.lucene.codecs.NormsFormat;
+import org.apache.lucene.codecs.SegmentInfoFormat;
import org.apache.lucene.util.LuceneTestCase;
/*
@@ -40,6 +41,17 @@
}
};
+ private final SegmentInfoFormat infosFormat = new Lucene40SegmentInfoFormat() {
+ @Override
+ public org.apache.lucene.codecs.SegmentInfoWriter getSegmentInfoWriter() {
+ if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) {
+ return super.getSegmentInfoWriter();
+ } else {
+ return new Lucene40SegmentInfoWriter();
+ }
+ }
+ };
+
private final DocValuesFormat docValues = new Lucene40RWDocValuesFormat();
private final NormsFormat norms = new Lucene40RWNormsFormat();
@@ -57,4 +69,10 @@
public NormsFormat normsFormat() {
return norms;
}
+
+ @Override
+ public SegmentInfoFormat segmentInfoFormat() {
+ return infosFormat;
+ }
+
}
Index: lucene/test-framework/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.java (revision 0)
+++ lucene/test-framework/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.java (working copy)
@@ -0,0 +1,76 @@
+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.Collections;
+
+import org.apache.lucene.codecs.CodecUtil;
+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.store.Directory;
+import org.apache.lucene.store.IOContext;
+import org.apache.lucene.store.IndexOutput;
+import org.apache.lucene.util.IOUtils;
+
+/**
+ * Lucene 4.0 implementation of {@link SegmentInfoWriter}.
+ *
+ * @see Lucene40SegmentInfoFormat
+ * @lucene.experimental
+ */
+@Deprecated
+public class Lucene40SegmentInfoWriter extends SegmentInfoWriter {
+
+ /** Sole constructor. */
+ public Lucene40SegmentInfoWriter() {
+ }
+
+ /** Save a single segment's info. */
+ @Override
+ public void write(Directory dir, SegmentInfo si, FieldInfos fis, IOContext ioContext) throws IOException {
+ final String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene40SegmentInfoFormat.SI_EXTENSION);
+ si.addFile(fileName);
+
+ final IndexOutput output = dir.createOutput(fileName, ioContext);
+
+ boolean success = false;
+ try {
+ CodecUtil.writeHeader(output, Lucene40SegmentInfoFormat.CODEC_NAME, Lucene40SegmentInfoFormat.VERSION_CURRENT);
+ // Write the Lucene version that created this segment, since 3.1
+ output.writeString(si.getVersion());
+ output.writeInt(si.getDocCount());
+
+ output.writeByte((byte) (si.getUseCompoundFile() ? SegmentInfo.YES : SegmentInfo.NO));
+ output.writeStringStringMap(si.getDiagnostics());
+ output.writeStringStringMap(Collections.emptyMap());
+ output.writeStringSet(si.files());
+
+ success = true;
+ } finally {
+ if (!success) {
+ IOUtils.closeWhileHandlingException(output);
+ si.dir.deleteFile(fileName);
+ } else {
+ output.close();
+ }
+ }
+ }
+}
Property changes on: lucene/test-framework/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: lucene/test-framework/src/java/org/apache/lucene/codecs/lucene41/Lucene41RWCodec.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/codecs/lucene41/Lucene41RWCodec.java (revision 1527180)
+++ lucene/test-framework/src/java/org/apache/lucene/codecs/lucene41/Lucene41RWCodec.java (working copy)
@@ -6,11 +6,14 @@
import org.apache.lucene.codecs.FieldInfosFormat;
import org.apache.lucene.codecs.FieldInfosWriter;
import org.apache.lucene.codecs.NormsFormat;
+import org.apache.lucene.codecs.SegmentInfoFormat;
import org.apache.lucene.codecs.StoredFieldsFormat;
import org.apache.lucene.codecs.lucene40.Lucene40FieldInfosFormat;
import org.apache.lucene.codecs.lucene40.Lucene40FieldInfosWriter;
import org.apache.lucene.codecs.lucene40.Lucene40RWDocValuesFormat;
import org.apache.lucene.codecs.lucene40.Lucene40RWNormsFormat;
+import org.apache.lucene.codecs.lucene40.Lucene40SegmentInfoFormat;
+import org.apache.lucene.codecs.lucene40.Lucene40SegmentInfoWriter;
import org.apache.lucene.util.LuceneTestCase;
/*
@@ -50,6 +53,17 @@
private final DocValuesFormat docValues = new Lucene40RWDocValuesFormat();
private final NormsFormat norms = new Lucene40RWNormsFormat();
+ private final SegmentInfoFormat segmentInfosFormat = new Lucene40SegmentInfoFormat() {
+ @Override
+ public org.apache.lucene.codecs.SegmentInfoWriter getSegmentInfoWriter() {
+ if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) {
+ return super.getSegmentInfoWriter();
+ } else {
+ return new Lucene40SegmentInfoWriter();
+ }
+ }
+ };
+
@Override
public FieldInfosFormat fieldInfosFormat() {
return fieldInfos;
@@ -69,4 +83,10 @@
public NormsFormat normsFormat() {
return norms;
}
+
+ @Override
+ public SegmentInfoFormat segmentInfoFormat() {
+ return segmentInfosFormat;
+ }
+
}
Index: lucene/test-framework/src/java/org/apache/lucene/codecs/lucene42/Lucene42RWCodec.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/codecs/lucene42/Lucene42RWCodec.java (revision 1527180)
+++ lucene/test-framework/src/java/org/apache/lucene/codecs/lucene42/Lucene42RWCodec.java (working copy)
@@ -23,6 +23,9 @@
import org.apache.lucene.codecs.FieldInfosFormat;
import org.apache.lucene.codecs.FieldInfosWriter;
import org.apache.lucene.codecs.NormsFormat;
+import org.apache.lucene.codecs.SegmentInfoFormat;
+import org.apache.lucene.codecs.lucene40.Lucene40SegmentInfoFormat;
+import org.apache.lucene.codecs.lucene40.Lucene40SegmentInfoWriter;
import org.apache.lucene.util.LuceneTestCase;
/**
@@ -30,9 +33,32 @@
*/
@SuppressWarnings("deprecation")
public class Lucene42RWCodec extends Lucene42Codec {
+
private static final DocValuesFormat dv = new Lucene42RWDocValuesFormat();
private static final NormsFormat norms = new Lucene42NormsFormat();
+ private final FieldInfosFormat fieldInfosFormat = new Lucene42FieldInfosFormat() {
+ @Override
+ public FieldInfosWriter getFieldInfosWriter() throws IOException {
+ if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) {
+ return super.getFieldInfosWriter();
+ } else {
+ return new Lucene42FieldInfosWriter();
+ }
+ }
+ };
+
+ private final SegmentInfoFormat segmentInfosFormat = new Lucene40SegmentInfoFormat() {
+ @Override
+ public org.apache.lucene.codecs.SegmentInfoWriter getSegmentInfoWriter() {
+ if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) {
+ return super.getSegmentInfoWriter();
+ } else {
+ return new Lucene40SegmentInfoWriter();
+ }
+ }
+ };
+
@Override
public DocValuesFormat getDocValuesFormatForField(String field) {
return dv;
@@ -45,16 +71,12 @@
@Override
public FieldInfosFormat fieldInfosFormat() {
- return new Lucene42FieldInfosFormat() {
- @Override
- public FieldInfosWriter getFieldInfosWriter() throws IOException {
- if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) {
- return super.getFieldInfosWriter();
- } else {
- return new Lucene42FieldInfosWriter();
- }
- }
- };
+ return fieldInfosFormat;
}
+ @Override
+ public SegmentInfoFormat segmentInfoFormat() {
+ return segmentInfosFormat;
+ }
+
}
Index: lucene/test-framework/src/java/org/apache/lucene/codecs/lucene45/Lucene45RWCodec.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/codecs/lucene45/Lucene45RWCodec.java (revision 1527180)
+++ lucene/test-framework/src/java/org/apache/lucene/codecs/lucene45/Lucene45RWCodec.java (working copy)
@@ -21,6 +21,9 @@
import org.apache.lucene.codecs.FieldInfosFormat;
import org.apache.lucene.codecs.FieldInfosWriter;
+import org.apache.lucene.codecs.SegmentInfoFormat;
+import org.apache.lucene.codecs.lucene40.Lucene40SegmentInfoFormat;
+import org.apache.lucene.codecs.lucene40.Lucene40SegmentInfoWriter;
import org.apache.lucene.codecs.lucene42.Lucene42FieldInfosFormat;
import org.apache.lucene.codecs.lucene42.Lucene42FieldInfosWriter;
import org.apache.lucene.util.LuceneTestCase;
@@ -31,18 +34,36 @@
@SuppressWarnings("deprecation")
public class Lucene45RWCodec extends Lucene45Codec {
+ private final FieldInfosFormat fieldInfosFormat = new Lucene42FieldInfosFormat() {
+ @Override
+ public FieldInfosWriter getFieldInfosWriter() throws IOException {
+ if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) {
+ return super.getFieldInfosWriter();
+ } else {
+ return new Lucene42FieldInfosWriter();
+ }
+ }
+ };
+
+ private final SegmentInfoFormat segmentInfosFormat = new Lucene40SegmentInfoFormat() {
+ @Override
+ public org.apache.lucene.codecs.SegmentInfoWriter getSegmentInfoWriter() {
+ if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) {
+ return super.getSegmentInfoWriter();
+ } else {
+ return new Lucene40SegmentInfoWriter();
+ }
+ }
+ };
+
@Override
public FieldInfosFormat fieldInfosFormat() {
- return new Lucene42FieldInfosFormat() {
- @Override
- public FieldInfosWriter getFieldInfosWriter() throws IOException {
- if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) {
- return super.getFieldInfosWriter();
- } else {
- return new Lucene42FieldInfosWriter();
- }
- }
- };
+ return fieldInfosFormat;
}
-
+
+ @Override
+ public SegmentInfoFormat segmentInfoFormat() {
+ return segmentInfosFormat;
+ }
+
}
Index: lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java (revision 1527180)
+++ lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java (working copy)
@@ -651,7 +651,7 @@
// randomly index at lower IndexOption
private FieldsProducer buildIndex(Directory dir, IndexOptions maxAllowed, boolean allowPayloads, boolean alwaysTestMax) throws IOException {
Codec codec = getCodec();
- SegmentInfo segmentInfo = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, "_0", maxDoc, false, codec, null, null);
+ SegmentInfo segmentInfo = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, "_0", maxDoc, false, codec, null);
int maxIndexOption = Arrays.asList(IndexOptions.values()).indexOf(maxAllowed);
if (VERBOSE) {