hazelcast-python-client icon indicating copy to clipboard operation
hazelcast-python-client copied to clipboard

Update Serializers (ArrayListSerializer, LinkedListSerializer and others) [API-1114]

Open srknzl opened this issue 3 years ago • 1 comments

Right now some serializers like ArrayListSerializer and LinkedListSerializer(maybe even more) are out of date. We were using NULL_ARRAY_LENGTH in serialization of these before 2019. It is changed in this pr: https://github.com/hazelcast/hazelcast/pull/15371/files

The ArrayListSerializer for example, never encounters with "None" input, since null has its own serializer. So there is an unnecessary check in the serializer.

class ArrayListSerializer(BaseSerializer):
    def read(self, inp):
        size = inp.read_int()
        if size > NULL_ARRAY_LENGTH:
            return [inp.read_object() for _ in range(0, size)]
        return None

    def write(self, out, obj):
        size = NULL_ARRAY_LENGTH if obj is None else len(obj)
        out.write_int(size)
        for i in range(0, size):
            out.write_object(obj[i])

    def get_type_id(self):
        return JAVA_DEFAULT_TYPE_ARRAY_LIST

srknzl avatar Jan 11 '22 06:01 srknzl

Internal Jira issue: API-1114

github-actions[bot] avatar Jan 11 '22 06:01 github-actions[bot]