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



##########
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 a bit confused about this assertion. Are we trying to assert no 
future node will be freed mistakenly? If that's the case, shouldn't we assert:
   ```
   assert outputNodes.get(outputFrom).inputNodes.stream().filter(n -> 
freeBefore > n).count() == 0
       : "FreeBefore " + freeBefore + " will free in use nodes"
   ```




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