glawson0 commented on a change in pull request #157:
URL: https://github.com/apache/lucene/pull/157#discussion_r641212886



##########
File path: 
lucene/analysis/common/src/java/org/apache/lucene/analysis/core/FlattenGraphFilter.java
##########
@@ -193,14 +194,25 @@ private boolean releaseBufferedToken() {
         }
         if (inputNode.tokens.size() == 0) {
           assert inputNode.nextOut == 0;
-          assert output.nextOut == 0;
           // Hole dest nodes should never be merged since 1) we always
           // assign them to a new output position, and 2) since they never
           // have arriving tokens they cannot be pushed:
-          assert output.inputNodes.size() == 1 : output.inputNodes.size();
+          // skip hole sources, but don't free until every input is checked
+          if (output.inputNodes.size() > 1) {
+            output.inputNodes.remove(output.nextOut);
+            if (output.nextOut < output.inputNodes.size()) {
+              continue;
+            }
+          }
+
           outputFrom++;
-          inputNodes.freeBefore(output.inputNodes.get(0));
+          int freeBefore = Collections.min(output.inputNodes);
+          assert outputNodes.get(outputFrom).inputNodes.stream().filter(n -> 
freeBefore < n).count()

Review comment:
       I'm nervous about iterating this list. It's going to scale with how many 
edges arrive at the same node in the output which _shouldn't_ be large. But 
that's a big risk for an assert 




-- 
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.

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