<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:56:58 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-2339] Reduce memory requirements for Document and BsonDocument when the number of keys is small</title>
                <link>https://jira.mongodb.org/browse/JAVA-2339</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Both Document and BsonDocument have an internal LinkedHashMap to store the entries in order.&lt;/p&gt;

&lt;p&gt;This is not the most efficient data structure to use when the number of entries is small.  &lt;/p&gt;

&lt;p&gt;Consider using just an ArrayList to handle small numbers of entries, and only start using a hash table when the number of entries grows to more than a handful (size of handful TBD).&lt;/p&gt;</description>
                <environment></environment>
        <key id="322587">JAVA-2339</key>
            <summary>Reduce memory requirements for Document and BsonDocument when the number of keys is small</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="jeff.yemin@mongodb.com">Jeffrey Yemin</assignee>
                                    <reporter username="jeff.yemin@mongodb.com">Jeffrey Yemin</reporter>
                        <labels>
                    </labels>
                <created>Mon, 10 Oct 2016 21:23:01 +0000</created>
                <updated>Thu, 15 Feb 2018 16:54:12 +0000</updated>
                            <resolved>Thu, 15 Feb 2018 16:54:12 +0000</resolved>
                                                                    <component>BSON</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="1806937" author="jeff.yemin" created="Thu, 15 Feb 2018 16:54:12 +0000"  >&lt;p&gt;I wrote a simple implementation of a Map which starts as an ArrayList and then adds a backing HashMap when the size goes above a threshold.  Source code is &lt;a href=&quot;https://gist.github.com/anonymous/7841624dc385a6410c25875dad6a0c31&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But benchmarking with &lt;a href=&quot;http://openjdk.java.net/projects/code-tools/jmh/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;jmh&lt;/a&gt; reveals that it&apos;s slower than LinkedHashMap in most cases, so I&apos;m abandoning the effort.&lt;/p&gt;</comment>
                            <comment id="1746654" author="ross@10gen.com" created="Fri, 8 Dec 2017 12:00:13 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=aharris&quot; class=&quot;user-hover&quot; rel=&quot;aharris&quot;&gt;aharris&lt;/a&gt; the final implementation is undecided, it could be a simple list of &lt;tt&gt;BsonElement&lt;/tt&gt; where each element would contain a key and value. Bson is field order sensitive, so we must maintain insertion order and couldn&apos;t use a Set.  What the value of a given key is somewhat arbitary, n-dimension documents are still just key-value pairs all the way down. We&apos;d obviously have to benchmark any changes to ensure we don&apos;t negative impact users.&lt;/p&gt;

&lt;p&gt;The CSharp driver has a List backing their &lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/blob/master/src/MongoDB.Bson/ObjectModel/BsonDocument.cs&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;BsonDocument.cs&lt;/a&gt; implementation and inspiration may be drawn from that.&lt;/p&gt;

&lt;p&gt;Please keep watching this ticket and we&apos;ll update with more information once progress has started.&lt;/p&gt;

&lt;p&gt;Ross&lt;/p&gt;</comment>
                            <comment id="1746619" author="aharris" created="Fri, 8 Dec 2017 10:31:55 +0000"  >&lt;p&gt;I wasn&apos;t talking about from a users perspective. I was merely asking how you would envisage implementing a multi-dimensional Set which supports countless imbedded Sets in an unordered single dimensional Array without introducing complex wrapper objects (which would be more expensive)? In the end, you would essentially have yet another Set implementation anyway.&lt;/p&gt;

&lt;p&gt;I suspect that even if it were possible the overhead of managing such a mechanism would far outway any resource savings you were trying to achieve in the first place.&lt;/p&gt;

&lt;p&gt;LinkedHashMap is based, of course, on a double linked list which I&apos;ll agree uses more resources than say a normal HashMap but it is required for consistent field ordering. Json isn&apos;t field order sensitive in itself but if your application might be (and certainly your unit tests might be).&lt;/p&gt;</comment>
                            <comment id="1746616" author="ross@10gen.com" created="Fri, 8 Dec 2017 10:22:23 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=aharris&quot; class=&quot;user-hover&quot; rel=&quot;aharris&quot;&gt;aharris&lt;/a&gt; this would be an internal optimization for performance / memory usage reasons.  From a users perspective there would be no difference to how they can be used.&lt;/p&gt;</comment>
                            <comment id="1746610" author="aharris" created="Fri, 8 Dec 2017 10:08:18 +0000"  >&lt;p&gt;Lists are not Sets so it would awkward to store a field name and value in a one-dimensional list or are you suggesting that two or more Lists are used? Also, how would this cater for n-dimensional embedded documents?&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|htdlsv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="1686">JVM Sprint 39</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>