avro 1.7.5 → 1.7.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +0 -1
- data/Rakefile +1 -1
- data/avro.gemspec +8 -8
- data/lib/avro.rb +3 -4
- data/lib/avro/data_file.rb +5 -3
- data/lib/avro/protocol.rb +5 -5
- data/lib/avro/schema.rb +4 -4
- data/test/test_datafile.rb +2 -2
- data/test/test_io.rb +2 -2
- metadata +8 -11
- data/lib/avro/collect_hash.rb +0 -25
data/Manifest
CHANGED
data/Rakefile
CHANGED
@@ -23,7 +23,7 @@ Echoe.new('avro', VERSION) do |p|
|
|
23
23
|
p.summary = "Apache Avro for Ruby"
|
24
24
|
p.description = "Avro is a data serialization and RPC format"
|
25
25
|
p.url = "http://hadoop.apache.org/avro/"
|
26
|
-
p.runtime_dependencies = %w[
|
26
|
+
p.runtime_dependencies = %w[multi_json]
|
27
27
|
end
|
28
28
|
|
29
29
|
t = Rake::TestTask.new(:interop)
|
data/avro.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "avro"
|
5
|
-
s.version = "1.7.
|
5
|
+
s.version = "1.7.7"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Apache Software Foundation"]
|
9
|
-
s.date = "
|
9
|
+
s.date = "2014-07-18"
|
10
10
|
s.description = "Avro is a data serialization and RPC format"
|
11
11
|
s.email = "avro-dev@hadoop.apache.org"
|
12
|
-
s.extra_rdoc_files = ["CHANGELOG", "lib/avro.rb", "lib/avro/
|
13
|
-
s.files = ["CHANGELOG", "Manifest", "Rakefile", "avro.gemspec", "interop/test_interop.rb", "lib/avro.rb", "lib/avro/
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "lib/avro.rb", "lib/avro/data_file.rb", "lib/avro/io.rb", "lib/avro/ipc.rb", "lib/avro/protocol.rb", "lib/avro/schema.rb"]
|
13
|
+
s.files = ["CHANGELOG", "Manifest", "Rakefile", "avro.gemspec", "interop/test_interop.rb", "lib/avro.rb", "lib/avro/data_file.rb", "lib/avro/io.rb", "lib/avro/ipc.rb", "lib/avro/protocol.rb", "lib/avro/schema.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_help.rb", "test/test_io.rb", "test/test_protocol.rb", "test/test_socket_transport.rb", "test/tool.rb", "test/test_schema.rb"]
|
14
14
|
s.homepage = "http://hadoop.apache.org/avro/"
|
15
|
-
s.rdoc_options = ["--line-numbers", "--
|
15
|
+
s.rdoc_options = ["--line-numbers", "--title", "Avro"]
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
s.rubyforge_project = "avro"
|
18
18
|
s.rubygems_version = "1.8.15"
|
@@ -23,11 +23,11 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.specification_version = 3
|
24
24
|
|
25
25
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
-
s.add_runtime_dependency(%q<
|
26
|
+
s.add_runtime_dependency(%q<multi_json>, [">= 0"])
|
27
27
|
else
|
28
|
-
s.add_dependency(%q<
|
28
|
+
s.add_dependency(%q<multi_json>, [">= 0"])
|
29
29
|
end
|
30
30
|
else
|
31
|
-
s.add_dependency(%q<
|
31
|
+
s.add_dependency(%q<multi_json>, [">= 0"])
|
32
32
|
end
|
33
33
|
end
|
data/lib/avro.rb
CHANGED
@@ -5,16 +5,16 @@
|
|
5
5
|
# to you under the Apache License, Version 2.0 (the
|
6
6
|
# "License"); you may not use this file except in compliance
|
7
7
|
# with the License. You may obtain a copy of the License at
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# Unless required by applicable law or agreed to in writing, software
|
12
12
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
-
require '
|
17
|
+
require 'multi_json'
|
18
18
|
require 'set'
|
19
19
|
require 'digest/md5'
|
20
20
|
require 'net/http'
|
@@ -34,7 +34,6 @@ module Avro
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
require 'avro/collect_hash'
|
38
37
|
require 'avro/schema'
|
39
38
|
require 'avro/io'
|
40
39
|
require 'avro/data_file'
|
data/lib/avro/data_file.rb
CHANGED
@@ -20,9 +20,10 @@ module Avro
|
|
20
20
|
module DataFile
|
21
21
|
VERSION = 1
|
22
22
|
MAGIC = "Obj" + [VERSION].pack('c')
|
23
|
-
|
23
|
+
MAGIC.force_encoding('BINARY') if MAGIC.respond_to?(:force_encoding)
|
24
|
+
MAGIC_SIZE = MAGIC.respond_to?(:bytesize) ? MAGIC.bytesize : MAGIC.size
|
24
25
|
SYNC_SIZE = 16
|
25
|
-
SYNC_INTERVAL =
|
26
|
+
SYNC_INTERVAL = 4000 * SYNC_SIZE
|
26
27
|
META_SCHEMA = Schema.parse('{"type": "map", "values": "bytes"}')
|
27
28
|
VALID_ENCODINGS = ['binary'] # not used yet
|
28
29
|
|
@@ -98,6 +99,7 @@ module Avro
|
|
98
99
|
@encoder = IO::BinaryEncoder.new(@writer)
|
99
100
|
@datum_writer = datum_writer
|
100
101
|
@buffer_writer = StringIO.new('', 'w')
|
102
|
+
@buffer_writer.set_encoding('BINARY') if @buffer_writer.respond_to?(:set_encoding)
|
101
103
|
@buffer_encoder = IO::BinaryEncoder.new(@buffer_writer)
|
102
104
|
@block_count = 0
|
103
105
|
|
@@ -181,7 +183,7 @@ module Avro
|
|
181
183
|
# write number of items in block and block size in bytes
|
182
184
|
encoder.write_long(block_count)
|
183
185
|
to_write = codec.compress(buffer_writer.string)
|
184
|
-
encoder.write_long(to_write.size)
|
186
|
+
encoder.write_long(to_write.respond_to?(:bytesize) ? to_write.bytesize : to_write.size)
|
185
187
|
|
186
188
|
# write block contents
|
187
189
|
writer.write(to_write)
|
data/lib/avro/protocol.rb
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
# to you under the Apache License, Version 2.0 (the
|
6
6
|
# "License"); you may not use this file except in compliance
|
7
7
|
# with the License. You may obtain a copy of the License at
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# Unless required by applicable law or agreed to in writing, software
|
12
12
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -22,7 +22,7 @@ module Avro
|
|
22
22
|
|
23
23
|
attr_reader :name, :namespace, :types, :messages, :md5
|
24
24
|
def self.parse(protocol_string)
|
25
|
-
json_data =
|
25
|
+
json_data = MultiJson.load(protocol_string)
|
26
26
|
|
27
27
|
if json_data.is_a? Hash
|
28
28
|
name = json_data['protocol']
|
@@ -58,7 +58,7 @@ module Avro
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def to_s
|
61
|
-
|
61
|
+
MultiJson.dump to_avro
|
62
62
|
end
|
63
63
|
|
64
64
|
def ==(other)
|
@@ -104,7 +104,7 @@ module Avro
|
|
104
104
|
hsh['types'] = types.map{|t| t.to_avro(names) } if types
|
105
105
|
|
106
106
|
if messages
|
107
|
-
hsh['messages'] = messages.
|
107
|
+
hsh['messages'] = messages.inject({}) {|h, (k,t)| h[k] = t.to_avro(names); h }
|
108
108
|
end
|
109
109
|
|
110
110
|
hsh
|
data/lib/avro/schema.rb
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
# to you under the Apache License, Version 2.0 (the
|
6
6
|
# "License"); you may not use this file except in compliance
|
7
7
|
# with the License. You may obtain a copy of the License at
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# Unless required by applicable law or agreed to in writing, software
|
12
12
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -33,7 +33,7 @@ module Avro
|
|
33
33
|
LONG_MAX_VALUE = (1 << 63) - 1
|
34
34
|
|
35
35
|
def self.parse(json_string)
|
36
|
-
real_parse(
|
36
|
+
real_parse(MultiJson.load(json_string), {})
|
37
37
|
end
|
38
38
|
|
39
39
|
# Build Avro Schema from data parsed out of JSON string.
|
@@ -165,7 +165,7 @@ module Avro
|
|
165
165
|
end
|
166
166
|
|
167
167
|
def to_s
|
168
|
-
|
168
|
+
MultiJson.dump to_avro
|
169
169
|
end
|
170
170
|
|
171
171
|
class NamedSchema < Schema
|
data/test/test_datafile.rb
CHANGED
@@ -108,9 +108,9 @@ JSON
|
|
108
108
|
end
|
109
109
|
|
110
110
|
%w[fixed enum record error array map union].each do |s|
|
111
|
-
reader =
|
111
|
+
reader = MultiJson.load(writer_schema)
|
112
112
|
reader['fields'] = reader['fields'].reject{|f| f['type']['type'] == s}
|
113
|
-
Avro::DataFile.open('data.avr', 'r',
|
113
|
+
Avro::DataFile.open('data.avr', 'r', MultiJson.dump(reader)) do |dr|
|
114
114
|
dr.each_with_index do |obj, i|
|
115
115
|
reader['fields'].each do |field|
|
116
116
|
assert_equal data[i][field['name']], obj[field['name']]
|
data/test/test_io.rb
CHANGED
@@ -308,8 +308,8 @@ EOS
|
|
308
308
|
|
309
309
|
# test that the round-trip didn't mess up anything
|
310
310
|
# NB: I don't think we should do this. Why enforce ordering?
|
311
|
-
assert_equal(
|
312
|
-
|
311
|
+
assert_equal(MultiJson.load(str),
|
312
|
+
MultiJson.load(parsed_string))
|
313
313
|
|
314
314
|
# test __eq__
|
315
315
|
assert_equal(schema, Avro::Schema.parse(str))
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 1.7.
|
9
|
+
- 7
|
10
|
+
version: 1.7.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Apache Software Foundation
|
@@ -15,12 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2014-07-18 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
22
|
none: false
|
25
23
|
requirements:
|
26
24
|
- - ">="
|
@@ -29,8 +27,10 @@ dependencies:
|
|
29
27
|
segments:
|
30
28
|
- 0
|
31
29
|
version: "0"
|
30
|
+
name: multi_json
|
31
|
+
prerelease: false
|
32
|
+
requirement: *id001
|
32
33
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
34
|
description: Avro is a data serialization and RPC format
|
35
35
|
email: avro-dev@hadoop.apache.org
|
36
36
|
executables: []
|
@@ -40,7 +40,6 @@ extensions: []
|
|
40
40
|
extra_rdoc_files:
|
41
41
|
- CHANGELOG
|
42
42
|
- lib/avro.rb
|
43
|
-
- lib/avro/collect_hash.rb
|
44
43
|
- lib/avro/data_file.rb
|
45
44
|
- lib/avro/io.rb
|
46
45
|
- lib/avro/ipc.rb
|
@@ -53,7 +52,6 @@ files:
|
|
53
52
|
- avro.gemspec
|
54
53
|
- interop/test_interop.rb
|
55
54
|
- lib/avro.rb
|
56
|
-
- lib/avro/collect_hash.rb
|
57
55
|
- lib/avro/data_file.rb
|
58
56
|
- lib/avro/io.rb
|
59
57
|
- lib/avro/ipc.rb
|
@@ -77,7 +75,6 @@ licenses: []
|
|
77
75
|
post_install_message:
|
78
76
|
rdoc_options:
|
79
77
|
- --line-numbers
|
80
|
-
- --inline-source
|
81
78
|
- --title
|
82
79
|
- Avro
|
83
80
|
require_paths:
|
data/lib/avro/collect_hash.rb
DELETED
@@ -1,25 +0,0 @@
|
|
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
|
-
|
17
|
-
module Enumerable
|
18
|
-
def collect_hash
|
19
|
-
inject(Hash.new) do |memo, i|
|
20
|
-
k, v = yield(i)
|
21
|
-
memo[k] = v if k
|
22
|
-
memo
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|