lz4_flex 0.1.1.pre2-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +21 -0
- data/README.md +99 -0
- data/lib/lz4_flex/3.2/lz4_flex_ext.bundle +0 -0
- data/lib/lz4_flex/3.3/lz4_flex_ext.bundle +0 -0
- data/lib/lz4_flex/version.rb +6 -0
- data/lib/lz4_flex.rb +10 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c0613aa1dd048b705253080ddf3c686caf87f81af10184c7d811acf078a98480
|
4
|
+
data.tar.gz: e02c7526fc72b8b0f9ef83e4f102c9a22cacd4a18e18be072cc81dc9b2bfd0e6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8edff6805db69d5eac77ede46db44e90dda0e3df707bfadd1110a54cd7faae34b0512206be1693148a7c76957654a6e73f8081956a78c46b48b338277601c7c3
|
7
|
+
data.tar.gz: 0527b06314a85f1ccc6269843d2af0517b7f8bfd8e2a17dcca77c2c8b2bcad5d5e51fa44a28fd7cf8d9c8c9f56d5de1aea1003b01f3330431560702466849c22
|
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Shopify
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# `lz4-flex-rb`
|
2
|
+
|
3
|
+
## About this library
|
4
|
+
|
5
|
+
**Introduction:**
|
6
|
+
`lz4-flex-rb` is a modern LZ4 compression library for Ruby, leveraging the
|
7
|
+
power of the [`lz4_flex`](https://github.com/PSeitz/lz4_flex) Rust crate. This
|
8
|
+
library provides a pure Rust implementation of the LZ4 algorithm, ensuring high
|
9
|
+
performance and safety. One of the standout features of `lz4_flex-rb` is its
|
10
|
+
ability to conditionally unlock the Global VM Lock (GVL) for threaded web
|
11
|
+
servers, enhancing concurrency and performance in multi-threaded environments.
|
12
|
+
|
13
|
+
## How to install this library
|
14
|
+
|
15
|
+
### Requirements
|
16
|
+
- Ruby 3.0 or higher
|
17
|
+
- Rust (for building the native extension)
|
18
|
+
|
19
|
+
### Setup
|
20
|
+
Add this line to your application's Gemfile:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'lz4_flex'
|
24
|
+
```
|
25
|
+
|
26
|
+
And then execute:
|
27
|
+
|
28
|
+
```sh
|
29
|
+
bundle install
|
30
|
+
```
|
31
|
+
|
32
|
+
### Troubleshooting
|
33
|
+
|
34
|
+
If you encounter issues during installation, ensure that Rust is correctly installed and available in your PATH. You can install Rust from [rustup.rs](https://rustup.rs/).
|
35
|
+
|
36
|
+
## How to use this library
|
37
|
+
|
38
|
+
There are two methods provided, `LZ4Flex.compress` and `Lz4Flex.decompress`.
|
39
|
+
Both of these methods utilize the lz4 block format, with a small header to
|
40
|
+
record the string's size and encoding.
|
41
|
+
|
42
|
+
### Basic Usage
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
require 'lz4_flex'
|
46
|
+
|
47
|
+
# Compress data
|
48
|
+
compressed = LZ4Flex.compress("Hello, World!")
|
49
|
+
|
50
|
+
# Decompress data
|
51
|
+
decompressed = LZ4Flex.decompress(compressed)
|
52
|
+
|
53
|
+
puts decompressed # => "Hello, World!"
|
54
|
+
puts decompressed.encoding # => Encoding::UTF_8
|
55
|
+
```
|
56
|
+
|
57
|
+
The header used in these methods will not be recognizable from other lz4 block
|
58
|
+
parsers. If you need that, it's best to use the Frame API (which is currently a
|
59
|
+
WIP).
|
60
|
+
|
61
|
+
### Migrating from `lz4-ruby`
|
62
|
+
|
63
|
+
The [`lz4-ruby`](https://github.com/komiya-atsushi/lz4-ruby) gem uses a slighty
|
64
|
+
different header format, which keeps track of string size but not the string's
|
65
|
+
encoding.
|
66
|
+
|
67
|
+
To make it easy to migrate to `lz4_flex`, we provide a parser for the
|
68
|
+
`lz4-ruby` format:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
# Say you have a string that was compressed with lz4-ruby...
|
72
|
+
lz4_ruby_compressed = LZ4.compress("Yo!")
|
73
|
+
|
74
|
+
# You can decode it with lz4_flex:
|
75
|
+
decompressed = Lz4Flex::VarInt.decompress(lz4_ruby_compressed)
|
76
|
+
|
77
|
+
puts decompressed #=> "Yo!"
|
78
|
+
puts decompressed.encoding #=> Encoding::BINARY
|
79
|
+
```
|
80
|
+
|
81
|
+
Combine
|
82
|
+
|
83
|
+
### Running Tests
|
84
|
+
To run the tests, execute:
|
85
|
+
|
86
|
+
```sh
|
87
|
+
bundle exec rake
|
88
|
+
```
|
89
|
+
|
90
|
+
## Contribute to this library (optional)
|
91
|
+
|
92
|
+
1. Fork the repository.
|
93
|
+
2. Create a new branch (`git checkout -b my-feature-branch`).
|
94
|
+
3. Make your changes.
|
95
|
+
4. Commit your changes (`git commit -am 'Add new feature'`).
|
96
|
+
5. Push to the branch (`git push origin my-feature-branch`).
|
97
|
+
6. Create a new Pull Request.
|
98
|
+
|
99
|
+
Please ensure your code adheres to the project's coding standards and includes appropriate tests.
|
Binary file
|
Binary file
|
data/lib/lz4_flex.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Tries to require the precompiled extension for the given Ruby version first
|
5
|
+
begin
|
6
|
+
RUBY_VERSION =~ /(\d+\.\d+)/
|
7
|
+
require "lz4_flex/#{Regexp.last_match(1)}/lz4_flex_ext"
|
8
|
+
rescue LoadError
|
9
|
+
require_relative "lz4_flex/lz4_flex_ext"
|
10
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lz4_flex
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1.pre2
|
5
|
+
platform: arm64-darwin
|
6
|
+
authors:
|
7
|
+
- Shopify Engineering
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-08-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A modern LZ4 compression library for Ruby, leveraging the power of the
|
14
|
+
[`lz4_flex`](https://github.com/PSeitz/lz4_flex) Rust crate. This library provides
|
15
|
+
a pure Rust implementation of the LZ4 algorithm, ensuring high performance and safety.
|
16
|
+
email:
|
17
|
+
- gems@shopify.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- LICENSE.md
|
23
|
+
- README.md
|
24
|
+
- lib/lz4_flex.rb
|
25
|
+
- lib/lz4_flex/3.2/lz4_flex_ext.bundle
|
26
|
+
- lib/lz4_flex/3.3/lz4_flex_ext.bundle
|
27
|
+
- lib/lz4_flex/version.rb
|
28
|
+
homepage: https://github.com/Shopify/lz4-flex-rb
|
29
|
+
licenses:
|
30
|
+
- MIT
|
31
|
+
metadata:
|
32
|
+
allowed_push_host: https://rubygems.org
|
33
|
+
homepage_uri: https://github.com/Shopify/lz4-flex-rb
|
34
|
+
source_code_uri: https://github.com/Shopify/lz4-flex-rb
|
35
|
+
changelog_uri: https://github.com/Shopify/lz4-flex-rb/releases
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '3.2'
|
45
|
+
- - "<"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.4.dev
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.3.1
|
53
|
+
requirements: []
|
54
|
+
rubygems_version: 3.4.4
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: A modern LZ4 compression library for Ruby, leveraging the `lz4_flex` Rust
|
58
|
+
crate.
|
59
|
+
test_files: []
|