29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/codec/bitmap.rb', line 29
def encode_bitmap(buf,fields_list,bitmap_index)
offset_id = bitmap_index * bitmap_length + 1
bitmap = ""
(offset_id...(offset_id + bitmap_length)).each do |i|
if fields_list.include?(i)
bitmap << "1"
else
bitmap << "0"
end
end
Logger.debug { "Encoding bitmap #{bitmap_index}
form #{offset_id} to #{offset_id + bitmap_length - 1}
with #{fields_list.collect{|id| id.to_s}.join(',')}
result #{bitmap}" }
buf << [bitmap].pack("B*")
end
|