[SERVER-8656] Updating pre-existing numeric fields (intermittently) causes documents to be moved? Created: 21/Feb/13 Updated: 07/Mar/14 Resolved: 25/Feb/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Write Ops |
| Affects Version/s: | 2.2.3 |
| Fix Version/s: | None |
| Type: | Question | Priority: | Minor - P4 |
| Reporter: | Alex Piggott | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Centos 5.5/6.3, driver 2.7.3 |
||
| Participants: |
| Description |
|
Originally posted here: https://groups.google.com/forum/?hl=en&fromgroups=#!topic/mongodb-user/T-NpDM6G0aM Sun Feb 17 04:11:31 [conn218] update doc_metadata.metadata query: { entities.index: "philip morris/company", communityId: ObjectId('4c927585d591d31d7b37097a')) }update: { $set: { entities.$.totalfrequency: 117, entities.$.doccount: 72 }} nscanned:107 nmoved:55 nupdated:72 numYields: 32 locks(micros) w:59851387 30783ms I'm trying to understand why nmoved>0 when my objects are all pre-populated as numeric (longs, via the Java driver) The thread includes some relevant gists: One thing I noticed in the example object is that some of the numbers are wrapped in NumberLong and some aren't - what determines this? |
| Comments |
| Comment by Alex Piggott [ 25/Feb/13 ] |
|
Oh I see, the issue is that if you use com.mongodb.util.JSON.parse to generate a DBObject, then it uses int32 for all integer fields that are smaller than INT_MAX (https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/util/JSON.java, parseNumber(), line 454) Personally I don't like that design decision, especially since objects are unnecessarily large anyway because of the inclusion of field names. But it's not a big deal, since there are alternative ways of creating DBObjects from JSON. I don't seem to be able to close this, can someone do the honors? |