Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-55386

Support hex conversion and binary operators to aggregation framework

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.4.4
    • Component/s: Query Language
    • Labels:
      None
    • Query Execution

      Are there any roadmaps to support number to hex conversion and binary operators? I can imagine several use cases where they would be really helpful. Typically and most required operations would be:

      • convert Int/Long to Hex
      • convert Hex to Int/Long
      • Create BinData from Hex string (already available in mongo shell `HexData(0,"...")` but not in aggregation framework)
      • Get Hex string of BinData (already available in mongo shell `b.hex()` but not in aggregation framework)
      • Binary AND
      • Binary OR
      • Binary XOR
      • Binary NOT (i.e. complement)

      Here are some examples:

       

      { $toHex: 44907 }    => "AF6B"
      { $fromHex: "AF6B" } => 44907
      
      { $binFromHex: "AF6B" }            => BinData(0,"r2s=")
      { $hexFromBin: BinData(0,"r2s=") } => "AF6B"
      
      { $bitAnd: [BinData(0,"r2s="), BinData(0,"/wA=")] } => BinData(0,"rwA=")
      { $bitOr:  [BinData(0,"r2s="), BinData(0,"/wA=")] } => BinData(0,"/2s=")
      { $bitXOr: [BinData(0,"r2s="), BinData(0,"/wA=")] } => BinData(0,"UGs=")
      { $bitComplement: BinData(0,"r2s=") }               => BinData(0,"UJQ=")
      
      { $bitAnd: [{$binFromHex: "AF6B"}, {$binFromHex: "FF00"}] } 
      => BinData(0,"rwA=") // HexData(0,"AF00")
      
      { $bitOr: [{$binFromHex: "AF6B"}, {$binFromHex: "FF00"}] }  
      => BinData(0,"/2s=") // HexData(0,"FF6B")
      
      { $bitXOr: [{$binFromHex: "AF6B"}, {$binFromHex: "FF00"}] } 
      => BinData(0,"UGs=") // HexData(0,"506B")
      
      { $bitComplement: {$binFromHex: "AF6B"} } 
      => BinData(0,"UJQ=") // HexData(0,"5094") 
      

       

       

       

       

       

       

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            wernfried.domscheit@sunrise.net Wernfried Domscheit
            Votes:
            2 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated: