Sha256: ac3fcd7016a2e71977fa338f11893179fe722615acda70bb2253a55baea009fa
Contents?: true
Size: 1.5 KB
Versions: 3
Compression:
Stored size: 1.5 KB
Contents
Avro::IO::DatumWriter.class_eval do def write_data(writers_schema, logical_datum, encoder) datum = writers_schema.type_adapter.encode(logical_datum) unless Avro::Schema.validate(writers_schema, datum, encoded = true) raise Avro::IO::AvroTypeError.new(writers_schema, datum) end # function dispatch to write datum case writers_schema.type_sym when :null; encoder.write_null(datum) when :boolean; encoder.write_boolean(datum) when :string; encoder.write_string(datum) when :int; encoder.write_int(datum) when :long; encoder.write_long(datum) when :float; encoder.write_float(datum) when :double; encoder.write_double(datum) when :bytes; encoder.write_bytes(datum) when :fixed; write_fixed(writers_schema, datum, encoder) when :enum; write_enum(writers_schema, datum, encoder) when :array; write_array(writers_schema, datum, encoder) when :map; write_map(writers_schema, datum, encoder) when :union; write_union(writers_schema, datum, encoder) when :record, :error, :request; write_record(writers_schema, datum, encoder) else raise Avro::AvroError.new("Unknown type: #{writers_schema.type}") end end end module AvroPatches module LogicalTypes module DatumReaderPatch def read_data(writers_schema, readers_schema, decoder) datum = super readers_schema.type_adapter.decode(datum) end end end end Avro::IO::DatumReader.prepend(AvroPatches::LogicalTypes::DatumReaderPatch)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
avro-patches-0.2.0 | lib/avro-patches/logical_types/io.rb |
avro-patches-0.1.0 | lib/avro-patches/logical_types/io.rb |
avro-patches-0.1.0.rc0 | lib/avro-patches/logical_types/io.rb |