From 0f062118e120702ad84343c3a29d84ee132fe968 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Tue, 9 Oct 2012 13:12:35 +0000 Subject: [PATCH] LUCENE-4399: Remove AppendingCodec git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1396020 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 5 + .../codecs/appending/AppendingCodec.java | 44 ----- .../appending/AppendingPostingsFormat.java | 80 --------- .../appending/AppendingTermsReader.java | 62 ------- .../appending/AppendingTermsWriter.java | 64 ------- .../lucene/codecs/appending/package.html | 25 --- .../codecs/block/BlockPostingsFormat.java | 4 +- .../codecs/blockterms/BlockTermsReader.java | 22 ++- .../codecs/blockterms/BlockTermsWriter.java | 13 +- .../blockterms/FixedGapTermsIndexReader.java | 23 ++- .../blockterms/FixedGapTermsIndexWriter.java | 10 +- .../VariableGapTermsIndexReader.java | 23 ++- .../VariableGapTermsIndexWriter.java | 10 +- .../services/org.apache.lucene.codecs.Codec | 1 - .../codecs/appending/TestAppendingCodec.java | 167 ------------------ .../TestAppendingPostingsFormat.java | 34 ---- .../codecs/block/TestBlockPostingsFormat.java | 1 - .../lucene/codecs/BlockTreeTermsReader.java | 37 ++-- .../lucene/codecs/BlockTreeTermsWriter.java | 24 +-- .../lucene40/Lucene40PostingsFormat.java | 11 +- .../lucene/store/BufferedIndexOutput.java | 24 --- .../lucene/store/ChecksumIndexOutput.java | 7 +- .../lucene/store/CompoundFileWriter.java | 6 - .../org/apache/lucene/store/FSDirectory.java | 7 - .../org/apache/lucene/store/IndexOutput.java | 5 - .../apache/lucene/store/RAMOutputStream.java | 13 -- .../apache/lucene/util/SlowRAMDirectory.java | 1 - .../lucene/store/NativeUnixDirectory.java | 20 --- .../lucene/store/MockIndexOutputWrapper.java | 5 - .../util/TestRuleSetupAndRestoreClassEnv.java | 3 - .../lucene/util/ThrottledIndexOutput.java | 6 - 31 files changed, 114 insertions(+), 643 deletions(-) delete mode 100644 lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingCodec.java delete mode 100644 lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingPostingsFormat.java delete mode 100644 lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingTermsReader.java delete mode 100644 lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingTermsWriter.java delete mode 100644 lucene/codecs/src/java/org/apache/lucene/codecs/appending/package.html delete mode 100644 lucene/codecs/src/test/org/apache/lucene/codecs/appending/TestAppendingCodec.java delete mode 100644 lucene/codecs/src/test/org/apache/lucene/codecs/appending/TestAppendingPostingsFormat.java diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 4e71bb03937..d4125f92011 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -44,6 +44,11 @@ New Features the suggester to ignore such variations. (Robert Muir, Sudarshan Gaikaiwari, Mike McCandless) +API Changes + +* LUCENE-4399: Deprecated AppendingCodec. Lucene's term dictionaries + no longer seek when writing. (Adrien Grand, Robert Muir) + Bug Fixes * LUCENE-1822: BaseFragListBuilder hard-coded 6 char margin is too naive. diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingCodec.java b/lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingCodec.java deleted file mode 100644 index f80c1d076f5..00000000000 --- a/lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingCodec.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.lucene.codecs.appending; - -/* - * 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 org.apache.lucene.codecs.FilterCodec; -import org.apache.lucene.codecs.PostingsFormat; -import org.apache.lucene.codecs.lucene40.Lucene40Codec; - -/** - * This codec uses an index format that is very similar to - * {@link Lucene40Codec} but works on append-only outputs, such as plain output - * streams and append-only filesystems. - * - * @lucene.experimental - */ -public final class AppendingCodec extends FilterCodec { - - public AppendingCodec() { - super("Appending", new Lucene40Codec()); - } - - private final PostingsFormat postings = new AppendingPostingsFormat(); - - @Override - public PostingsFormat postingsFormat() { - return postings; - } - -} diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingPostingsFormat.java b/lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingPostingsFormat.java deleted file mode 100644 index a96b3a6169b..00000000000 --- a/lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingPostingsFormat.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.apache.lucene.codecs.appending; - -/* - * 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.codecs.BlockTreeTermsWriter; -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.lucene40.Lucene40PostingsReader; -import org.apache.lucene.codecs.lucene40.Lucene40PostingsWriter; -import org.apache.lucene.index.SegmentReadState; -import org.apache.lucene.index.SegmentWriteState; - -/** - * Appending postings impl. - */ -final class AppendingPostingsFormat extends PostingsFormat { - public static String CODEC_NAME = "Appending"; - - public AppendingPostingsFormat() { - super(CODEC_NAME); - } - - @Override - public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException { - PostingsWriterBase docsWriter = new Lucene40PostingsWriter(state); - boolean success = false; - try { - FieldsConsumer ret = new AppendingTermsWriter(state, docsWriter, BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE, BlockTreeTermsWriter.DEFAULT_MAX_BLOCK_SIZE); - success = true; - return ret; - } finally { - if (!success) { - docsWriter.close(); - } - } - } - - @Override - public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException { - PostingsReaderBase postings = new Lucene40PostingsReader(state.dir, state.fieldInfos, state.segmentInfo, state.context, state.segmentSuffix); - - boolean success = false; - try { - FieldsProducer ret = new AppendingTermsReader( - state.dir, - state.fieldInfos, - state.segmentInfo, - postings, - state.context, - state.segmentSuffix, - state.termsIndexDivisor); - success = true; - return ret; - } finally { - if (!success) { - postings.close(); - } - } - } -} diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingTermsReader.java b/lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingTermsReader.java deleted file mode 100644 index f89eae1af6e..00000000000 --- a/lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingTermsReader.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.lucene.codecs.appending; - -/* - * 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.codecs.BlockTreeTermsReader; -import org.apache.lucene.codecs.CodecUtil; -import org.apache.lucene.codecs.PostingsReaderBase; -import org.apache.lucene.index.FieldInfos; -import org.apache.lucene.index.SegmentInfo; -import org.apache.lucene.store.Directory; -import org.apache.lucene.store.IOContext; -import org.apache.lucene.store.IndexInput; - -/** - * Reads append-only terms from {@link AppendingTermsWriter} - * @lucene.experimental - */ -public class AppendingTermsReader extends BlockTreeTermsReader { - - public AppendingTermsReader(Directory dir, FieldInfos fieldInfos, SegmentInfo info, PostingsReaderBase postingsReader, - IOContext ioContext, String segmentSuffix, int indexDivisor) throws IOException { - super(dir, fieldInfos, info, postingsReader, ioContext, segmentSuffix, indexDivisor); - } - - @Override - protected void readHeader(IndexInput input) throws IOException { - CodecUtil.checkHeader(input, AppendingTermsWriter.TERMS_CODEC_NAME, - AppendingTermsWriter.TERMS_VERSION_START, - AppendingTermsWriter.TERMS_VERSION_CURRENT); - } - - @Override - protected void readIndexHeader(IndexInput input) throws IOException { - CodecUtil.checkHeader(input, AppendingTermsWriter.TERMS_INDEX_CODEC_NAME, - AppendingTermsWriter.TERMS_INDEX_VERSION_START, - AppendingTermsWriter.TERMS_INDEX_VERSION_CURRENT); - } - - @Override - protected void seekDir(IndexInput input, long dirOffset) throws IOException { - input.seek(input.length() - Long.SIZE / 8); - long offset = input.readLong(); - input.seek(offset); - } -} diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingTermsWriter.java b/lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingTermsWriter.java deleted file mode 100644 index 8025a2198b6..00000000000 --- a/lucene/codecs/src/java/org/apache/lucene/codecs/appending/AppendingTermsWriter.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.apache.lucene.codecs.appending; - -/* - * 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.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; - -/** - * Append-only version of {@link BlockTreeTermsWriter} - * @lucene.experimental - */ -public class AppendingTermsWriter extends BlockTreeTermsWriter { - final static String TERMS_CODEC_NAME = "APPENDING_TERMS_DICT"; - final static int TERMS_VERSION_START = 0; - final static int TERMS_VERSION_CURRENT = TERMS_VERSION_START; - - final static String TERMS_INDEX_CODEC_NAME = "APPENDING_TERMS_INDEX"; - final static int TERMS_INDEX_VERSION_START = 0; - final static int TERMS_INDEX_VERSION_CURRENT = TERMS_INDEX_VERSION_START; - - public AppendingTermsWriter(SegmentWriteState state, PostingsWriterBase postingsWriter, int minItemsInBlock, int maxItemsInBlock) throws IOException { - super(state, postingsWriter, minItemsInBlock, maxItemsInBlock); - } - - @Override - protected void writeHeader(IndexOutput out) throws IOException { - CodecUtil.writeHeader(out, TERMS_CODEC_NAME, TERMS_VERSION_CURRENT); - } - - @Override - protected void writeIndexHeader(IndexOutput out) throws IOException { - CodecUtil.writeHeader(out, TERMS_INDEX_CODEC_NAME, TERMS_INDEX_VERSION_CURRENT); - } - - @Override - protected void writeTrailer(IndexOutput out, long dirStart) throws IOException { - out.writeLong(dirStart); - } - - @Override - protected void writeIndexTrailer(IndexOutput indexOut, long dirStart) throws IOException { - indexOut.writeLong(dirStart); - } -} diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/appending/package.html b/lucene/codecs/src/java/org/apache/lucene/codecs/appending/package.html deleted file mode 100644 index 940808a1b41..00000000000 --- a/lucene/codecs/src/java/org/apache/lucene/codecs/appending/package.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - -Codec for on append-only outputs, such as plain output streams and append-only filesystems. - - \ No newline at end of file diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/block/BlockPostingsFormat.java b/lucene/codecs/src/java/org/apache/lucene/codecs/block/BlockPostingsFormat.java index b26d0c65746..e3c0fc31291 100644 --- a/lucene/codecs/src/java/org/apache/lucene/codecs/block/BlockPostingsFormat.java +++ b/lucene/codecs/src/java/org/apache/lucene/codecs/block/BlockPostingsFormat.java @@ -118,8 +118,8 @@ import org.apache.lucene.util.packed.PackedInts; * *