Hi,
It looks like that hasNext()
uses next()
and as result hasNext()
is non-idempotent.
As an example:
QueryPolicy policy = new QueryPolicy();
policy.priority = Priority.LOW;
Statement statement = new Statement();
statement.setNamespace(NAMESPACE);
statement.setSetName(SET_NAME);
RecordSet recordSet = client.query(policy, statement);
int counter = 0;
Iterator<KeyRecord> iterator = recordSet.iterator();
while (iterator.hasNext()) {
KeyRecord next = iterator.next();
counter++;
//..some kind of procession
if (!iterator.hasNext()) {
// ....some kind of logic
}
}
System.err.println("Totally scanned " + counter);
In this case only half of records will be processed, because additional hasNext()
inside of loop implicitly calls next()
.
Question: is it a bug?