diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleDocValuesConsumer.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleDocValuesConsumer.java index 47164b42bd4..59619782550 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleDocValuesConsumer.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleDocValuesConsumer.java @@ -38,8 +38,12 @@ class Lucene41SimpleDocValuesConsumer extends SimpleDVConsumer { Lucene41SimpleDocValuesConsumer(SegmentWriteState state) throws IOException { String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "dvd"); data = state.directory.createOutput(dataName, state.context); + CodecUtil.writeHeader(data, Lucene41SimpleDocValuesFormat.DATA_CODEC, + Lucene41SimpleDocValuesFormat.VERSION_CURRENT); String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "dvm"); meta = state.directory.createOutput(metaName, state.context); + CodecUtil.writeHeader(meta, Lucene41SimpleDocValuesFormat.METADATA_CODEC, + Lucene41SimpleDocValuesFormat.VERSION_CURRENT); maxDoc = state.segmentInfo.getDocCount(); } diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleDocValuesFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleDocValuesFormat.java index 37dce4905f6..5dd3f987a30 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleDocValuesFormat.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleDocValuesFormat.java @@ -52,4 +52,9 @@ public class Lucene41SimpleDocValuesFormat extends SimpleDocValuesFormat { public SimpleDVProducer fieldsProducer(SegmentReadState state) throws IOException { return new Lucene41SimpleDocValuesProducer(state); } + + static final String DATA_CODEC = "Lucene41DocValuesData"; + static final String METADATA_CODEC = "Lucene41DocValuesMetadata"; + static final int VERSION_START = 0; + static final int VERSION_CURRENT = VERSION_START; } diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleDocValuesProducer.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleDocValuesProducer.java index c94394a209e..9caeb08a9dc 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleDocValuesProducer.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleDocValuesProducer.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.SimpleDVProducer; import org.apache.lucene.index.BinaryDocValues; import org.apache.lucene.index.CorruptIndexException; @@ -48,6 +49,9 @@ class Lucene41SimpleDocValuesProducer extends SimpleDVProducer { IndexInput in = state.directory.openInput(metaName, state.context); boolean success = false; try { + CodecUtil.checkHeader(in, Lucene41SimpleDocValuesFormat.METADATA_CODEC, + Lucene41SimpleDocValuesFormat.VERSION_START, + Lucene41SimpleDocValuesFormat.VERSION_START); numerics = new HashMap(); ords = new HashMap(); binaries = new HashMap(); @@ -63,6 +67,9 @@ class Lucene41SimpleDocValuesProducer extends SimpleDVProducer { String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "dvd"); data = state.directory.openInput(dataName, state.context); + CodecUtil.checkHeader(data, Lucene41SimpleDocValuesFormat.DATA_CODEC, + Lucene41SimpleDocValuesFormat.VERSION_START, + Lucene41SimpleDocValuesFormat.VERSION_START); } private void readFields(IndexInput meta, FieldInfos infos) throws IOException { diff --git a/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java index 80ae3557863..d8ef32103ce 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java @@ -38,7 +38,6 @@ import org.junit.Ignore; /** * Test that a plain default puts codec headers in all files. */ -@Ignore("re-enable once Lucene41 doesn't secretly wrap SimpleText anymore") public class TestAllFilesHaveCodecHeader extends LuceneTestCase { public void test() throws Exception { Directory dir = newDirectory();