def test_nullable(self): self.mark_initial_frame_as_non_final() CodecUtil.encode_nullable(self.buf, "a", StringCodec.encode) CodecUtil.encode_nullable(self.buf, None, StringCodec.encode, True) message = self.write_and_decode() message.next_frame() # initial frame self.assertEqual("a", CodecUtil.decode_nullable(message, StringCodec.decode)) self.assertIsNone(CodecUtil.decode_nullable(message, StringCodec.decode))
def decode_response(msg): initial_frame = msg.next_frame() response = dict() response["update_count"] = FixSizedTypesCodec.decode_long( initial_frame.buf, _RESPONSE_UPDATE_COUNT_OFFSET) response["row_metadata"] = ListMultiFrameCodec.decode_nullable( msg, SqlColumnMetadataCodec.decode) response["row_page"] = CodecUtil.decode_nullable(msg, SqlPageCodec.decode) response["error"] = CodecUtil.decode_nullable(msg, SqlErrorCodec.decode) return response
def decode(msg): msg.next_frame() initial_frame = msg.next_frame() type = FixSizedTypesCodec.decode_int(initial_frame.buf, _TYPE_DECODE_OFFSET) name = CodecUtil.decode_nullable(msg, StringCodec.decode) attributes = ListMultiFrameCodec.decode(msg, StringCodec.decode) bitmap_index_options = CodecUtil.decode_nullable( msg, BitmapIndexOptionsCodec.decode) CodecUtil.fast_forward_to_end_frame(msg) return IndexConfig(name, type, attributes, bitmap_index_options)
def decode(msg): msg.next_frame() initial_frame = msg.next_frame() page_size = FixSizedTypesCodec.decode_int(initial_frame.buf, _PAGE_SIZE_DECODE_OFFSET) page = FixSizedTypesCodec.decode_int(initial_frame.buf, _PAGE_DECODE_OFFSET) iteration_type_id = FixSizedTypesCodec.decode_byte(initial_frame.buf, _ITERATION_TYPE_ID_DECODE_OFFSET) anchor_data_list_holder = AnchorDataListHolderCodec.decode(msg) predicate_data = CodecUtil.decode_nullable(msg, DataCodec.decode) comparator_data = CodecUtil.decode_nullable(msg, DataCodec.decode) partition_key_data = CodecUtil.decode_nullable(msg, DataCodec.decode) CodecUtil.fast_forward_to_end_frame(msg) return PagingPredicateHolder(anchor_data_list_holder, predicate_data, comparator_data, page_size, page, iteration_type_id, partition_key_data)
def decode(msg): msg.next_frame() initial_frame = msg.next_frame() code = FixSizedTypesCodec.decode_int(initial_frame.buf, _CODE_DECODE_OFFSET) originating_member_id = FixSizedTypesCodec.decode_uuid(initial_frame.buf, _ORIGINATING_MEMBER_ID_DECODE_OFFSET) message = CodecUtil.decode_nullable(msg, StringCodec.decode) is_suggestion_exists = False suggestion = None if not msg.peek_next_frame().is_end_frame(): suggestion = CodecUtil.decode_nullable(msg, StringCodec.decode) is_suggestion_exists = True CodecUtil.fast_forward_to_end_frame(msg) return _SqlError(code, message, originating_member_id, is_suggestion_exists, suggestion)
def handle(msg, handle_entry_event=None): message_type = msg.get_message_type() if message_type == _EVENT_ENTRY_MESSAGE_TYPE and handle_entry_event is not None: initial_frame = msg.next_frame() event_type = FixSizedTypesCodec.decode_int(initial_frame.buf, _EVENT_ENTRY_EVENT_TYPE_OFFSET) uuid = FixSizedTypesCodec.decode_uuid(initial_frame.buf, _EVENT_ENTRY_UUID_OFFSET) number_of_affected_entries = FixSizedTypesCodec.decode_int(initial_frame.buf, _EVENT_ENTRY_NUMBER_OF_AFFECTED_ENTRIES_OFFSET) key = CodecUtil.decode_nullable(msg, DataCodec.decode) value = CodecUtil.decode_nullable(msg, DataCodec.decode) old_value = CodecUtil.decode_nullable(msg, DataCodec.decode) merging_value = CodecUtil.decode_nullable(msg, DataCodec.decode) handle_entry_event(key, value, old_value, merging_value, event_type, uuid, number_of_affected_entries) return
def handle(msg, handle_i_map_invalidation_event=None, handle_i_map_batch_invalidation_event=None): message_type = msg.get_message_type() if message_type == _EVENT_I_MAP_INVALIDATION_MESSAGE_TYPE and handle_i_map_invalidation_event is not None: initial_frame = msg.next_frame() source_uuid = FixSizedTypesCodec.decode_uuid( initial_frame.buf, _EVENT_I_MAP_INVALIDATION_SOURCE_UUID_OFFSET) partition_uuid = FixSizedTypesCodec.decode_uuid( initial_frame.buf, _EVENT_I_MAP_INVALIDATION_PARTITION_UUID_OFFSET) sequence = FixSizedTypesCodec.decode_long( initial_frame.buf, _EVENT_I_MAP_INVALIDATION_SEQUENCE_OFFSET) key = CodecUtil.decode_nullable(msg, DataCodec.decode) handle_i_map_invalidation_event(key, source_uuid, partition_uuid, sequence) return if message_type == _EVENT_I_MAP_BATCH_INVALIDATION_MESSAGE_TYPE and handle_i_map_batch_invalidation_event is not None: msg.next_frame() keys = ListMultiFrameCodec.decode(msg, DataCodec.decode) source_uuids = ListUUIDCodec.decode(msg) partition_uuids = ListUUIDCodec.decode(msg) sequences = ListLongCodec.decode(msg) handle_i_map_batch_invalidation_event(keys, source_uuids, partition_uuids, sequences) return
def decode(msg): msg.next_frame() initial_frame = msg.next_frame() type = FixSizedTypesCodec.decode_int(initial_frame.buf, _TYPE_DECODE_OFFSET) identifier = CodecUtil.decode_nullable(msg, StringCodec.decode) CodecUtil.fast_forward_to_end_frame(msg) return EndpointQualifier(type, identifier)
def decode_response(msg): initial_frame = msg.next_frame() response = dict() response["max_idle"] = FixSizedTypesCodec.decode_long( initial_frame.buf, _RESPONSE_MAX_IDLE_OFFSET) response["response"] = CodecUtil.decode_nullable( msg, SimpleEntryViewCodec.decode) return response
def handle(msg, handle_item_event=None): message_type = msg.get_message_type() if message_type == _EVENT_ITEM_MESSAGE_TYPE and handle_item_event is not None: initial_frame = msg.next_frame() uuid = FixSizedTypesCodec.decode_uuid(initial_frame.buf, _EVENT_ITEM_UUID_OFFSET) event_type = FixSizedTypesCodec.decode_int(initial_frame.buf, _EVENT_ITEM_EVENT_TYPE_OFFSET) item = CodecUtil.decode_nullable(msg, DataCodec.decode) handle_item_event(item, uuid, event_type) return
def decode(msg): msg.next_frame() initial_frame = msg.next_frame() error_code = FixSizedTypesCodec.decode_int(initial_frame.buf, _ERROR_CODE_DECODE_OFFSET) class_name = StringCodec.decode(msg) message = CodecUtil.decode_nullable(msg, StringCodec.decode) stack_trace_elements = ListMultiFrameCodec.decode(msg, StackTraceElementCodec.decode) CodecUtil.fast_forward_to_end_frame(msg) return ErrorHolder(error_code, class_name, message, stack_trace_elements)
def decode(msg): msg.next_frame() initial_frame = msg.next_frame() line_number = FixSizedTypesCodec.decode_int( initial_frame.buf, _LINE_NUMBER_DECODE_OFFSET) class_name = StringCodec.decode(msg) method_name = StringCodec.decode(msg) file_name = CodecUtil.decode_nullable(msg, StringCodec.decode) CodecUtil.fast_forward_to_end_frame(msg) return StackTraceElement(class_name, method_name, file_name, line_number)
def decode_response(msg): initial_frame = msg.next_frame() response = dict() response["read_count"] = FixSizedTypesCodec.decode_int( initial_frame.buf, _RESPONSE_READ_COUNT_OFFSET) response["next_seq"] = FixSizedTypesCodec.decode_long( initial_frame.buf, _RESPONSE_NEXT_SEQ_OFFSET) response["items"] = ListMultiFrameCodec.decode(msg, DataCodec.decode) response["item_seqs"] = CodecUtil.decode_nullable(msg, LongArrayCodec.decode) return response
def decode_response(msg): initial_frame = msg.next_frame() response = dict() response["status"] = FixSizedTypesCodec.decode_byte( initial_frame.buf, _RESPONSE_STATUS_OFFSET) response["member_uuid"] = FixSizedTypesCodec.decode_uuid( initial_frame.buf, _RESPONSE_MEMBER_UUID_OFFSET) response["serialization_version"] = FixSizedTypesCodec.decode_byte( initial_frame.buf, _RESPONSE_SERIALIZATION_VERSION_OFFSET) response["partition_count"] = FixSizedTypesCodec.decode_int( initial_frame.buf, _RESPONSE_PARTITION_COUNT_OFFSET) response["cluster_id"] = FixSizedTypesCodec.decode_uuid( initial_frame.buf, _RESPONSE_CLUSTER_ID_OFFSET) response["failover_supported"] = FixSizedTypesCodec.decode_boolean( initial_frame.buf, _RESPONSE_FAILOVER_SUPPORTED_OFFSET) response["address"] = CodecUtil.decode_nullable(msg, AddressCodec.decode) response["server_hazelcast_version"] = StringCodec.decode(msg) return response
def decode_response(msg): msg.next_frame() return CodecUtil.decode_nullable(msg, DataCodec.decode)
def decode_response(msg): msg.next_frame() response = dict() response["row_page"] = CodecUtil.decode_nullable(msg, SqlPageCodec.decode) response["error"] = CodecUtil.decode_nullable(msg, SqlErrorCodec.decode) return response