ddanielr commented on code in PR #5341:
URL: https://github.com/apache/accumulo/pull/5341#discussion_r2018920613


##########
core/src/main/java/org/apache/accumulo/core/util/PeekingIterator.java:
##########
@@ -91,4 +94,39 @@ public boolean hasNext() {
     }
     return top != null;
   }
+
+  /**
+   * Advances the underlying iterator looking for a match, inspecting up to 
{@code limit} elements
+   * from the iterator. If this method finds a match to the predicate, then it 
will return true and
+   * will be positioned before the matching element (peek() and next() will 
return the matching
+   * element). If this method does not find a match because the underlying 
iterator ended before
+   * {@code limit}, then it will return false and hasNext will also return 
false. Otherwise, if this
+   * method does not find a match, then it will return false and be positioned 
before the limit
+   * element (peek() and next() will return the {@code limit} element).
+   *
+   * @param predicate condition that we are looking for, parameter could be 
null, so the Predicate
+   *        implementation needs to handle this.
+   * @param limit number of times that we should look for a match, parameter 
should be a positive

Review Comment:
   ```suggestion
      * @param limit number of times that we should look for a match, parameter 
must be a positive
   ```
   `should` suggests that a negative value could be passed but is not 
recommended. However doing that always results in an  
`IllegalArgumentException` being thrown from line 118
   



##########
core/src/main/java/org/apache/accumulo/core/util/PeekingIterator.java:
##########
@@ -91,4 +94,39 @@ public boolean hasNext() {
     }
     return top != null;
   }
+
+  /**
+   * Advances the underlying iterator looking for a match, inspecting up to 
{@code limit} elements
+   * from the iterator. If this method finds a match to the predicate, then it 
will return true and
+   * will be positioned before the matching element (peek() and next() will 
return the matching
+   * element). If this method does not find a match because the underlying 
iterator ended before
+   * {@code limit}, then it will return false and hasNext will also return 
false. Otherwise, if this
+   * method does not find a match, then it will return false and be positioned 
before the limit
+   * element (peek() and next() will return the {@code limit} element).
+   *
+   * @param predicate condition that we are looking for, parameter could be 
null, so the Predicate
+   *        implementation needs to handle this.
+   * @param limit number of times that we should look for a match, parameter 
should be a positive
+   *        int
+   * @return true if an element matched the predicate or false otherwise. When 
true hasNext() will
+   *         return true and peek() and next() will return the matching 
element. When false
+   *         hasNext() may return false if the end has been reached, or 
hasNext() may return true in
+   *         which case peek() and next() will return the element {@code 
limit} positions ahead of
+   *         where this iterator was before this method was called.
+   */
+  public boolean findWithin(Predicate<E> predicate, int limit) {

Review Comment:
   I like the `findWithin` naming!



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to