snappy 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +34 -0
  3. data/.github/workflows/publish.yml +34 -0
  4. data/Gemfile +3 -4
  5. data/Rakefile +32 -30
  6. data/ext/api.c +6 -1
  7. data/lib/snappy.rb +5 -5
  8. data/lib/snappy/hadoop/reader.rb +6 -2
  9. data/lib/snappy/reader.rb +11 -7
  10. data/lib/snappy/shim.rb +1 -1
  11. data/lib/snappy/version.rb +1 -1
  12. data/snappy.gemspec +13 -9
  13. data/test/hadoop/snappy_hadoop_reader_test.rb +115 -0
  14. data/test/hadoop/snappy_hadoop_writer_test.rb +48 -0
  15. data/test/snappy_hadoop_test.rb +26 -0
  16. data/test/snappy_reader_test.rb +148 -0
  17. data/test/snappy_test.rb +95 -0
  18. data/test/snappy_writer_test.rb +55 -0
  19. data/test/test_helper.rb +7 -0
  20. data/vendor/snappy/CMakeLists.txt +177 -54
  21. data/vendor/snappy/NEWS +8 -0
  22. data/vendor/snappy/README.md +19 -20
  23. data/vendor/snappy/cmake/SnappyConfig.cmake.in +33 -0
  24. data/vendor/snappy/cmake/config.h.in +6 -6
  25. data/vendor/snappy/docs/README.md +72 -0
  26. data/vendor/snappy/snappy-internal.h +12 -5
  27. data/vendor/snappy/snappy-stubs-internal.cc +1 -1
  28. data/vendor/snappy/snappy-stubs-internal.h +60 -15
  29. data/vendor/snappy/snappy-stubs-public.h.in +16 -36
  30. data/vendor/snappy/snappy-test.cc +16 -15
  31. data/vendor/snappy/snappy-test.h +12 -60
  32. data/vendor/snappy/snappy.cc +333 -187
  33. data/vendor/snappy/snappy.h +14 -10
  34. data/vendor/snappy/snappy_compress_fuzzer.cc +59 -0
  35. data/vendor/snappy/snappy_uncompress_fuzzer.cc +57 -0
  36. data/vendor/snappy/snappy_unittest.cc +220 -124
  37. metadata +26 -20
  38. data/.travis.yml +0 -31
  39. data/smoke.sh +0 -8
  40. data/test/hadoop/test-snappy-hadoop-reader.rb +0 -103
  41. data/test/hadoop/test-snappy-hadoop-writer.rb +0 -48
  42. data/test/test-snappy-hadoop.rb +0 -22
  43. data/test/test-snappy-reader.rb +0 -129
  44. data/test/test-snappy-writer.rb +0 -55
  45. data/test/test-snappy.rb +0 -58
  46. data/vendor/snappy/cmake/SnappyConfig.cmake +0 -1
@@ -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
@@ -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")