What is the algorithm used for counting the set bit (number of ones) of a bitmap/bitarray/betset in postgresql?

Поиск
Список
Период
Сортировка
От Kanarupan Kularatnarajah
Тема What is the algorithm used for counting the set bit (number of ones) of a bitmap/bitarray/betset in postgresql?
Дата
Msg-id CAFf4ZT3bVCM+KPT=3zohJMv3d76WhrNQsur=yO=-r3MeBKeCEw@mail.gmail.com
обсуждение исходный текст
Список pgsql-hackers

I've come across lookup tables, Hamming weights and Brain Kernighan's Algo. Are they used (combined or separately) in bitmap counting? 

Where can I find the coding and please explain the flow a count function (for a bit counting) via coding rather than the high level architectural diagrams (which I'm aware of). 

I've noted using the below expression to count a particular bits (0 or 1 with minor modification). Could anyone explain at the coding level of postgresql and what algorithms are used?

postgres=> SELECT LENGTH( REPLACE( CAST( B'101000000000000000000010' 
AS TEXT ), '0', ''));  


Regards,
K.Kanarupan
Undergraduate,k
Dept. of Computer Science & Engineering
University of Moratuwa

Mobile:  +94 777 420 179

В списке pgsql-hackers по дате отправления: