26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/avro/schema_compatibility.rb', line 26
def self.match_schemas(writers_schema, readers_schema)
w_type = writers_schema.type_sym
r_type = readers_schema.type_sym
if w_type == :union || r_type == :union
return true
end
if w_type == r_type
return true if Schema::PRIMITIVE_TYPES_SYM.include?(r_type)
case r_type
when :record
return writers_schema.fullname == readers_schema.fullname
when :error
return writers_schema.fullname == readers_schema.fullname
when :request
return true
when :fixed
return writers_schema.fullname == readers_schema.fullname &&
writers_schema.size == readers_schema.size
when :enum
return writers_schema.fullname == readers_schema.fullname
when :map
return match_schemas(writers_schema.values, readers_schema.values)
when :array
return match_schemas(writers_schema.items, readers_schema.items)
end
end
if w_type == :int && [:long, :float, :double].include?(r_type)
return true
elsif w_type == :long && [:float, :double].include?(r_type)
return true
elsif w_type == :float && r_type == :double
return true
elsif w_type == :string && r_type == :bytes
return true
elsif w_type == :bytes && r_type == :string
return true
end
return false
end
|