You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2011/10/26 22:44:06 UTC

svn commit: r1189441 - in /lucene/dev/branches/lucene2621/lucene/contrib/misc/src: java/org/apache/lucene/index/codecs/appending/ test/org/apache/lucene/index/codecs/appending/

Author: rmuir
Date: Wed Oct 26 20:44:05 2011
New Revision: 1189441

URL: http://svn.apache.org/viewvc?rev=1189441&view=rev
Log:
LUCENE-3490: fix AppendingCodec

Added:
    lucene/dev/branches/lucene2621/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingCodec.java   (with props)
Modified:
    lucene/dev/branches/lucene2621/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingPostingsFormat.java
    lucene/dev/branches/lucene2621/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java

Added: lucene/dev/branches/lucene2621/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingCodec.java?rev=1189441&view=auto
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingCodec.java (added)
+++ lucene/dev/branches/lucene2621/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingCodec.java Wed Oct 26 20:44:05 2011
@@ -0,0 +1,54 @@
+package org.apache.lucene.index.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.index.codecs.Codec;
+import org.apache.lucene.index.codecs.DefaultFieldsFormat;
+import org.apache.lucene.index.codecs.FieldsFormat;
+import org.apache.lucene.index.codecs.PostingsFormat;
+import org.apache.lucene.index.codecs.lucene40.Lucene40PostingsFormat;
+
+/**
+ * This codec extends {@link Lucene40PostingsFormat} to work on append-only outputs, such
+ * as plain output streams and append-only filesystems.
+ *
+ * <p>Note: compound file format feature is not compatible with
+ * this codec.  You must call both
+ * LogMergePolicy.setUseCompoundFile(false) and
+ * LogMergePolicy.setUseCompoundDocStore(false) to disable
+ * compound file format.</p>
+ * @lucene.experimental
+ */
+public class AppendingCodec extends Codec {
+  public AppendingCodec() {
+    super("Appending");
+  }
+
+  private final PostingsFormat postings = new AppendingPostingsFormat();
+  private final FieldsFormat fields = new DefaultFieldsFormat();
+
+  @Override
+  public PostingsFormat postingsFormat() {
+    return postings;
+  }
+
+  @Override
+  public FieldsFormat fieldsFormat() {
+    return fields;
+  }
+}

Modified: lucene/dev/branches/lucene2621/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingPostingsFormat.java?rev=1189441&r1=1189440&r2=1189441&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingPostingsFormat.java (original)
+++ lucene/dev/branches/lucene2621/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingPostingsFormat.java Wed Oct 26 20:44:05 2011
@@ -43,17 +43,9 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.util.BytesRef;
 
 /**
- * This codec extends {@link Lucene40PostingsFormat} to work on append-only outputs, such
- * as plain output streams and append-only filesystems.
- *
- * <p>Note: compound file format feature is not compatible with
- * this codec.  You must call both
- * LogMergePolicy.setUseCompoundFile(false) and
- * LogMergePolicy.setUseCompoundDocStore(false) to disable
- * compound file format.</p>
- * @lucene.experimental
+ * Appending postings impl
  */
-public class AppendingPostingsFormat extends PostingsFormat {
+class AppendingPostingsFormat extends PostingsFormat {
   public static String CODEC_NAME = "Appending";
   
   public AppendingPostingsFormat() {

Modified: lucene/dev/branches/lucene2621/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java?rev=1189441&r1=1189440&r2=1189441&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java (original)
+++ lucene/dev/branches/lucene2621/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java Wed Oct 26 20:44:05 2011
@@ -34,7 +34,7 @@ import org.apache.lucene.index.MultiFiel
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.index.TermsEnum.SeekStatus;
-import org.apache.lucene.index.codecs.PostingsFormat;
+import org.apache.lucene.index.codecs.Codec;
 import org.apache.lucene.index.codecs.CodecProvider;
 import org.apache.lucene.index.codecs.SegmentInfosReader;
 import org.apache.lucene.index.codecs.SegmentInfosWriter;
@@ -50,18 +50,22 @@ import org.apache.lucene.util.Version;
 public class TestAppendingCodec extends LuceneTestCase {
   
   static class AppendingCodecProvider extends CodecProvider {
-    PostingsFormat appending = new AppendingPostingsFormat();
+    Codec appending = new AppendingCodec();
     SegmentInfosWriter infosWriter = new AppendingSegmentInfosWriter();
     SegmentInfosReader infosReader = new AppendingSegmentInfosReader();
-    public AppendingCodecProvider() {
-      setDefaultFieldCodec(appending.name);
-    }
+
+    // TODO: a little evil that we return appending regardless of what we are asked for :)
     @Override
-    public PostingsFormat lookup(String name) {
+    public Codec lookup(String name) {
       return appending;
     }
    
     @Override
+    public Codec getDefaultCodec() {
+      return appending;
+    }
+
+    @Override
     public SegmentInfosReader getSegmentInfosReader() {
       return infosReader;
     }