Browse files

Fix BatchSize -1 (missed merge)

  • Loading branch information...
1 parent a3ed7f3 commit 3b1267c9ab2861fb8c5d81e2358154c84c2ca8a0 @krestenkrab krestenkrab committed Apr 22, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/riak_mongo_riak.erl
View
6 src/riak_mongo_riak.erl
@@ -115,8 +115,10 @@ find(#mongo_query{dbcoll=Bucket, selector=Selector, projector=Projection, batchs
if
BatchSize == 0 ->
Batch = ?DEFAULT_FIND_SIZE;
+ BatchSize == -1 ->
+ Batch = 1;
true ->
- Batch = abs(BatchSize)
+ Batch = BatchSize
end,
error_logger:info_msg("Find executed ~p, ~p, ~p~n", [Projection, CompiledQuery, Project]),
@@ -131,7 +133,7 @@ find(#mongo_query{dbcoll=Bucket, selector=Selector, projector=Projection, batchs
case cursor_get_results(CursorPID, Batch) of
{more, StartingFrom, Documents} ->
- if BatchSize < 0 ->
+ if BatchSize == -1 ->
CursorPID ! die,
{ok,
#mongo_reply{ startingfrom = StartingFrom,

3 comments on commit 3b1267c

@pavlobaron
Owner

we still need to deal with BatchSize < -1. There is a corresponding JS command for that. Anything that is < 0 just delivers abs(BatchSize) and lets the cursor die: http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-OPQUERY

@krestenkrab
Collaborator

Goot catch. Fixed in krestenkrab@32c16f1

@krestenkrab
Collaborator

How about this:

            if
                BatchSize == 0 ->
                    KillCursor = false,
                    FindSize = ?DEFAULT_FIND_SIZE;
                BatchSize < 0 ->
                    KillCursor = true,
                    FindSize = -BatchSize;
                BatchSize == 1 ->
                    KillCursor = true,
                    FindSize = BatchSize;
                true ->
                    KillCursor = false,
                    FindSize = BatchSize
            end,

Just pushed code to this efect on krestenkrab/master

Please sign in to comment.