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-2.0.0.rc3 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-2.0.0.rc2 lib/inferno/ext/bloomer.rb
onc_certification_g10_test_kit-2.0.0.rc1 lib/inferno/ext/bloomer.rb