google-code-export / objectify-appengine

Automatically exported from code.google.com/p/objectify-appengine
MIT License
1 stars 0 forks source link

Issue with cursor #182

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a query
2. Get an entity
3. Get the cursor

What is the expected output? What do you see instead?
The cursor should point to the value I've just got. The cursor fails to point 
to the correct entity when the entity I got is the last of the chunk. This also 
fails when I ask for the cursor without having asked for the entity yet.

What version of the product are you using? On what operating system?
objectify-4.0b1

Please provide any additional information below.

Let's say I have an entity of 10 (from 0 to 9) elements and make a query with a 
chunk size of 5. When I create the query and get the cursor (without asking for 
an element yet) I get "4" as the current element. When I get the first element 
"0", and then get the cursor, I get "0", and that is correct.
This behavior is fine until I get to "4" (fifth element), where after getting 
the value "4" I ask for the cursor but instead of getting "4" I get "9" (the 
same situation as when starting the query). Let's suppose you read a value and 
get the cursor you would get the following

value 0 - cursor 0
...
value 4 - cursor 9
value 5 - cursor 5
..
value 9 - cursor 9

Now, let suppose I change the chunk size to 6, I'd get the following:

value 0 - cursor 0
...
value 5 - cursor 9
value 6 - cursor 6
..
value 9 - cursor 9

I think the value of the cursor should always be the same regardless of the 
value of the chunk size.

You can test it with this code snippet

QueryResultIterator<SomeEntity> iterator = 
ObjectifyService.ofy().load().type(SomeEntity.class)
        .chunk(20).iterator();
    while (iterator.hasNext()) {
      SomeEntity next = iterator.next();
      if (!iterator.getCursor().toString().contains(next.getId())) {
        System.out.println(next.getId() + " - " + iterator.getCursor()); // a few came up here and they shouldn't have
      }
    }

Thanks,
Juan

Original issue reported on code.google.com by juanma...@gmail.com on 11 Dec 2013 at 6:58

GoogleCodeExporter commented 9 years ago
Please try this with the latest release of Objectify; the iteration code has 
changed since b1 and it is much more thoroughly tested.

Original comment by lhori...@gmail.com on 12 Dec 2013 at 10:23

GoogleCodeExporter commented 9 years ago
Closing this as presumed fixed in more recent versions. If not, please comment 
and I will reopen the issue.

Original comment by lhori...@gmail.com on 6 Jan 2014 at 5:46