[SERVER-4362] Add XOR operator to $bit Created: 23/Nov/11  Updated: 28/Oct/15  Resolved: 20/Aug/13

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.0.1
Fix Version/s: 2.5.2

Type: New Feature Priority: Minor - P4
Reporter: Remon van Vliet Assignee: Andrew Morrow (Inactive)
Resolution: Done Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-6399 Refactor update() code Closed
Related
related to SERVER-6399 Refactor update() code Closed
is related to SERVER-8716 Various update() operators for Binary... Backlog
is related to SERVER-3281 Support $bit operator for binary types Backlog
Participants:

 Description   

The XOR operator is lacking from the $bit operation. Useful for situations where you want to flip a flag :

{flag: 1}

db.col.update(

{..}

, {$bit:{flag:

{xor:1}

}})



 Comments   
Comment by auto [ 20/Aug/13 ]

Author:

{u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@10gen.com'}

Message: SERVER-4362 Implement xor support for $bit
Branch: master
https://github.com/mongodb/mongo/commit/fce3b4ce8fe848c332657f3accf596e6b087bce9

Comment by Andrew Morrow (Inactive) [ 19/Aug/13 ]

This will provide a new feature for $bit: the 'xor' operator. We will need to document this new functionality.

Comment by Remon van Vliet [ 26/Sep/12 ]

There are a number of useful usecases for it. I think an equally valid motivation to add the various bit operators is that the $bit operator simply isn't functionally complete at the moment. I'm a little puzzled as to why this isn't just added. We're literally talking about 2-3 lines of zero risk code. Fruit doesn't get more low hanging than that.

Comment by Onur GUNDURU [ 26/Sep/12 ]

XOR would be great for calculating binary distances, such as Hamming distance

Comment by Remon van Vliet [ 27/Feb/12 ]

Nice. I would add all NOT versions of the standard binary operators (NAND, NOR, NXOR) as well since there's no way to compose them with a NOT. I can't think of any downsides to adding these so hopefully your patch gets accepted.

Comment by Derick Rethans [ 27/Feb/12 ]

It's at https://github.com/mongodb/mongo/pull/182, with some RFCs.

Comment by Derick Rethans [ 27/Feb/12 ]

I have a patch for this. I'll create a pull request once I've cleaned it up.

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