lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1364069 - /lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java
Date Sat, 21 Jul 2012 12:12:37 GMT
Author: rmuir
Date: Sat Jul 21 12:12:37 2012
New Revision: 1364069

URL: http://svn.apache.org/viewvc?rev=1364069&view=rev
Log:
fix bugs in DirectPF's lowFreq d-and-p-enum, set payload.bytes/offset/length in getPayload,
also skip payload pointer correctly when scanning over deleted docs in nextDoc

Modified:
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java?rev=1364069&r1=1364068&r2=1364069&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java
Sat Jul 21 12:12:37 2012
@@ -1680,8 +1680,10 @@ public class DirectPostingsFormat extend
     private int skipPositions;
     private int startOffset;
     private int endOffset;
+    private int lastPayloadOffset;
     private int payloadOffset;
     private int payloadLength;
+    private byte[] payloadBytes;
 
     public LowFreqDocsAndPositionsEnum(Bits liveDocs, boolean hasOffsets, boolean hasPayloads)
{
       this.liveDocs = liveDocs;
@@ -1708,7 +1710,7 @@ public class DirectPostingsFormat extend
       endOffset = -1;
       docID = -1;
       payloadLength = 0;
-      payload.bytes = payloadBytes;
+      this.payloadBytes = payloadBytes;
       return this;
     }
 
@@ -1741,7 +1743,17 @@ public class DirectPostingsFormat extend
             skipPositions = freq;
             return docID;
           }
-          upto += posMult * freq;
+          if (hasPayloads) {
+            for(int i=0;i<freq;i++) {
+              upto++;
+              if (hasOffsets) {
+                upto += 2;
+              }
+              payloadOffset += postings[upto++];
+            }
+          } else {
+            upto += posMult * freq;
+          }
         }
       }
 
@@ -1769,7 +1781,7 @@ public class DirectPostingsFormat extend
       }
       if (hasPayloads) {
         payloadLength = postings[upto++];
-        payload.offset = payloadOffset;
+        lastPayloadOffset = payloadOffset;
         payloadOffset += payloadLength;
       }
       return pos;
@@ -1802,6 +1814,8 @@ public class DirectPostingsFormat extend
     @Override
     public BytesRef getPayload() {
       if (payloadLength > 0) {
+        payload.bytes = payloadBytes;
+        payload.offset = lastPayloadOffset;
         payload.length = payloadLength;
         payloadLength = 0;
         return payload;



Mime
View raw message