<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:26 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-65] BasicDBObject.entrySet().iterator does not produce values in the same order as BasicDBObject.keySet()</title>
                <link>https://jira.mongodb.org/browse/JAVA-65</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;BasicDBObject preserves insertion order of keys - and really needs to - so keySet() is returned in insertion order, BUT it does not provide this functionality for entrySet() - which I generally use a lot more often than keySet() when iterating through maps.&lt;/p&gt;

&lt;p&gt;Digging into the code I see BasicDBObject is a HashMap combined with an OrderedSet was used to maintain insertion key order, but entrySet is not overridden.&lt;/p&gt;

&lt;p&gt;I&apos;m guessing the original author was unaware of  java.util.LinkedHashMap. I changed BasicDBObject to extend LinkedHashMap, and removed _keys. All unit tests pass. I&apos;m seeing pretty significant speed improvements in some benchmarks I put together to compare implementations. And the code is a little simpler too.&lt;/p&gt;

&lt;p&gt;I have attached a modified copy of BasicDBObject for consideration, as well as a copy of DBObjectTest that includes a new test - testEntrySetOrder that asserts that the entrySet and keySet are both maintained in insertion order.&lt;/p&gt;</description>
                <environment>All</environment>
        <key id="11022">JAVA-65</key>
            <summary>BasicDBObject.entrySet().iterator does not produce values in the same order as BasicDBObject.keySet()</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="eliot">Eliot Horowitz</assignee>
                                    <reporter username="keithbranton">Keith Branton</reporter>
                        <labels>
                    </labels>
                <created>Fri, 18 Dec 2009 15:30:12 +0000</created>
                <updated>Wed, 13 Jan 2010 15:51:03 +0000</updated>
                            <resolved>Fri, 18 Dec 2009 15:52:53 +0000</resolved>
                                    <version>1.1</version>
                                    <fixVersion>1.2</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="11418" author="eliot" created="Fri, 18 Dec 2009 15:52:53 +0000"  >&lt;p&gt;Thanks - merged this in.&lt;br/&gt;
Only generally used LinkedHashMap for caches, so didn&apos;t think of it for this use case.&lt;/p&gt;</comment>
                            <comment id="11417" author="auto" created="Fri, 18 Dec 2009 15:52:07 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Eliot Horowitz&apos;, &apos;email&apos;: &apos;eliot@10gen.com&apos;}
&lt;p&gt;Message: use LinkedHashMap for BasicDBObject since it maintains insertion order &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-65&quot; title=&quot;BasicDBObject.entrySet().iterator does not produce values in the same order as BasicDBObject.keySet()&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-65&quot;&gt;&lt;del&gt;JAVA-65&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo-java-driver/commit/729fc494e5305d362eea95b01c381f2a7daf2652&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo-java-driver/commit/729fc494e5305d362eea95b01c381f2a7daf2652&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="10107" name="BasicDBObject.java" size="5669" author="keithbranton" created="Fri, 18 Dec 2009 15:30:12 +0000"/>
                            <attachment id="10108" name="DBObjectTest.java" size="5574" author="keithbranton" created="Fri, 18 Dec 2009 15:30:12 +0000"/>
                    </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|hrhdfb:</customfieldvalue>

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