teyeheimans opened a new issue #8560: Feature request: Implement bitwise 
operators `&` and `|`
URL: https://github.com/apache/incubator-druid/issues/8560
 
 
   ### Description
   
   Currently it is not possible to do a bitwise operator expression. The only 
way to do this now is by using a javascript function to do the bitwise logic. 
   
   I would suggest to build in the bitwise operators `&` and `|` to the druid 
expressions: https://druid.apache.org/docs/latest/misc/math-expr.html
   
   ### Motivation
   
   In many situations we use a "flags" field, where every bit is a feature 
which can be enabled or disabled. In this way we can store a lot of boolean 
fields in just 1 decimal field. 
   
   We can then simply check if the specific bit is enabled by doing a bitwise 
and:
   
   `(flags & 16) = 16`
   
   In the current situation we solved this by a very complex way using a 
javascript function like this (replace `%BIT_TO_CHECK%` with the value to check:
   
   `function(v1) { var v2 = %BIT_TO_CHECK%; var hi = 0x80000000; var low = 
0x7fffffff; var hi1 = ~~(v1 / hi); var hi2 = ~~(v2 / hi); var low1 = v1 & low; 
var low2 = v2 & low; var h = hi1 & hi2; var l = low1 & low2; return (h*hi + l) 
== v2; }`
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to