Skip to content

Apache Lucene open-source search software

remove final nocommits

Michael McCandless922efb15b838
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/MultiLevelSkipListReader.java b/lucene/core/src/java/org/apache/lucene/codecs/MultiLevelSkipListReader.java
index b136c2ad318..73274b29849 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/MultiLevelSkipListReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/MultiLevelSkipListReader.java
@@ -67,7 +67,6 @@ public abstract class MultiLevelSkipListReader {
private boolean inputIsBuffered;
private final int skipMultiplier;
- // nocommit made protected from public
protected MultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval, int skipMultiplier) {
this.skipStream = new IndexInput[maxSkipLevels];
this.skipPointer = new long[maxSkipLevels];
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/block/ForUtil.java b/lucene/core/src/java/org/apache/lucene/codecs/block/ForUtil.java
index 66c214bae5c..1cae3d40cc2 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/block/ForUtil.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/block/ForUtil.java
@@ -16,18 +16,19 @@ package org.apache.lucene.codecs.block;
* limitations under the License.
*/
-import static org.apache.lucene.codecs.block.BlockPostingsFormat.BLOCK_SIZE;
-
import java.io.IOException;
import java.util.Arrays;
+import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.store.DataInput;
import org.apache.lucene.store.DataOutput;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
-import org.apache.lucene.util.packed.PackedInts;
import org.apache.lucene.util.packed.PackedInts.Decoder;
import org.apache.lucene.util.packed.PackedInts.FormatAndBits;
+import org.apache.lucene.util.packed.PackedInts;
+
+import static org.apache.lucene.codecs.block.BlockPostingsFormat.BLOCK_SIZE;
/**
* Encode all values in normal area with fixed bit width,
@@ -39,7 +40,8 @@ final class ForUtil {
* Special number of bits per value used whenever all values to encode are equal.
*/
private static final int ALL_VALUES_EQUAL = 0;
- private static final int PACKED_INTS_VERSION = 0; // nocommit: encode in the stream?
+ private static final int PACKED_INTS_VERSION_START = 0;
+ private static final int PACKED_INTS_VERSION_CURRENT = PACKED_INTS_VERSION_START;
/**
* Upper limit of the number of bytes that might be required to stored
@@ -61,7 +63,7 @@ final class ForUtil {
if (!format.isSupported(bpv)) {
continue;
}
- final PackedInts.Decoder decoder = PackedInts.getDecoder(format, PACKED_INTS_VERSION, bpv);
+ final PackedInts.Decoder decoder = PackedInts.getDecoder(format, PACKED_INTS_VERSION_START, bpv);
final int iterations = (int) Math.ceil((float) BLOCK_SIZE / decoder.valueCount());
maxDataSize = Math.max(maxDataSize, iterations * decoder.valueCount());
}
@@ -94,6 +96,7 @@ final class ForUtil {
* Create a new {@link ForUtil} instance and save state into <code>out</code>.
*/
ForUtil(float acceptableOverheadRatio, DataOutput out) throws IOException {
+ out.writeVInt(PACKED_INTS_VERSION_CURRENT);
encodedSizes = new int[33];
encoders = new PackedInts.Encoder[33];
decoders = new PackedInts.Decoder[33];
@@ -106,9 +109,9 @@ final class ForUtil {
assert formatAndBits.bitsPerValue <= 32;
encodedSizes[bpv] = encodedSize(formatAndBits.format, formatAndBits.bitsPerValue);
encoders[bpv] = PackedInts.getEncoder(
- formatAndBits.format, PACKED_INTS_VERSION, formatAndBits.bitsPerValue);
+ formatAndBits.format, PACKED_INTS_VERSION_CURRENT, formatAndBits.bitsPerValue);
decoders[bpv] = PackedInts.getDecoder(
- formatAndBits.format, PACKED_INTS_VERSION, formatAndBits.bitsPerValue);
+ formatAndBits.format, PACKED_INTS_VERSION_CURRENT, formatAndBits.bitsPerValue);
iterations[bpv] = computeIterations(decoders[bpv]);
out.writeVInt(formatAndBits.format.getId() << 5 | (formatAndBits.bitsPerValue - 1));
@@ -119,6 +122,10 @@ final class ForUtil {
* Restore a {@link ForUtil} from a {@link DataInput}.
*/
ForUtil(DataInput in) throws IOException {
+ int packedIntsVersion = in.readVInt();
+ if (packedIntsVersion != PACKED_INTS_VERSION_START) {
+ throw new CorruptIndexException("expected version=" + PACKED_INTS_VERSION_START + " but got version=" + packedIntsVersion);
+ }
encodedSizes = new int[33];
encoders = new PackedInts.Encoder[33];
decoders = new PackedInts.Decoder[33];
@@ -133,9 +140,9 @@ final class ForUtil {
assert format.isSupported(bitsPerValue);
encodedSizes[bpv] = encodedSize(format, bitsPerValue);
encoders[bpv] = PackedInts.getEncoder(
- format, PACKED_INTS_VERSION, bitsPerValue);
+ format, packedIntsVersion, bitsPerValue);
decoders[bpv] = PackedInts.getDecoder(
- format, PACKED_INTS_VERSION, bitsPerValue);
+ format, packedIntsVersion, bitsPerValue);
iterations[bpv] = computeIterations(decoders[bpv]);
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/bulkvint/BulkVIntPostingsFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/bulkvint/BulkVIntPostingsFormat.java
deleted file mode 100644
index 5461c7bebec..00000000000
--- a/lucene/core/src/java/org/apache/lucene/codecs/bulkvint/BulkVIntPostingsFormat.java
+++ /dev/null
@@ -1,203 +0,0 @@
-package org.apache.lucene.codecs.bulkvint;
-
-/**
- * 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 java.util.Set;
-
-import org.apache.lucene.codecs.BlockTermsReader;
-import org.apache.lucene.codecs.BlockTermsWriter;
-import org.apache.lucene.codecs.BlockTreeTermsReader;
-import org.apache.lucene.codecs.BlockTreeTermsWriter;
-import org.apache.lucene.codecs.Codec;
-import org.apache.lucene.codecs.FieldsConsumer;
-import org.apache.lucene.codecs.FieldsProducer;
-import org.apache.lucene.codecs.PostingsFormat;
-import org.apache.lucene.codecs.PostingsReaderBase;
-import org.apache.lucene.codecs.PostingsWriterBase;
-import org.apache.lucene.codecs.TermsIndexReaderBase;
-import org.apache.lucene.codecs.TermsIndexWriterBase;
-import org.apache.lucene.codecs.VariableGapTermsIndexReader;
-import org.apache.lucene.codecs.VariableGapTermsIndexWriter;
-import org.apache.lucene.codecs.intblock.FixedIntBlockIndexInput;
-import org.apache.lucene.codecs.intblock.FixedIntBlockIndexOutput;
-import org.apache.lucene.codecs.sep.IntStreamFactory;
-import org.apache.lucene.codecs.sep.SepPostingsReader;
-import org.apache.lucene.codecs.sep.SepPostingsWriter;
-import org.apache.lucene.index.SegmentInfo;
-import org.apache.lucene.index.SegmentReadState;
-import org.apache.lucene.index.SegmentWriteState;
-import org.apache.lucene.store.*;
-import org.apache.lucene.util.BytesRef;
-
-/**
- * Silly codec that acts like MockFixedIntBlockCodec mostly (uses vint encoding):
- * writes a single vint header (uncompressed size of the block in bytes)
- * writes the block as a list of vints
- */
-
-public final class BulkVIntPostingsFormat extends PostingsFormat {
-
- private final int blockSize;
- private final int minBlockSize;
- private final int maxBlockSize;
- public final static int DEFAULT_BLOCK_SIZE = 128;
-
- public BulkVIntPostingsFormat() {
- this(BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE, BlockTreeTermsWriter.DEFAULT_MAX_BLOCK_SIZE, DEFAULT_BLOCK_SIZE);
- }
-
- // nocommit: can't make this public until we write blockSize
- // into index somewhere (where/how? private file? pass through to
- // sep somehow?)
- private BulkVIntPostingsFormat(int minBlockSize, int maxBlockSize, int blockSize) {
- super("BulkVInt");
- this.blockSize = blockSize;
- this.minBlockSize = minBlockSize;
- this.maxBlockSize = maxBlockSize;
- }
-
- @Override
- public String toString() {
- return getName() + "(blockSize=" + blockSize + ")";
- }
-
- private class BulkVIntFactory extends IntStreamFactory {
-
- @Override
- public FixedIntBlockIndexInput openInput(Directory dir, String fileName, IOContext context) throws IOException {
- return new FixedIntBlockIndexInput(dir.openInput(fileName, context)) {
-
- @Override
- protected BlockReader getBlockReader(final IndexInput in, final int[] buffer) throws IOException {
- return new BlockReader() {
- private final byte bytes[] = new byte[blockSize*5]; // header * max(Vint)
-
- @Override
- public void readBlock() throws IOException {
- final int numBytes = in.readVInt(); // read header
- if (numBytes == 0) { // 1's
- Arrays.fill(buffer, 1);
- return;
- }
- in.readBytes(bytes, 0, numBytes); // readBytes
-
- int upto = 0;
-
- // decode bytes
- for(int i=0;i<buffer.length;i++) {
- byte b = bytes[upto++];
- int j = b & 0x7F;
- for (int shift = 7; (b & 0x80) != 0; shift += 7) {
- b = bytes[upto++];
- j |= (b & 0x7F) << shift;
- }
- buffer[i] = j;
- }
- }
- };
- }
- };
- }
-
- @Override
- public FixedIntBlockIndexOutput createOutput(Directory dir, String fileName, IOContext context) throws IOException {
- return new FixedIntBlockIndexOutput(dir.createOutput(fileName, context), blockSize) {
- private final byte bytes[] = new byte[blockSize*5]; // header * max(Vint)
-
- @Override
- protected void flushBlock() throws IOException {
- int upto = 0;
-
- boolean allOnes = true;
- // encode ints
- for(int i=0;i<buffer.length;i++) {
- int j = buffer[i];
- if (j != 1) {
- allOnes = false;
- }
- while ((j & ~0x7F) != 0) {
- bytes[upto++] = (byte)((j & 0x7f) | 0x80);
- j >>>= 7;
- }
- bytes[upto++] = (byte)j;
- }
-
- if (allOnes) {
- // the most common int pattern (all 1's)
- // write a special header (numBytes=0) for this case.
- out.writeVInt(0);
- } else {
- // write header (length in bytes)
- out.writeVInt(upto);
-
- // write block
- out.writeBytes(bytes, 0, upto);
- }
- }
- };
- }
- }
-
- @Override
- public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
- // TODO: implement a new PostingsWriterBase to improve skip-settings
- PostingsWriterBase postingsWriter = new SepPostingsWriter(state, new BulkVIntFactory());
- boolean success = false;
- try {
- FieldsConsumer ret = new BlockTreeTermsWriter(state,
- postingsWriter,
- minBlockSize,
- maxBlockSize);
- success = true;
- return ret;
- } finally {
- if (!success) {
- postingsWriter.close();
- }
- }
- }
-
- @Override
- public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException {
- PostingsReaderBase postingsReader = new SepPostingsReader(state.dir,
- state.fieldInfos,
- state.segmentInfo,
- state.context,
- new BulkVIntFactory(),
- state.segmentSuffix);
-
- boolean success = false;
- try {
- FieldsProducer ret = new BlockTreeTermsReader(state.dir,
- state.fieldInfos,
- state.segmentInfo.name,
- postingsReader,
- state.context,
- state.segmentSuffix,
- state.termsIndexDivisor);
- success = true;
- return ret;
- } finally {
- if (!success) {
- postingsReader.close();
- }
- }
- }
-}
diff --git a/lucene/core/src/resources/META-INF/services/org.apache.lucene.codecs.PostingsFormat b/lucene/core/src/resources/META-INF/services/org.apache.lucene.codecs.PostingsFormat
index 8a246a8a29d..7bc89a047fe 100644
--- a/lucene/core/src/resources/META-INF/services/org.apache.lucene.codecs.PostingsFormat
+++ b/lucene/core/src/resources/META-INF/services/org.apache.lucene.codecs.PostingsFormat
@@ -17,7 +17,6 @@ org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat
org.apache.lucene.codecs.pulsing.Pulsing40PostingsFormat
org.apache.lucene.codecs.simpletext.SimpleTextPostingsFormat
org.apache.lucene.codecs.memory.MemoryPostingsFormat
-org.apache.lucene.codecs.bulkvint.BulkVIntPostingsFormat
org.apache.lucene.codecs.bloom.BloomFilteringPostingsFormat
org.apache.lucene.codecs.memory.DirectPostingsFormat
org.apache.lucene.codecs.block.BlockPostingsFormat