Sha256: 0a2de11fbd5776d24cdd0cbfcf193f2132b1b1f2ee31fa93c4c45b15019bbfb0

Contents?: true

Size: 1.08 KB

Versions: 386

Compression:

Stored size: 1.08 KB

Contents

module Digest
  ds = Struct.new(:digest_length, :seed_length)
  s1 = ds.new(4, 4)
  s2 = ds.new(8, 8)
  s3 = ds.new(16, 4)
  {
    '1' => s1,
    '2' => s1,
    '2A' => s1,
    '64A' => s2,
    '64B' => s2,
    'Aligned2' => s1,
    'Neutral2' => s1,
    '3_x86_32' => s1,
    '3_x86_128' => s3,
    '3_x64_128' => s3,
  }.each do |name, s|
    class_eval %Q{
      class MurmurHashMRI#{name} < Digest::Class
        DEFAULT_SEED = "#{"\x00" * s.seed_length}".b

        def initialize
          @buffer = ""
          @seed = DEFAULT_SEED
        end

        def update(str)
          @buffer << str
          self
        end
        alias << update

        def reset
          @buffer.clear
          @seed = DEFAULT_SEED
          self
        end

        def seed
          @seed
        end

        def seed=(s)
          raise ArgumentError, "seed string should be #{s.seed_length} length" if #{s.seed_length} != s.length
          @seed = s
        end

        def digest_length
          #{s.digest_length}
        end

        def block_length
          0
        end
      end
    }
  end
end

Version data entries

386 entries across 386 versions & 1 rubygems

Version Path
splitclient-rb-8.5.0-java lib/murmurhash/base.rb
splitclient-rb-8.5.0 lib/murmurhash/base.rb
splitclient-rb-8.5.0.pre.rc1-java lib/murmurhash/base.rb
splitclient-rb-8.5.0.pre.rc1 lib/murmurhash/base.rb
splitclient-rb-8.4.1.pre.rc1-java lib/murmurhash/base.rb
splitclient-rb-8.4.1.pre.rc1 lib/murmurhash/base.rb
splitclient-rb-8.4.0-java lib/murmurhash/base.rb
splitclient-rb-8.4.0 lib/murmurhash/base.rb
splitclient-rb-8.4.0.pre.rc1-java lib/murmurhash/base.rb
splitclient-rb-8.4.0.pre.rc1 lib/murmurhash/base.rb
splitclient-rb-8.4.0.rc.1-java lib/murmurhash/base.rb
splitclient-rb-8.4.0.rc.1 lib/murmurhash/base.rb
splitclient-rb-8.3.2.pre.rc2-java lib/murmurhash/base.rb
splitclient-rb-8.3.2.pre.rc2 lib/murmurhash/base.rb
splitclient-rb-8.3.2.pre.rc1-java lib/murmurhash/base.rb
splitclient-rb-8.3.2.pre.rc1 lib/murmurhash/base.rb
splitclient-rb-8.3.1-java lib/murmurhash/base.rb
splitclient-rb-8.3.1 lib/murmurhash/base.rb
splitclient-rb-8.3.1.pre.rc1-java lib/murmurhash/base.rb
splitclient-rb-8.3.1.pre.rc1 lib/murmurhash/base.rb