<commit_before>class Fluent::Plugin::TimerangeFilter < Fluent::Plugin::Filter
  Fluent::Plugin.register_filter('timerange', self)

  config_param :starttime, :string
  config_param :endtime, :string

  def start
    super
  end

  def shutdown
    super
  end

  def configure(conf)
    super
    @starttime = Time.parse('1970-01-01 ' << conf['starttime'])
    @endtime = Time.parse('1970-01-01 ' << conf['endtime'])
  end

  def filter(tag, time, record)
    @now = Time.parse('1970-01-01 ' << Time.at(time).strftime('%R'))
    if @now > @starttime and @now < @endtime
      return record
    else
      return nil
    end
  end

end
<commit_msg>fix filter method to use filter_stream method<commit_after>class Fluent::Plugin::TimerangeFilter < Fluent::Plugin::Filter
  Fluent::Plugin.register_filter('timerange', self)

  config_param :starttime, :string
  config_param :endtime, :string

  def start
    super
  end

  def shutdown
    super
  end

  def configure(conf)
    super
    @starttime = Time.parse('1970-01-01 ' << conf['starttime'])
    @endtime = Time.parse('1970-01-01 ' << conf['endtime'])
  end

  def filter(tag, time, record)
    @now = Time.parse('1970-01-01 ' << Time.at(time).strftime('%R'))
    if @now > @starttime and @now < @endtime
      return record
    else
      return nil
    end
  end

  def filter_stream(tag, es)
    new_es = Fluent::MultiEventStream.new
    es.each { |time, record|
      @now = Time.parse('1970-01-01 ' << Time.at(time).strftime('%R'))
      if @now > @starttime and @now < @endtime
        new_es.add(time, filter(tag, time, record))
      end
    }
    new_es
  end

end
{'fraction_non_alphanumeric': 0.1368937998772253, 'fraction_numerical': 0.03437691835481891, 'mean_word_length': 3.1475826972010177, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4922784', 'n_tokens_mistral': 601, 'n_tokens_neox': 549, 'n_words': 130}