Function Decoder.readMapStart

Reads and returns the size of the next block of map-entries. Similar to [readArrayStart].

abstract ulong readMapStart() @safe;

As an example, let's say you want to read a map of records, the record consisting of an Long field and a Boolean field. Your code would look something like this:

GenericRecord[string] m;
GenericRecord reuse = new GenericRecord();
for (long i = in.readMapStart(); i != 0; i = in.readMapNext()) {
  for (long j = 0; j < i; j++) {
    string key = in.readString();
    reuse.intField = in.readInt();
    reuse.boolField = in.readBoolean();
    m.put(key, reuse);
  }
}

Throws

AvroTypeException If this is a stateful reader and map is not the type of the next value to be read