Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for 128bit murmur variant #42

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/logstash/filters/fingerprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class LogStash::Filters::Fingerprint < LogStash::Filters::Base
# If set to `UUID`, a
# https://en.wikipedia.org/wiki/Universally_unique_identifier[UUID] will
# be generated. The result will be random and thus not a consistent hash.
config :method, :validate => ['SHA1', 'SHA256', 'SHA384', 'SHA512', 'MD5', "MURMUR3", "IPV4_NETWORK", "UUID", "PUNCTUATION"], :required => true, :default => 'SHA1'
config :method, :validate => ['SHA1', 'SHA256', 'SHA384', 'SHA512', 'MD5', "MURMUR3", "MURMUR3_128", "IPV4_NETWORK", "UUID", "PUNCTUATION"], :required => true, :default => 'SHA1'

# When set to `true` and `method` isn't `UUID` or `PUNCTUATION`, the
# plugin concatenates the names and values of all fields given in the
Expand Down Expand Up @@ -94,6 +94,8 @@ def register
class << self; alias_method :fingerprint, :fingerprint_ipv4_network; end
when :MURMUR3
class << self; alias_method :fingerprint, :fingerprint_murmur3; end
when :MURMUR3_128
class << self; alias_method :fingerprint, :fingerprint_murmur3_128; end
when :UUID
# nothing
when :PUNCTUATION
Expand Down Expand Up @@ -179,6 +181,17 @@ def fingerprint_murmur3(value)
end
end

def fingerprint_murmur3_128(value)
case value
when Fixnum
MurmurHash3::V128.int32_hash(value, 2)
when Bignum
MurmurHash3::V128.int64_hash(value, 2)
else
MurmurHash3::V128.str_hash(value.to_s, 2)
end
end

def select_digest(method)
case method
when :SHA1
Expand Down