Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dorner authored Dec 19, 2023
1 parent 26224e5 commit e2db79a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protoc --avro_out=. --avro_opt=namespace_map=foo:bar,baz:spam *.proto

...will change the output namespace for `foo` to `bar` and `baz` to `spam`.

* `collapse_fields` - A semicolon-separated list of records to collapse. If not specified, no records will be collapsed. Collapsed records should have a single field in them, and they will be replaced in the output by that field. This can be useful to overcome some limitations of Protobuf - e.g. Protobuf doesn't have the ability to have a map of arrays, while Avro does.
* `collapse_fields` - A semicolon-separated list of records to collapse. Collapsed records should have a single field in them, and they will be replaced in the output by that field. This can be useful to overcome some limitations of Protobuf - e.g. Protobuf doesn't have the ability to have an array of maps, while Avro does.

```bash
protoc --avro_out=. --avro_opt=collapse_fields=StringList;SomeOtherRecord *.proto
Expand All @@ -46,23 +46,26 @@ message StringList {
repeated string strings = 1;
}
message MyRecord {
repeated StringList my_field = 1;
map<string, StringList> my_field = 1;
}
```

...the output will look like:

```avro
```json
{
"type": "record",
"name": "MyRecord",
"fields": [
{
"name": "my_field",
"type": {
"type": "array",
"items": {
"type": "string"
"type": "map",
"values": {
"type": {
"type": "array",
"items": "string"
}
}
}
}
Expand All @@ -80,7 +83,7 @@ enum Category {

...with this option on, it will be translated into:

```avro
```json
{
"type": "enum",
"name": "CATEGORY",
Expand Down

0 comments on commit e2db79a

Please sign in to comment.