Sha256: 63587347b9bcb0c57078e307851ac9476f8468e376d5a4722a0845180e014ee0

Contents?: true

Size: 1.04 KB

Versions: 9

Compression:

Stored size: 1.04 KB

Contents

# encoding: utf-8

require "securerandom"

module LogStash module Filters module Dictionary
  def self.create_huge_csv_dictionary(directory, name, size)
    tmppath = directory.join("temp_big.csv")
    tmppath.open("w") do |file|
      file.puts("foo,#{SecureRandom.hex(4)}")
      file.puts("bar,#{SecureRandom.hex(4)}")
      size.times do |i|
        file.puts("#{SecureRandom.hex(12)},#{1000000 + i}")
      end
      file.puts("baz,quux")
    end
    tmppath.rename(directory.join(name))
  end

  def self.create_huge_json_dictionary(directory, name, size)
    tmppath = directory.join("temp_big.json")
    tmppath.open("w") do |file|
      file.puts("{")
      file.puts('  "foo":"'.concat(SecureRandom.hex(4)).concat('",'))
      file.puts('  "bar":"'.concat(SecureRandom.hex(4)).concat('",'))
      size.times do |i|
        file.puts('  "'.concat(SecureRandom.hex(12)).concat('":"').concat("#{1000000 + i}").concat('",'))
      end
      file.puts('  "baz":"quux"')
      file.puts("}")
    end
    tmppath.rename(directory.join(name))
  end
end end end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
logstash-filter-translate-3.4.2 spec/support/build_huge_dictionaries.rb
logstash-filter-translate-3.4.1 spec/support/build_huge_dictionaries.rb
logstash-filter-translate-3.4.0 spec/support/build_huge_dictionaries.rb
logstash-filter-translate-3.3.1 spec/support/build_huge_dictionaries.rb
logstash-filter-translate-3.3.0 spec/support/build_huge_dictionaries.rb
logstash-filter-translate-3.2.3 spec/support/build_huge_dictionaries.rb
logstash-filter-translate-3.2.2 spec/support/build_huge_dictionaries.rb
logstash-filter-translate-3.2.1 spec/support/build_huge_dictionaries.rb
logstash-filter-translate-3.2.0 spec/support/build_huge_dictionaries.rb