Skip to content

Commit

Permalink
scripts: handle float64 and totally same type definitions in kafka_…
Browse files Browse the repository at this point in the history
…gen.py
  • Loading branch information
Commelina committed Dec 26, 2024
1 parent d77cf56 commit 12e9f1d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions script/kafka_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"int32": "{{-# UNPACK #-}} !Int32",
"int16": "{{-# UNPACK #-}} !Int16",
"int64": "{{-# UNPACK #-}} !Int64",
"float64": "{{-# UNPACK #-}} !Double",
"string": "!Text",
"bool": "Bool",
"bytes": "!ByteString",
Expand Down Expand Up @@ -131,6 +132,9 @@ def get_field_default(field_type, default=None):
"DescribeGroups": (0, 1),
"FindCoordinator": (0, 1),
"CreatePartitions": (0, 1),
"CreateAcls": (0, 1),
"DeleteAcls": (0, 1),
"DescribeAcls": (0, 1)
}

# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -306,10 +310,11 @@ def format(self):

def append_hs_datas(datas: List[HsData], data: HsData):
same_found = False
totally_same_found = False
for data_ in datas:
if data.name == data_.name:
# The same data_name should not has the same version
assert data.version != data_.version
if (data.version == data_.version and data.fields == data_.fields):
totally_same_found = True

# Use the first same type is OK
if (
Expand All @@ -322,8 +327,10 @@ def append_hs_datas(datas: List[HsData], data: HsData):
f"{data.name}V{data_.version}"
)
data.fields = data_.version

same_found = True
datas.append(data)
if (not totally_same_found):
datas.append(data)


# -----------------------------------------------------------------------------
Expand Down

0 comments on commit 12e9f1d

Please sign in to comment.