Index: lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/BinaryDictionary.java =================================================================== --- lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/BinaryDictionary.java (revision 1352864) +++ lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/BinaryDictionary.java (working copy) @@ -26,9 +26,9 @@ import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.store.DataInput; import org.apache.lucene.store.InputStreamDataInput; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IntsRef; import org.apache.lucene.util.IOUtils; Index: lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/CharacterDefinition.java =================================================================== --- lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/CharacterDefinition.java (revision 1352864) +++ lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/CharacterDefinition.java (working copy) @@ -21,9 +21,9 @@ import java.io.IOException; import java.io.InputStream; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.store.DataInput; import org.apache.lucene.store.InputStreamDataInput; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; /** Index: lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/ConnectionCosts.java =================================================================== --- lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/ConnectionCosts.java (revision 1352864) +++ lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/ConnectionCosts.java (working copy) @@ -21,9 +21,9 @@ import java.io.IOException; import java.io.InputStream; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.store.DataInput; import org.apache.lucene.store.InputStreamDataInput; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; /** Index: lucene/CHANGES.txt =================================================================== --- lucene/CHANGES.txt (revision 1352864) +++ lucene/CHANGES.txt (working copy) @@ -283,6 +283,11 @@ removed, as IndexReaderContext.leaves() is now the preferred way to access sub-readers. (Uwe Schindler) +* LUCENE-4155: oal.util.ReaderUtil, TwoPhaseCommit, TwoPhaseCommitTool + classes were moved to oal.index package. oal.util.CodecUtil class was moved + to oal.codecs package. oal.util.DummyConcurrentLock was removed + (no longer used in Lucene 4.0). (Uwe Schindler) + Changes in Runtime Behavior * LUCENE-2846: omitNorms now behaves like omitTermFrequencyAndPositions, if you Index: lucene/core/src/java/org/apache/lucene/codecs/appending/AppendingTermsReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/appending/AppendingTermsReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/appending/AppendingTermsReader.java (working copy) @@ -20,12 +20,12 @@ import java.io.IOException; import org.apache.lucene.codecs.BlockTreeTermsReader; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.PostingsReaderBase; import org.apache.lucene.index.FieldInfos; import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; -import org.apache.lucene.util.CodecUtil; /** * Reads append-only terms from {@link AppendingTermsWriter} Index: lucene/core/src/java/org/apache/lucene/codecs/appending/AppendingTermsWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/appending/AppendingTermsWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/appending/AppendingTermsWriter.java (working copy) @@ -20,10 +20,10 @@ import java.io.IOException; import org.apache.lucene.codecs.BlockTreeTermsWriter; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.PostingsWriterBase; import org.apache.lucene.index.SegmentWriteState; import org.apache.lucene.store.IndexOutput; -import org.apache.lucene.util.CodecUtil; /** * Append-only version of {@link BlockTreeTermsWriter} Index: lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java (working copy) @@ -41,7 +41,6 @@ import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.DoubleBarrelLRUCache; /** Handles a terms dict, but decouples all details of Index: lucene/core/src/java/org/apache/lucene/codecs/BlockTermsWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/BlockTermsWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/BlockTermsWriter.java (working copy) @@ -31,7 +31,6 @@ import org.apache.lucene.store.RAMOutputStream; import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.RamUsageEstimator; Index: lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java (working copy) @@ -41,7 +41,6 @@ import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.RamUsageEstimator; import org.apache.lucene.util.StringHelper; Index: lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsWriter.java (working copy) @@ -31,7 +31,6 @@ import org.apache.lucene.store.RAMOutputStream; import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.IntsRef; import org.apache.lucene.util.fst.Builder; Index: lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java (revision 0) +++ lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java (working copy) @@ -0,0 +1,153 @@ +package org.apache.lucene.codecs; + +/* + * 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 org.apache.lucene.index.CorruptIndexException; +import org.apache.lucene.index.IndexFormatTooNewException; +import org.apache.lucene.index.IndexFormatTooOldException; +import org.apache.lucene.store.DataInput; +import org.apache.lucene.store.DataOutput; +import org.apache.lucene.util.BytesRef; + +/** + * Utility class for reading and writing versioned headers. + *

+ * Writing codec headers is useful to ensure that a file is in + * the format you think it is. + * + * @lucene.experimental + */ + +public final class CodecUtil { + private CodecUtil() {} // no instance + + /** + * Constant to identify the start of a codec header. + */ + public final static int CODEC_MAGIC = 0x3fd76c17; + + /** + * Writes a codec header, which records both a string to + * identify the file and a version number. This header can + * be parsed and validated with + * {@link #checkHeader(DataInput, String, int, int) checkHeader()}. + *

+ * CodecHeader --> Magic,CodecName,Version + *

+ *

+ * Note that the length of a codec header depends only upon the + * name of the codec, so this length can be computed at any time + * with {@link #headerLength(String)}. + * + * @param out Output stream + * @param codec String to identify this file. It should be simple ASCII, + * less than 128 characters in length. + * @param version Version number + * @throws IOException If there is an I/O error writing to the underlying medium. + */ + public static void writeHeader(DataOutput out, String codec, int version) + throws IOException { + BytesRef bytes = new BytesRef(codec); + if (bytes.length != codec.length() || bytes.length >= 128) { + throw new IllegalArgumentException("codec must be simple ASCII, less than 128 characters in length [got " + codec + "]"); + } + out.writeInt(CODEC_MAGIC); + out.writeString(codec); + out.writeInt(version); + } + + /** + * Computes the length of a codec header. + * + * @param codec Codec name. + * @return length of the entire codec header. + * @see #writeHeader(DataOutput, String, int) + */ + public static int headerLength(String codec) { + return 9+codec.length(); + } + + /** + * Reads and validates a header previously written with + * {@link #writeHeader(DataOutput, String, int)}. + *

+ * When reading a file, supply the expected codec and + * an expected version range (minVersion to maxVersion). + * + * @param in Input stream, positioned at the point where the + * header was previously written. Typically this is located + * at the beginning of the file. + * @param codec The expected codec name. + * @param minVersion The minimum supported expected version number. + * @param maxVersion The maximum supported expected version number. + * @return The actual version found, when a valid header is found + * that matches codec, with an actual version + * where minVersion <= actual <= maxVersion. + * Otherwise an exception is thrown. + * @throws CorruptIndexException If the first four bytes are not + * {@link #CODEC_MAGIC}, or if the actual codec found is + * not codec. + * @throws IndexFormatTooOldException If the actual version is less + * than minVersion. + * @throws IndexFormatTooNewException If the actual version is greater + * than maxVersion. + * @throws IOException If there is an I/O error reading from the underlying medium. + * @see #writeHeader(DataOutput, String, int) + */ + public static int checkHeader(DataInput in, String codec, int minVersion, int maxVersion) + throws IOException { + + // Safety to guard against reading a bogus string: + final int actualHeader = in.readInt(); + if (actualHeader != CODEC_MAGIC) { + throw new CorruptIndexException("codec header mismatch: actual header=" + actualHeader + " vs expected header=" + CODEC_MAGIC + " (resource: " + in + ")"); + } + return checkHeaderNoMagic(in, codec, minVersion, maxVersion); + } + + /** Like {@link + * #checkHeader(DataInput,String,int,int)} except this + * version assumes the first int has already been read + * and validated from the input. */ + public static int checkHeaderNoMagic(DataInput in, String codec, int minVersion, int maxVersion) throws IOException { + final String actualCodec = in.readString(); + if (!actualCodec.equals(codec)) { + throw new CorruptIndexException("codec mismatch: actual codec=" + actualCodec + " vs expected codec=" + codec + " (resource: " + in + ")"); + } + + final int actualVersion = in.readInt(); + if (actualVersion < minVersion) { + throw new IndexFormatTooOldException(in, actualVersion, minVersion, maxVersion); + } + if (actualVersion > maxVersion) { + throw new IndexFormatTooNewException(in, actualVersion, minVersion, maxVersion); + } + + return actualVersion; + } +} Index: lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java (revision 1352832) +++ lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java (working copy) Property changes on: lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: lucene/core/src/java/org/apache/lucene/codecs/FixedGapTermsIndexReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/FixedGapTermsIndexReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/FixedGapTermsIndexReader.java (working copy) @@ -23,7 +23,6 @@ import org.apache.lucene.index.FieldInfos; import org.apache.lucene.index.FieldInfo; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.PagedBytes; import org.apache.lucene.util.packed.PackedInts; Index: lucene/core/src/java/org/apache/lucene/codecs/FixedGapTermsIndexWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/FixedGapTermsIndexWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/FixedGapTermsIndexWriter.java (working copy) @@ -23,7 +23,6 @@ import org.apache.lucene.index.IndexFileNames; import org.apache.lucene.index.SegmentWriteState; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.packed.PackedInts; Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/BitVector.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/BitVector.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/BitVector.java (working copy) @@ -20,12 +20,12 @@ import java.io.IOException; import java.util.Arrays; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.store.CompoundFileDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexOutput; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.MutableBits; /** Optimized implementation of a vector of bits. This is more-or-less like Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40DocValuesFormat.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40DocValuesFormat.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40DocValuesFormat.java (working copy) @@ -19,6 +19,7 @@ import java.io.IOException; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.DocValuesFormat; import org.apache.lucene.codecs.PerDocConsumer; import org.apache.lucene.codecs.PerDocProducer; @@ -28,7 +29,6 @@ import org.apache.lucene.index.SegmentReadState; import org.apache.lucene.store.CompoundFileDirectory; // javadocs import org.apache.lucene.store.DataOutput; // javadocs -import org.apache.lucene.util.CodecUtil; // javadocs import org.apache.lucene.util.packed.PackedInts; // javadocs /** Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.java (working copy) @@ -19,13 +19,13 @@ import java.io.IOException; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.FieldInfosFormat; import org.apache.lucene.codecs.FieldInfosReader; import org.apache.lucene.codecs.FieldInfosWriter; import org.apache.lucene.index.DocValues; // javadoc import org.apache.lucene.index.DocValues.Type; // javadoc import org.apache.lucene.store.DataOutput; // javadoc -import org.apache.lucene.util.CodecUtil; // javadoc /** * Lucene 4.0 Field Infos format. Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java (working copy) @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.Map; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.FieldInfosReader; import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.index.FieldInfo; @@ -14,7 +15,6 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; -import org.apache.lucene.util.CodecUtil; /* * Licensed to the Apache Software Foundation (ASF) under one or more Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosWriter.java (working copy) @@ -18,6 +18,7 @@ */ import java.io.IOException; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.FieldInfosWriter; import org.apache.lucene.index.DocValues.Type; import org.apache.lucene.index.FieldInfo; @@ -27,7 +28,6 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexOutput; -import org.apache.lucene.util.CodecUtil; /** * Lucene 4.0 FieldInfos writer. Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.java (working copy) @@ -20,6 +20,7 @@ import java.io.IOException; import java.util.Collection; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.LiveDocsFormat; import org.apache.lucene.index.IndexFileNames; import org.apache.lucene.index.SegmentInfoPerCommit; @@ -27,7 +28,6 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.CodecUtil; // javadocs import org.apache.lucene.util.MutableBits; /** Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.java (working copy) @@ -21,6 +21,7 @@ import org.apache.lucene.codecs.BlockTreeTermsReader; import org.apache.lucene.codecs.BlockTreeTermsWriter; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.FieldsConsumer; import org.apache.lucene.codecs.FieldsProducer; import org.apache.lucene.codecs.PostingsFormat; @@ -32,7 +33,6 @@ import org.apache.lucene.index.SegmentReadState; import org.apache.lucene.index.SegmentWriteState; import org.apache.lucene.store.DataOutput; // javadocs -import org.apache.lucene.util.CodecUtil; // javadocs import org.apache.lucene.util.fst.FST; // javadocs /** Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java (working copy) @@ -20,6 +20,7 @@ import java.io.IOException; import org.apache.lucene.codecs.BlockTermState; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.PostingsReaderBase; import org.apache.lucene.index.DocsAndPositionsEnum; import org.apache.lucene.index.DocsEnum; @@ -36,7 +37,6 @@ import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; /** Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsWriter.java (working copy) @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.List; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.PostingsWriterBase; import org.apache.lucene.codecs.TermStats; import org.apache.lucene.index.CorruptIndexException; @@ -35,7 +36,6 @@ import org.apache.lucene.store.IndexOutput; import org.apache.lucene.store.RAMOutputStream; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; /** Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoFormat.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoFormat.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoFormat.java (working copy) @@ -17,13 +17,13 @@ * limitations under the License. */ +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.SegmentInfoFormat; import org.apache.lucene.codecs.SegmentInfoReader; import org.apache.lucene.codecs.SegmentInfoWriter; import org.apache.lucene.index.IndexWriter; // javadocs import org.apache.lucene.index.SegmentInfos; // javadocs import org.apache.lucene.store.DataOutput; // javadocs -import org.apache.lucene.util.CodecUtil; // javadocs /** * Lucene 4.0 Segment info format. Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoReader.java (working copy) @@ -22,13 +22,13 @@ import java.util.Map; import java.util.Set; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.SegmentInfoReader; 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.IndexInput; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; /** Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.java (working copy) @@ -19,6 +19,7 @@ import java.io.IOException; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.SegmentInfoWriter; import org.apache.lucene.index.FieldInfos; import org.apache.lucene.index.IndexFileNames; @@ -26,7 +27,6 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexOutput; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; /** Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsFormat.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsFormat.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsFormat.java (working copy) @@ -19,6 +19,7 @@ import java.io.IOException; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.StoredFieldsFormat; import org.apache.lucene.codecs.StoredFieldsReader; import org.apache.lucene.codecs.StoredFieldsWriter; @@ -27,7 +28,6 @@ import org.apache.lucene.store.DataOutput; // javadocs import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; -import org.apache.lucene.util.CodecUtil; /** * Lucene 4.0 Stored Fields Format. Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsReader.java (working copy) @@ -19,6 +19,7 @@ import java.io.IOException; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.StoredFieldsReader; import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.index.FieldInfo; @@ -30,7 +31,6 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; import java.io.Closeable; Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java (working copy) @@ -18,6 +18,7 @@ import java.io.IOException; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.StoredFieldsReader; import org.apache.lucene.codecs.StoredFieldsWriter; import org.apache.lucene.document.Document; @@ -35,7 +36,6 @@ import org.apache.lucene.store.IndexOutput; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; /** Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsFormat.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsFormat.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsFormat.java (working copy) @@ -19,6 +19,7 @@ import java.io.IOException; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.TermVectorsFormat; import org.apache.lucene.codecs.TermVectorsReader; import org.apache.lucene.codecs.TermVectorsWriter; @@ -27,7 +28,6 @@ import org.apache.lucene.store.DataOutput; // javadocs import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; -import org.apache.lucene.util.CodecUtil; /** * Lucene 4.0 Term Vectors format. Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsReader.java (working copy) @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.Map; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.TermVectorsReader; import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.index.DocsAndPositionsEnum; @@ -40,7 +41,6 @@ import org.apache.lucene.store.IndexInput; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; /** Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsWriter.java (working copy) @@ -20,6 +20,7 @@ import java.io.IOException; import java.util.Comparator; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.TermVectorsReader; import org.apache.lucene.codecs.TermVectorsWriter; import org.apache.lucene.index.FieldInfo; @@ -36,7 +37,6 @@ import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.StringHelper; Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Bytes.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Bytes.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Bytes.java (working copy) @@ -22,6 +22,7 @@ import java.util.Comparator; import java.util.concurrent.atomic.AtomicLong; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.DocValuesConsumer; import org.apache.lucene.index.DocValues.SortedSource; import org.apache.lucene.index.DocValues.Source; @@ -41,7 +42,6 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRefHash.TrackingDirectBytesStartArray; import org.apache.lucene.util.BytesRefHash; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.Counter; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.PagedBytes; Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/PackedIntValues.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/PackedIntValues.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/PackedIntValues.java (working copy) @@ -18,6 +18,7 @@ */ import java.io.IOException; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.DocValuesArraySource; import org.apache.lucene.codecs.lucene40.values.FixedStraightBytesImpl.FixedBytesWriterBase; import org.apache.lucene.index.DocValues.Source; @@ -30,7 +31,6 @@ import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexOutput; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.Counter; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.packed.PackedInts; Index: lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsReader.java (working copy) @@ -22,6 +22,7 @@ import java.util.Map; import org.apache.lucene.codecs.BlockTermState; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.PostingsReaderBase; import org.apache.lucene.index.DocsAndPositionsEnum; import org.apache.lucene.index.DocsEnum; @@ -36,7 +37,6 @@ import org.apache.lucene.util.AttributeSource; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; /** Concrete class that reads the current doc/freq/skip * postings format Index: lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsWriter.java (working copy) @@ -21,6 +21,7 @@ import java.util.List; import java.util.ArrayList; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.PostingsWriterBase; import org.apache.lucene.codecs.TermStats; import org.apache.lucene.index.FieldInfo; @@ -28,7 +29,6 @@ import org.apache.lucene.store.IndexOutput; import org.apache.lucene.store.RAMOutputStream; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; // TODO: we now inline based on total TF of the term, // but it might be better to inline by "net bytes used" Index: lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsReader.java (working copy) @@ -20,6 +20,7 @@ import java.io.IOException; import org.apache.lucene.codecs.BlockTermState; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.PostingsReaderBase; import org.apache.lucene.index.DocsAndPositionsEnum; import org.apache.lucene.index.DocsEnum; @@ -36,7 +37,6 @@ import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; /** Concrete class that reads the current doc/freq/skip * postings format. Index: lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsWriter.java (working copy) @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.List; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.PostingsWriterBase; import org.apache.lucene.codecs.TermStats; import org.apache.lucene.index.CorruptIndexException; @@ -32,7 +33,6 @@ import org.apache.lucene.store.IndexOutput; import org.apache.lucene.store.RAMOutputStream; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; /** Writes frq to .frq, docs to .doc, pos to .pos, payloads Index: lucene/core/src/java/org/apache/lucene/codecs/VariableGapTermsIndexReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/VariableGapTermsIndexReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/VariableGapTermsIndexReader.java (working copy) @@ -30,7 +30,6 @@ import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IntsRef; import org.apache.lucene.util.fst.Builder; import org.apache.lucene.util.fst.BytesRefFSTEnum; Index: lucene/core/src/java/org/apache/lucene/codecs/VariableGapTermsIndexWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/VariableGapTermsIndexWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/codecs/VariableGapTermsIndexWriter.java (working copy) @@ -27,7 +27,6 @@ import org.apache.lucene.index.SegmentWriteState; import org.apache.lucene.store.IndexOutput; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.IntsRef; import org.apache.lucene.util.fst.Builder; Index: lucene/core/src/java/org/apache/lucene/index/AtomicReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/AtomicReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/index/AtomicReader.java (working copy) @@ -22,7 +22,6 @@ import org.apache.lucene.search.SearcherManager; // javadocs import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.ReaderUtil; // for javadocs /** {@code AtomicReader} is an abstract class, providing an interface for accessing an index. Search of an index is done entirely through this abstract interface, Index: lucene/core/src/java/org/apache/lucene/index/BaseCompositeReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/BaseCompositeReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/index/BaseCompositeReader.java (working copy) @@ -23,7 +23,6 @@ import java.util.List; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.ReaderUtil; /** Base class for implementing {@link CompositeReader}s based on an array * of sub-readers. The implementing class has to add code for Index: lucene/core/src/java/org/apache/lucene/index/BitsSlice.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/BitsSlice.java (revision 0) +++ lucene/core/src/java/org/apache/lucene/index/BitsSlice.java (working copy) @@ -0,0 +1,51 @@ +package org.apache.lucene.index; + +import org.apache.lucene.util.Bits; + +/* + * 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. + */ + +/** + * Exposes a slice of an existing Bits as a new Bits. + * + * @lucene.internal + */ +final class BitsSlice implements Bits { + private final Bits parent; + private final int start; + private final int length; + + // start is inclusive; end is exclusive (length = end-start) + public BitsSlice(Bits parent, ReaderSlice slice) { + this.parent = parent; + this.start = slice.start; + this.length = slice.length; + assert length >= 0: "length=" + length; + } + + public boolean get(int doc) { + if (doc >= length) { + throw new RuntimeException("doc " + doc + " is out of bounds 0 .. " + (length-1)); + } + assert doc < length: "doc=" + doc + " length=" + length; + return parent.get(doc+start); + } + + public int length() { + return length; + } +} Index: lucene/core/src/java/org/apache/lucene/index/BitsSlice.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/BitsSlice.java (revision 1352563) +++ lucene/core/src/java/org/apache/lucene/index/BitsSlice.java (working copy) Property changes on: lucene/core/src/java/org/apache/lucene/index/BitsSlice.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: lucene/core/src/java/org/apache/lucene/index/IndexReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/IndexReader.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/index/IndexReader.java (working copy) @@ -31,7 +31,6 @@ import org.apache.lucene.store.*; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.ReaderUtil; // for javadocs /** IndexReader is an abstract class, providing an interface for accessing an index. Search of an index is done entirely through this abstract interface, Index: lucene/core/src/java/org/apache/lucene/index/IndexWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/IndexWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/index/IndexWriter.java (working copy) @@ -53,7 +53,6 @@ import org.apache.lucene.util.InfoStream; import org.apache.lucene.util.MutableBits; import org.apache.lucene.util.ThreadInterruptedException; -import org.apache.lucene.util.TwoPhaseCommit; /** An IndexWriter creates and maintains an index. Index: lucene/core/src/java/org/apache/lucene/index/MultiBits.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/MultiBits.java (revision 0) +++ lucene/core/src/java/org/apache/lucene/index/MultiBits.java (working copy) @@ -0,0 +1,115 @@ +package org.apache.lucene.index; + +import org.apache.lucene.util.Bits; + +/* + * 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. + */ + +/** + * Concatenates multiple Bits together, on every lookup. + * + *

NOTE: This is very costly, as every lookup must + * do a binary search to locate the right sub-reader. + * + * @lucene.experimental + */ +final class MultiBits implements Bits { + private final Bits[] subs; + + // length is 1+subs.length (the last entry has the maxDoc): + private final int[] starts; + + private final boolean defaultValue; + + public MultiBits(Bits[] subs, int[] starts, boolean defaultValue) { + assert starts.length == 1+subs.length; + this.subs = subs; + this.starts = starts; + this.defaultValue = defaultValue; + } + + private boolean checkLength(int reader, int doc) { + final int length = starts[1+reader]-starts[reader]; + assert doc - starts[reader] < length: "doc=" + doc + " reader=" + reader + " starts[reader]=" + starts[reader] + " length=" + length; + return true; + } + + public boolean get(int doc) { + final int reader = ReaderUtil.subIndex(doc, starts); + assert reader != -1; + final Bits bits = subs[reader]; + if (bits == null) { + return defaultValue; + } else { + assert checkLength(reader, doc); + return bits.get(doc-starts[reader]); + } + } + + @Override + public String toString() { + StringBuilder b = new StringBuilder(); + b.append(subs.length + " subs: "); + for(int i=0;in in the + * array used to construct this searcher/reader. + */ + public static int subIndex(int n, int[] docStarts) { // find + // searcher/reader for doc n: + int size = docStarts.length; + int lo = 0; // search starts array + int hi = size - 1; // for first element less than n, return its index + while (hi >= lo) { + int mid = (lo + hi) >>> 1; + int midValue = docStarts[mid]; + if (n < midValue) + hi = mid - 1; + else if (n > midValue) + lo = mid + 1; + else { // found a match + while (mid + 1 < size && docStarts[mid + 1] == midValue) { + mid++; // scan to last match + } + return mid; + } + } + return hi; + } + + /** + * Returns index of the searcher/reader for document n in the + * array used to construct this searcher/reader. + */ + public static int subIndex(int n, List leaves) { // find + // searcher/reader for doc n: + int size = leaves.size(); + int lo = 0; // search starts array + int hi = size - 1; // for first element less than n, return its index + while (hi >= lo) { + int mid = (lo + hi) >>> 1; + int midValue = leaves.get(mid).docBase; + if (n < midValue) + hi = mid - 1; + else if (n > midValue) + lo = mid + 1; + else { // found a match + while (mid + 1 < size && leaves.get(mid + 1).docBase == midValue) { + mid++; // scan to last match + } + return mid; + } + } + return hi; + } +} Index: lucene/core/src/java/org/apache/lucene/index/ReaderUtil.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/ReaderUtil.java (revision 1352563) +++ lucene/core/src/java/org/apache/lucene/index/ReaderUtil.java (working copy) Property changes on: lucene/core/src/java/org/apache/lucene/index/ReaderUtil.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java (working copy) @@ -32,6 +32,7 @@ import java.util.Set; import org.apache.lucene.codecs.Codec; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.LiveDocsFormat; import org.apache.lucene.store.ChecksumIndexInput; import org.apache.lucene.store.ChecksumIndexOutput; @@ -41,7 +42,6 @@ import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexOutput; import org.apache.lucene.store.NoSuchDirectoryException; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.StringHelper; import org.apache.lucene.util.ThreadInterruptedException; Index: lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java (working copy) @@ -34,8 +34,6 @@ import org.apache.lucene.util.Bits; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.InfoStream; -import org.apache.lucene.util.ReaderUtil; -import org.apache.lucene.util.ReaderSlice; /** * The SegmentMerger class combines two or more Segments, represented by an IndexReader ({@link #add}, Index: lucene/core/src/java/org/apache/lucene/index/TermContext.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/TermContext.java (revision 0) +++ lucene/core/src/java/org/apache/lucene/index/TermContext.java (working copy) @@ -0,0 +1,165 @@ +package org.apache.lucene.index; + +/* + * 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.Arrays; + +import org.apache.lucene.util.BytesRef; + +/** + * Maintains a {@link IndexReader} {@link TermState} view over + * {@link IndexReader} instances containing a single term. The + * {@link TermContext} doesn't track if the given {@link TermState} + * objects are valid, neither if the {@link TermState} instances refer to the + * same terms in the associated readers. + * + * @lucene.experimental + */ +public final class TermContext { + public final IndexReaderContext topReaderContext; // for asserting! + private final TermState[] states; + private int docFreq; + private long totalTermFreq; + + //public static boolean DEBUG = BlockTreeTermsWriter.DEBUG; + + /** + * Creates an empty {@link TermContext} from a {@link IndexReaderContext} + */ + public TermContext(IndexReaderContext context) { + assert context != null && context.isTopLevel; + topReaderContext = context; + docFreq = 0; + final int len; + if (context.leaves() == null) { + len = 1; + } else { + len = context.leaves().size(); + } + states = new TermState[len]; + } + + /** + * Creates a {@link TermContext} with an initial {@link TermState}, + * {@link IndexReader} pair. + */ + public TermContext(IndexReaderContext context, TermState state, int ord, int docFreq, long totalTermFreq) { + this(context); + register(state, ord, docFreq, totalTermFreq); + } + + /** + * Creates a {@link TermContext} from a top-level {@link IndexReaderContext} and the + * given {@link Term}. This method will lookup the given term in all context's leaf readers + * and register each of the readers containing the term in the returned {@link TermContext} + * using the leaf reader's ordinal. + *

+ * Note: the given context must be a top-level context. + */ + public static TermContext build(IndexReaderContext context, Term term, boolean cache) + throws IOException { + assert context != null && context.isTopLevel; + final String field = term.field(); + final BytesRef bytes = term.bytes(); + final TermContext perReaderTermState = new TermContext(context); + //if (DEBUG) System.out.println("prts.build term=" + term); + for (final AtomicReaderContext ctx : context.leaves()) { + //if (DEBUG) System.out.println(" r=" + leaves[i].reader); + final Fields fields = ctx.reader().fields(); + if (fields != null) { + final Terms terms = fields.terms(field); + if (terms != null) { + final TermsEnum termsEnum = terms.iterator(null); + if (termsEnum.seekExact(bytes, cache)) { + final TermState termState = termsEnum.termState(); + //if (DEBUG) System.out.println(" found"); + perReaderTermState.register(termState, ctx.ord, termsEnum.docFreq(), termsEnum.totalTermFreq()); + } + } + } + } + return perReaderTermState; + } + + /** + * Clears the {@link TermContext} internal state and removes all + * registered {@link TermState}s + */ + public void clear() { + docFreq = 0; + Arrays.fill(states, null); + } + + /** + * Registers and associates a {@link TermState} with an leaf ordinal. The leaf ordinal + * should be derived from a {@link IndexReaderContext}'s leaf ord. + */ + public void register(TermState state, final int ord, final int docFreq, final long totalTermFreq) { + assert state != null : "state must not be null"; + assert ord >= 0 && ord < states.length; + assert states[ord] == null : "state for ord: " + ord + + " already registered"; + this.docFreq += docFreq; + if (this.totalTermFreq >= 0 && totalTermFreq >= 0) + this.totalTermFreq += totalTermFreq; + else + this.totalTermFreq = -1; + states[ord] = state; + } + + /** + * Returns the {@link TermState} for an leaf ordinal or null if no + * {@link TermState} for the ordinal was registered. + * + * @param ord + * the readers leaf ordinal to get the {@link TermState} for. + * @return the {@link TermState} for the given readers ord or null if no + * {@link TermState} for the reader was registered + */ + public TermState get(int ord) { + assert ord >= 0 && ord < states.length; + return states[ord]; + } + + /** + * Returns the accumulated document frequency of all {@link TermState} + * instances passed to {@link #register(TermState, int, int, long)}. + * @return the accumulated document frequency of all {@link TermState} + * instances passed to {@link #register(TermState, int, int, long)}. + */ + public int docFreq() { + return docFreq; + } + + /** + * Returns the accumulated term frequency of all {@link TermState} + * instances passed to {@link #register(TermState, int, int, long)}. + * @return the accumulated term frequency of all {@link TermState} + * instances passed to {@link #register(TermState, int, int, long)}. + */ + public long totalTermFreq() { + return totalTermFreq; + } + + /** expert: only available for queries that want to lie about docfreq + * @lucene.internal */ + public void setDocFreq(int docFreq) { + this.docFreq = docFreq; + } +} \ No newline at end of file Index: lucene/core/src/java/org/apache/lucene/index/TermContext.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/TermContext.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/index/TermContext.java (working copy) Property changes on: lucene/core/src/java/org/apache/lucene/index/TermContext.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommit.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommit.java (revision 0) +++ lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommit.java (working copy) @@ -0,0 +1,77 @@ +package org.apache.lucene.index; + +import java.io.IOException; +import java.util.Map; + +/* + * 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. + */ + +/** + * An interface for implementations that support 2-phase commit. You can use + * {@link TwoPhaseCommitTool} to execute a 2-phase commit algorithm over several + * {@link TwoPhaseCommit}s. + * + * @lucene.experimental + */ +public interface TwoPhaseCommit { + + /** + * The first stage of a 2-phase commit. Implementations should do as much work + * as possible in this method, but avoid actual committing changes. If the + * 2-phase commit fails, {@link #rollback()} is called to discard all changes + * since last successful commit. + */ + public void prepareCommit() throws IOException; + + /** + * Like {@link #commit()}, but takes an additional commit data to be included + * w/ the commit. + *

+ * NOTE: some implementations may not support any custom data to be + * included w/ the commit and may discard it altogether. Consult the actual + * implementation documentation for verifying if this is supported. + * + * @see #prepareCommit() + */ + public void prepareCommit(Map commitData) throws IOException; + + /** + * The second phase of a 2-phase commit. Implementations should ideally do + * very little work in this method (following {@link #prepareCommit()}, and + * after it returns, the caller can assume that the changes were successfully + * committed to the underlying storage. + */ + public void commit() throws IOException; + + /** + * Like {@link #commit()}, but takes an additional commit data to be included + * w/ the commit. + * + * @see #commit() + * @see #prepareCommit(Map) + */ + public void commit(Map commitData) throws IOException; + + /** + * Discards any changes that have occurred since the last commit. In a 2-phase + * commit algorithm, where one of the objects failed to {@link #commit()} or + * {@link #prepareCommit()}, this method is used to roll all other objects + * back to their previous state. + */ + public void rollback() throws IOException; + +} Index: lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommit.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommit.java (revision 1352832) +++ lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommit.java (working copy) Property changes on: lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommit.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommitTool.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommitTool.java (revision 0) +++ lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommitTool.java (working copy) @@ -0,0 +1,162 @@ +package org.apache.lucene.index; + +import java.io.IOException; +import java.util.Map; + +/* + * 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. + */ + +/** + * A utility for executing 2-phase commit on several objects. + * + * @see TwoPhaseCommit + * @lucene.experimental + */ +public final class TwoPhaseCommitTool { + + /** + * A wrapper of a {@link TwoPhaseCommit}, which delegates all calls to the + * wrapped object, passing the specified commitData. This object is useful for + * use with {@link TwoPhaseCommitTool#execute(TwoPhaseCommit...)} if one would + * like to store commitData as part of the commit. + */ + public static final class TwoPhaseCommitWrapper implements TwoPhaseCommit { + + private final TwoPhaseCommit tpc; + private final Map commitData; + + public TwoPhaseCommitWrapper(TwoPhaseCommit tpc, Map commitData) { + this.tpc = tpc; + this.commitData = commitData; + } + + public void prepareCommit() throws IOException { + prepareCommit(commitData); + } + + public void prepareCommit(Map commitData) throws IOException { + tpc.prepareCommit(this.commitData); + } + + public void commit() throws IOException { + commit(commitData); + } + + public void commit(Map commitData) throws IOException { + tpc.commit(this.commitData); + } + + public void rollback() throws IOException { + tpc.rollback(); + } + } + + /** + * Thrown by {@link TwoPhaseCommitTool#execute(TwoPhaseCommit...)} when an + * object fails to prepareCommit(). + */ + public static class PrepareCommitFailException extends IOException { + + public PrepareCommitFailException(Throwable cause, TwoPhaseCommit obj) { + super("prepareCommit() failed on " + obj); + initCause(cause); + } + + } + + /** + * Thrown by {@link TwoPhaseCommitTool#execute(TwoPhaseCommit...)} when an + * object fails to commit(). + */ + public static class CommitFailException extends IOException { + + public CommitFailException(Throwable cause, TwoPhaseCommit obj) { + super("commit() failed on " + obj); + initCause(cause); + } + + } + + /** rollback all objects, discarding any exceptions that occur. */ + private static void rollback(TwoPhaseCommit... objects) { + for (TwoPhaseCommit tpc : objects) { + // ignore any exception that occurs during rollback - we want to ensure + // all objects are rolled-back. + if (tpc != null) { + try { + tpc.rollback(); + } catch (Throwable t) {} + } + } + } + + /** + * Executes a 2-phase commit algorithm by first + * {@link TwoPhaseCommit#prepareCommit()} all objects and only if all succeed, + * it proceeds with {@link TwoPhaseCommit#commit()}. If any of the objects + * fail on either the preparation or actual commit, it terminates and + * {@link TwoPhaseCommit#rollback()} all of them. + *

+ * NOTE: it may happen that an object fails to commit, after few have + * already successfully committed. This tool will still issue a rollback + * instruction on them as well, but depending on the implementation, it may + * not have any effect. + *

+ * NOTE: if any of the objects are {@code null}, this method simply + * skips over them. + * + * @throws PrepareCommitFailException + * if any of the objects fail to + * {@link TwoPhaseCommit#prepareCommit()} + * @throws CommitFailException + * if any of the objects fail to {@link TwoPhaseCommit#commit()} + */ + public static void execute(TwoPhaseCommit... objects) + throws PrepareCommitFailException, CommitFailException { + TwoPhaseCommit tpc = null; + try { + // first, all should successfully prepareCommit() + for (int i = 0; i < objects.length; i++) { + tpc = objects[i]; + if (tpc != null) { + tpc.prepareCommit(); + } + } + } catch (Throwable t) { + // first object that fails results in rollback all of them and + // throwing an exception. + rollback(objects); + throw new PrepareCommitFailException(t, tpc); + } + + // If all successfully prepareCommit(), attempt the actual commit() + try { + for (int i = 0; i < objects.length; i++) { + tpc = objects[i]; + if (tpc != null) { + tpc.commit(); + } + } + } catch (Throwable t) { + // first object that fails results in rollback all of them and + // throwing an exception. + rollback(objects); + throw new CommitFailException(t, tpc); + } + } + +} Index: lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommitTool.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommitTool.java (revision 1352832) +++ lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommitTool.java (working copy) Property changes on: lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommitTool.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: lucene/core/src/java/org/apache/lucene/search/ConstantScoreAutoRewrite.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/ConstantScoreAutoRewrite.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/ConstantScoreAutoRewrite.java (working copy) @@ -21,13 +21,13 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.index.TermState; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.ByteBlockPool; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRefHash; -import org.apache.lucene.util.TermContext; import org.apache.lucene.util.RamUsageEstimator; import org.apache.lucene.util.BytesRefHash.DirectBytesStartArray; Index: lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java (working copy) @@ -39,14 +39,14 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.MultiFields; import org.apache.lucene.index.IndexReaderContext; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.StoredFieldVisitor; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.index.Terms; import org.apache.lucene.search.similarities.DefaultSimilarity; import org.apache.lucene.search.similarities.Similarity; import org.apache.lucene.store.NIOFSDirectory; // javadoc -import org.apache.lucene.util.ReaderUtil; -import org.apache.lucene.util.TermContext; import org.apache.lucene.util.ThreadInterruptedException; import org.apache.lucene.index.IndexWriter; // javadocs Index: lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java (working copy) @@ -26,6 +26,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReaderContext; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.index.TermState; import org.apache.lucene.index.Terms; import org.apache.lucene.index.TermsEnum; @@ -35,7 +36,6 @@ import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.PriorityQueue; -import org.apache.lucene.util.TermContext; import org.apache.lucene.util.ToStringUtils; /** Index: lucene/core/src/java/org/apache/lucene/search/MultiTermQuery.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/MultiTermQuery.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/MultiTermQuery.java (working copy) @@ -23,10 +23,10 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.SingleTermsEnum; // javadocs import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.index.Terms; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.util.AttributeSource; -import org.apache.lucene.util.TermContext; /** * An abstract {@link Query} that matches documents Index: lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java (working copy) @@ -30,6 +30,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReaderContext; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.DisjunctionMaxQuery; @@ -43,7 +44,6 @@ import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.search.spans.SpanTermQuery; import org.apache.lucene.search.spans.Spans; -import org.apache.lucene.util.TermContext; /** * Experimental class to get set of payloads for most standard Lucene queries. Index: lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java (working copy) @@ -28,6 +28,7 @@ import org.apache.lucene.index.AtomicReader; import org.apache.lucene.index.IndexReaderContext; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.index.TermState; import org.apache.lucene.index.Terms; import org.apache.lucene.index.TermsEnum; @@ -36,7 +37,6 @@ import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.TermContext; import org.apache.lucene.util.ToStringUtils; /** A Query that matches documents containing a particular sequence of terms. Index: lucene/core/src/java/org/apache/lucene/search/ScoringRewrite.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/ScoringRewrite.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/ScoringRewrite.java (working copy) @@ -20,6 +20,7 @@ import java.io.IOException; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.index.TermState; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.search.MultiTermQuery.RewriteMethod; @@ -28,7 +29,6 @@ import org.apache.lucene.util.ByteBlockPool; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRefHash; -import org.apache.lucene.util.TermContext; import org.apache.lucene.util.RamUsageEstimator; import org.apache.lucene.util.BytesRefHash.DirectBytesStartArray; Index: lucene/core/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java (working copy) @@ -24,11 +24,11 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.search.Query; import org.apache.lucene.search.Weight; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.TermContext; import org.apache.lucene.util.ToStringUtils; /** Index: lucene/core/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java (working copy) @@ -19,9 +19,9 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.TermContext; import java.io.IOException; import java.util.ArrayList; Index: lucene/core/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java (working copy) @@ -19,9 +19,9 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.util.Bits; import org.apache.lucene.util.PriorityQueue; -import org.apache.lucene.util.TermContext; import java.io.IOException; import java.util.ArrayList; Index: lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java (working copy) @@ -23,13 +23,13 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.TopTermsRewrite; import org.apache.lucene.search.ScoringRewrite; import org.apache.lucene.search.BooleanClause.Occur; // javadocs only import org.apache.lucene.util.Bits; -import org.apache.lucene.util.TermContext; /** * Wraps any {@link MultiTermQuery} as a {@link SpanQuery}, Index: lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java (working copy) @@ -30,9 +30,9 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.search.Query; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.TermContext; import org.apache.lucene.util.ToStringUtils; /** Matches spans which are near one another. One can specify slop, the Index: lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java (working copy) @@ -20,9 +20,9 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.search.Query; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.TermContext; import org.apache.lucene.util.ToStringUtils; import java.io.IOException; Index: lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java (working copy) @@ -29,9 +29,9 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.util.Bits; import org.apache.lucene.util.PriorityQueue; -import org.apache.lucene.util.TermContext; import org.apache.lucene.util.ToStringUtils; import org.apache.lucene.search.Query; Index: lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionCheckQuery.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionCheckQuery.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionCheckQuery.java (working copy) @@ -20,9 +20,9 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.search.Query; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.TermContext; import java.io.IOException; import java.util.ArrayList; Index: lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java (working copy) @@ -22,11 +22,11 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.search.Query; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Weight; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.TermContext; /** Base class for span-based queries. */ public abstract class SpanQuery extends Query { Index: lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java (working copy) @@ -21,11 +21,11 @@ import org.apache.lucene.index.Fields; import org.apache.lucene.index.Term; import org.apache.lucene.index.DocsAndPositionsEnum; +import org.apache.lucene.index.TermContext; import org.apache.lucene.index.TermState; import org.apache.lucene.index.Terms; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.TermContext; import org.apache.lucene.util.ToStringUtils; import java.io.IOException; Index: lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java (working copy) @@ -20,11 +20,11 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.IndexReaderContext; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.search.*; import org.apache.lucene.search.similarities.Similarity; import org.apache.lucene.search.similarities.Similarity.SloppySimScorer; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.TermContext; import java.io.IOException; import java.util.HashMap; Index: lucene/core/src/java/org/apache/lucene/search/TermCollectingRewrite.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/TermCollectingRewrite.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/TermCollectingRewrite.java (working copy) @@ -25,11 +25,11 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReaderContext; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.index.Terms; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.util.AttributeSource; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.TermContext; abstract class TermCollectingRewrite extends MultiTermQuery.RewriteMethod { Index: lucene/core/src/java/org/apache/lucene/search/TermQuery.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/TermQuery.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/TermQuery.java (working copy) @@ -24,15 +24,15 @@ import org.apache.lucene.index.DocsEnum; import org.apache.lucene.index.AtomicReader; import org.apache.lucene.index.IndexReaderContext; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.index.TermState; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.search.similarities.Similarity.ExactSimScorer; import org.apache.lucene.search.similarities.Similarity; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.ReaderUtil; -import org.apache.lucene.util.TermContext; import org.apache.lucene.util.ToStringUtils; /** A Query that matches documents containing a term. Index: lucene/core/src/java/org/apache/lucene/search/TopTermsRewrite.java =================================================================== --- lucene/core/src/java/org/apache/lucene/search/TopTermsRewrite.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/search/TopTermsRewrite.java (working copy) @@ -25,11 +25,11 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.index.TermState; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.TermContext; /** * Base rewrite method for collecting only the top terms Index: lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java =================================================================== --- lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java (working copy) @@ -18,11 +18,11 @@ */ import org.apache.lucene.codecs.Codec; // javadocs +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.LiveDocsFormat; // javadocs import org.apache.lucene.index.IndexFileNames; import org.apache.lucene.index.IndexFormatTooOldException; import org.apache.lucene.store.DataOutput; // javadocs -import org.apache.lucene.util.CodecUtil; // javadocs import org.apache.lucene.util.IOUtils; import java.util.Collection; Index: lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java (working copy) @@ -29,9 +29,9 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.index.IndexFileNames; import org.apache.lucene.index.MergePolicy.MergeAbortedException; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; /** Index: lucene/core/src/java/org/apache/lucene/util/BitsSlice.java =================================================================== --- lucene/core/src/java/org/apache/lucene/util/BitsSlice.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/util/BitsSlice.java (working copy) @@ -1,46 +0,0 @@ -package org.apache.lucene.util; - -/* - * 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. - */ - -/** Exposes a slice of an existing Bits as a new Bits. */ - -public final class BitsSlice implements Bits { - private final Bits parent; - private final int start; - private final int length; - - // start is inclusive; end is exclusive (length = end-start) - public BitsSlice(Bits parent, ReaderSlice slice) { - this.parent = parent; - this.start = slice.start; - this.length = slice.length; - assert length >= 0: "length=" + length; - } - - public boolean get(int doc) { - if (doc >= length) { - throw new RuntimeException("doc " + doc + " is out of bounds 0 .. " + (length-1)); - } - assert doc < length: "doc=" + doc + " length=" + length; - return parent.get(doc+start); - } - - public int length() { - return length; - } -} Index: lucene/core/src/java/org/apache/lucene/util/CodecUtil.java =================================================================== --- lucene/core/src/java/org/apache/lucene/util/CodecUtil.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/util/CodecUtil.java (working copy) @@ -1,152 +0,0 @@ -package org.apache.lucene.util; - -/* - * 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 org.apache.lucene.index.CorruptIndexException; -import org.apache.lucene.index.IndexFormatTooNewException; -import org.apache.lucene.index.IndexFormatTooOldException; -import org.apache.lucene.store.DataInput; -import org.apache.lucene.store.DataOutput; - -/** - * Utility class for reading and writing versioned headers. - *

- * Writing codec headers is useful to ensure that a file is in - * the format you think it is. - * - * @lucene.experimental - */ - -public final class CodecUtil { - private CodecUtil() {} // no instance - - /** - * Constant to identify the start of a codec header. - */ - public final static int CODEC_MAGIC = 0x3fd76c17; - - /** - * Writes a codec header, which records both a string to - * identify the file and a version number. This header can - * be parsed and validated with - * {@link #checkHeader(DataInput, String, int, int) checkHeader()}. - *

- * CodecHeader --> Magic,CodecName,Version - *

- *

- * Note that the length of a codec header depends only upon the - * name of the codec, so this length can be computed at any time - * with {@link #headerLength(String)}. - * - * @param out Output stream - * @param codec String to identify this file. It should be simple ASCII, - * less than 128 characters in length. - * @param version Version number - * @throws IOException If there is an I/O error writing to the underlying medium. - */ - public static void writeHeader(DataOutput out, String codec, int version) - throws IOException { - BytesRef bytes = new BytesRef(codec); - if (bytes.length != codec.length() || bytes.length >= 128) { - throw new IllegalArgumentException("codec must be simple ASCII, less than 128 characters in length [got " + codec + "]"); - } - out.writeInt(CODEC_MAGIC); - out.writeString(codec); - out.writeInt(version); - } - - /** - * Computes the length of a codec header. - * - * @param codec Codec name. - * @return length of the entire codec header. - * @see #writeHeader(DataOutput, String, int) - */ - public static int headerLength(String codec) { - return 9+codec.length(); - } - - /** - * Reads and validates a header previously written with - * {@link #writeHeader(DataOutput, String, int)}. - *

- * When reading a file, supply the expected codec and - * an expected version range (minVersion to maxVersion). - * - * @param in Input stream, positioned at the point where the - * header was previously written. Typically this is located - * at the beginning of the file. - * @param codec The expected codec name. - * @param minVersion The minimum supported expected version number. - * @param maxVersion The maximum supported expected version number. - * @return The actual version found, when a valid header is found - * that matches codec, with an actual version - * where minVersion <= actual <= maxVersion. - * Otherwise an exception is thrown. - * @throws CorruptIndexException If the first four bytes are not - * {@link #CODEC_MAGIC}, or if the actual codec found is - * not codec. - * @throws IndexFormatTooOldException If the actual version is less - * than minVersion. - * @throws IndexFormatTooNewException If the actual version is greater - * than maxVersion. - * @throws IOException If there is an I/O error reading from the underlying medium. - * @see #writeHeader(DataOutput, String, int) - */ - public static int checkHeader(DataInput in, String codec, int minVersion, int maxVersion) - throws IOException { - - // Safety to guard against reading a bogus string: - final int actualHeader = in.readInt(); - if (actualHeader != CODEC_MAGIC) { - throw new CorruptIndexException("codec header mismatch: actual header=" + actualHeader + " vs expected header=" + CODEC_MAGIC + " (resource: " + in + ")"); - } - return checkHeaderNoMagic(in, codec, minVersion, maxVersion); - } - - /** Like {@link - * #checkHeader(DataInput,String,int,int)} except this - * version assumes the first int has already been read - * and validated from the input. */ - public static int checkHeaderNoMagic(DataInput in, String codec, int minVersion, int maxVersion) throws IOException { - final String actualCodec = in.readString(); - if (!actualCodec.equals(codec)) { - throw new CorruptIndexException("codec mismatch: actual codec=" + actualCodec + " vs expected codec=" + codec + " (resource: " + in + ")"); - } - - final int actualVersion = in.readInt(); - if (actualVersion < minVersion) { - throw new IndexFormatTooOldException(in, actualVersion, minVersion, maxVersion); - } - if (actualVersion > maxVersion) { - throw new IndexFormatTooNewException(in, actualVersion, minVersion, maxVersion); - } - - return actualVersion; - } -} Index: lucene/core/src/java/org/apache/lucene/util/DummyConcurrentLock.java =================================================================== --- lucene/core/src/java/org/apache/lucene/util/DummyConcurrentLock.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/util/DummyConcurrentLock.java (working copy) @@ -1,52 +0,0 @@ -package org.apache.lucene.util; - -/* - * 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.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.Condition; -import java.util.concurrent.locks.ReentrantLock; - -/** - * A dummy lock as a replacement for {@link ReentrantLock} to disable locking - * @lucene.internal - */ -public final class DummyConcurrentLock implements Lock { - - /** a default instance, can be always used, as this {@link Lock} is stateless. */ - public static final DummyConcurrentLock INSTANCE = new DummyConcurrentLock(); - - public void lock() {} - - public void lockInterruptibly() {} - - public boolean tryLock() { - return true; - } - - public boolean tryLock(long time, TimeUnit unit) { - return true; - } - - public void unlock() {} - - public Condition newCondition() { - throw new UnsupportedOperationException(); - } - -} Index: lucene/core/src/java/org/apache/lucene/util/fst/FST.java =================================================================== --- lucene/core/src/java/org/apache/lucene/util/fst/FST.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/util/fst/FST.java (working copy) @@ -28,12 +28,12 @@ import java.util.HashMap; import java.util.Map; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.store.DataInput; import org.apache.lucene.store.DataOutput; import org.apache.lucene.store.InputStreamDataInput; import org.apache.lucene.store.OutputStreamDataOutput; import org.apache.lucene.util.ArrayUtil; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.IntsRef; import org.apache.lucene.util.PriorityQueue; Index: lucene/core/src/java/org/apache/lucene/util/MultiBits.java =================================================================== --- lucene/core/src/java/org/apache/lucene/util/MultiBits.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/util/MultiBits.java (working copy) @@ -1,114 +0,0 @@ -package org.apache.lucene.util; - -/* - * 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. - */ - -/** - * Concatenates multiple Bits together, on every lookup. - * - *

NOTE: This is very costly, as every lookup must - * do a binary search to locate the right sub-reader. - * - * @lucene.experimental - */ - -public final class MultiBits implements Bits { - private final Bits[] subs; - - // length is 1+subs.length (the last entry has the maxDoc): - private final int[] starts; - - private final boolean defaultValue; - - public MultiBits(Bits[] subs, int[] starts, boolean defaultValue) { - assert starts.length == 1+subs.length; - this.subs = subs; - this.starts = starts; - this.defaultValue = defaultValue; - } - - private boolean checkLength(int reader, int doc) { - final int length = starts[1+reader]-starts[reader]; - assert doc - starts[reader] < length: "doc=" + doc + " reader=" + reader + " starts[reader]=" + starts[reader] + " length=" + length; - return true; - } - - public boolean get(int doc) { - final int reader = ReaderUtil.subIndex(doc, starts); - assert reader != -1; - final Bits bits = subs[reader]; - if (bits == null) { - return defaultValue; - } else { - assert checkLength(reader, doc); - return bits.get(doc-starts[reader]); - } - } - - @Override - public String toString() { - StringBuilder b = new StringBuilder(); - b.append(subs.length + " subs: "); - for(int i=0;in in the - * array used to construct this searcher/reader. - */ - public static int subIndex(int n, int[] docStarts) { // find - // searcher/reader for doc n: - int size = docStarts.length; - int lo = 0; // search starts array - int hi = size - 1; // for first element less than n, return its index - while (hi >= lo) { - int mid = (lo + hi) >>> 1; - int midValue = docStarts[mid]; - if (n < midValue) - hi = mid - 1; - else if (n > midValue) - lo = mid + 1; - else { // found a match - while (mid + 1 < size && docStarts[mid + 1] == midValue) { - mid++; // scan to last match - } - return mid; - } - } - return hi; - } - - /** - * Returns index of the searcher/reader for document n in the - * array used to construct this searcher/reader. - */ - public static int subIndex(int n, List leaves) { // find - // searcher/reader for doc n: - int size = leaves.size(); - int lo = 0; // search starts array - int hi = size - 1; // for first element less than n, return its index - while (hi >= lo) { - int mid = (lo + hi) >>> 1; - int midValue = leaves.get(mid).docBase; - if (n < midValue) - hi = mid - 1; - else if (n > midValue) - lo = mid + 1; - else { // found a match - while (mid + 1 < size && leaves.get(mid + 1).docBase == midValue) { - mid++; // scan to last match - } - return mid; - } - } - return hi; - } -} Index: lucene/core/src/java/org/apache/lucene/util/TermContext.java =================================================================== --- lucene/core/src/java/org/apache/lucene/util/TermContext.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/util/TermContext.java (working copy) @@ -1,172 +0,0 @@ -package org.apache.lucene.util; - -/* - * 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.Arrays; - -import org.apache.lucene.index.AtomicReaderContext; -import org.apache.lucene.index.Fields; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexReaderContext; -import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermState; -import org.apache.lucene.index.Terms; -import org.apache.lucene.index.TermsEnum; - -/** - * Maintains a {@link IndexReader} {@link TermState} view over - * {@link IndexReader} instances containing a single term. The - * {@link TermContext} doesn't track if the given {@link TermState} - * objects are valid, neither if the {@link TermState} instances refer to the - * same terms in the associated readers. - * - * @lucene.experimental - */ -public final class TermContext { - public final IndexReaderContext topReaderContext; // for asserting! - private final TermState[] states; - private int docFreq; - private long totalTermFreq; - - //public static boolean DEBUG = BlockTreeTermsWriter.DEBUG; - - /** - * Creates an empty {@link TermContext} from a {@link IndexReaderContext} - */ - public TermContext(IndexReaderContext context) { - assert context != null && context.isTopLevel; - topReaderContext = context; - docFreq = 0; - final int len; - if (context.leaves() == null) { - len = 1; - } else { - len = context.leaves().size(); - } - states = new TermState[len]; - } - - /** - * Creates a {@link TermContext} with an initial {@link TermState}, - * {@link IndexReader} pair. - */ - public TermContext(IndexReaderContext context, TermState state, int ord, int docFreq, long totalTermFreq) { - this(context); - register(state, ord, docFreq, totalTermFreq); - } - - /** - * Creates a {@link TermContext} from a top-level {@link IndexReaderContext} and the - * given {@link Term}. This method will lookup the given term in all context's leaf readers - * and register each of the readers containing the term in the returned {@link TermContext} - * using the leaf reader's ordinal. - *

- * Note: the given context must be a top-level context. - */ - public static TermContext build(IndexReaderContext context, Term term, boolean cache) - throws IOException { - assert context != null && context.isTopLevel; - final String field = term.field(); - final BytesRef bytes = term.bytes(); - final TermContext perReaderTermState = new TermContext(context); - //if (DEBUG) System.out.println("prts.build term=" + term); - for (final AtomicReaderContext ctx : context.leaves()) { - //if (DEBUG) System.out.println(" r=" + leaves[i].reader); - final Fields fields = ctx.reader().fields(); - if (fields != null) { - final Terms terms = fields.terms(field); - if (terms != null) { - final TermsEnum termsEnum = terms.iterator(null); - if (termsEnum.seekExact(bytes, cache)) { - final TermState termState = termsEnum.termState(); - //if (DEBUG) System.out.println(" found"); - perReaderTermState.register(termState, ctx.ord, termsEnum.docFreq(), termsEnum.totalTermFreq()); - } - } - } - } - return perReaderTermState; - } - - /** - * Clears the {@link TermContext} internal state and removes all - * registered {@link TermState}s - */ - public void clear() { - docFreq = 0; - Arrays.fill(states, null); - } - - /** - * Registers and associates a {@link TermState} with an leaf ordinal. The leaf ordinal - * should be derived from a {@link IndexReaderContext}'s leaf ord. - */ - public void register(TermState state, final int ord, final int docFreq, final long totalTermFreq) { - assert state != null : "state must not be null"; - assert ord >= 0 && ord < states.length; - assert states[ord] == null : "state for ord: " + ord - + " already registered"; - this.docFreq += docFreq; - if (this.totalTermFreq >= 0 && totalTermFreq >= 0) - this.totalTermFreq += totalTermFreq; - else - this.totalTermFreq = -1; - states[ord] = state; - } - - /** - * Returns the {@link TermState} for an leaf ordinal or null if no - * {@link TermState} for the ordinal was registered. - * - * @param ord - * the readers leaf ordinal to get the {@link TermState} for. - * @return the {@link TermState} for the given readers ord or null if no - * {@link TermState} for the reader was registered - */ - public TermState get(int ord) { - assert ord >= 0 && ord < states.length; - return states[ord]; - } - - /** - * Returns the accumulated document frequency of all {@link TermState} - * instances passed to {@link #register(TermState, int, int, long)}. - * @return the accumulated document frequency of all {@link TermState} - * instances passed to {@link #register(TermState, int, int, long)}. - */ - public int docFreq() { - return docFreq; - } - - /** - * Returns the accumulated term frequency of all {@link TermState} - * instances passed to {@link #register(TermState, int, int, long)}. - * @return the accumulated term frequency of all {@link TermState} - * instances passed to {@link #register(TermState, int, int, long)}. - */ - public long totalTermFreq() { - return totalTermFreq; - } - - /** expert: only available for queries that want to lie about docfreq - * @lucene.internal */ - public void setDocFreq(int docFreq) { - this.docFreq = docFreq; - } -} \ No newline at end of file Index: lucene/core/src/java/org/apache/lucene/util/TwoPhaseCommit.java =================================================================== --- lucene/core/src/java/org/apache/lucene/util/TwoPhaseCommit.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/util/TwoPhaseCommit.java (working copy) @@ -1,77 +0,0 @@ -package org.apache.lucene.util; - -import java.io.IOException; -import java.util.Map; - -/* - * 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. - */ - -/** - * An interface for implementations that support 2-phase commit. You can use - * {@link TwoPhaseCommitTool} to execute a 2-phase commit algorithm over several - * {@link TwoPhaseCommit}s. - * - * @lucene.experimental - */ -public interface TwoPhaseCommit { - - /** - * The first stage of a 2-phase commit. Implementations should do as much work - * as possible in this method, but avoid actual committing changes. If the - * 2-phase commit fails, {@link #rollback()} is called to discard all changes - * since last successful commit. - */ - public void prepareCommit() throws IOException; - - /** - * Like {@link #commit()}, but takes an additional commit data to be included - * w/ the commit. - *

- * NOTE: some implementations may not support any custom data to be - * included w/ the commit and may discard it altogether. Consult the actual - * implementation documentation for verifying if this is supported. - * - * @see #prepareCommit() - */ - public void prepareCommit(Map commitData) throws IOException; - - /** - * The second phase of a 2-phase commit. Implementations should ideally do - * very little work in this method (following {@link #prepareCommit()}, and - * after it returns, the caller can assume that the changes were successfully - * committed to the underlying storage. - */ - public void commit() throws IOException; - - /** - * Like {@link #commit()}, but takes an additional commit data to be included - * w/ the commit. - * - * @see #commit() - * @see #prepareCommit(Map) - */ - public void commit(Map commitData) throws IOException; - - /** - * Discards any changes that have occurred since the last commit. In a 2-phase - * commit algorithm, where one of the objects failed to {@link #commit()} or - * {@link #prepareCommit()}, this method is used to roll all other objects - * back to their previous state. - */ - public void rollback() throws IOException; - -} Index: lucene/core/src/java/org/apache/lucene/util/TwoPhaseCommitTool.java =================================================================== --- lucene/core/src/java/org/apache/lucene/util/TwoPhaseCommitTool.java (revision 1352864) +++ lucene/core/src/java/org/apache/lucene/util/TwoPhaseCommitTool.java (working copy) @@ -1,162 +0,0 @@ -package org.apache.lucene.util; - -import java.io.IOException; -import java.util.Map; - -/* - * 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. - */ - -/** - * A utility for executing 2-phase commit on several objects. - * - * @see TwoPhaseCommit - * @lucene.experimental - */ -public final class TwoPhaseCommitTool { - - /** - * A wrapper of a {@link TwoPhaseCommit}, which delegates all calls to the - * wrapped object, passing the specified commitData. This object is useful for - * use with {@link TwoPhaseCommitTool#execute(TwoPhaseCommit...)} if one would - * like to store commitData as part of the commit. - */ - public static final class TwoPhaseCommitWrapper implements TwoPhaseCommit { - - private final TwoPhaseCommit tpc; - private final Map commitData; - - public TwoPhaseCommitWrapper(TwoPhaseCommit tpc, Map commitData) { - this.tpc = tpc; - this.commitData = commitData; - } - - public void prepareCommit() throws IOException { - prepareCommit(commitData); - } - - public void prepareCommit(Map commitData) throws IOException { - tpc.prepareCommit(this.commitData); - } - - public void commit() throws IOException { - commit(commitData); - } - - public void commit(Map commitData) throws IOException { - tpc.commit(this.commitData); - } - - public void rollback() throws IOException { - tpc.rollback(); - } - } - - /** - * Thrown by {@link TwoPhaseCommitTool#execute(TwoPhaseCommit...)} when an - * object fails to prepareCommit(). - */ - public static class PrepareCommitFailException extends IOException { - - public PrepareCommitFailException(Throwable cause, TwoPhaseCommit obj) { - super("prepareCommit() failed on " + obj); - initCause(cause); - } - - } - - /** - * Thrown by {@link TwoPhaseCommitTool#execute(TwoPhaseCommit...)} when an - * object fails to commit(). - */ - public static class CommitFailException extends IOException { - - public CommitFailException(Throwable cause, TwoPhaseCommit obj) { - super("commit() failed on " + obj); - initCause(cause); - } - - } - - /** rollback all objects, discarding any exceptions that occur. */ - private static void rollback(TwoPhaseCommit... objects) { - for (TwoPhaseCommit tpc : objects) { - // ignore any exception that occurs during rollback - we want to ensure - // all objects are rolled-back. - if (tpc != null) { - try { - tpc.rollback(); - } catch (Throwable t) {} - } - } - } - - /** - * Executes a 2-phase commit algorithm by first - * {@link TwoPhaseCommit#prepareCommit()} all objects and only if all succeed, - * it proceeds with {@link TwoPhaseCommit#commit()}. If any of the objects - * fail on either the preparation or actual commit, it terminates and - * {@link TwoPhaseCommit#rollback()} all of them. - *

- * NOTE: it may happen that an object fails to commit, after few have - * already successfully committed. This tool will still issue a rollback - * instruction on them as well, but depending on the implementation, it may - * not have any effect. - *

- * NOTE: if any of the objects are {@code null}, this method simply - * skips over them. - * - * @throws PrepareCommitFailException - * if any of the objects fail to - * {@link TwoPhaseCommit#prepareCommit()} - * @throws CommitFailException - * if any of the objects fail to {@link TwoPhaseCommit#commit()} - */ - public static void execute(TwoPhaseCommit... objects) - throws PrepareCommitFailException, CommitFailException { - TwoPhaseCommit tpc = null; - try { - // first, all should successfully prepareCommit() - for (int i = 0; i < objects.length; i++) { - tpc = objects[i]; - if (tpc != null) { - tpc.prepareCommit(); - } - } - } catch (Throwable t) { - // first object that fails results in rollback all of them and - // throwing an exception. - rollback(objects); - throw new PrepareCommitFailException(t, tpc); - } - - // If all successfully prepareCommit(), attempt the actual commit() - try { - for (int i = 0; i < objects.length; i++) { - tpc = objects[i]; - if (tpc != null) { - tpc.commit(); - } - } - } catch (Throwable t) { - // first object that fails results in rollback all of them and - // throwing an exception. - rollback(objects); - throw new CommitFailException(t, tpc); - } - } - -} Index: lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestAllFilesHaveCodecHeader.java =================================================================== --- lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestAllFilesHaveCodecHeader.java (revision 1352864) +++ lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestAllFilesHaveCodecHeader.java (working copy) @@ -21,6 +21,7 @@ import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.codecs.Codec; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexFileNames; @@ -29,7 +30,6 @@ import org.apache.lucene.store.CompoundFileDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.store.IndexInput; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util._TestUtil; Index: lucene/core/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java =================================================================== --- lucene/core/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java (revision 1352864) +++ lucene/core/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java (working copy) @@ -23,10 +23,10 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.search.Weight; import org.apache.lucene.search.similarities.Similarity; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.TermContext; /** * Holds all implementations of classes in the o.a.l.s.spans package as a Index: lucene/core/src/test/org/apache/lucene/search/spans/MultiSpansWrapper.java =================================================================== --- lucene/core/src/test/org/apache/lucene/search/spans/MultiSpansWrapper.java (revision 1352864) +++ lucene/core/src/test/org/apache/lucene/search/spans/MultiSpansWrapper.java (working copy) @@ -27,10 +27,10 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.IndexReaderContext; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.search.DocIdSetIterator; -import org.apache.lucene.util.ReaderUtil; -import org.apache.lucene.util.TermContext; /** * Index: lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java =================================================================== --- lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java (revision 1352864) +++ lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java (working copy) @@ -30,6 +30,7 @@ import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.Term; import org.apache.lucene.search.CheckHits; import org.apache.lucene.search.DocIdSetIterator; @@ -41,7 +42,6 @@ import org.apache.lucene.search.similarities.Similarity; import org.apache.lucene.store.Directory; import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.ReaderUtil; public class TestSpans extends LuceneTestCase { private IndexSearcher searcher; Index: lucene/core/src/test/org/apache/lucene/search/TestTopDocsMerge.java =================================================================== --- lucene/core/src/test/org/apache/lucene/search/TestTopDocsMerge.java (revision 1352864) +++ lucene/core/src/test/org/apache/lucene/search/TestTopDocsMerge.java (working copy) @@ -31,10 +31,10 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReaderContext; import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.Term; import org.apache.lucene.store.Directory; import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.ReaderUtil; import org.apache.lucene.util._TestUtil; public class TestTopDocsMerge extends LuceneTestCase { Index: lucene/core/src/test/org/apache/lucene/util/TestTwoPhaseCommitTool.java =================================================================== --- lucene/core/src/test/org/apache/lucene/util/TestTwoPhaseCommitTool.java (revision 1352864) +++ lucene/core/src/test/org/apache/lucene/util/TestTwoPhaseCommitTool.java (working copy) @@ -21,7 +21,9 @@ import java.util.HashMap; import java.util.Map; -import org.apache.lucene.util.TwoPhaseCommitTool.TwoPhaseCommitWrapper; +import org.apache.lucene.index.TwoPhaseCommit; +import org.apache.lucene.index.TwoPhaseCommitTool; +import org.apache.lucene.index.TwoPhaseCommitTool.TwoPhaseCommitWrapper; public class TestTwoPhaseCommitTool extends LuceneTestCase { Index: lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyWriter.java =================================================================== --- lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyWriter.java (revision 1352864) +++ lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyWriter.java (working copy) @@ -3,7 +3,7 @@ import java.io.Closeable; import java.io.IOException; -import org.apache.lucene.util.TwoPhaseCommit; +import org.apache.lucene.index.TwoPhaseCommit; /* * Licensed to the Apache Software Foundation (ASF) under one or more Index: lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java =================================================================== --- lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java (revision 1352864) +++ lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java (working copy) @@ -23,6 +23,7 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.CompositeReaderContext; import org.apache.lucene.index.DirectoryReader; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.FieldInfo.IndexOptions; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.IndexReaderContext; @@ -44,7 +45,6 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.ReaderUtil; import org.apache.lucene.util._TestUtil; import org.apache.lucene.util.mutable.MutableValue; import org.apache.lucene.util.mutable.MutableValueStr; Index: lucene/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java =================================================================== --- lucene/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java (revision 1352864) +++ lucene/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java (working copy) @@ -32,6 +32,7 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.index.memory.MemoryIndex; import org.apache.lucene.search.*; import org.apache.lucene.search.spans.FieldMaskingSpanQuery; @@ -43,7 +44,6 @@ import org.apache.lucene.search.spans.SpanTermQuery; import org.apache.lucene.search.spans.Spans; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.TermContext; /** * Class used to extract {@link WeightedSpanTerm}s from a {@link Query} based on whether Index: lucene/misc/src/java/org/apache/lucene/misc/HighFreqTerms.java =================================================================== --- lucene/misc/src/java/org/apache/lucene/misc/HighFreqTerms.java (revision 1352864) +++ lucene/misc/src/java/org/apache/lucene/misc/HighFreqTerms.java (working copy) @@ -23,6 +23,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.MultiFields; import org.apache.lucene.index.Fields; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.index.FieldsEnum; import org.apache.lucene.index.Terms; @@ -32,7 +33,6 @@ import org.apache.lucene.util.PriorityQueue; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.ReaderUtil; import java.io.File; import java.io.IOException; Index: lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/JoinDocFreqValueSource.java =================================================================== --- lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/JoinDocFreqValueSource.java (revision 1352864) +++ lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/JoinDocFreqValueSource.java (working copy) @@ -22,11 +22,11 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.queries.function.FunctionValues; import org.apache.lucene.queries.function.docvalues.IntDocValues; import org.apache.lucene.search.FieldCache.DocTerms; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.ReaderUtil; import org.apache.lucene.util.packed.PackedInts; /** Index: lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/NumDocsValueSource.java =================================================================== --- lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/NumDocsValueSource.java (revision 1352864) +++ lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/NumDocsValueSource.java (working copy) @@ -17,9 +17,9 @@ package org.apache.lucene.queries.function.valuesource; import org.apache.lucene.index.AtomicReaderContext; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.queries.function.FunctionValues; import org.apache.lucene.queries.function.ValueSource; -import org.apache.lucene.util.ReaderUtil; import java.io.IOException; import java.util.Map; Index: lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/OrdFieldSource.java =================================================================== --- lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/OrdFieldSource.java (revision 1352864) +++ lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/OrdFieldSource.java (working copy) @@ -21,12 +21,12 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.CompositeReader; import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.SlowCompositeReaderWrapper; import org.apache.lucene.queries.function.FunctionValues; import org.apache.lucene.queries.function.ValueSource; import org.apache.lucene.queries.function.docvalues.IntDocValues; import org.apache.lucene.search.FieldCache; -import org.apache.lucene.util.ReaderUtil; import org.apache.lucene.util.mutable.MutableValue; import org.apache.lucene.util.mutable.MutableValueInt; Index: lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java =================================================================== --- lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java (revision 1352864) +++ lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java (working copy) @@ -18,12 +18,12 @@ package org.apache.lucene.queries.function.valuesource; import org.apache.lucene.index.AtomicReaderContext; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.queries.function.FunctionValues; import org.apache.lucene.queries.function.ValueSource; import org.apache.lucene.queries.function.docvalues.FloatDocValues; import org.apache.lucene.search.*; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.ReaderUtil; import org.apache.lucene.util.mutable.MutableValue; import org.apache.lucene.util.mutable.MutableValueFloat; Index: lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/ReverseOrdFieldSource.java =================================================================== --- lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/ReverseOrdFieldSource.java (revision 1352864) +++ lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/ReverseOrdFieldSource.java (working copy) @@ -21,12 +21,12 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.CompositeReader; import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.SlowCompositeReaderWrapper; import org.apache.lucene.queries.function.FunctionValues; import org.apache.lucene.queries.function.ValueSource; import org.apache.lucene.queries.function.docvalues.IntDocValues; import org.apache.lucene.search.FieldCache; -import org.apache.lucene.util.ReaderUtil; import java.io.IOException; import java.util.Map; Index: lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/ScaleFloatFunction.java =================================================================== --- lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/ScaleFloatFunction.java (revision 1352864) +++ lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/ScaleFloatFunction.java (working copy) @@ -18,11 +18,11 @@ package org.apache.lucene.queries.function.valuesource; import org.apache.lucene.index.AtomicReaderContext; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.queries.function.FunctionValues; import org.apache.lucene.queries.function.ValueSource; import org.apache.lucene.queries.function.docvalues.FloatDocValues; import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.util.ReaderUtil; import java.io.IOException; import java.util.List; Index: lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java =================================================================== --- lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java (revision 1352864) +++ lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java (working copy) @@ -33,6 +33,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.Term; import org.apache.lucene.index.IndexWriterConfig.OpenMode; import org.apache.lucene.index.Terms; @@ -47,7 +48,6 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRefIterator; -import org.apache.lucene.util.ReaderUtil; import org.apache.lucene.util.Version; /** Index: lucene/test-framework/src/java/org/apache/lucene/codecs/mocksep/MockSingleIntIndexInput.java =================================================================== --- lucene/test-framework/src/java/org/apache/lucene/codecs/mocksep/MockSingleIntIndexInput.java (revision 1352864) +++ lucene/test-framework/src/java/org/apache/lucene/codecs/mocksep/MockSingleIntIndexInput.java (working copy) @@ -19,12 +19,12 @@ import java.io.IOException; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.sep.IntIndexInput; import org.apache.lucene.store.DataInput; import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; -import org.apache.lucene.util.CodecUtil; /** Reads IndexInputs written with {@link * MockSingleIntIndexOutput}. NOTE: this class is just for Index: lucene/test-framework/src/java/org/apache/lucene/codecs/mocksep/MockSingleIntIndexOutput.java =================================================================== --- lucene/test-framework/src/java/org/apache/lucene/codecs/mocksep/MockSingleIntIndexOutput.java (revision 1352864) +++ lucene/test-framework/src/java/org/apache/lucene/codecs/mocksep/MockSingleIntIndexOutput.java (working copy) @@ -20,8 +20,8 @@ import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexOutput; import org.apache.lucene.store.Directory; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.sep.IntIndexOutput; import java.io.IOException; Index: lucene/test-framework/src/java/org/apache/lucene/codecs/ramonly/RAMOnlyPostingsFormat.java =================================================================== --- lucene/test-framework/src/java/org/apache/lucene/codecs/ramonly/RAMOnlyPostingsFormat.java (revision 1352864) +++ lucene/test-framework/src/java/org/apache/lucene/codecs/ramonly/RAMOnlyPostingsFormat.java (working copy) @@ -28,6 +28,7 @@ import java.util.TreeMap; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.FieldsConsumer; import org.apache.lucene.codecs.FieldsProducer; import org.apache.lucene.codecs.PostingsConsumer; @@ -48,7 +49,6 @@ import org.apache.lucene.store.IndexOutput; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CodecUtil; import org.apache.lucene.util.IOUtils; /** Stores all postings data in RAM, but writes a small Index: lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java =================================================================== --- lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java (revision 1352864) +++ lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java (working copy) @@ -31,11 +31,11 @@ import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermContext; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.store.Directory; import org.apache.lucene.util.LineFileDocs; import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.TermContext; // TODO // - doc blocks? so we can test joins/grouping... Index: solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java =================================================================== --- solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java (revision 1352864) +++ solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java (working copy) @@ -21,6 +21,7 @@ import org.apache.lucene.document.StringField; import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.IndexReaderContext; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.Term; import org.apache.lucene.queryparser.classic.ParseException; import org.apache.lucene.search.*; @@ -29,7 +30,6 @@ import org.apache.lucene.search.grouping.TopGroups; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.CharsRef; -import org.apache.lucene.util.ReaderUtil; import org.apache.lucene.util.UnicodeUtil; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.common.SolrDocument; Index: solr/core/src/java/org/apache/solr/response/transform/ValueSourceAugmenter.java =================================================================== --- solr/core/src/java/org/apache/solr/response/transform/ValueSourceAugmenter.java (revision 1352864) +++ solr/core/src/java/org/apache/solr/response/transform/ValueSourceAugmenter.java (working copy) @@ -22,9 +22,9 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.queries.function.FunctionValues; import org.apache.lucene.queries.function.ValueSource; -import org.apache.lucene.util.ReaderUtil; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrException; import org.apache.solr.search.QParser; Index: solr/core/src/java/org/apache/solr/schema/RandomSortField.java =================================================================== --- solr/core/src/java/org/apache/solr/schema/RandomSortField.java (revision 1352864) +++ solr/core/src/java/org/apache/solr/schema/RandomSortField.java (working copy) @@ -23,11 +23,11 @@ import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.AtomicReaderContext; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.queries.function.FunctionValues; import org.apache.lucene.queries.function.ValueSource; import org.apache.lucene.queries.function.docvalues.IntDocValues; import org.apache.lucene.search.*; -import org.apache.lucene.util.ReaderUtil; import org.apache.solr.response.TextResponseWriter; import org.apache.solr.search.QParser; Index: solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java =================================================================== --- solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java (revision 1352864) +++ solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java (working copy) @@ -31,6 +31,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.MultiFields; import org.apache.lucene.index.IndexReaderContext; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.queries.function.FunctionValues; @@ -38,7 +39,6 @@ import org.apache.lucene.queries.function.docvalues.FloatDocValues; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.ReaderUtil; import org.apache.solr.core.SolrCore; import org.apache.solr.handler.RequestHandlerBase; import org.apache.solr.handler.RequestHandlerUtils; Index: solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java =================================================================== --- solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java (revision 1352864) +++ solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java (working copy) @@ -18,9 +18,9 @@ import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.IndexReaderContext; +import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.queries.function.FunctionValues; import org.apache.lucene.queries.function.ValueSource; -import org.apache.lucene.util.ReaderUtil; import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.schema.SchemaField;