mirror of https://github.com/apache/lucene.git
LUCENE-4055: add codecHeader
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4055@1342223 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d00b63db82
commit
89aba400df
|
@ -29,12 +29,13 @@ import org.apache.lucene.store.DataOutput; // javadocs
|
||||||
* <p>
|
* <p>
|
||||||
* Files:
|
* Files:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li><tt>.si</tt>: SegVersion, SegSize, IsCompoundFile, Diagnostics, Attributes, Files
|
* <li><tt>.si</tt>: Header, SegVersion, SegSize, IsCompoundFile, Diagnostics, Attributes, Files
|
||||||
* </ul>
|
* </ul>
|
||||||
* </p>
|
* </p>
|
||||||
* Data types:
|
* Data types:
|
||||||
* <p>
|
* <p>
|
||||||
* <ul>
|
* <ul>
|
||||||
|
* <li>Header --> {@link CodecUtil#writeHeader CodecHeader}</li>
|
||||||
* <li>SegSize --> {@link DataOutput#writeInt Int32}</li>
|
* <li>SegSize --> {@link DataOutput#writeInt Int32}</li>
|
||||||
* <li>SegVersion --> {@link DataOutput#writeString String}</li>
|
* <li>SegVersion --> {@link DataOutput#writeString String}</li>
|
||||||
* <li>Files --> {@link DataOutput#writeStringSet Set<String>}</li>
|
* <li>Files --> {@link DataOutput#writeStringSet Set<String>}</li>
|
||||||
|
@ -80,4 +81,7 @@ public class Lucene40SegmentInfoFormat extends SegmentInfoFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static String SI_EXTENSION = "si";
|
public final static String SI_EXTENSION = "si";
|
||||||
|
static final String CODEC_NAME = "Lucene40SegmentInfo";
|
||||||
|
static final int VERSION_START = 0;
|
||||||
|
static final int VERSION_CURRENT = VERSION_START;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.lucene.index.SegmentInfo;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.IOContext;
|
import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.store.IndexInput;
|
import org.apache.lucene.store.IndexInput;
|
||||||
|
import org.apache.lucene.util.CodecUtil;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,6 +45,9 @@ public class Lucene40SegmentInfoReader extends SegmentInfoReader {
|
||||||
final IndexInput input = dir.openInput(fileName, context);
|
final IndexInput input = dir.openInput(fileName, context);
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
|
CodecUtil.checkHeader(input, Lucene40SegmentInfoFormat.CODEC_NAME,
|
||||||
|
Lucene40SegmentInfoFormat.VERSION_START,
|
||||||
|
Lucene40SegmentInfoFormat.VERSION_CURRENT);
|
||||||
final String version = input.readString();
|
final String version = input.readString();
|
||||||
final int docCount = input.readInt();
|
final int docCount = input.readInt();
|
||||||
final Map<Integer,Long> normGen = null;
|
final Map<Integer,Long> normGen = null;
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.lucene.index.SegmentInfo;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.IOContext;
|
import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.store.IndexOutput;
|
import org.apache.lucene.store.IndexOutput;
|
||||||
|
import org.apache.lucene.util.CodecUtil;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +47,7 @@ public class Lucene40SegmentInfoWriter extends SegmentInfoWriter {
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
|
CodecUtil.writeHeader(output, Lucene40SegmentInfoFormat.CODEC_NAME, Lucene40SegmentInfoFormat.VERSION_CURRENT);
|
||||||
// Write the Lucene version that created this segment, since 3.1
|
// Write the Lucene version that created this segment, since 3.1
|
||||||
output.writeString(si.getVersion());
|
output.writeString(si.getVersion());
|
||||||
output.writeInt(si.getDocCount());
|
output.writeInt(si.getDocCount());
|
||||||
|
|
Loading…
Reference in New Issue