lib/rimless/avro_helpers.rb
# Convert the given deep hash into a sparsed flat hash while transforming
# all values to strings. This allows to convert a schema-less hash to a
# Apache Avro compatible map.
#
# @see http://avro.apache.org/docs/current/spec.html#Maps
# @example Convert schema-less hash
#   avro_schemaless_map(a: { b: { c: true } })
#   # => { "a.b.c" => "true" }
#
# @param hash [Hash{Mixed => Mixed}] the deep hash
# @return [Hash{String => String}] the flatted and sparsed hash
Convert the given deep hash into a sparsed flat hash while transforming
all values to strings. This allows to convert a schema-less hash to a
Apache Avro compatible map.
Convert the given deep hash into a sparsed flat hash while transforming all values to strings . This allows to convert a schema - less hash to a Apache Avro compatible map .
def avro_schemaless_h(hash)
        Sparsify(hash, sparse_array: true)
          .transform_values(&:to_s)
          .transform_keys { |key| key.delete('\\') }
      end
def avro_schemaless_h ( hash ) Sparsify ( hash , sparse_array : true ) . transform_values ( & :to_s ) . transform_keys { | key | key . delete ( '\\' ) } end
Convert the given deep hash into a sparsed flat hash while transforming
all values to strings.
Convert the given deep hash into a sparsed flat hash while transforming all values to strings .
the flatted and sparsed hash
the flatted and sparsed hash
Hash{String => String}
hash
the deep hash
the deep hash
see
None
example
Convert schema-less hash avro_schemaless_map(a: { b: { c: true } }) # => { "a.b.c" => "true" }
Convert schema - less hash avro_schemaless_map ( a : { b : { c : true } } ) # = > { " a . b . c " = > " true " }