예제 #1
0
 def find_portable_version(self, factory_id, class_id, portable):
     current_version = self._portable_context.get_class_version(factory_id, class_id)
     if current_version < 0:
         current_version = util.get_portable_version(portable, self._portable_context.portable_version)
     if current_version > 0:
         self._portable_context.set_class_version(factory_id, class_id, current_version)
     return current_version
 def find_portable_version(self, factory_id, class_id, portable):
     current_version = self._portable_context.get_class_version(factory_id, class_id)
     if current_version < 0:
         current_version = util.get_portable_version(portable, self._portable_context.portable_version)
     if current_version > 0:
         self._portable_context.set_class_version(factory_id, class_id, current_version)
     return current_version
예제 #3
0
    def write_portable(self, field_name, portable):
        if portable is None:
            raise HazelcastSerializationError("Cannot write None portable without explicitly registering class definition!")
        version = util.get_portable_version(portable, self.portable_context.get_version())

        nested_builder = ClassDefinitionBuilder(portable.get_factory_id(), portable.get_class_id(), version)
        nested_class_def = self._create_nested_class_def(portable, nested_builder)
        self._builder.add_portable_field(field_name, nested_class_def)
예제 #4
0
    def write_portable(self, field_name, portable):
        if portable is None:
            raise HazelcastSerializationError(
                "Cannot write None portable without explicitly registering class definition!"
            )
        version = util.get_portable_version(portable, self.portable_context.portable_version)

        factory_id = portable.get_factory_id()
        class_id = portable.get_class_id()
        nested_builder = ClassDefinitionBuilder(factory_id, class_id, version)
        nested_class_def = self._create_nested_class_def(portable, nested_builder)
        self._builder.add_portable_field(field_name, nested_class_def)
예제 #5
0
    def lookup_or_register_class_definition(self, portable):
        fid = portable.get_factory_id()
        cid = portable.get_class_id()
        portable_version = util.get_portable_version(portable, self.portable_version)
        class_def = self.lookup_class_definition(fid, cid, portable_version)

        if class_def is None:
            writer = ClassDefinitionWriter(self, fid, cid, portable_version)
            portable.write_portable(writer)
            class_def = writer.register_and_get()

        return class_def
예제 #6
0
 def write_portable_array(self, field_name, values):
     if values is None or len(values) == 0:
         raise HazelcastSerializationError("Cannot write None portable without explicitly registering class definition!")
     portable = values[0]
     _class_id = portable.get_class_id()
     for i in xrange(1, len(values)):
         if values[i].get_class_id() != _class_id:
             raise ValueError("Detected different class-ids in portable array!")
     version = util.get_portable_version(portable, self.portable_context.get_version())
     nested_builder = ClassDefinitionBuilder(portable.get_factory_id(), portable.get_class_id(), version)
     nested_class_def = self._create_nested_class_def(portable, nested_builder)
     self._builder.add_portable_array_field(field_name, nested_class_def)
예제 #7
0
    def lookup_or_register_class_definition(self, portable):
        fid = portable.get_factory_id()
        cid = portable.get_class_id()
        portable_version = util.get_portable_version(portable, self.portable_version)
        class_def = self.lookup_class_definition(fid, cid, portable_version)

        if class_def is None:
            writer = ClassDefinitionWriter(self, fid, cid, portable_version)
            portable.write_portable(writer)
            class_def = writer.register_and_get()

        return class_def
예제 #8
0
 def write_portable_array(self, field_name, values):
     if values is None or len(values) == 0:
         raise HazelcastSerializationError(
             "Cannot write None portable without explicitly registering class definition!"
         )
     portable = values[0]
     _class_id = portable.get_class_id()
     for i in range(1, len(values)):
         if values[i].get_class_id() != _class_id:
             raise ValueError("Detected different class-ids in portable array!")
     version = util.get_portable_version(portable, self.portable_context.portable_version)
     nested_builder = ClassDefinitionBuilder(
         portable.get_factory_id(), portable.get_class_id(), version
     )
     nested_class_def = self._create_nested_class_def(portable, nested_builder)
     self._builder.add_portable_array_field(field_name, nested_class_def)