[CSHARP-309] Change argument type to long Created: 24/Aug/11  Updated: 20/Mar/14  Resolved: 13/Sep/11

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.1
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Timofei Mironov Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: driver
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Driver 1.1
Mongo 1.8.3


Backwards Compatibility: Major Change

 Description   

In version 1.1 you changed type of return value of .Count() to long
So now we can have long-size count.

but we can't skip some long-size items becasue MongoCursor<T>.SetSkip and MongoCursor<T>.SetLimit()
have the int arguments both.

Please fix it.



 Comments   
Comment by Robert Stam [ 25/Aug/11 ]

This algorithm for paging will only work it the total count of documents in the collection is not too large. If you know in advance that the count is reasonable, you could just change the code like this:

var total = (int) cursor.Count(); // we know the count is small and will fit in an int
// etc...

Comment by Timofei Mironov [ 25/Aug/11 ]

Actualy not, we don't use large values for skip.
We meet it at the following case:

long total = cursor.Count()
long pageCount = total/pagesize; // can be long
var skip = pageNum*pagesize; // can be long if pageNum is long, 1 <= pageNum <= pageCount

cursor.Find(...).SetSkip(skip); // but argument is int

I know that this situation looks like a joke, because of what is the paging where count of pages is long.
But it is possible by theory. For example if we process the items of big collections by 10 or 100 pieces.

Comment by Robert Stam [ 24/Aug/11 ]

I don't think it makes sense to use 64 bit values here. If you are skipping more than 2^31 results the cursor will timeout before ever returning the first document. And normally the limit value will be relatively small also, on the order of a few hundred or thousand, and certainly less than 2^31.

What is your use case? Are you actually using large values for Skip and Limit?

Generated at Wed Feb 07 21:36:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.