Sha256: ee9ed195c350ebea5db888b9cb9fcdfca17df5ac217d494fadc69015ab0387d9

Contents?: true

Size: 646 Bytes

Versions: 43

Compression:

Stored size: 646 Bytes

Contents

class Bloomer
  class Scalable
    # Scalable bloom filters report very inaccurate sizes because they contain
    # multiple filters and don't check them all before adding something. This
    # makes them check all of the filters before adding an element so that the
    # size is more accurate.
    def add_without_duplication(string)
      return false if include? string

      add string
    end

    def self.create_with_sufficient_size(length = 256)
      size = initial_size(length)
      new(size, 0.00001)
    end

    def self.initial_size(length)
      size = 2**Math.log2(length).ceil

      size < 256 ? 256 : size
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
onc_certification_g10_test_kit-7.0.3 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-7.0.2 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-7.0.1 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-7.0.0 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-6.0.3 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-6.0.2 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-6.0.1 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-6.0.0 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-5.4.2 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-5.4.1 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-5.3.0 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-5.2.0 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-5.1.0 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-5.0.0 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-4.1.0 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-4.0.0 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-3.8.1 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-3.8.0 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-3.7.2 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-3.7.1 lib/inferno/ext/bloomer.rb