Simplified a bit and more commented patch version is in attach.
Algorithm were switched to linear probing, it makes code simpler and clearer. Flag usages were toggled: now it indicates that hash table were built, it also makes code clearer. XidInXip and some other functions got comments.
-- With regards, Sokolov Yura aka funny_falcon Postgres Professional: https://postgrespro.ru The Russian Postgres Company