Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

k/protocol: Checking for tag value to be 0 #11443

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/v/kafka/protocol/schemata/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,21 +1335,28 @@ class response;
{%- endif %}
{%- endmacro %}

{% macro conditional_tag_encode(tdef, vec) %}
{% macro conditional_tag_encode(tdef, vec, obj = "") %}
{%- if obj %}
{%- set fname = obj + "." + tdef.name %}
{%- else %}
{%- set fname = tdef.name %}
{%- endif %}
{%- if tdef.nullable() %}
if ({{ tdef.name }}) {
if ({{ fname }}) {
{{ vec }}.push_back({{ tdef.tag() }});
}
{%- elif tdef.is_array %}
if (!{{ tdef.name }}.empty()) {
if (!{{ fname }}.empty()) {
{{ vec }}.push_back({{ tdef.tag() }});
}
{%- elif tdef.default_value() != "" %}
if ({{ tdef.name }} != {{ tdef.default_value() }}) {
if ({{ fname }} != {{ tdef.default_value() }}) {
michael-redpanda marked this conversation as resolved.
Show resolved Hide resolved
{{ vec }}.push_back({{ tdef.tag() }});
}
{%- else %}
{{ vec }}.push_back({{ tdef.tag() }});
if ({{ fname }} != {{ tdef.type_name.0 }}{0}) {
{{ vec }}.push_back({{ tdef.tag() }});
}
{%- endif %}
{%- endmacro %}

Expand All @@ -1358,7 +1365,7 @@ class response;
std::vector<uint32_t> to_encode;
{%- for tdef in tag_definitions -%}
{%- call tag_version_guard(tdef) %}
{{- conditional_tag_encode(tdef, "to_encode") }}
{{- conditional_tag_encode(tdef, "to_encode", obj) }}
{%- endcall %}
{%- endfor %}
{%- set tf = "unknown_tags" %}
Expand Down