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 +4 -4
- data/lib/sampling-hash.rb +10 -3
- data/lib/sampling-hash/hash.rb +2 -2
- data/lib/sampling-hash/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9edbe5d8263f8f1bb98e2687b248d889609c3756
|
4
|
+
data.tar.gz: 4b9f82dd03f06665d425f40fb8d59b668a8926d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
data/lib/sampling-hash/hash.rb
CHANGED
@@ -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 =
|
5
|
+
@xxhash = xxhash
|
6
6
|
|
7
7
|
# Position in data stream.
|
8
8
|
@position = 0
|
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
|
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-
|
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.
|
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.
|
26
|
+
version: '0.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|