Class: RbBCC::ArrayTable

Inherits:
TableBase show all
Defined in:
lib/rbbcc/table.rb

Instance Attribute Summary

Attributes inherited from TableBase

#bpf, #flags, #keysize, #leafsize, #leaftype, #map_fd, #map_id, #name, #ttype

Instance Method Summary collapse

Methods inherited from TableBase

#[]=, #each_key, #each_pair, #each_value, #fetch, #items, #next, #print_linear_hist, #print_log2_hist, #structured_key?, #values

Methods included from CPUHelper

_read_cpu_range, get_online_cpus, get_possible_cpus

Constructor Details

#initialize(bpf, map_id, map_fd, keytype, leaftype, name: nil) ⇒ ArrayTable

Returns a new instance of ArrayTable.



186
187
188
189
# File 'lib/rbbcc/table.rb', line 186

def initialize(bpf, map_id, map_fd, keytype, leaftype, name: nil)
  super
  @max_entries = Clib.bpf_table_max_entries_id(bpf.module, map_id)
end

Instance Method Details

#[](key) ⇒ Object



197
198
199
# File 'lib/rbbcc/table.rb', line 197

def [](key)
  super(normalize_key(key))
end

#each(&b) ⇒ Object



201
202
203
204
205
# File 'lib/rbbcc/table.rb', line 201

def each(&b)
  each_value do |v|
    b.call(v.to_bcc_value)
  end
end

#sizeObject Also known as: length

We now emulate the Array class of Ruby



192
193
194
# File 'lib/rbbcc/table.rb', line 192

def size
  @max_entries
end