avro-salsify-fork 1.9.0.3.pre1 → 1.9.0.3.pre2
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/Manifest +2 -0
- data/Rakefile +1 -1
- data/avro-salsify-fork.gemspec +4 -4
- data/avro.gemspec +2 -2
- data/lib/avro/schema_compatibility.rb +160 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 687f4bcd8ca075dd2a402056d0da7ffb3f80afa9
|
|
4
|
+
data.tar.gz: 8ad612d52014c605de66e41aff1d79752bf10993
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f85b51bd26f1e36951632d7a7783288c0d6bfee1206a6525641be42c72cb011f85091d227b852a4a15288d0fa6a867c49db0c706f8cc3fa1bfe540220ce0ae05
|
|
7
|
+
data.tar.gz: 539b5237d35f256afa6b7d252ee70e56f9c2305794a01389bb15578c4a29baaac7993fdcf2c25ac8daf4864111720bd72b25a38342986740f5db8d8b26b3419f
|
data/Manifest
CHANGED
|
@@ -12,6 +12,7 @@ lib/avro/ipc.rb
|
|
|
12
12
|
lib/avro/logical_types.rb
|
|
13
13
|
lib/avro/protocol.rb
|
|
14
14
|
lib/avro/schema.rb
|
|
15
|
+
lib/avro/schema_compatibility.rb
|
|
15
16
|
lib/avro/schema_normalization.rb
|
|
16
17
|
test/case_finder.rb
|
|
17
18
|
test/random_data.rb
|
|
@@ -26,6 +27,7 @@ test/test_io.rb
|
|
|
26
27
|
test/test_logical_types.rb
|
|
27
28
|
test/test_protocol.rb
|
|
28
29
|
test/test_schema.rb
|
|
30
|
+
test/test_schema_compatibility.rb
|
|
29
31
|
test/test_schema_normalization.rb
|
|
30
32
|
test/test_socket_transport.rb
|
|
31
33
|
test/tool.rb
|
data/Rakefile
CHANGED
data/avro-salsify-fork.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: avro-salsify-fork 1.9.0.3.
|
|
2
|
+
# stub: avro-salsify-fork 1.9.0.3.pre2 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "avro-salsify-fork".freeze
|
|
6
|
-
s.version = "1.9.0.3.
|
|
6
|
+
s.version = "1.9.0.3.pre2"
|
|
7
7
|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2".freeze) if s.respond_to? :required_rubygems_version=
|
|
9
9
|
s.require_paths = ["lib".freeze]
|
|
@@ -11,8 +11,8 @@ Gem::Specification.new do |s|
|
|
|
11
11
|
s.date = "2016-12-15"
|
|
12
12
|
s.description = "Avro is a data serialization and RPC format.\nThis release contains the changes submitted in https://github.com/apache/avro/pull/116\nto support logical types in the Ruby gem.".freeze
|
|
13
13
|
s.email = "engineering@salsify.com".freeze
|
|
14
|
-
s.extra_rdoc_files = ["CHANGELOG".freeze, "LICENSE".freeze, "lib/avro.rb".freeze, "lib/avro/data_file.rb".freeze, "lib/avro/io.rb".freeze, "lib/avro/ipc.rb".freeze, "lib/avro/logical_types.rb".freeze, "lib/avro/protocol.rb".freeze, "lib/avro/schema.rb".freeze, "lib/avro/schema_normalization.rb".freeze]
|
|
15
|
-
s.files = ["CHANGELOG".freeze, "LICENSE".freeze, "Manifest".freeze, "NOTICE".freeze, "Rakefile".freeze, "avro-salsify-fork.gemspec".freeze, "avro.gemspec".freeze, "interop/test_interop.rb".freeze, "lib/avro.rb".freeze, "lib/avro/data_file.rb".freeze, "lib/avro/io.rb".freeze, "lib/avro/ipc.rb".freeze, "lib/avro/logical_types.rb".freeze, "lib/avro/protocol.rb".freeze, "lib/avro/schema.rb".freeze, "lib/avro/schema_normalization.rb".freeze, "test/case_finder.rb".freeze, "test/random_data.rb".freeze, "test/sample_ipc_client.rb".freeze, "test/sample_ipc_http_client.rb".freeze, "test/sample_ipc_http_server.rb".freeze, "test/sample_ipc_server.rb".freeze, "test/test_datafile.rb".freeze, "test/test_fingerprints.rb".freeze, "test/test_help.rb".freeze, "test/test_io.rb".freeze, "test/test_logical_types.rb".freeze, "test/test_protocol.rb".freeze, "test/test_schema.rb".freeze, "test/test_schema_compatibility.rb".freeze, "test/test_schema_normalization.rb".freeze, "test/test_socket_transport.rb".freeze, "test/tool.rb".freeze]
|
|
14
|
+
s.extra_rdoc_files = ["CHANGELOG".freeze, "LICENSE".freeze, "lib/avro.rb".freeze, "lib/avro/data_file.rb".freeze, "lib/avro/io.rb".freeze, "lib/avro/ipc.rb".freeze, "lib/avro/logical_types.rb".freeze, "lib/avro/protocol.rb".freeze, "lib/avro/schema.rb".freeze, "lib/avro/schema_compatibility.rb".freeze, "lib/avro/schema_normalization.rb".freeze]
|
|
15
|
+
s.files = ["CHANGELOG".freeze, "LICENSE".freeze, "Manifest".freeze, "NOTICE".freeze, "Rakefile".freeze, "avro-salsify-fork.gemspec".freeze, "avro.gemspec".freeze, "interop/test_interop.rb".freeze, "lib/avro.rb".freeze, "lib/avro/data_file.rb".freeze, "lib/avro/io.rb".freeze, "lib/avro/ipc.rb".freeze, "lib/avro/logical_types.rb".freeze, "lib/avro/protocol.rb".freeze, "lib/avro/schema.rb".freeze, "lib/avro/schema_compatibility.rb".freeze, "lib/avro/schema_normalization.rb".freeze, "test/case_finder.rb".freeze, "test/random_data.rb".freeze, "test/sample_ipc_client.rb".freeze, "test/sample_ipc_http_client.rb".freeze, "test/sample_ipc_http_server.rb".freeze, "test/sample_ipc_server.rb".freeze, "test/test_datafile.rb".freeze, "test/test_fingerprints.rb".freeze, "test/test_help.rb".freeze, "test/test_io.rb".freeze, "test/test_logical_types.rb".freeze, "test/test_protocol.rb".freeze, "test/test_schema.rb".freeze, "test/test_schema_compatibility.rb".freeze, "test/test_schema_normalization.rb".freeze, "test/test_socket_transport.rb".freeze, "test/tool.rb".freeze]
|
|
16
16
|
s.homepage = "https://github.com/salsify/avro".freeze
|
|
17
17
|
s.licenses = ["Apache License 2.0 (Apache-2.0)".freeze]
|
|
18
18
|
s.rdoc_options = ["--line-numbers".freeze, "--title".freeze, "Avro-salsify-fork".freeze]
|
data/avro.gemspec
CHANGED
|
@@ -11,8 +11,8 @@ Gem::Specification.new do |s|
|
|
|
11
11
|
s.date = "2016-09-06"
|
|
12
12
|
s.description = "Avro is a data serialization and RPC format".freeze
|
|
13
13
|
s.email = "dev@avro.apache.org".freeze
|
|
14
|
-
s.extra_rdoc_files = ["CHANGELOG".freeze, "LICENSE".freeze, "lib/avro.rb".freeze, "lib/avro/data_file.rb".freeze, "lib/avro/io.rb".freeze, "lib/avro/ipc.rb".freeze, "lib/avro/logical_types.rb".freeze, "lib/avro/protocol.rb".freeze, "lib/avro/schema.rb".freeze, "lib/avro/schema_normalization.rb".freeze]
|
|
15
|
-
s.files = ["CHANGELOG".freeze, "LICENSE".freeze, "Manifest".freeze, "NOTICE".freeze, "Rakefile".freeze, "avro.gemspec".freeze, "interop/test_interop.rb".freeze, "lib/avro.rb".freeze, "lib/avro/data_file.rb".freeze, "lib/avro/io.rb".freeze, "lib/avro/ipc.rb".freeze, "lib/avro/logical_types.rb".freeze, "lib/avro/protocol.rb".freeze, "lib/avro/schema.rb".freeze, "lib/avro/schema_normalization.rb".freeze, "test/case_finder.rb".freeze, "test/random_data.rb".freeze, "test/sample_ipc_client.rb".freeze, "test/sample_ipc_http_client.rb".freeze, "test/sample_ipc_http_server.rb".freeze, "test/sample_ipc_server.rb".freeze, "test/test_datafile.rb".freeze, "test/test_fingerprints.rb".freeze, "test/test_help.rb".freeze, "test/test_io.rb".freeze, "test/test_logical_types.rb".freeze, "test/test_protocol.rb".freeze, "test/test_schema.rb".freeze, "test/test_schema_normalization.rb".freeze, "test/test_socket_transport.rb".freeze, "test/tool.rb".freeze]
|
|
14
|
+
s.extra_rdoc_files = ["CHANGELOG".freeze, "LICENSE".freeze, "lib/avro.rb".freeze, "lib/avro/data_file.rb".freeze, "lib/avro/io.rb".freeze, "lib/avro/ipc.rb".freeze, "lib/avro/logical_types.rb".freeze, "lib/avro/protocol.rb".freeze, "lib/avro/schema.rb".freeze, "lib/avro/schema_compatibility.rb".freeze, "lib/avro/schema_normalization.rb".freeze]
|
|
15
|
+
s.files = ["CHANGELOG".freeze, "LICENSE".freeze, "Manifest".freeze, "NOTICE".freeze, "Rakefile".freeze, "avro.gemspec".freeze, "interop/test_interop.rb".freeze, "lib/avro.rb".freeze, "lib/avro/data_file.rb".freeze, "lib/avro/io.rb".freeze, "lib/avro/ipc.rb".freeze, "lib/avro/logical_types.rb".freeze, "lib/avro/protocol.rb".freeze, "lib/avro/schema.rb".freeze, "lib/avro/schema_compatibility.rb".freeze, "lib/avro/schema_normalization.rb".freeze, "test/case_finder.rb".freeze, "test/random_data.rb".freeze, "test/sample_ipc_client.rb".freeze, "test/sample_ipc_http_client.rb".freeze, "test/sample_ipc_http_server.rb".freeze, "test/sample_ipc_server.rb".freeze, "test/test_datafile.rb".freeze, "test/test_fingerprints.rb".freeze, "test/test_help.rb".freeze, "test/test_io.rb".freeze, "test/test_logical_types.rb".freeze, "test/test_protocol.rb".freeze, "test/test_schema.rb".freeze, "test/test_schema_compatibility.rb".freeze, "test/test_schema_normalization.rb".freeze, "test/test_socket_transport.rb".freeze, "test/tool.rb".freeze]
|
|
16
16
|
s.homepage = "http://avro.apache.org/".freeze
|
|
17
17
|
s.licenses = ["Apache License 2.0 (Apache-2.0)".freeze]
|
|
18
18
|
s.rdoc_options = ["--line-numbers".freeze, "--title".freeze, "Avro".freeze]
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
# to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License. You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
module Avro
|
|
17
|
+
module SchemaCompatibility
|
|
18
|
+
def self.can_read?(writers_schema, readers_schema)
|
|
19
|
+
Checker.new.can_read?(writers_schema, readers_schema)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.mutual_read?(writers_schema, readers_schema)
|
|
23
|
+
Checker.new.mutual_read?(writers_schema, readers_schema)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.match_schemas(writers_schema, readers_schema)
|
|
27
|
+
# Note: this does not support aliases!
|
|
28
|
+
w_type = writers_schema.type_sym
|
|
29
|
+
r_type = readers_schema.type_sym
|
|
30
|
+
|
|
31
|
+
# This conditional is begging for some OO love.
|
|
32
|
+
if w_type == :union || r_type == :union
|
|
33
|
+
return true
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
if w_type == r_type
|
|
37
|
+
return true if Schema::PRIMITIVE_TYPES_SYM.include?(r_type)
|
|
38
|
+
|
|
39
|
+
case r_type
|
|
40
|
+
when :record
|
|
41
|
+
return writers_schema.fullname == readers_schema.fullname
|
|
42
|
+
when :error
|
|
43
|
+
return writers_schema.fullname == readers_schema.fullname
|
|
44
|
+
when :request
|
|
45
|
+
return true
|
|
46
|
+
when :fixed
|
|
47
|
+
return writers_schema.fullname == readers_schema.fullname &&
|
|
48
|
+
writers_schema.size == readers_schema.size
|
|
49
|
+
when :enum
|
|
50
|
+
return writers_schema.fullname == readers_schema.fullname
|
|
51
|
+
when :map
|
|
52
|
+
return match_schemas(writers_schema.values, readers_schema.values)
|
|
53
|
+
when :array
|
|
54
|
+
return match_schemas(writers_schema.items, readers_schema.items)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Handle schema promotion
|
|
59
|
+
if w_type == :int && [:long, :float, :double].include?(r_type)
|
|
60
|
+
return true
|
|
61
|
+
elsif w_type == :long && [:float, :double].include?(r_type)
|
|
62
|
+
return true
|
|
63
|
+
elsif w_type == :float && r_type == :double
|
|
64
|
+
return true
|
|
65
|
+
elsif w_type == :string && r_type == :bytes
|
|
66
|
+
return true
|
|
67
|
+
elsif w_type == :bytes && r_type == :string
|
|
68
|
+
return true
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
return false
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
class Checker
|
|
75
|
+
SIMPLE_CHECKS = Schema::PRIMITIVE_TYPES_SYM.dup.add(:fixed).freeze
|
|
76
|
+
|
|
77
|
+
attr_reader :recursion_set
|
|
78
|
+
private :recursion_set
|
|
79
|
+
|
|
80
|
+
def initialize
|
|
81
|
+
@recursion_set = Set.new
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def can_read?(writers_schema, readers_schema)
|
|
85
|
+
full_match_schemas(writers_schema, readers_schema)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def mutual_read?(writers_schema, readers_schema)
|
|
89
|
+
can_read?(writers_schema, readers_schema) && can_read?(readers_schema, writers_schema)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
|
|
94
|
+
def full_match_schemas(writers_schema, readers_schema)
|
|
95
|
+
return true if recursion_in_progress?(writers_schema, readers_schema)
|
|
96
|
+
|
|
97
|
+
return false unless Avro::SchemaCompatibility.match_schemas(writers_schema, readers_schema)
|
|
98
|
+
|
|
99
|
+
if writers_schema.type_sym != :union && SIMPLE_CHECKS.include?(readers_schema.type_sym)
|
|
100
|
+
return true
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
case readers_schema.type_sym
|
|
104
|
+
when :record
|
|
105
|
+
match_record_schemas(writers_schema, readers_schema)
|
|
106
|
+
when :map
|
|
107
|
+
full_match_schemas(writers_schema.values, readers_schema.values)
|
|
108
|
+
when :array
|
|
109
|
+
full_match_schemas(writers_schema.items, readers_schema.items)
|
|
110
|
+
when :union
|
|
111
|
+
match_union_schemas(writers_schema, readers_schema)
|
|
112
|
+
when :enum
|
|
113
|
+
# reader's symbols must contain all writer's symbols
|
|
114
|
+
(writers_schema.symbols - readers_schema.symbols).empty?
|
|
115
|
+
else
|
|
116
|
+
if writers_schema.type_sym == :union && writers_schema.schemas.size == 1
|
|
117
|
+
full_match_schemas(writers_schema.schemas.first, readers_schema)
|
|
118
|
+
else
|
|
119
|
+
false
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def match_union_schemas(writers_schema, readers_schema)
|
|
125
|
+
raise 'readers_schema must be a union' unless readers_schema.type_sym == :union
|
|
126
|
+
|
|
127
|
+
case writers_schema.type_sym
|
|
128
|
+
when :union
|
|
129
|
+
writers_schema.schemas.all? { |writer_type| full_match_schemas(writer_type, readers_schema) }
|
|
130
|
+
else
|
|
131
|
+
readers_schema.schemas.any? { |reader_type| full_match_schemas(writers_schema, reader_type) }
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def match_record_schemas(writers_schema, readers_schema)
|
|
136
|
+
writer_fields_hash = writers_schema.fields_hash
|
|
137
|
+
readers_schema.fields.each do |field|
|
|
138
|
+
if writer_fields_hash.key?(field.name)
|
|
139
|
+
return false unless full_match_schemas(writer_fields_hash[field.name].type, field.type)
|
|
140
|
+
else
|
|
141
|
+
return false unless field.default?
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
return true
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def recursion_in_progress?(writers_schema, readers_schema)
|
|
149
|
+
key = [writers_schema.object_id, readers_schema.object_id]
|
|
150
|
+
|
|
151
|
+
if recursion_set.include?(key)
|
|
152
|
+
true
|
|
153
|
+
else
|
|
154
|
+
recursion_set.add(key)
|
|
155
|
+
false
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: avro-salsify-fork
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.0.3.
|
|
4
|
+
version: 1.9.0.3.pre2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Apache Software Foundation / Salsify Engineering
|
|
@@ -41,6 +41,7 @@ extra_rdoc_files:
|
|
|
41
41
|
- lib/avro/logical_types.rb
|
|
42
42
|
- lib/avro/protocol.rb
|
|
43
43
|
- lib/avro/schema.rb
|
|
44
|
+
- lib/avro/schema_compatibility.rb
|
|
44
45
|
- lib/avro/schema_normalization.rb
|
|
45
46
|
files:
|
|
46
47
|
- CHANGELOG
|
|
@@ -58,6 +59,7 @@ files:
|
|
|
58
59
|
- lib/avro/logical_types.rb
|
|
59
60
|
- lib/avro/protocol.rb
|
|
60
61
|
- lib/avro/schema.rb
|
|
62
|
+
- lib/avro/schema_compatibility.rb
|
|
61
63
|
- lib/avro/schema_normalization.rb
|
|
62
64
|
- test/case_finder.rb
|
|
63
65
|
- test/random_data.rb
|