Class: RbBCC::ArrayTable
Instance Attribute Summary
Attributes inherited from TableBase
#bpf, #flags, #keysize, #keytype, #leafsize, #leaftype, #map_fd, #map_id, #name, #ttype
Instance Method Summary collapse
- #clearitem(key) ⇒ Object
- #delete(key) ⇒ Object
- #each(&b) ⇒ Object
-
#initialize(bpf, map_id, map_fd, keytype, leaftype, name: nil, keysize: nil, leafsize: nil) ⇒ ArrayTable
constructor
A new instance of ArrayTable.
-
#size ⇒ Object
(also: #length)
We now emulate the Array class of Ruby.
Methods inherited from TableBase
#[], #[]=, #clear, #each_key, #each_pair, #each_value, #fetch, from_pin, #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, keysize: nil, leafsize: nil) ⇒ ArrayTable
Returns a new instance of ArrayTable.
326 327 328 329 |
# File 'lib/rbbcc/table.rb', line 326 def initialize(bpf, map_id, map_fd, keytype, leaftype, name: nil, keysize: nil, leafsize: nil) super @max_entries = Clib.bpf_table_max_entries_id(bpf.module, map_id) if bpf end |
Instance Method Details
#clearitem(key) ⇒ Object
337 338 339 |
# File 'lib/rbbcc/table.rb', line 337 def clearitem(key) self[key] = byref(0, @leafsize) end |
#delete(key) ⇒ Object
341 342 343 344 |
# File 'lib/rbbcc/table.rb', line 341 def delete(key) # Delete in Array type does not have an effect, so zero out instead clearitem(key) end |
#each(&b) ⇒ Object
346 347 348 349 350 |
# File 'lib/rbbcc/table.rb', line 346 def each(&b) each_value do |v| b.call(v.to_bcc_value) end end |
#size ⇒ Object Also known as: length
We now emulate the Array class of Ruby
332 333 334 |
# File 'lib/rbbcc/table.rb', line 332 def size @max_entries end |