lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject svn commit: r1515695 - in /lucene/dev/branches/lucene3069/lucene/codecs/src: java/org/apache/lucene/codecs/temp/ resources/META-INF/services/
Date Tue, 20 Aug 2013 03:30:44 GMT
Author: han
Date: Tue Aug 20 03:30:43 2013
New Revision: 1515695

URL: http://svn.apache.org/r1515695
Log:
fix bug on TempNestedPF

Added:
    lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempNestedPulsingPostingsFormat.java
      - copied, changed from r1515469, lucene/dev/branches/lucene3069/lucene/test-framework/src/java/org/apache/lucene/codecs/nestedpulsing/NestedPulsingPostingsFormat.java
Modified:
    lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempPulsingPostingsReader.java
    lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempPulsingPostingsWriter.java
    lucene/dev/branches/lucene3069/lucene/codecs/src/resources/META-INF/services/org.apache.lucene.codecs.PostingsFormat

Copied: lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempNestedPulsingPostingsFormat.java
(from r1515469, lucene/dev/branches/lucene3069/lucene/test-framework/src/java/org/apache/lucene/codecs/nestedpulsing/NestedPulsingPostingsFormat.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempNestedPulsingPostingsFormat.java?p2=lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempNestedPulsingPostingsFormat.java&p1=lucene/dev/branches/lucene3069/lucene/test-framework/src/java/org/apache/lucene/codecs/nestedpulsing/NestedPulsingPostingsFormat.java&r1=1515469&r2=1515695&rev=1515695&view=diff
==============================================================================
--- lucene/dev/branches/lucene3069/lucene/test-framework/src/java/org/apache/lucene/codecs/nestedpulsing/NestedPulsingPostingsFormat.java
(original)
+++ lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempNestedPulsingPostingsFormat.java
Tue Aug 20 03:30:43 2013
@@ -1,4 +1,4 @@
-package org.apache.lucene.codecs.nestedpulsing;
+package org.apache.lucene.codecs.temp;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -19,17 +19,11 @@ package org.apache.lucene.codecs.nestedp
 
 import java.io.IOException;
 
-import org.apache.lucene.codecs.BlockTreeTermsReader;
-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.lucene41.Lucene41PostingsReader;
-import org.apache.lucene.codecs.lucene41.Lucene41PostingsWriter;
-import org.apache.lucene.codecs.pulsing.PulsingPostingsReader;
-import org.apache.lucene.codecs.pulsing.PulsingPostingsWriter;
+import org.apache.lucene.codecs.TempPostingsReaderBase;
+import org.apache.lucene.codecs.TempPostingsWriterBase;
 import org.apache.lucene.index.SegmentReadState;
 import org.apache.lucene.index.SegmentWriteState;
 import org.apache.lucene.util.IOUtils;
@@ -41,26 +35,26 @@ import org.apache.lucene.util.IOUtils;
 // TODO: if we create PulsingPostingsBaseFormat then we
 // can simplify this? note: I don't like the *BaseFormat
 // hierarchy, maybe we can clean that up...
-public final class NestedPulsingPostingsFormat extends PostingsFormat {
-  public NestedPulsingPostingsFormat() {
-    super("NestedPulsing");
+public final class TempNestedPulsingPostingsFormat extends PostingsFormat {
+  public TempNestedPulsingPostingsFormat() {
+    super("TempNestedPulsing");
   }
   
   @Override
   public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
-    PostingsWriterBase docsWriter = null;
-    PostingsWriterBase pulsingWriterInner = null;
-    PostingsWriterBase pulsingWriter = null;
+    TempPostingsWriterBase docsWriter = null;
+    TempPostingsWriterBase pulsingWriterInner = null;
+    TempPostingsWriterBase pulsingWriter = null;
     
     // Terms dict
     boolean success = false;
     try {
-      docsWriter = new Lucene41PostingsWriter(state);
+      docsWriter = new TempPostingsWriter(state);
 
-      pulsingWriterInner = new PulsingPostingsWriter(2, docsWriter);
-      pulsingWriter = new PulsingPostingsWriter(1, pulsingWriterInner);
-      FieldsConsumer ret = new BlockTreeTermsWriter(state, pulsingWriter, 
-          BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE, BlockTreeTermsWriter.DEFAULT_MAX_BLOCK_SIZE);
+      pulsingWriterInner = new TempPulsingPostingsWriter(state, 2, docsWriter);
+      pulsingWriter = new TempPulsingPostingsWriter(state, 1, pulsingWriterInner);
+      FieldsConsumer ret = new TempBlockTreeTermsWriter(state, pulsingWriter, 
+          TempBlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE, TempBlockTreeTermsWriter.DEFAULT_MAX_BLOCK_SIZE);
       success = true;
       return ret;
     } finally {
@@ -72,15 +66,15 @@ public final class NestedPulsingPostings
 
   @Override
   public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException {
-    PostingsReaderBase docsReader = null;
-    PostingsReaderBase pulsingReaderInner = null;
-    PostingsReaderBase pulsingReader = null;
+    TempPostingsReaderBase docsReader = null;
+    TempPostingsReaderBase pulsingReaderInner = null;
+    TempPostingsReaderBase pulsingReader = null;
     boolean success = false;
     try {
-      docsReader = new Lucene41PostingsReader(state.directory, state.fieldInfos, state.segmentInfo,
state.context, state.segmentSuffix);
-      pulsingReaderInner = new PulsingPostingsReader(docsReader);
-      pulsingReader = new PulsingPostingsReader(pulsingReaderInner);
-      FieldsProducer ret = new BlockTreeTermsReader(
+      docsReader = new TempPostingsReader(state.directory, state.fieldInfos, state.segmentInfo,
state.context, state.segmentSuffix);
+      pulsingReaderInner = new TempPulsingPostingsReader(state, docsReader);
+      pulsingReader = new TempPulsingPostingsReader(state, pulsingReaderInner);
+      FieldsProducer ret = new TempBlockTreeTermsReader(
                                                     state.directory, state.fieldInfos, state.segmentInfo,
                                                     pulsingReader,
                                                     state.context,

Modified: lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempPulsingPostingsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempPulsingPostingsReader.java?rev=1515695&r1=1515694&r2=1515695&view=diff
==============================================================================
--- lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempPulsingPostingsReader.java
(original)
+++ lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempPulsingPostingsReader.java
Tue Aug 20 03:30:43 2013
@@ -70,10 +70,12 @@ public class TempPulsingPostingsReader e
     version = CodecUtil.checkHeader(termsIn, TempPulsingPostingsWriter.CODEC,
                                     TempPulsingPostingsWriter.VERSION_START, 
                                     TempPulsingPostingsWriter.VERSION_CURRENT);
-    // nocommit: here open file to load field summary
     maxPositions = termsIn.readVInt();
     wrappedPostingsReader.init(termsIn);
-    if (version >= TempPulsingPostingsWriter.VERSION_META_ARRAY) {
+    if (wrappedPostingsReader instanceof TempPulsingPostingsReader || 
+        version < TempPulsingPostingsWriter.VERSION_META_ARRAY) {
+      fields = null;
+    } else {
       fields = new TreeMap<Integer, Integer>();
       String summaryFileName = IndexFileNames.segmentFileName(segmentState.segmentInfo.name,
segmentState.segmentSuffix, TempPulsingPostingsWriter.SUMMARY_EXTENSION);
       IndexInput in = null;
@@ -90,9 +92,6 @@ public class TempPulsingPostingsReader e
       } finally {
         IOUtils.closeWhileHandlingException(in);
       }
-    } else {
-      assert false;
-      fields = null;
     }
   }
 
@@ -164,11 +163,6 @@ public class TempPulsingPostingsReader e
     long count = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)
>= 0 ? termState.totalTermFreq : termState.docFreq;
     //System.out.println("  count=" + count + " threshold=" + maxPositions);
 
-    // term dict have no chance to init this
-    // nocommit: nuke this?
-    if (termState.termBlockOrd == 0) {  
-      termState.wrappedTermState.termBlockOrd = 0;
-    }
     if (count <= maxPositions) {
       // Inlined into terms dict -- just read the byte[] blob in,
       // but don't decode it now (we only decode when a DocsEnum
@@ -183,14 +177,12 @@ public class TempPulsingPostingsReader e
       // blob for this term)...
       in.readBytes(termState.postings, 0, termState.postingsSize);
       //System.out.println("  inlined bytes=" + termState.postingsSize);
-      termState.absolute = absolute ? true : termState.absolute;
+      termState.absolute = termState.absolute || absolute;
     } else {
       //System.out.println("  not inlined");
-      final int longsSize = fields.get(fieldInfo.number);
+      final int longsSize = fields == null ? 0 : fields.get(fieldInfo.number);
       if (termState.longs == null) {
         termState.longs = new long[longsSize];
-      } else {
-        assert termState.longs.length == longsSize;
       }
       for (int i = 0; i < longsSize; i++) {
         termState.longs[i] = in.readVLong();
@@ -199,7 +191,6 @@ public class TempPulsingPostingsReader e
       termState.wrappedTermState.docFreq = termState.docFreq;
       termState.wrappedTermState.totalTermFreq = termState.totalTermFreq;
       wrappedPostingsReader.decodeTerm(termState.longs, in, fieldInfo, termState.wrappedTermState,
termState.absolute);
-      termState.wrappedTermState.termBlockOrd++;
       termState.absolute = false;
     }
   }

Modified: lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempPulsingPostingsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempPulsingPostingsWriter.java?rev=1515695&r1=1515694&r2=1515695&view=diff
==============================================================================
--- lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempPulsingPostingsWriter.java
(original)
+++ lucene/dev/branches/lucene3069/lucene/codecs/src/java/org/apache/lucene/codecs/temp/TempPulsingPostingsWriter.java
Tue Aug 20 03:30:43 2013
@@ -384,7 +384,6 @@ public final class TempPulsingPostingsWr
     assert empty.length == 0;
     this.absolute = this.absolute || absolute;
     if (state.bytes == null) {
-      assert longsSize > 0;
       wrappedPostingsWriter.encodeTerm(longs, buffer, fieldInfo, state.wrappedState, this.absolute);
       for (int i = 0; i < longsSize; i++) {
         out.writeVLong(longs[i]);
@@ -395,14 +394,17 @@ public final class TempPulsingPostingsWr
     } else {
       out.writeVInt(state.bytes.length);
       out.writeBytes(state.bytes, 0, state.bytes.length);
-      this.absolute = absolute ? true : this.absolute;
+      this.absolute = this.absolute || absolute;
     }
   }
 
   @Override
   public void close() throws IOException {
     wrappedPostingsWriter.close();
-    assert (VERSION_CURRENT >= VERSION_META_ARRAY);
+    if (wrappedPostingsWriter instanceof TempPulsingPostingsWriter ||
+        VERSION_CURRENT < VERSION_META_ARRAY) {
+      return;
+    }
     String summaryFileName = IndexFileNames.segmentFileName(segmentState.segmentInfo.name,
segmentState.segmentSuffix, SUMMARY_EXTENSION);
     IndexOutput out = null;
     try {

Modified: lucene/dev/branches/lucene3069/lucene/codecs/src/resources/META-INF/services/org.apache.lucene.codecs.PostingsFormat
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3069/lucene/codecs/src/resources/META-INF/services/org.apache.lucene.codecs.PostingsFormat?rev=1515695&r1=1515694&r2=1515695&view=diff
==============================================================================
--- lucene/dev/branches/lucene3069/lucene/codecs/src/resources/META-INF/services/org.apache.lucene.codecs.PostingsFormat
(original)
+++ lucene/dev/branches/lucene3069/lucene/codecs/src/resources/META-INF/services/org.apache.lucene.codecs.PostingsFormat
Tue Aug 20 03:30:43 2013
@@ -22,3 +22,4 @@ org.apache.lucene.codecs.temp.TempBlockP
 org.apache.lucene.codecs.temp.TempPulsing41PostingsFormat
 org.apache.lucene.codecs.temp.TempFSTPulsing41PostingsFormat
 org.apache.lucene.codecs.temp.TempFSTOrdPulsing41PostingsFormat
+org.apache.lucene.codecs.temp.TempNestedPulsingPostingsFormat



Mime
View raw message