snappy 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +34 -0
- data/.github/workflows/publish.yml +34 -0
- data/Gemfile +3 -4
- data/Rakefile +32 -30
- data/ext/api.c +6 -1
- data/lib/snappy.rb +5 -5
- data/lib/snappy/hadoop/reader.rb +6 -2
- data/lib/snappy/reader.rb +11 -7
- data/lib/snappy/shim.rb +1 -1
- data/lib/snappy/version.rb +1 -1
- data/snappy.gemspec +13 -9
- data/test/hadoop/snappy_hadoop_reader_test.rb +115 -0
- data/test/hadoop/snappy_hadoop_writer_test.rb +48 -0
- data/test/snappy_hadoop_test.rb +26 -0
- data/test/snappy_reader_test.rb +148 -0
- data/test/snappy_test.rb +95 -0
- data/test/snappy_writer_test.rb +55 -0
- data/test/test_helper.rb +7 -0
- data/vendor/snappy/CMakeLists.txt +177 -54
- data/vendor/snappy/NEWS +8 -0
- data/vendor/snappy/README.md +19 -20
- data/vendor/snappy/cmake/SnappyConfig.cmake.in +33 -0
- data/vendor/snappy/cmake/config.h.in +6 -6
- data/vendor/snappy/docs/README.md +72 -0
- data/vendor/snappy/snappy-internal.h +12 -5
- data/vendor/snappy/snappy-stubs-internal.cc +1 -1
- data/vendor/snappy/snappy-stubs-internal.h +60 -15
- data/vendor/snappy/snappy-stubs-public.h.in +16 -36
- data/vendor/snappy/snappy-test.cc +16 -15
- data/vendor/snappy/snappy-test.h +12 -60
- data/vendor/snappy/snappy.cc +333 -187
- data/vendor/snappy/snappy.h +14 -10
- data/vendor/snappy/snappy_compress_fuzzer.cc +59 -0
- data/vendor/snappy/snappy_uncompress_fuzzer.cc +57 -0
- data/vendor/snappy/snappy_unittest.cc +220 -124
- metadata +26 -20
- data/.travis.yml +0 -31
- data/smoke.sh +0 -8
- data/test/hadoop/test-snappy-hadoop-reader.rb +0 -103
- data/test/hadoop/test-snappy-hadoop-writer.rb +0 -48
- data/test/test-snappy-hadoop.rb +0 -22
- data/test/test-snappy-reader.rb +0 -129
- data/test/test-snappy-writer.rb +0 -55
- data/test/test-snappy.rb +0 -58
- data/vendor/snappy/cmake/SnappyConfig.cmake +0 -1
data/test/test-snappy-writer.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require "minitest/autorun"
|
2
|
-
require "minitest/spec"
|
3
|
-
require "snappy"
|
4
|
-
require "stringio"
|
5
|
-
|
6
|
-
describe Snappy::Writer do
|
7
|
-
before do
|
8
|
-
@buffer = StringIO.new
|
9
|
-
end
|
10
|
-
|
11
|
-
subject do
|
12
|
-
Snappy::Writer.new @buffer
|
13
|
-
end
|
14
|
-
|
15
|
-
describe :initialize do
|
16
|
-
it "should yield itself to the block" do
|
17
|
-
yielded = nil
|
18
|
-
returned = Snappy::Writer.new @buffer do |w|
|
19
|
-
yielded = w
|
20
|
-
end
|
21
|
-
returned.must_equal yielded
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should write the header" do
|
25
|
-
subject.io.string.must_equal [Snappy::Writer::MAGIC,
|
26
|
-
Snappy::Writer::DEFAULT_VERSION,
|
27
|
-
Snappy::Writer::MINIMUM_COMPATIBLE_VERSION].pack("a8NN")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should dump on the end of yield" do
|
31
|
-
Snappy::Writer.new @buffer do |w|
|
32
|
-
w << "foo"
|
33
|
-
end
|
34
|
-
foo = Snappy.deflate "foo"
|
35
|
-
@buffer.string[16, @buffer.size - 16].must_equal [foo.size, foo].pack("Na#{foo.size}")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe :io do
|
40
|
-
it "should be a constructor argument" do
|
41
|
-
io = StringIO.new
|
42
|
-
Snappy::Writer.new(io).io.must_equal io
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe :block_size do
|
47
|
-
it "should default to DEFAULT_BLOCK_SIZE" do
|
48
|
-
Snappy::Writer.new(StringIO.new).block_size.must_equal Snappy::Writer::DEFAULT_BLOCK_SIZE
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should be settable via the constructor" do
|
52
|
-
Snappy::Writer.new(StringIO.new, 42).block_size.must_equal 42
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/test/test-snappy.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
require 'minitest/spec'
|
3
|
-
require 'snappy'
|
4
|
-
|
5
|
-
describe Snappy do
|
6
|
-
T = [*'a'..'z', *'A'..'Z', *'0'..'9']
|
7
|
-
|
8
|
-
it 'well done' do
|
9
|
-
s = Array.new(1024){T.sample}.join
|
10
|
-
Snappy.inflate(Snappy.deflate s).must_equal(s)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'well done (pair)' do
|
14
|
-
s = Array.new(1024){T.sample}.join
|
15
|
-
[
|
16
|
-
[:deflate, :inflate],
|
17
|
-
[:compress, :uncompress],
|
18
|
-
[:dump, :load],
|
19
|
-
].each do |(i, o)|
|
20
|
-
Snappy.__send__(o, (Snappy.__send__ i, s)).must_equal(s)
|
21
|
-
eval %{Snappy.#{o}(Snappy.#{i} s).must_equal(s)}
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#deflate' do
|
26
|
-
it 'can pass buffer' do
|
27
|
-
skip 'cannot pass buffer in jruby' if defined? JRUBY_VERSION
|
28
|
-
s = 'a' * 1024
|
29
|
-
d = ' ' * 1024
|
30
|
-
r = Snappy.deflate(s, d)
|
31
|
-
d.must_be_same_as r
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '#inflate' do
|
36
|
-
it 'can pass buffer' do
|
37
|
-
skip 'cannot pass buffer in jruby' if defined? JRUBY_VERSION
|
38
|
-
s = Snappy.deflate('a' * 1024)
|
39
|
-
d = ' ' * 1024
|
40
|
-
r = Snappy.inflate(s, d)
|
41
|
-
d.must_be_same_as r
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#valid?' do
|
46
|
-
it 'return true when passed deflated data' do
|
47
|
-
skip 'snappy-jars does not have valid?' if defined? JRUBY_VERSION
|
48
|
-
d = Snappy.deflate(Array.new(1024){T.sample}.join)
|
49
|
-
Snappy.valid?(d).must_equal true
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'return false when passed invalid data' do
|
53
|
-
skip 'snappy-jars does not have valid?' if defined? JRUBY_VERSION
|
54
|
-
d = Snappy.deflate(Array.new(1024){T.sample}.join).reverse
|
55
|
-
Snappy.valid?(d).must_equal false
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
include("${CMAKE_CURRENT_LIST_DIR}/SnappyTargets.cmake")
|