avro-patches 0.4.0 → 0.4.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +1 -0
- data/lib/avro-patches.rb +1 -0
- data/lib/avro-patches/optimized_serde.rb +53 -0
- data/lib/avro-patches/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 109a268a05fcd52d0d049da87d7df92db395abc7df29cfef3391077101b11219
|
4
|
+
data.tar.gz: 61f5af08f76002e30ec70f8847733b538b115eb1110898fb7b548e938e5f0998
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93640a4b5bbf69dafdd509edf636f80ced9bc03d9c2543b95152b8a25c1dfb1e035feefa89250f96367746c3744cf66229f229402c5697e9565addc1ca097009
|
7
|
+
data.tar.gz: ddcb35507cdc65d87fd7bf6ee03a0d35ad611a498643b0ef037f7c50e8d1aeca0e188e021d7753c1b7dda2277dc749e27b95098cbe006c8717a155600c845c66
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -13,6 +13,7 @@ The following pending or unreleased changes are included:
|
|
13
13
|
- [AVRO-2039: Ruby encoding performance improvements](https://github.com/apache/avro/pull/230)
|
14
14
|
- [AVRO-2200: Option to fail when extra fields are in the payload](https://github.com/apache/avro/pull/321)
|
15
15
|
- [AVRO-2199: Validate that field defaults have the correct type](https://github.com/apache/avro/pull/320)
|
16
|
+
- [AVRO-2281: Optimize ruby binary encoder/decoder](https://github.com/apache/avro/pull/401)
|
16
17
|
|
17
18
|
In addition, compatibility with Ruby 2.4 (https://github.com/apache/avro/pull/191)
|
18
19
|
has been integrated with the changes above.
|
data/lib/avro-patches.rb
CHANGED
@@ -34,6 +34,7 @@ require 'avro-patches/schema_validator'
|
|
34
34
|
require 'avro-patches/logical_types'
|
35
35
|
require 'avro-patches/schema_compatibility'
|
36
36
|
require 'avro-patches/default_validation'
|
37
|
+
require 'avro-patches/optimized_serde'
|
37
38
|
|
38
39
|
# Remaining requires from the official avro gem
|
39
40
|
require 'avro/data_file'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Avro::IO::BinaryDecoder.class_eval do
|
2
|
+
|
3
|
+
def byte!
|
4
|
+
@reader.readbyte
|
5
|
+
end
|
6
|
+
|
7
|
+
def read_float
|
8
|
+
read_and_unpack(4, 'e'.freeze)
|
9
|
+
end
|
10
|
+
|
11
|
+
def read_double
|
12
|
+
read_and_unpack(8, 'E'.freeze)
|
13
|
+
end
|
14
|
+
|
15
|
+
def read_string
|
16
|
+
read_bytes.tap do |string|
|
17
|
+
string.force_encoding('utf-8'.freeze) if string.respond_to?(:force_encoding)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# Optimize unpacking strings when `unpack1` is available (ruby >= 2.4)
|
24
|
+
if String.instance_methods.include?(:unpack1)
|
25
|
+
|
26
|
+
def read_and_unpack(byte_count, format)
|
27
|
+
@reader.read(byte_count).unpack1(format)
|
28
|
+
end
|
29
|
+
|
30
|
+
else
|
31
|
+
|
32
|
+
def read_and_unpack(byte_count, format)
|
33
|
+
@reader.read(byte_count).unpack(format)[0]
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Avro::IO::BinaryEncoder.class_eval do
|
40
|
+
|
41
|
+
def write_float(datum)
|
42
|
+
@writer.write([datum].pack('e'.freeze))
|
43
|
+
end
|
44
|
+
|
45
|
+
def write_double(datum)
|
46
|
+
@writer.write([datum].pack('E'.freeze))
|
47
|
+
end
|
48
|
+
|
49
|
+
def write_string(datum)
|
50
|
+
datum = datum.encode('utf-8'.freeze) if datum.respond_to?(:encode)
|
51
|
+
write_bytes(datum)
|
52
|
+
end
|
53
|
+
end
|
data/lib/avro-patches/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avro-patches
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Salsify, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/avro-patches/logical_types/logical_types.rb
|
110
110
|
- lib/avro-patches/logical_types/schema.rb
|
111
111
|
- lib/avro-patches/logical_types/schema_validator.rb
|
112
|
+
- lib/avro-patches/optimized_serde.rb
|
112
113
|
- lib/avro-patches/schema_compatibility.rb
|
113
114
|
- lib/avro-patches/schema_compatibility/io.rb
|
114
115
|
- lib/avro-patches/schema_compatibility/schema.rb
|
@@ -140,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
141
|
version: '0'
|
141
142
|
requirements: []
|
142
143
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.7.
|
144
|
+
rubygems_version: 2.7.7
|
144
145
|
signing_key:
|
145
146
|
specification_version: 4
|
146
147
|
summary: Patches for the official Apache Avro Ruby implementation
|