[SERVER-3719] woCompare does not provide a total order over doubles and longs. Created: 30/Aug/11  Updated: 06/Nov/17  Resolved: 09/Jan/15

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Querying
Affects Version/s: None
Fix Version/s: 2.8.0-rc5

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: query_triage, todo_in_code
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File numberlong4.js    
Issue Links:
Documented
is documented by DOCS-4650 Update documentation to reflect order... Closed
Related
related to SERVER-6126 Value::compare is not a transitive co... Closed
is related to SERVER-3717 loss of precision for long long value... Closed
Tested
Backwards Compatibility: Minor Change
Operating System: ALL
Participants:

 Description   

Consider the following BSON objects, in shell notation.

a = { x: NumberLong("72057594037927936") }
b = { x: 72057594037927936.0 }
c = { x: NumberLong("72057594037927937") } // c.x == a.x+1

The following expressions all evaluate to true.

bsonWoCompare(a, b) == bsonWoCompare(b, a) == 0
bsonWoCompare(a, c) == -1
bsonWoCompare(c, b) == 0

So, a < c is true, a < b and b < a are false, and c < b and b < c are false. This lack of a total ordering means that you can construct an index on field x where document c occurs either before or after document a, due to the presence of documents like b.



 Comments   
Comment by Githook User [ 07/Jan/15 ]

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: Make BSONObj::woCompare a total ordering

Changes:

  • Date and Timestamp are now distinct with all Dates before all Timestamps.
  • Numeric comparisons now correctly handle Doubles and Long > 2**53.
  • CodeWScope doesn't strcmp BSONObjs or strings which may contain NULs.

There should be no changes in any of the cases where woCompare defined a
correct total ordering before. The new behavior matches the ordering defined
by KeyString.

Related tickets:

Changes to the comparison function for aggregation will be handled separately
as SERVER-16708.
Branch: master
https://github.com/mongodb/mongo/commit/f58fa5f78a91ce36d8e31d6730ebfdaa6cc1d5ab

Comment by Benety Goh [ 07/Nov/13 ]

version of numberlong4.js with tests enabled (line 6).

Comment by auto [ 13/Feb/12 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-3719 specify correct jira number
Branch: master
https://github.com/mongodb/mongo/commit/43da6ce816036f436c27e8ec2bd58ca6d90f7ceb

Comment by auto [ 18/Dec/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-3719 test
Branch: master
https://github.com/mongodb/mongo/commit/6389c67a0f499b23f60aaad80657b75856f3549c

Comment by auto [ 30/Aug/11 ]

Author:

{u'login': u'dwight', u'name': u'Dwight', u'email': u'dwight@10gen.com'}

Message: SERVER-3719 long long values in v1 indexes were losing precision
Branch: master
https://github.com/mongodb/mongo/commit/9fd22cb86de06cbb4b710e4d399f81b9a709f4f3

Comment by auto [ 30/Aug/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-3719 test
Branch: master
https://github.com/mongodb/mongo/commit/922398f47c570793463f90268725cb33b33760c1

Generated at Thu Feb 08 03:03:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.