avro-patches 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28f04e46e3ccd4a1d9400d32fed8474f1d4b9edc
4
- data.tar.gz: 412323d266beed3d397ee861775dc340e2d12020
3
+ metadata.gz: 676a9d9b3febd0bdde356e8215466ec4605ffc4b
4
+ data.tar.gz: 4623aad3b6d0c7c7e50e4eedf86e3bdabf5c5b70
5
5
  SHA512:
6
- metadata.gz: d95df0967c75e5f5aba614785db7f7407e9e5b88f35c2c524ed230555425d4dc846cde3ae15cfe8f8923c6f1792d8724e01ca9e8dfda73a230304a6e56ad6714
7
- data.tar.gz: 568746bb7f634a1168a1b109f59170f7ad79e3ed1cbcf99f6325913b559283c235c66d1c8e3e08ec5e7032bc610dcb62b4dc84e4ce3eb366e77fc78ba759003b
6
+ metadata.gz: cd158af3a8f6912e003a01785700bec22525dfbbc39711f8a545afda49871080f97d6df54b6bf622dcf586eb78fb9316144d42c4f74c9714fe387efa00a6197f
7
+ data.tar.gz: 1d9cc525627b20fc67e860edd4d152f6e644f35b210dd12d703f1a088bec17ef8ea399dc4420489cc0224d2ad711901fc36993c7e5685715795bc2c192418ccc
@@ -1,5 +1,8 @@
1
1
  # avro-patches
2
2
 
3
+ ## v0.3.1
4
+ - Fix references to `Avro::SchemaParseError` and `Avro::UnknownSchemaError`.
5
+
3
6
  ## v0.3.0
4
7
  - Further performance improvements for `Avro::SchemaValidator` and encoding.
5
8
  - Ensure that strings are encoded as UTF-8.
data/README.md CHANGED
@@ -10,6 +10,7 @@ The following pending or unreleased changes are included:
10
10
  - [AVRO-1886: Add validation messages](https://github.com/apache/avro/pull/111)
11
11
  - [AVRO-1695: Ruby support for logical types revisited](https://github.com/apache/avro/pull/116)
12
12
  - [AVRO-1969: Add schema compatibility checker for Ruby](https://github.com/apache/avro/pull/170)
13
+ - [AVRO-2039: Ruby encoding performance improvements](https://github.com/apache/avro/pull/230)
13
14
 
14
15
  In addition, compatibility with Ruby 2.4 (https://github.com/apache/avro/pull/191)
15
16
  has been integrated with the changes above.
@@ -6,12 +6,12 @@ Avro::Schema.class_eval do
6
6
  if json_obj.is_a? Hash
7
7
  type = json_obj['type']
8
8
  logical_type = json_obj['logicalType']
9
- raise Avro::Schema::SchemaParseError, %Q(No "type" property: #{json_obj}) if type.nil?
9
+ raise Avro::SchemaParseError, %Q(No "type" property: #{json_obj}) if type.nil?
10
10
 
11
11
  # Check that the type is valid before calling #to_sym, since symbols are never garbage
12
12
  # collected (important to avoid DoS if we're accepting schemas from untrusted clients)
13
13
  unless Avro::Schema::VALID_TYPES.include?(type)
14
- raise Avro::Schema::SchemaParseError, "Unknown type: #{type}"
14
+ raise Avro::SchemaParseError, "Unknown type: #{type}"
15
15
  end
16
16
 
17
17
  type_sym = type.to_sym
@@ -31,8 +31,6 @@ Avro::Schema.class_eval do
31
31
  when :record, :error
32
32
  fields = json_obj['fields']
33
33
  return Avro::Schema::RecordSchema.new(name, namespace, fields, names, type_sym)
34
- else
35
- raise Avro::Schema::SchemaParseError.new("Unknown named type: #{type}")
36
34
  end
37
35
 
38
36
  else
@@ -42,7 +40,7 @@ Avro::Schema.class_eval do
42
40
  when :map
43
41
  return Avro::Schema::MapSchema.new(json_obj['values'], names, default_namespace)
44
42
  else
45
- raise Avro::Schema::SchemaParseError.new("Unknown Valid Type: #{type}")
43
+ raise Avro::SchemaParseError.new("Unknown Valid Type: #{type}")
46
44
  end
47
45
  end
48
46
 
@@ -52,7 +50,7 @@ Avro::Schema.class_eval do
52
50
  elsif Avro::Schema::PRIMITIVE_TYPES.include? json_obj
53
51
  return Avro::Schema::PrimitiveSchema.new(json_obj)
54
52
  else
55
- raise Avro::Schema::UnknownSchemaError.new(json_obj)
53
+ raise Avro::UnknownSchemaError.new(json_obj)
56
54
  end
57
55
  end
58
56
 
@@ -2,3 +2,4 @@
2
2
  # https://github.com/apache/avro/pull/111
3
3
  require_relative 'schema_validator/schema_validator'
4
4
  require_relative 'schema_validator/schema'
5
+ require_relative 'schema_validator/io'
@@ -0,0 +1,27 @@
1
+ Avro::IO::DatumWriter.class_eval do
2
+ def write_data(writers_schema, datum, encoder)
3
+ unless Avro::Schema.validate(writers_schema, datum, recursive: false)
4
+ raise Avro::IO::AvroTypeError.new(writers_schema, datum)
5
+ end
6
+
7
+ # function dispatch to write datum
8
+ case writers_schema.type_sym
9
+ when :null; encoder.write_null(datum)
10
+ when :boolean; encoder.write_boolean(datum)
11
+ when :string; encoder.write_string(datum)
12
+ when :int; encoder.write_int(datum)
13
+ when :long; encoder.write_long(datum)
14
+ when :float; encoder.write_float(datum)
15
+ when :double; encoder.write_double(datum)
16
+ when :bytes; encoder.write_bytes(datum)
17
+ when :fixed; write_fixed(writers_schema, datum, encoder)
18
+ when :enum; write_enum(writers_schema, datum, encoder)
19
+ when :array; write_array(writers_schema, datum, encoder)
20
+ when :map; write_map(writers_schema, datum, encoder)
21
+ when :union; write_union(writers_schema, datum, encoder)
22
+ when :record, :error, :request; write_record(writers_schema, datum, encoder)
23
+ else
24
+ raise Avro::AvroError.new("Unknown type: #{writers_schema.type}")
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module AvroPatches
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.3.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.3.0
4
+ version: 0.3.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: 2017-06-08 00:00:00.000000000 Z
11
+ date: 2017-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,6 +114,7 @@ files:
114
114
  - lib/avro-patches/schema_compatibility/schema.rb
115
115
  - lib/avro-patches/schema_compatibility/schema_compatibility.rb
116
116
  - lib/avro-patches/schema_validator.rb
117
+ - lib/avro-patches/schema_validator/io.rb
117
118
  - lib/avro-patches/schema_validator/schema.rb
118
119
  - lib/avro-patches/schema_validator/schema_validator.rb
119
120
  - lib/avro-patches/version.rb