lz4-ruby 0.2.0-java

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.
@@ -0,0 +1,64 @@
1
+ package com.headius.jruby.lz4;
2
+
3
+ import net.jpountz.lz4.LZ4Compressor;
4
+ import net.jpountz.lz4.LZ4Factory;
5
+ import org.jruby.RubyInteger;
6
+ import org.jruby.RubyString;
7
+ import org.jruby.anno.JRubyMethod;
8
+ import org.jruby.runtime.ThreadContext;
9
+ import org.jruby.runtime.builtin.IRubyObject;
10
+ import org.jruby.util.ByteList;
11
+
12
+ public class LZ4Internal {
13
+ private static final LZ4Factory FACTORY = LZ4Factory.fastestInstance();
14
+
15
+ public static IRubyObject compress_internal(ThreadContext context, LZ4Compressor compressor, IRubyObject _header, IRubyObject _input, IRubyObject _in_size) {
16
+ RubyString input = _input.convertToString();
17
+ RubyString header = _header.convertToString();
18
+ RubyInteger in_size = _in_size.convertToInteger();
19
+
20
+ ByteList inputBL = input.getByteList();
21
+ int srcSize = (int)in_size.getLongValue();
22
+
23
+ ByteList headerBL = header.getByteList();
24
+ int headerSize = headerBL.getRealSize();
25
+
26
+ int bufSize = compressor.maxCompressedLength(srcSize);
27
+ byte[] buf = new byte[bufSize + headerSize];
28
+
29
+ System.arraycopy(headerBL.getUnsafeBytes(), headerBL.getBegin(), buf, 0, headerSize);
30
+
31
+ compressor.compress(inputBL.getUnsafeBytes(), inputBL.getBegin(), srcSize, buf, headerSize);
32
+
33
+ return RubyString.newStringNoCopy(context.runtime, buf);
34
+ }
35
+
36
+ @JRubyMethod(module = true)
37
+ public static IRubyObject compress(ThreadContext context, IRubyObject self, IRubyObject _header, IRubyObject _input, IRubyObject _in_size) {
38
+ return compress_internal(context, FACTORY.fastCompressor(), _header, _input, _in_size);
39
+ }
40
+
41
+ @JRubyMethod(module = true)
42
+ public static IRubyObject compressHC(ThreadContext context, IRubyObject self, IRubyObject _header, IRubyObject _input, IRubyObject _in_size) {
43
+ return compress_internal(context, FACTORY.highCompressor(), _header, _input, _in_size);
44
+ }
45
+
46
+ @JRubyMethod(required = 4, module = true)
47
+ public static IRubyObject uncompress(ThreadContext context, IRubyObject self, IRubyObject[] args) {
48
+ RubyString input = args[0].convertToString();
49
+ RubyInteger in_size = args[1].convertToInteger();
50
+ RubyInteger header_size = args[2].convertToInteger();
51
+ RubyInteger buf_size = args[3].convertToInteger();
52
+
53
+ ByteList inputBL = input.getByteList();
54
+ int inSize = (int)in_size.getLongValue();
55
+ int headerSize = (int)header_size.getLongValue();
56
+ int bufSize = (int)buf_size.getLongValue();
57
+
58
+ byte[] buf = new byte[bufSize];
59
+
60
+ FACTORY.decompressor().decompress(inputBL.getUnsafeBytes(), inputBL.getBegin() + headerSize, buf, 0, buf.length);
61
+
62
+ return RubyString.newStringNoCopy(context.runtime, buf);
63
+ }
64
+ }
@@ -0,0 +1,18 @@
1
+ package com.headius.jruby.lz4;
2
+
3
+ import java.io.IOException;
4
+ import org.jruby.Ruby;
5
+ import org.jruby.RubyModule;
6
+ import org.jruby.runtime.load.Library;
7
+
8
+ public class LZ4Library implements Library {
9
+
10
+ public void load(Ruby runtime, boolean wrap) throws IOException {
11
+ RubyModule lz4Internal = runtime.defineModule("LZ4Internal");
12
+
13
+ lz4Internal.defineAnnotatedMethods(LZ4Internal.class);
14
+
15
+ lz4Internal.defineClassUnder("Error", runtime.getStandardError(), runtime.getStandardError().getAllocator());
16
+ }
17
+
18
+ }
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lz4-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: java
6
+ authors:
7
+ - KOMIYA Atsushi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - '>='
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
25
+ prerelease: false
26
+ type: :development
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '3.12'
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '3.12'
39
+ prerelease: false
40
+ type: :development
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ prerelease: false
54
+ type: :development
55
+ - !ruby/object:Gem::Dependency
56
+ name: jeweler
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.3
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 1.8.3
67
+ prerelease: false
68
+ type: :development
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake-compiler
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ prerelease: false
82
+ type: :development
83
+ description: Ruby bindings for LZ4. LZ4 is a very fast lossless compression algorithm.
84
+ email: komiya.atsushi@gmail.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files:
88
+ - LICENSE.txt
89
+ - README.rdoc
90
+ files:
91
+ - .document
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.rdoc
95
+ - Rakefile
96
+ - VERSION
97
+ - benchmarking/bench.rb
98
+ - benchmarking/bench_all.sh
99
+ - benchmarking/compressor.rb
100
+ - benchmarking/compressor_lz4.rb
101
+ - benchmarking/compressor_lzo.rb
102
+ - benchmarking/compressor_snappy.rb
103
+ - ext/lz4ruby/extconf.rb
104
+ - ext/lz4ruby/lz4.c
105
+ - ext/lz4ruby/lz4.h
106
+ - ext/lz4ruby/lz4hc.c
107
+ - ext/lz4ruby/lz4hc.h
108
+ - ext/lz4ruby/lz4ruby.c
109
+ - lib/lz4-jruby.rb
110
+ - lib/lz4-ruby.rb
111
+ - lib/lz4ruby.jar
112
+ - pom.xml
113
+ - spec/helper.rb
114
+ - spec/lz4_compressHC_spec.rb
115
+ - spec/lz4_compress_spec.rb
116
+ - src/main/java/com/headius/jruby/lz4/LZ4Internal.java
117
+ - src/main/java/com/headius/jruby/lz4/LZ4Library.java
118
+ homepage: http://github.com/komiya-atsushi/lz4-ruby
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.1.9
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Ruby bindings for LZ4 (Extremely Fast Compression algorithm).
142
+ test_files: []