Interface MapBuilder


@Experimental public interface MapBuilder

Appends the entries of one MAP instance.

A map's entries are a repeated struct of a key and a value, so an entry is populated through the same StructBuilder a nested struct uses, with those two field names:

row.setMap("props", props -> props
        .addEntry(entry -> entry
                .setString("key", "region")
                .setString("value", "eu-central-1")));

This shape carries every key and value type the schema can declare, including struct, list and map values, which a typed put per key/value combination could not. The key is REQUIRED by the format, so an entry that leaves it unset throws; the value follows the schema like any other field.

A filler that appends no entry writes an empty map, which is distinct from the absent map that leaving the field unset writes.

The builder is valid only inside the lambda it was passed to. Retaining one and using it afterwards throws IllegalStateException rather than appending to a later map.

This API is Experimental: the shape may change in future releases.

  • Method Summary

    Modifier and Type
    Method
    Description
    Appends one entry, populating its key and value fields through filler.