sampling-hash 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c23548b53d3e58d84b8afe14257056af0845c78c
4
- data.tar.gz: cb8dde11bb5d817a4d5d8ece28ae6b2fa57e5338
3
+ metadata.gz: 9edbe5d8263f8f1bb98e2687b248d889609c3756
4
+ data.tar.gz: 4b9f82dd03f06665d425f40fb8d59b668a8926d3
5
5
  SHA512:
6
- metadata.gz: 9970df8f3b947c935fb4f0ffbf1a03d8fda4c77ee78cf0ed5d8548c546c142ce5890e6dcd8324c8d904959739e290d10ffa9c9ba89f7e86a96378f76d4bb7780
7
- data.tar.gz: ef3a29c998552fb6578295926a2d73cf223c976053a270af774c53694b74a5a88140bdc4d506186d16b6cb75edb75584125d919da7345d7a36bd616e93d8b4c2
6
+ metadata.gz: 973518617f9842cbaf9050aca73f329f53e9bccc19f02a3160bfd13af72d16d3c8e7311a6857fdf5cdae81e178fb07963a5a333bd1920ec57d6e5434ac6e70e2
7
+ data.tar.gz: 9a716b4bdbb9998780051e00438d982b865570e4d094519506e28542a79ecc66f29642854275d28dfa8b74037ac8ee7c29a90938614f5882186874af89fc1f50
data/lib/sampling-hash.rb CHANGED
@@ -5,11 +5,10 @@ require 'sampling-hash/version'
5
5
  require 'xxhash'
6
6
 
7
7
  module SamplingHash
8
- def self.hash(path, seed = File.size(path))
8
+ # We default to 64 bit xxhash.
9
+ def self.hash(path, seed = File.size(path), hash = XXhash::XXhashInternal::StreamingHash64.new(seed))
9
10
  raise ArgumentError, 'file not found' unless File.file?(path)
10
11
 
11
- hash = XXhash::Internal::StreamingHash.new(seed)
12
-
13
12
  File.open(path, 'r') do |fd|
14
13
 
15
14
  sio = SamplingIO.new(fd)
@@ -21,4 +20,12 @@ module SamplingHash
21
20
 
22
21
  end
23
22
  end
23
+
24
+ def self.hash32(path, seed = File.size(path))
25
+ hash path, seed, XXHash::XXhashInternal::StreamingHash32.new(seed)
26
+ end
27
+
28
+ def self.hash64(path, seed = File.size(path))
29
+ hash path, seed, XXHash::XXhashInternal::StreamingHash64.new(seed)
30
+ end
24
31
  end
@@ -1,8 +1,8 @@
1
1
  module SamplingHash
2
2
  class Hash
3
- def initialize(size, seed = size, sampler = nil)
3
+ def initialize(size, seed = size, sampler = nil, xxhash = XXhash::XXhashInternal::StreamingHash64.new(seed))
4
4
  @sampler = sampler || Sampler.new(size)
5
- @xxhash = XXhash::Internal::StreamingHash.new(seed)
5
+ @xxhash = xxhash
6
6
 
7
7
  # Position in data stream.
8
8
  @position = 0
@@ -1,3 +1,3 @@
1
1
  module SamplingHash
2
- VERSION = '0.0.3'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sampling-hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - FlavourSys Technology GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-07 00:00:00.000000000 Z
11
+ date: 2015-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xxhash
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.0
19
+ version: '0.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.0
26
+ version: '0.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement