-
Type: New Feature
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.5
-
Component/s: None
-
Labels:
-
Environment:All
It's a very common use case in SQL databases to want to perform bitwise operations during queries. While there the server doesn't offer these yet (there are open pull requests to add it), it would be useful if such logic could be implemented in the driver.
Couple ways of doing this off the top of my head:
1. Augment the query with MapReduce; many trivial statements like (x & 2) == 2 or (x & 2) != 0 can be emitted pretty easily, same goes for parameter values that get serialized.
2. Could also special case scenarios where the operation is x & <power of 2 - 1>, since that is equivalent to a $mod; i.e. (x & 3) == 3 would be { x :
} and (x & 3) != 0 would be { x : { $not:
{ $mod : [4, 0] } } }
2a. Of particular interest to this optimization is (x & 1) => (x % 2) which is a relative frequent case.
If one really wanted to exceed expectations, translating any sort of simple arithmetic computation to a JavaScript function would be fantastic and provide lasting value (type safe complex data analysis scenarios for one).