Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-540

Support Bitwise Operators in LINQ (and possibly Query)

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • 1.5
    • None
    • All

    Description

      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 :

      { $mod : [4, 3] }

      } 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).

      Attachments

        Activity

          People

            Unassigned Unassigned
            optimiz3 Alexander Nagy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: