mirror of https://github.com/apache/lucene.git
LUCENE-3117: move norms version constant out of SegmentMerger
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1126573 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4666e84ee1
commit
3be9e4b90a
|
@ -51,7 +51,7 @@ final class NormsWriter extends InvertedDocEndConsumer {
|
||||||
IndexOutput normsOut = state.directory.createOutput(normsFileName);
|
IndexOutput normsOut = state.directory.createOutput(normsFileName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
normsOut.writeBytes(SegmentMerger.NORMS_HEADER, 0, SegmentMerger.NORMS_HEADER.length);
|
normsOut.writeBytes(SegmentNorms.NORMS_HEADER, 0, SegmentNorms.NORMS_HEADER.length);
|
||||||
|
|
||||||
int normCount = 0;
|
int normCount = 0;
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,6 @@ import org.apache.lucene.util.ReaderUtil;
|
||||||
* @see #add
|
* @see #add
|
||||||
*/
|
*/
|
||||||
final class SegmentMerger {
|
final class SegmentMerger {
|
||||||
|
|
||||||
/** norms header placeholder */
|
|
||||||
static final byte[] NORMS_HEADER = new byte[]{'N','R','M',-1};
|
|
||||||
|
|
||||||
private Directory directory;
|
private Directory directory;
|
||||||
private String segment;
|
private String segment;
|
||||||
private int termIndexInterval = IndexWriterConfig.DEFAULT_TERM_INDEX_INTERVAL;
|
private int termIndexInterval = IndexWriterConfig.DEFAULT_TERM_INDEX_INTERVAL;
|
||||||
|
@ -578,7 +574,7 @@ final class SegmentMerger {
|
||||||
if (fi.isIndexed && !fi.omitNorms) {
|
if (fi.isIndexed && !fi.omitNorms) {
|
||||||
if (output == null) {
|
if (output == null) {
|
||||||
output = directory.createOutput(IndexFileNames.segmentFileName(segment, "", IndexFileNames.NORMS_EXTENSION));
|
output = directory.createOutput(IndexFileNames.segmentFileName(segment, "", IndexFileNames.NORMS_EXTENSION));
|
||||||
output.writeBytes(NORMS_HEADER,NORMS_HEADER.length);
|
output.writeBytes(SegmentNorms.NORMS_HEADER, SegmentNorms.NORMS_HEADER.length);
|
||||||
}
|
}
|
||||||
for (IndexReader reader : readers) {
|
for (IndexReader reader : readers) {
|
||||||
final int maxDoc = reader.maxDoc();
|
final int maxDoc = reader.maxDoc();
|
||||||
|
|
|
@ -33,6 +33,10 @@ import org.apache.lucene.store.IndexOutput;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
final class SegmentNorms implements Cloneable {
|
final class SegmentNorms implements Cloneable {
|
||||||
|
|
||||||
|
/** norms header placeholder */
|
||||||
|
static final byte[] NORMS_HEADER = new byte[]{'N','R','M',-1};
|
||||||
|
|
||||||
int refCount = 1;
|
int refCount = 1;
|
||||||
|
|
||||||
// If this instance is a clone, the originalNorm
|
// If this instance is a clone, the originalNorm
|
||||||
|
@ -219,7 +223,7 @@ final class SegmentNorms implements Cloneable {
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
out.writeBytes(SegmentMerger.NORMS_HEADER, 0, SegmentMerger.NORMS_HEADER.length);
|
out.writeBytes(SegmentNorms.NORMS_HEADER, 0, SegmentNorms.NORMS_HEADER.length);
|
||||||
out.writeBytes(bytes, owner.maxDoc());
|
out.writeBytes(bytes, owner.maxDoc());
|
||||||
} finally {
|
} finally {
|
||||||
out.close();
|
out.close();
|
||||||
|
|
|
@ -574,7 +574,7 @@ public class SegmentReader extends IndexReader implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openNorms(Directory cfsDir, int readBufferSize) throws IOException {
|
private void openNorms(Directory cfsDir, int readBufferSize) throws IOException {
|
||||||
long nextNormSeek = SegmentMerger.NORMS_HEADER.length; //skip header (header unused for now)
|
long nextNormSeek = SegmentNorms.NORMS_HEADER.length; //skip header (header unused for now)
|
||||||
int maxDoc = maxDoc();
|
int maxDoc = maxDoc();
|
||||||
for (FieldInfo fi : core.fieldInfos) {
|
for (FieldInfo fi : core.fieldInfos) {
|
||||||
if (norms.containsKey(fi.name)) {
|
if (norms.containsKey(fi.name)) {
|
||||||
|
@ -619,7 +619,7 @@ public class SegmentReader extends IndexReader implements Cloneable {
|
||||||
if (isUnversioned) {
|
if (isUnversioned) {
|
||||||
normSeek = 0;
|
normSeek = 0;
|
||||||
} else {
|
} else {
|
||||||
normSeek = SegmentMerger.NORMS_HEADER.length;
|
normSeek = SegmentNorms.NORMS_HEADER.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue