Skip to content

Commit 88eac93

Browse files
committed
address review comments
1 parent 606eeef commit 88eac93

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

hazelcast/serialization/compact.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,11 +1559,10 @@ def _raise_on_none_value_in_fix_sized_item_array(field: "FieldDescriptor") -> ty
15591559
class SchemaWriter(CompactWriter):
15601560
def __init__(self, type_name: str):
15611561
self._type_name = type_name
1562-
self._fields: typing.List[FieldDescriptor] = []
1563-
self._field_names: typing.Set[str] = set()
1562+
self._fields: typing.Dict[str, FieldDescriptor] = {}
15641563

15651564
def build(self) -> "Schema":
1566-
return Schema(self._type_name, self._fields)
1565+
return Schema(self._type_name, list(self._fields.values()))
15671566

15681567
def write_boolean(self, field_name: str, value: bool) -> None:
15691568
self._add_field(field_name, FieldKind.BOOLEAN)
@@ -1740,11 +1739,10 @@ def write_array_of_compact(
17401739
self._add_field(field_name, FieldKind.ARRAY_OF_COMPACT)
17411740

17421741
def _add_field(self, name: str, kind: "FieldKind"):
1743-
if name in self._field_names:
1742+
if name in self._fields:
17441743
raise HazelcastSerializationError(f"Field with the name '{name}' already exists")
17451744

1746-
self._field_names.add(name)
1747-
self._fields.append(FieldDescriptor(name, kind))
1745+
self._fields[name] = FieldDescriptor(name, kind)
17481746

17491747

17501748
class Schema:

hazelcast/serialization/service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import typing
88

99
from hazelcast.config import IntType, Config
10-
from hazelcast.errors import HazelcastInstanceNotActiveError
10+
from hazelcast.errors import HazelcastInstanceNotActiveError, IllegalArgumentError
1111
from hazelcast.serialization.api import IdentifiedDataSerializable, Portable
1212
from hazelcast.serialization.compact import (
1313
SchemaNotFoundError,
@@ -511,7 +511,7 @@ def validate(self):
511511
"""
512512
for compact_type in self._compact_types:
513513
if compact_type in self._constant_type_dict:
514-
raise HazelcastSerializationError(
514+
raise IllegalArgumentError(
515515
f"Compact serializer for the class {compact_type}' can not be "
516516
f"registered as it overrides the default serializer for that "
517517
f"class provided by Hazelcast."

0 commit comments

Comments
 (0)