Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ruby implementation of noncriptographic hash Murmur3 (both native and pure ruby)

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 ext
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md readme August 02, 2012
Octocat-spinner-32 Rakefile
Octocat-spinner-32 murmurhash3.gemspec
README.md

Murmurhash3

This is an implementation of MurmurHash3 - noncriptographic hash function.

It includes x86_32bit variant and x64_128bit variant. x86_128bit variant is ommited.

It exposes finalization mix functions as variant of superfast integer hashing.

Installation

Add this line to your application's Gemfile:

gem 'murmurhash3'

And then execute:

$ bundle

Or install it yourself as:

$ gem install murmurhash3

Usage

    require 'murmurhash3'

    MurmurHash3::V32.fmix(some_32bit_integer)
    MurmurHash3::V32.str_hash(some_string)
    MurmurHash3::V32.str_hash(some_string, seed)
    MurmurHash3::V32.int32_hash(some_32bit_integer)
    MurmurHash3::V32.int32_hash(some_32bit_integer, seed)
    MurmurHash3::V32.int64_hash(some_64bit_integer)
    MurmurHash3::V32.int64_hash(some_64bit_integer, seed)

    class SomeClass
      include MurmurHash32::V32
      def func
        murmur3_32_fmix(some_32bit_integer)
        murmur3_32_str_hash(some_string)
        murmur3_32_str_hash(some_string, seed)
        murmur3_32_int32_hash(some_32bit_integer)
        murmur3_32_int32_hash(some_32bit_integer, seed)
        murmur3_32_int64_hash(some_64bit_integer)
        murmur3_32_int64_hash(some_64bit_integer, seed)
      end
    end

    MurmurHash3::V128.fmix(some_64bit_integer)    # => int64
    MurmurHash3::V128.str_hash(some_string)       # => [int32_0, int32_1, int32_2, int32_3]
    MurmurHash3::V128.str_hash(some_string, seed) # => [int32_0, int32_1, int32_2, int32_3]
    MurmurHash3::V128.int32_hash(some_32bit_integer)       # => [int32_0, int32_1, int32_2, int32_3]
    MurmurHash3::V128.int32_hash(some_32bit_integer, seed) # => [int32_0, int32_1, int32_2, int32_3]
    MurmurHash3::V128.int64_hash(some_64bit_integer)       # => [int32_0, int32_1, int32_2, int32_3]
    MurmurHash3::V128.int64_hash(some_64bit_integer, seed) # => [int32_0, int32_1, int32_2, int32_3]

    class SomeClass
      include MurmurHash32::V128
      def func
        murmur3_128_fmix(some_64bit_integer)             # => int64
        murmur3_128_str_hash(some_string)                # => [int32_0, int32_1, int32_2, int32_3]
        murmur3_128_str_hash(some_string, seed)          # => [int32_0, int32_1, int32_2, int32_3]
        murmur3_128_int32_hash(some_32bit_integer)       # => [int32_0, int32_1, int32_2, int32_3]
        murmur3_128_int32_hash(some_32bit_integer, seed) # => [int32_0, int32_1, int32_2, int32_3]
        murmur3_128_int64_hash(some_64bit_integer)       # => [int32_0, int32_1, int32_2, int32_3]
        murmur3_128_int64_hash(some_64bit_integer, seed) # => [int32_0, int32_1, int32_2, int32_3]
      end
    end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.