avro-salsify-fork 1.9.0.0 → 1.9.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/Rakefile +1 -1
- data/avro-salsify-fork.gemspec +21 -21
- data/lib/avro/io.rb +1 -1
- data/lib/avro/schema.rb +10 -2
- data/test/random_data.rb +21 -2
- data/test/test_io.rb +12 -1
- data/test/test_schema.rb +15 -0
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZmE2MTc2YmEzZjFiZGM4Y2MwOWY0MmM0NDRmZWNiY2Y5YzA0NDg5Ng==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
M2ZjZWRlNWQ2NDVkODljZjk4MGQ3YmY4Y2VhMDQ4NzMyMzhmNGFhZA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NjA2N2JmM2MzYWM1MWQzOGNmNzg0NDM3Nzk3NDQ4NDRiYzY5N2I1YjZhNmZm
|
10
|
+
ZGQyYzJjZjAxNjBhNjFhZGQ0YTk2NTNhNmMzY2NlMmU0MTMwOGUyMTQ2ZDU2
|
11
|
+
Y2U1NDI5OGMxZmM2OGUyOTliMmY5ZTQ2MjI2OTdmYWNhZTlmM2M=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NDFhOTMyOTY1OTcxZGE0YzgzOGE4ZmU1Njk0ZTUwZjY0ODk4ZmZlYjUyYzg4
|
14
|
+
N2RmNDBmNjMwMTM4ODMzMTRiMTQyOTc4OTU5NmZjMjg2YjkzMGNjNTQxNjFj
|
15
|
+
Mjc3YzViMzY3NzM2MzVmMWRlNTRlNTA0Nzc5ZWIzZDYwZTkwYmQ=
|
data/Rakefile
CHANGED
data/avro-salsify-fork.gemspec
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: avro-salsify-fork 1.9.0.
|
2
|
+
# stub: avro-salsify-fork 1.9.0.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name = "avro-salsify-fork"
|
6
|
-
s.version = "1.9.0.
|
5
|
+
s.name = "avro-salsify-fork"
|
6
|
+
s.version = "1.9.0.1"
|
7
7
|
|
8
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 1.2"
|
9
|
-
s.require_paths = ["lib"
|
10
|
-
s.authors = ["Apache Software Foundation / Salsify Engineering"
|
11
|
-
s.date = "2016-08-
|
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."
|
13
|
-
s.email = "engineering@salsify.com"
|
14
|
-
s.extra_rdoc_files = ["CHANGELOG"
|
15
|
-
s.files = ["CHANGELOG"
|
16
|
-
s.homepage = "https://github.com/salsify/avro"
|
17
|
-
s.licenses = ["Apache License 2.0 (Apache-2.0)"
|
18
|
-
s.rdoc_options = ["--line-numbers"
|
19
|
-
s.rubyforge_project = "avro-salsify-fork"
|
20
|
-
s.rubygems_version = "2.
|
21
|
-
s.summary = "Apache Avro for Ruby with logical types patch"
|
22
|
-
s.test_files = ["test/test_datafile.rb"
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
9
|
+
s.require_paths = ["lib"]
|
10
|
+
s.authors = ["Apache Software Foundation / Salsify Engineering"]
|
11
|
+
s.date = "2016-08-29"
|
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."
|
13
|
+
s.email = "engineering@salsify.com"
|
14
|
+
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "lib/avro.rb", "lib/avro/data_file.rb", "lib/avro/io.rb", "lib/avro/ipc.rb", "lib/avro/logical_types.rb", "lib/avro/protocol.rb", "lib/avro/schema.rb", "lib/avro/schema_normalization.rb"]
|
15
|
+
s.files = ["CHANGELOG", "LICENSE", "Manifest", "NOTICE", "Rakefile", "avro-salsify-fork.gemspec", "avro.gemspec", "interop/test_interop.rb", "lib/avro.rb", "lib/avro/data_file.rb", "lib/avro/io.rb", "lib/avro/ipc.rb", "lib/avro/logical_types.rb", "lib/avro/protocol.rb", "lib/avro/schema.rb", "lib/avro/schema_normalization.rb", "test/case_finder.rb", "test/random_data.rb", "test/sample_ipc_client.rb", "test/sample_ipc_http_client.rb", "test/sample_ipc_http_server.rb", "test/sample_ipc_server.rb", "test/test_datafile.rb", "test/test_fingerprints.rb", "test/test_help.rb", "test/test_io.rb", "test/test_logical_types.rb", "test/test_protocol.rb", "test/test_schema.rb", "test/test_schema_normalization.rb", "test/test_socket_transport.rb", "test/tool.rb"]
|
16
|
+
s.homepage = "https://github.com/salsify/avro"
|
17
|
+
s.licenses = ["Apache License 2.0 (Apache-2.0)"]
|
18
|
+
s.rdoc_options = ["--line-numbers", "--title", "Avro-salsify-fork"]
|
19
|
+
s.rubyforge_project = "avro-salsify-fork"
|
20
|
+
s.rubygems_version = "2.4.8"
|
21
|
+
s.summary = "Apache Avro for Ruby with logical types patch"
|
22
|
+
s.test_files = ["test/test_datafile.rb", "test/test_fingerprints.rb", "test/test_help.rb", "test/test_io.rb", "test/test_logical_types.rb", "test/test_protocol.rb", "test/test_schema.rb", "test/test_schema_normalization.rb", "test/test_socket_transport.rb"]
|
23
23
|
|
24
24
|
if s.respond_to? :specification_version then
|
25
25
|
s.specification_version = 4
|
26
26
|
|
27
27
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
28
|
-
s.add_runtime_dependency(%q<multi_json
|
28
|
+
s.add_runtime_dependency(%q<multi_json>, [">= 0"])
|
29
29
|
else
|
30
|
-
s.add_dependency(%q<multi_json
|
30
|
+
s.add_dependency(%q<multi_json>, [">= 0"])
|
31
31
|
end
|
32
32
|
else
|
33
|
-
s.add_dependency(%q<multi_json
|
33
|
+
s.add_dependency(%q<multi_json>, [">= 0"])
|
34
34
|
end
|
35
35
|
end
|
data/lib/avro/io.rb
CHANGED
@@ -543,7 +543,7 @@ module Avro
|
|
543
543
|
def write_data(writers_schema, logical_datum, encoder)
|
544
544
|
datum = writers_schema.type_adapter.encode(logical_datum)
|
545
545
|
|
546
|
-
unless Schema.validate(writers_schema, datum)
|
546
|
+
unless Schema.validate(writers_schema, datum, encoded = true)
|
547
547
|
raise AvroTypeError.new(writers_schema, datum)
|
548
548
|
end
|
549
549
|
|
data/lib/avro/schema.rb
CHANGED
@@ -94,7 +94,13 @@ module Avro
|
|
94
94
|
end
|
95
95
|
|
96
96
|
# Determine if a ruby datum is an instance of a schema
|
97
|
-
def self.validate(expected_schema,
|
97
|
+
def self.validate(expected_schema, logical_datum, encoded = false)
|
98
|
+
datum = if encoded
|
99
|
+
logical_datum
|
100
|
+
else
|
101
|
+
expected_schema.type_adapter.encode(logical_datum)
|
102
|
+
end
|
103
|
+
|
98
104
|
case expected_schema.type_sym
|
99
105
|
when :null
|
100
106
|
datum.nil?
|
@@ -181,7 +187,9 @@ module Avro
|
|
181
187
|
end
|
182
188
|
|
183
189
|
def to_avro(names=nil)
|
184
|
-
{'type' => type}
|
190
|
+
props = {'type' => type}
|
191
|
+
props['logicalType'] = logical_type if logical_type
|
192
|
+
props
|
185
193
|
end
|
186
194
|
|
187
195
|
def to_s
|
data/test/random_data.rb
CHANGED
@@ -27,15 +27,17 @@ class RandomData
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def nextdata(schm, d=0)
|
30
|
+
return logical_nextdata(schm, d=0) unless schm.type_adapter.eql?(Avro::LogicalTypes::Identity)
|
31
|
+
|
30
32
|
case schm.type_sym
|
31
33
|
when :boolean
|
32
34
|
rand > 0.5
|
33
35
|
when :string
|
34
36
|
randstr()
|
35
37
|
when :int
|
36
|
-
|
38
|
+
rand_int
|
37
39
|
when :long
|
38
|
-
|
40
|
+
rand_long
|
39
41
|
when :float
|
40
42
|
(-1024 + 2048 * rand).round.to_f
|
41
43
|
when :double
|
@@ -79,6 +81,15 @@ class RandomData
|
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
84
|
+
def logical_nextdata(schm, _d=0)
|
85
|
+
case schm.logical_type
|
86
|
+
when 'date'
|
87
|
+
Avro::LogicalTypes::IntDate.decode(rand_int)
|
88
|
+
when 'timestamp-millis', 'timestamp-micros'
|
89
|
+
Avro::LogicalTypes::TimestampMicros.decode(rand_long)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
82
93
|
CHARPOOL = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'
|
83
94
|
BYTEPOOL = '12345abcd'
|
84
95
|
|
@@ -87,4 +98,12 @@ class RandomData
|
|
87
98
|
rand(length+1).times { str << chars[rand(chars.size)] }
|
88
99
|
str
|
89
100
|
end
|
101
|
+
|
102
|
+
def rand_int
|
103
|
+
rand(Avro::Schema::INT_MAX_VALUE - Avro::Schema::INT_MIN_VALUE) + Avro::Schema::INT_MIN_VALUE
|
104
|
+
end
|
105
|
+
|
106
|
+
def rand_long
|
107
|
+
rand(Avro::Schema::LONG_MAX_VALUE - Avro::Schema::LONG_MIN_VALUE) + Avro::Schema::LONG_MIN_VALUE
|
108
|
+
end
|
90
109
|
end
|
data/test/test_io.rb
CHANGED
@@ -84,6 +84,17 @@ EOS
|
|
84
84
|
check_default(record_schema, '{"f": 11}', {"f" => 11})
|
85
85
|
end
|
86
86
|
|
87
|
+
def test_record_with_logical_type
|
88
|
+
record_schema = <<EOS
|
89
|
+
{"type": "record",
|
90
|
+
"name": "Test",
|
91
|
+
"fields": [{"name": "ts",
|
92
|
+
"type": {"type": "long",
|
93
|
+
"logicalType": "timestamp-micros"}}]}
|
94
|
+
EOS
|
95
|
+
check(record_schema)
|
96
|
+
end
|
97
|
+
|
87
98
|
def test_error
|
88
99
|
error_schema = <<EOS
|
89
100
|
{"type": "error",
|
@@ -385,7 +396,7 @@ EOS
|
|
385
396
|
|
386
397
|
def checkser(schm, randomdata)
|
387
398
|
datum = randomdata.next
|
388
|
-
assert validate(schm, datum)
|
399
|
+
assert validate(schm, datum), 'datum is not valid for schema'
|
389
400
|
w = Avro::IO::DatumWriter.new(schm)
|
390
401
|
writer = StringIO.new "", "w"
|
391
402
|
w.write(datum, Avro::IO::BinaryEncoder.new(writer))
|
data/test/test_schema.rb
CHANGED
@@ -132,6 +132,21 @@ class TestSchema < Test::Unit::TestCase
|
|
132
132
|
}
|
133
133
|
end
|
134
134
|
|
135
|
+
def test_to_avro_includes_logical_type
|
136
|
+
schema = Avro::Schema.parse <<-SCHEMA
|
137
|
+
{"type": "record", "name": "has_logical", "fields": [
|
138
|
+
{"name": "dt", "type": {"type": "int", "logicalType": "date"}}]
|
139
|
+
}
|
140
|
+
SCHEMA
|
141
|
+
|
142
|
+
assert_equal schema.to_avro, {
|
143
|
+
'type' => 'record', 'name' => 'has_logical',
|
144
|
+
'fields' => [
|
145
|
+
{'name' => 'dt', 'type' => {'type' => 'int', 'logicalType' => 'date'}}
|
146
|
+
]
|
147
|
+
}
|
148
|
+
end
|
149
|
+
|
135
150
|
def test_unknown_named_type
|
136
151
|
error = assert_raise Avro::UnknownSchemaError do
|
137
152
|
Avro::Schema.parse <<-SCHEMA
|
metadata
CHANGED
@@ -1,33 +1,34 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avro-salsify-fork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.0.
|
4
|
+
version: 1.9.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Apache Software Foundation / Salsify Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description:
|
28
|
-
|
27
|
+
description: ! 'Avro is a data serialization and RPC format.
|
28
|
+
|
29
29
|
This release contains the changes submitted in https://github.com/apache/avro/pull/116
|
30
|
-
|
30
|
+
|
31
|
+
to support logical types in the Ruby gem.'
|
31
32
|
email: engineering@salsify.com
|
32
33
|
executables: []
|
33
34
|
extensions: []
|
@@ -81,24 +82,24 @@ licenses:
|
|
81
82
|
metadata: {}
|
82
83
|
post_install_message:
|
83
84
|
rdoc_options:
|
84
|
-
-
|
85
|
-
-
|
85
|
+
- --line-numbers
|
86
|
+
- --title
|
86
87
|
- Avro-salsify-fork
|
87
88
|
require_paths:
|
88
89
|
- lib
|
89
90
|
required_ruby_version: !ruby/object:Gem::Requirement
|
90
91
|
requirements:
|
91
|
-
- -
|
92
|
+
- - ! '>='
|
92
93
|
- !ruby/object:Gem::Version
|
93
94
|
version: '0'
|
94
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
96
|
requirements:
|
96
|
-
- -
|
97
|
+
- - ! '>='
|
97
98
|
- !ruby/object:Gem::Version
|
98
99
|
version: '1.2'
|
99
100
|
requirements: []
|
100
101
|
rubyforge_project: avro-salsify-fork
|
101
|
-
rubygems_version: 2.
|
102
|
+
rubygems_version: 2.4.8
|
102
103
|
signing_key:
|
103
104
|
specification_version: 4
|
104
105
|
summary: Apache Avro for Ruby with logical types patch
|