<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:52:12 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-402] Only 1 batch is returned if batchSize on cursor is set and results are sorted</title>
                <link>https://jira.mongodb.org/browse/JAVA-402</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;import com.mongodb.*; &lt;br/&gt;
import org.junit.Test; &lt;br/&gt;
import java.net.UnknownHostException; &lt;/p&gt;

&lt;p&gt;public class MongoDriverSortAndBatchSizeTest { &lt;br/&gt;
    @Test &lt;br/&gt;
    public void batchSizeAndSortBy() throws UnknownHostException { &lt;br/&gt;
        Mongo mongo = new Mongo(new ServerAddress(&quot;localhost&quot;, &lt;br/&gt;
27017)); &lt;br/&gt;
        DB test = mongo.getDB(&quot;test&quot;); &lt;br/&gt;
        DBCollection collection = test.getCollection(&quot;test&quot;); &lt;br/&gt;
        // add 100 documents &lt;br/&gt;
        for (int i = 0; i &amp;lt; 1000; i++) &lt;/p&gt;
{ 
            collection.save(new BasicDBObject(&quot;sortby&quot;, i)); 
        }
&lt;p&gt; &lt;br/&gt;
        //get the cursor - batchsize = 500 &lt;br/&gt;
        DBCursor dbCursor = collection.find(new BasicDBObject()) &lt;br/&gt;
                .batchSize(500) &lt;br/&gt;
                .sort(new BasicDBObject(&quot;sortby&quot;, 1)); &lt;br/&gt;
        int counter = 0; &lt;br/&gt;
        try { &lt;br/&gt;
            //consume cursor &lt;br/&gt;
            while (dbCursor.hasNext()) &lt;/p&gt;
{ 
                DBObject next = dbCursor.next(); 
                counter++; 
            }
&lt;p&gt; &lt;br/&gt;
        } finally &lt;/p&gt;
{ 
            dbCursor.close(); 
        }
&lt;p&gt; &lt;br/&gt;
        assertEquals(1000, counter); //fails - counter is 500 &lt;br/&gt;
    } &lt;/p&gt;</description>
                <environment>Mongo 1.8.2&lt;br/&gt;
Java Driver 2.6.3&lt;br/&gt;
windows 32-bit</environment>
        <key id="20184">JAVA-402</key>
            <summary>Only 1 batch is returned if batchSize on cursor is set and results are sorted</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="antoine">Antoine Girbal</assignee>
                                    <reporter username="westernsam">sam owen</reporter>
                        <labels>
                    </labels>
                <created>Wed, 27 Jul 2011 08:30:36 +0000</created>
                <updated>Wed, 19 Oct 2016 14:17:24 +0000</updated>
                            <resolved>Mon, 24 Oct 2011 11:30:42 +0000</resolved>
                                    <version>2.6.3</version>
                                                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="79391" author="agiamas" created="Thu, 12 Jan 2012 18:34:05 +0000"  >&lt;p&gt;That&apos;s great news Scott, thanks!&lt;/p&gt;</comment>
                            <comment id="79359" author="scotthernandez" created="Thu, 12 Jan 2012 16:48:42 +0000"  >&lt;p&gt;Let me linked the server issue. 2.1.x is the current dev release. I expect a fix in 2.2.0 which is the next production release.&lt;/p&gt;</comment>
                            <comment id="79351" author="agiamas" created="Thu, 12 Jan 2012 16:19:55 +0000"  >&lt;p&gt;expected fix version? 2.2.1 maybe? &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                            <comment id="79336" author="scotthernandez" created="Thu, 12 Jan 2012 14:37:20 +0000"  >&lt;p&gt;This is still a server issue, and not a driver one.&lt;/p&gt;</comment>
                            <comment id="79335" author="agiamas" created="Thu, 12 Jan 2012 14:22:02 +0000"  >&lt;p&gt;Looks like this hasn&apos;t been fixed and should be reopened. We bumped into it again with DB 2.0.2 and Java driver 2.7.2. Looks like we are in the same boat as this guy:&lt;br/&gt;
&lt;a href=&quot;http://comments.gmane.org/gmane.comp.db.mongodb.user/56322&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://comments.gmane.org/gmane.comp.db.mongodb.user/56322&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;i.e. We are using an index for the query but it&apos;s doing scanAndOrder:true, with sort() we only get the first batch of results, without sort we are fine.&lt;/p&gt;</comment>
                            <comment id="62142" author="scotthernandez" created="Mon, 24 Oct 2011 11:30:43 +0000"  >&lt;p&gt;This was a server problem and has been fixed.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrhbun:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14720</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>