Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
PHP driver - problem with batchSize and sorting
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Matt Parlane  
View profile  
 More options Aug 14 2012, 12:31 am
From: Matt Parlane <matt.parl...@gmail.com>
Date: Mon, 13 Aug 2012 21:31:06 -0700 (PDT)
Local: Tues, Aug 14 2012 12:31 am
Subject: PHP driver - problem with batchSize and sorting

Hi all...

I added the following test:

diff --git a/tests/MongoCursorTest.php b/tests/MongoCursorTest.php
index 9519f55..ffd9aa5 100644
--- a/tests/MongoCursorTest.php
+++ b/tests/MongoCursorTest.php
@@ -786,6 +786,15 @@ class MongoCursorTest extends
PHPUnit_Framework_TestCase
             }
         }
         $this->assertEquals(2000, $count);
+
+        $count = 0;
+        $cursor->reset();
+        $cursor->batchSize(20)->sort(array('y' => 1));
+        while ($cursor->hasNext()) {
+            $cursor->getNext();
+            $count++;
+        }
+        $this->assertEquals(2000, $count);
     }

     public function testExplainReset() {

And it fails:

2) MongoCursorTest::testBatchSize
Failed asserting that 20 matches expected 2000.

/home/wg/mongo-php-driver/tests/MongoCursorTest.php:797

From my reading of the docs, the test should pass -- am I right?

If I am, I can send a pull request with the new test. I'd much rather send
a pull request with a fix as well, but I haven't been able to figure out
what's going wrong from looking through the driver source.

Thanks,

Matt


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Derick Rethans  
View profile  
 More options Aug 14 2012, 6:06 am
From: Derick Rethans <der...@10gen.com>
Date: Tue, 14 Aug 2012 11:06:12 +0100 (BST)
Local: Tues, Aug 14 2012 6:06 am
Subject: Re: [mongodb-dev] PHP driver - problem with batchSize and sorting
Hi Matt!

On Mon, 13 Aug 2012, Matt Parlane wrote:
> I added the following test:

> diff --git a/tests/MongoCursorTest.php b/tests/MongoCursorTest.php
> index 9519f55..ffd9aa5 100644
> --- a/tests/MongoCursorTest.php
> +++ b/tests/MongoCursorTest.php

Just FYI: We're migrating away from the phpunit tests and instead will
use the phpt tests (in the tests directory too)

Maybe, it might have to do with the $cursor->reset() or something. Could
you please file a bugreport at https://jira.mongodb.org/browse/PHP so
that we can track this? We'll take it from there then. It would be best
if it contained a self-contained script (just a .php) file instead of a
patch to a phpunit test.

cheers,
Derick

--
http://mongodb.org | http://derickrethans.nl
twitter: @derickr and @mongodb


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roman Skvazh  
View profile   Translate to Translated (View Original)
 More options Aug 16 2012, 9:53 am
From: Roman Skvazh <roman.skv...@gmail.com>
Date: Thu, 16 Aug 2012 06:53:57 -0700 (PDT)
Local: Thurs, Aug 16 2012 9:53 am
Subject: Re: PHP driver - problem with batchSize and sorting

I confirm that there is a problem with batchSize and sort. (I tested on
system.profile collection on slave)

вторник, 14 августа 2012 г., 8:31:06 UTC+4 пользователь Matt Parlane
написал:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex Montgomery  
View profile  
 More options Sep 25 2012, 8:46 am
From: Alex Montgomery <alexander.h.montgom...@gmail.com>
Date: Tue, 25 Sep 2012 05:46:06 -0700 (PDT)
Local: Tues, Sep 25 2012 8:46 am
Subject: Re: [mongodb-dev] PHP driver - problem with batchSize and sorting

Hello all,

I am seeing a similar issue.  The only difference between my code and what
Matt has written is the order in which I set the batchSize and sort on the
cursor.  

I do something like:
$cursor = $mongo->{$table_name}->find($mongo_args)->sort(array('ts' => 1));
$cursor->batchSize(5000);

Would this cause any discrepancies.  Derick, I read your article on how
Mongo cursors work in PHP ... really great stuff.  It is this article that
inspired me to use the batchSize because the logs I am pulling from mongo
are enormous.  Any idea on when this issue might be resolved?

Regards,
Alex


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Derick Rethans  
View profile  
 More options Sep 25 2012, 11:48 am
From: Derick Rethans <der...@10gen.com>
Date: Tue, 25 Sep 2012 10:48:51 -0500 (CDT)
Local: Tues, Sep 25 2012 11:48 am
Subject: Re: [mongodb-dev] PHP driver - problem with batchSize and sorting

On Tue, 25 Sep 2012, Alex Montgomery wrote:
> Hello all,

> I am seeing a similar issue.  The only difference between my code and what
> Matt has written is the order in which I set the batchSize and sort on the
> cursor.  

> I do something like:
> $cursor = $mongo->{$table_name}->find($mongo_args)->sort(array('ts' => 1));
> $cursor->batchSize(5000);

Order doesn't matter, as the query only gets send to the server when you
start iterating with foreach().

> Would this cause any discrepancies.  Derick, I read your article on
> how Mongo cursors work in PHP ... really great stuff.  It is this
> article that inspired me to use the batchSize because the logs I am
> pulling from mongo are enormous.  Any idea on when this issue might be
> resolved?

The thread initiator didn't give us an issue - if you can create one
with a full dataset and example for us to try to reproduce it, we'd be
happy to look at it.

cheers,
Derick

--
{
  website: [ "http://mongodb.org", "http://derickrethans.nl" ],
  twitter: [ "@derickr", "@mongodb" ]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »