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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c6ca3081364705f70d24e2993fd79e3f0fd24f241f4a5fd9e432fa4a55b70d2
4
- data.tar.gz: 4277a7ce247beeac5ee52ad75c6a5bd7854fe673c8298c1e3f3654890b30db8b
3
+ metadata.gz: 109a268a05fcd52d0d049da87d7df92db395abc7df29cfef3391077101b11219
4
+ data.tar.gz: 61f5af08f76002e30ec70f8847733b538b115eb1110898fb7b548e938e5f0998
5
5
  SHA512:
6
- metadata.gz: 7f25cd04b62ba3f44f050d32b27e8e28fc32714acc930a369baff540c8ae306494cfaa75b82882db4013bf9b0d28168f8bd3d2d33b48065ff0345d581675e69b
7
- data.tar.gz: ee430790f1dc828a3101d132501acf86e05dc55d21e9b613a4dad28fe4c480395c596af56627ab35dfa1dd1545a00808dfd58ebbdd23dfb76284b2bd79e0424f
6
+ metadata.gz: 93640a4b5bbf69dafdd509edf636f80ced9bc03d9c2543b95152b8a25c1dfb1e035feefa89250f96367746c3744cf66229f229402c5697e9565addc1ca097009
7
+ data.tar.gz: ddcb35507cdc65d87fd7bf6ee03a0d35ad611a498643b0ef037f7c50e8d1aeca0e188e021d7753c1b7dda2277dc749e27b95098cbe006c8717a155600c845c66
@@ -1,5 +1,8 @@
1
1
  # avro-patches
2
2
 
3
+ ## v0.4.1
4
+ - Optimize binary encoder and decoder.
5
+
3
6
  ## v0.4.0
4
7
  - Optionally fail validation when extra fields are present.
5
8
  - Check that field defaults have the correct type.
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.
@@ -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
@@ -1,3 +1,3 @@
1
1
  module AvroPatches
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.4.1'.freeze
3
3
  end
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.0
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-07-31 00:00:00.000000000 Z
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.6
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