def encode(buf, paging_predicate_holder, is_final=False): initial_frame_buf = create_initial_buffer_custom(_INITIAL_FRAME_SIZE) FixSizedTypesCodec.encode_int(initial_frame_buf, _PAGE_SIZE_ENCODE_OFFSET, paging_predicate_holder.page_size) FixSizedTypesCodec.encode_int(initial_frame_buf, _PAGE_ENCODE_OFFSET, paging_predicate_holder.page) FixSizedTypesCodec.encode_byte(initial_frame_buf, _ITERATION_TYPE_ID_ENCODE_OFFSET, paging_predicate_holder.iteration_type_id) buf.extend(initial_frame_buf) AnchorDataListHolderCodec.encode(buf, paging_predicate_holder.anchor_data_list_holder) CodecUtil.encode_nullable(buf, paging_predicate_holder.predicate_data, DataCodec.encode) CodecUtil.encode_nullable(buf, paging_predicate_holder.comparator_data, DataCodec.encode) CodecUtil.encode_nullable(buf, paging_predicate_holder.partition_key_data, DataCodec.encode) if is_final: buf.extend(END_FINAL_FRAME_BUF) else: buf.extend(END_FRAME_BUF)
def encode_request(cluster_name, credentials, uuid, client_type, serialization_version, client_hazelcast_version, client_name, labels): buf = create_initial_buffer(_REQUEST_INITIAL_FRAME_SIZE, _REQUEST_MESSAGE_TYPE) FixSizedTypesCodec.encode_uuid(buf, _REQUEST_UUID_OFFSET, uuid) FixSizedTypesCodec.encode_byte(buf, _REQUEST_SERIALIZATION_VERSION_OFFSET, serialization_version) StringCodec.encode(buf, cluster_name) ByteArrayCodec.encode(buf, credentials) StringCodec.encode(buf, client_type) StringCodec.encode(buf, client_hazelcast_version) StringCodec.encode(buf, client_name) ListMultiFrameCodec.encode(buf, labels, StringCodec.encode, True) return OutboundMessage(buf, True)
def encode_request(sql, parameters, timeout_millis, cursor_buffer_size, schema, expected_result_type, query_id): buf = create_initial_buffer(_REQUEST_INITIAL_FRAME_SIZE, _REQUEST_MESSAGE_TYPE) FixSizedTypesCodec.encode_long(buf, _REQUEST_TIMEOUT_MILLIS_OFFSET, timeout_millis) FixSizedTypesCodec.encode_int(buf, _REQUEST_CURSOR_BUFFER_SIZE_OFFSET, cursor_buffer_size) FixSizedTypesCodec.encode_byte(buf, _REQUEST_EXPECTED_RESULT_TYPE_OFFSET, expected_result_type) StringCodec.encode(buf, sql) ListMultiFrameCodec.encode_contains_nullable(buf, parameters, DataCodec.encode) CodecUtil.encode_nullable(buf, schema, StringCodec.encode) SqlQueryIdCodec.encode(buf, query_id, True) return OutboundMessage(buf, False)
def encode(buf, member_version, is_final=False): initial_frame_buf = create_initial_buffer_custom(_INITIAL_FRAME_SIZE) FixSizedTypesCodec.encode_byte(initial_frame_buf, _MAJOR_ENCODE_OFFSET, member_version.major) FixSizedTypesCodec.encode_byte(initial_frame_buf, _MINOR_ENCODE_OFFSET, member_version.minor) FixSizedTypesCodec.encode_byte(initial_frame_buf, _PATCH_ENCODE_OFFSET, member_version.patch) buf.extend(initial_frame_buf) if is_final: buf.extend(END_FINAL_FRAME_BUF) else: buf.extend(END_FRAME_BUF)
def test_byte(self): FixSizedTypesCodec.encode_byte(self.buf, 16, 3) message = self.write_and_decode() buf = message.next_frame().buf self.assertEqual(3, FixSizedTypesCodec.decode_byte(buf, 10))