From 3be9e4b90a2f71ee1dae5009fd584c1cfe565f3e Mon Sep 17 00:00:00 2001 From: Robert Muir <rmuir@apache.org> Date: Mon, 23 May 2011 16:36:22 +0000 Subject: [PATCH] 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 --- lucene/src/java/org/apache/lucene/index/NormsWriter.java | 2 +- lucene/src/java/org/apache/lucene/index/SegmentMerger.java | 6 +----- lucene/src/java/org/apache/lucene/index/SegmentNorms.java | 6 +++++- lucene/src/java/org/apache/lucene/index/SegmentReader.java | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lucene/src/java/org/apache/lucene/index/NormsWriter.java b/lucene/src/java/org/apache/lucene/index/NormsWriter.java index 5064a47f3bc..05c1d063e7b 100644 --- a/lucene/src/java/org/apache/lucene/index/NormsWriter.java +++ b/lucene/src/java/org/apache/lucene/index/NormsWriter.java @@ -51,7 +51,7 @@ final class NormsWriter extends InvertedDocEndConsumer { IndexOutput normsOut = state.directory.createOutput(normsFileName); try { - normsOut.writeBytes(SegmentMerger.NORMS_HEADER, 0, SegmentMerger.NORMS_HEADER.length); + normsOut.writeBytes(SegmentNorms.NORMS_HEADER, 0, SegmentNorms.NORMS_HEADER.length); int normCount = 0; diff --git a/lucene/src/java/org/apache/lucene/index/SegmentMerger.java b/lucene/src/java/org/apache/lucene/index/SegmentMerger.java index 394f3cc501e..701e168a701 100644 --- a/lucene/src/java/org/apache/lucene/index/SegmentMerger.java +++ b/lucene/src/java/org/apache/lucene/index/SegmentMerger.java @@ -46,10 +46,6 @@ import org.apache.lucene.util.ReaderUtil; * @see #add */ final class SegmentMerger { - - /** norms header placeholder */ - static final byte[] NORMS_HEADER = new byte[]{'N','R','M',-1}; - private Directory directory; private String segment; private int termIndexInterval = IndexWriterConfig.DEFAULT_TERM_INDEX_INTERVAL; @@ -578,7 +574,7 @@ final class SegmentMerger { if (fi.isIndexed && !fi.omitNorms) { if (output == null) { 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) { final int maxDoc = reader.maxDoc(); diff --git a/lucene/src/java/org/apache/lucene/index/SegmentNorms.java b/lucene/src/java/org/apache/lucene/index/SegmentNorms.java index 64f282291d3..df8bf9a7d31 100644 --- a/lucene/src/java/org/apache/lucene/index/SegmentNorms.java +++ b/lucene/src/java/org/apache/lucene/index/SegmentNorms.java @@ -33,6 +33,10 @@ import org.apache.lucene.store.IndexOutput; */ final class SegmentNorms implements Cloneable { + + /** norms header placeholder */ + static final byte[] NORMS_HEADER = new byte[]{'N','R','M',-1}; + int refCount = 1; // If this instance is a clone, the originalNorm @@ -219,7 +223,7 @@ final class SegmentNorms implements Cloneable { boolean success = false; 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()); } finally { out.close(); diff --git a/lucene/src/java/org/apache/lucene/index/SegmentReader.java b/lucene/src/java/org/apache/lucene/index/SegmentReader.java index 47d4cc62c66..0e674311384 100644 --- a/lucene/src/java/org/apache/lucene/index/SegmentReader.java +++ b/lucene/src/java/org/apache/lucene/index/SegmentReader.java @@ -574,7 +574,7 @@ public class SegmentReader extends IndexReader implements Cloneable { } 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(); for (FieldInfo fi : core.fieldInfos) { if (norms.containsKey(fi.name)) { @@ -619,7 +619,7 @@ public class SegmentReader extends IndexReader implements Cloneable { if (isUnversioned) { normSeek = 0; } else { - normSeek = SegmentMerger.NORMS_HEADER.length; + normSeek = SegmentNorms.NORMS_HEADER.length; } }