Query iterator - hasNext() is non-idempotent

query

#1

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?


#2

I would consider it a minor bug. It will be fixed in the next release.


#3

Java client 3.3.0 has been released:

http://www.aerospike.com/download/client/java/3.3.0/