class Fluent::MultiEventStream
EventStream from entries: numbers of pairs of time and record.
This class can handle many events more efficiently than ArrayEventStream because this class generate less objects than ArrayEventStream.
Use this class as below, in loop of data-enumeration:
1. initialize blank stream: streams[tag] ||= MultiEventStream.new 2. add events stream[tag].add(time, record)
Public Class Methods
new(time_array = [], record_array = [])
click to toggle source
# File lib/fluent/event.rb, line 159 def initialize(time_array = [], record_array = []) @time_array = time_array @record_array = record_array end
Public Instance Methods
add(time, record)
click to toggle source
# File lib/fluent/event.rb, line 172 def add(time, record) @time_array << time @record_array << record end
dup()
click to toggle source
# File lib/fluent/event.rb, line 164 def dup MultiEventStream.new(@time_array.dup, @record_array.map(&:dup)) end
each(&block)
click to toggle source
# File lib/fluent/event.rb, line 189 def each(&block) time_array = @time_array record_array = @record_array for i in 0..time_array.length-1 block.call(time_array[i], record_array[i]) end nil end
empty?()
click to toggle source
# File lib/fluent/event.rb, line 181 def empty? @time_array.empty? end
repeatable?()
click to toggle source
# File lib/fluent/event.rb, line 177 def repeatable? true end
size()
click to toggle source
# File lib/fluent/event.rb, line 168 def size @time_array.size end
slice(index, num)
click to toggle source
# File lib/fluent/event.rb, line 185 def slice(index, num) MultiEventStream.new(@time_array.slice(index, num), @record_array.slice(index, num)) end