[JAVA-1317] The MapReduce output field "Ok" value is not correct Created: 22/Jul/14 Updated: 23/Jul/14 Resolved: 22/Jul/14 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Dong [X] | Assignee: | Ross Lawley |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Mongodb 2.6.3, java driver 2.12.3 |
||
| Attachments: |
|
| Description |
|
The map reduce out put is
but the field "ok" is 1.0, it should be 1, it's not correct. |
| Comments |
| Comment by Ross Lawley [ 23/Jul/14 ] | |||||
|
Hi Dong that all looks fine. The "ok" value in a command result is set as a Double by the server so 1.0 is the correct representation. Other than being represented differently in the shell (for the reasons mentioned above) is there any other reason why you think it should be an integer? | |||||
| Comment by Dong [X] [ 23/Jul/14 ] | |||||
|
Hi Ross, I have not use command result for an inline map reduce, I used Mapreduceoutput for merge, and my java code in the attachment, please check it. | |||||
| Comment by Ross Lawley [ 22/Jul/14 ] | |||||
|
Hi Rambo, I think you are referring to the command result for an inline map reduce? And the differences between the shell representation and Java? The command result is a wrapper of a DBObject and as such is handled the same as any DBObject coming from the server. CommandResults return a double value for the "ok" field which is why its expressed as 1.0 So why is this different from the shell? In truth its not different! However, in javascript the representation of numbers is different and the mongo shell treats all numbers as floating-point values [1]. You can test that in JS 1 and 1.0 are the same in the shell by doing:
So they appear to be different in the string representations of the command result document - however the types are the same and that is why in Java it is a Double. I hope that clarifies why they appear to be different. It should also be noted access to the commandResult via the getCommandResult() or getRaw() methods are deprecated and due to be removed in the future. [1] http://docs.mongodb.org/manual/core/shell-types/#numberint |