Skip to content

Add Map support in Avro compiled semantics plugin #151

@deaktator

Description

@deaktator

Allow map variables to be extracted as final field in a variable path. Currently, nothing should be allowed to come after a Map object.

Based on the Avro map spec , only maps with string based keys are allowed. Most likely, these Strings are actually Utf8 instances and the Maps are probably java.util.Map instances. These should be turned into Scala Maps with some function like:

def toMap[V](m: java.util.Map[Utf8, V]): Map[String, V] = ???

Example Avro Protocol (example.avpr)

{
  "namespace": "a.b",
  "protocol": "Example",
  "doc": "Example protocol",
  "types": [
    { "name": "X", "type": "record",
      "fields": [ { "name": "m", "type": {"type": "map", "values": "long"} } ]
    },
    { "name": "Msg", "type": "record",
      "fields": [ 
        { "name": "x", "type": ["null", "X"] },
        { "name": "m", "type": {"type": "map", "values": "Msg"} }
      ]
    }
  ]
}

Examples of Acceptable Aloha Feature Specifications

{ "name": "sum_key_lengths", "spec": "(0 /: ${x.m}.keys)(_ + _.length)" }
{ "name": "sum_values", "spec": "${x.m}.values.sum" }

Examples of Unacceptable Aloha Feature Specifications

{ "name": "sum_values", "spec": "${m.x}" }
{ "name": "sum_values", "spec": "${m[msg1]}" }
{ "name": "sum_values", "spec": "${m[msg1].x}" }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions