jpountz commented on code in PR #13892:
URL: https://github.com/apache/lucene/pull/13892#discussion_r1797694604


##########
lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsReader.java:
##########
@@ -1326,8 +1270,88 @@ public BytesRef getPayload() {
     }
 
     @Override
-    public int docID() {
-      return doc;
+    public long cost() {
+      return docFreq;
+    }
+
+    private final Impacts impacts =
+        new Impacts() {
+
+          private final ByteArrayDataInput scratch = new ByteArrayDataInput();
+
+          @Override
+          public int numLevels() {
+            int numLevels = 0;
+            if (level0LastDocID != NO_MORE_DOCS) {
+              numLevels++;
+            }
+            if (level1LastDocID != NO_MORE_DOCS) {
+              numLevels++;
+            }
+            if (numLevels == 0) {
+              numLevels++;
+            }
+            return numLevels;

Review Comment:
   Nit: this method could be simplified to `return level1LastDocID != 
NO_MORE_DOCS ? 2 : 1;`



##########
lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsReader.java:
##########
@@ -1326,8 +1270,88 @@ public BytesRef getPayload() {
     }
 
     @Override
-    public int docID() {
-      return doc;
+    public long cost() {
+      return docFreq;
+    }
+
+    private final Impacts impacts =
+        new Impacts() {
+
+          private final ByteArrayDataInput scratch = new ByteArrayDataInput();
+
+          @Override
+          public int numLevels() {
+            int numLevels = 0;
+            if (level0LastDocID != NO_MORE_DOCS) {
+              numLevels++;
+            }
+            if (level1LastDocID != NO_MORE_DOCS) {
+              numLevels++;
+            }
+            if (numLevels == 0) {
+              numLevels++;
+            }
+            return numLevels;
+          }
+
+          @Override
+          public int getDocIdUpTo(int level) {
+            if (level == 0) {
+              return level0LastDocID;
+            }
+            return level == 1 ? level1LastDocID : NO_MORE_DOCS;
+          }
+
+          @Override
+          public List<Impact> getImpacts(int level) {
+            if (level == 0 && level0LastDocID != NO_MORE_DOCS) {
+              return readImpacts(level0SerializedImpacts, level0Impacts);
+            }
+            if (level == 1 && level1LastDocID != NO_MORE_DOCS) {

Review Comment:
   Nit: The second condition is not necessary I believe (ie. it could be just 
`if (level == 1)`) as we only ever return 2 levels if `level1LastDocID != 
NO_MORE_DOCS`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to