<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:57:53 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-2708] What are the differences between org.bson.BsonValue and classes defined under org.bson.types</title>
                <link>https://jira.mongodb.org/browse/JAVA-2708</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Hi Mongodb team,&lt;/p&gt;

&lt;p&gt;I&apos;m on data analysis in java application and found that for the data(field) type there are some similar definitions, &lt;br/&gt;
e.g. &lt;br/&gt;
     org.bson.types.&lt;font color=&quot;red&quot;&gt;BSON&lt;/font&gt;Timestamp&lt;br/&gt;
     org.bson.&lt;font color=&quot;red&quot;&gt;Bson&lt;/font&gt;Timestamp&lt;/p&gt;

&lt;p&gt;Most of fields&apos; type on java can be matched to classes defined under org.bson.types.* but only bson timestamp is exceptional, which is matched to org.bson.BsonTimestamp.&lt;/p&gt;

&lt;p&gt;below is the results of &amp;lt;fieldValue&amp;gt;.getClass().getName(), which is printed by my application.&lt;br/&gt;
java.lang.String&lt;br/&gt;
&lt;font color=&quot;red&quot;&gt;org.bson.BsonTimestamp&lt;/font&gt;        // &lt;font color=&quot;red&quot;&gt;never be org.bson.types.BSONTimestamp&lt;/font&gt;&lt;br/&gt;
org.bson.types.ObjectId&lt;br/&gt;
org.bson.Document&lt;br/&gt;
org.bson.types.MinKey&lt;br/&gt;
org.bson.BsonTimestamp&lt;br/&gt;
org.bson.types.ObjectId&lt;br/&gt;
org.bson.types.MaxKey&lt;br/&gt;
java.lang.String&lt;br/&gt;
org.bson.Document&lt;/p&gt;

&lt;p&gt;it shows that field type comes from both subtype of org.bson.BsonValue and org.bson.types.*&lt;/p&gt;

&lt;p&gt;What is the difference between them, or some duplicated definitions?&lt;/p&gt;

&lt;p&gt;Can you please give me help or guide?&lt;br/&gt;
Thanks.&lt;/p&gt;</description>
                <environment>mongo-java-driver-3.5.0.jar</environment>
        <key id="472799">JAVA-2708</key>
            <summary>What are the differences between org.bson.BsonValue and classes defined under org.bson.types</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="13201">Fixed</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="8666592@qq.com">jacky chen</reporter>
                        <labels>
                    </labels>
                <created>Fri, 15 Dec 2017 03:21:05 +0000</created>
                <updated>Sat, 28 Oct 2023 11:23:03 +0000</updated>
                            <resolved>Fri, 15 Dec 2017 10:24:00 +0000</resolved>
                                    <version>3.5.0</version>
                                                    <component>BSON</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1752876" author="ross@10gen.com" created="Fri, 15 Dec 2017 10:23:48 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=update0412&quot; class=&quot;user-hover&quot; rel=&quot;update0412&quot;&gt;update0412&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thanks for the ticket, the BSON spec supports various &lt;a href=&quot;https://docs.mongodb.com/manual/reference/bson-types/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;BSON types&lt;/a&gt;.  The &lt;tt&gt;org.bson.types&lt;/tt&gt; package contains classes implementing various BSON types for use with Java.  These are the types where there is no Java equivalent (eg. &lt;tt&gt;MaxKey&lt;/tt&gt;). &lt;/p&gt;

&lt;p&gt;If you were to use the &lt;tt&gt;org.bson.Document&lt;/tt&gt; type to represent BSON documents, then typically the &lt;tt&gt;_id&lt;/tt&gt; field will contain an &lt;tt&gt;org.bson.types.ObjectId&lt;/tt&gt; value.  The &lt;tt&gt;Document&lt;/tt&gt; class is essentially a &lt;tt&gt;Map&amp;lt;String, Object&amp;gt;&lt;/tt&gt; and values can be of any type.  When encoding them to BSON, the values have to be mapped to a BSON type (this is done via &lt;a href=&quot;http://mongodb.github.io/mongo-java-driver/3.6/bson/codecs/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Codecs and the CodecRegistry&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Some users wanted a type-safe BSON document implementation, this is where &lt;tt&gt;BsonDocument&lt;/tt&gt; comes in as it essentially is a &lt;tt&gt;Map&amp;lt;String, BsonValue&amp;gt;&lt;/tt&gt;. Only implementations of the &lt;tt&gt;BsonValue&lt;/tt&gt; class can be stored in a &lt;tt&gt;BsonDocument&lt;/tt&gt;, making it type-safe and complete.  Most users will prefer either the &lt;tt&gt;Document&lt;/tt&gt; or &lt;a href=&quot;http://mongodb.github.io/mongo-java-driver/3.6/bson/pojos/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;POJOs&lt;/a&gt; as they are easier to use. &lt;/p&gt;

&lt;p&gt;For more information see the &lt;a href=&quot;http://mongodb.github.io/mongo-java-driver/3.6/bson/documents/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;documents documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Just to let you know for future reference, this project is for Java driver bugs or feature requests.  The best place for questions regarding MongoDB usage or the Java driver specifics is the &lt;a href=&quot;https://groups.google.com/forum/#!forum/mongodb-user&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;mongodb-user mailinglist&lt;/a&gt; or &lt;a href=&quot;http://stackoverflow.com&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;stackoverflow&lt;/a&gt; as you will reach a boarder audience there.  If your business requires an answer from MongoDB within a time frame then we do offer &lt;a href=&quot;https://www.mongodb.com/products/production-support&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;production support&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you do follow up via one of the options above please post a link and I will follow the conversation there.&lt;/p&gt;

&lt;p&gt;All the best,&lt;/p&gt;

&lt;p&gt;Ross&lt;/p&gt;</comment>
                            <comment id="1752784" author="8666592@qq.com" created="Fri, 15 Dec 2017 04:08:04 +0000"  >&lt;p&gt;mongos&amp;gt; db.chunks.find({_id:&quot;test.users-id_MinKey&quot;}).pretty()&lt;br/&gt;
{&lt;br/&gt;
	&quot;_id&quot; : &quot;test.users-id_MinKey&quot;,&lt;br/&gt;
	&quot;lastmod&quot; : Timestamp(2, 0),&lt;br/&gt;
	&quot;lastmodEpoch&quot; : ObjectId(&quot;5a331bff821258f0068b6372&quot;),&lt;br/&gt;
	&quot;ns&quot; : &quot;test.users&quot;,&lt;br/&gt;
	&quot;min&quot; : {&lt;br/&gt;
		&quot;id&quot; : &lt;/p&gt;
{ &quot;$minKey&quot; : 1 }
&lt;p&gt;	},&lt;br/&gt;
	&quot;max&quot; : &lt;/p&gt;
{
		&quot;id&quot; : 1
	}
&lt;p&gt;,&lt;br/&gt;
	&quot;shard&quot; : &quot;replset1&quot;&lt;br/&gt;
}&lt;br/&gt;
mongos&amp;gt;&lt;/p&gt;


&lt;p&gt;&quot;lastmod&quot; : Timestamp(2, 0) is matched to org.bson.BsonTimestamp&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|htdx5b:</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>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>