How to handle bit flags in Druid

17 views
Skip to first unread message

DeWayne Thomas

unread,
Apr 5, 2023, 7:41:06 PM4/5/23
to Druid User
Hello, a Druid newbie here.  We are moving an application from the mainframe to x86.  The app code is written in assembler and as such was designed with many one byte flags which are used as bit switches.  Sometimes only one bit in the byte is 'on' and in others you may have multiples.

My question is:  How best can we handle this in Druid?  In assembler I would have compare and test instructions that would let me find what I'm looking for.  I'm not familiar enough with Druid query languages to know if there's something equivalent.

An example that demonstrates what I'm looking for....x'D4' which in binary 1101 0100 or integer 212.   I might need to see if the 3rd bit is on or maybe 8th and 7th....

Sorry for what may be a simple question, but I'm still learning.  Any suggestions are welcome.

Thanks,
DeWayne

Sergio Ferragut

unread,
Apr 6, 2023, 11:55:38 AM4/6/23
to Druid User
Druid has a whole set of Bitwise functions that you should be able to use to access these values.

You should consider however, that if you are filtering on such individual bits, it will need to scan all values in the column to find matches. Meaning that you will not be taking advantage of indexes. So you might want to consider converting some of the bits that will be used for filtering into separate columns for performance reasons.

Reply all
Reply to author
Forward
0 new messages