コード例 #1
0
ファイル: protocol.py プロジェクト: LeonZav/python-dse-driver
    def recv_error_info(f, protocol_version):
        consistency = read_consistency_level(f)
        received_responses = read_int(f)
        required_responses = read_int(f)

        if ProtocolVersion.uses_error_code_map(protocol_version):
            error_code_map = read_error_code_map(f)
            failures = len(error_code_map)
        else:
            error_code_map = None
            failures = read_int(f)

        data_retrieved = bool(read_byte(f))

        return {
            'consistency': consistency,
            'received_responses': received_responses,
            'required_responses': required_responses,
            'failures': failures,
            'error_code_map': error_code_map,
            'data_retrieved': data_retrieved
        }
コード例 #2
0
ファイル: protocol.py プロジェクト: rmatam/python-dse-driver
    def recv_error_info(f, protocol_version):
        consistency = read_consistency_level(f)
        received_responses = read_int(f)
        required_responses = read_int(f)

        if ProtocolVersion.uses_error_code_map(protocol_version):
            error_code_map = read_error_code_map(f)
            failures = len(error_code_map)
        else:
            error_code_map = None
            failures = read_int(f)

        write_type = WriteType.name_to_value[read_string(f)]

        return {
            'consistency': consistency,
            'received_responses': received_responses,
            'required_responses': required_responses,
            'failures': failures,
            'error_code_map': error_code_map,
            'write_type': write_type
        }
コード例 #3
0
 def send_body(self, f, protocol_version):
     write_longstring(f, self.query)
     if ProtocolVersion.uses_prepare_flags(protocol_version):
         # Write the flags byte; with 0 value for now, but this should change in PYTHON-678
         write_uint(f, 0)
コード例 #4
0
ファイル: protocol.py プロジェクト: LeonZav/python-dse-driver
 def send_body(self, f, protocol_version):
     write_string(f, self.query_id)
     if ProtocolVersion.uses_prepared_metadata(protocol_version):
         write_string(f, self.result_metadata_id)
     self._write_query_params(f, protocol_version)
コード例 #5
0
ファイル: protocol.py プロジェクト: LeonZav/python-dse-driver
 def _write_paging_options(self, f, paging_options, protocol_version):
     write_int(f, paging_options.max_pages)
     write_int(f, paging_options.max_pages_per_second)
     if ProtocolVersion.has_continuous_paging_next_pages(protocol_version):
         write_int(f, paging_options.max_queue_size)
コード例 #6
0
ファイル: protocol.py プロジェクト: LeonZav/python-dse-driver
    def _write_query_params(self, f, protocol_version):
        write_consistency_level(f, self.consistency_level)
        flags = 0x00
        if self.query_params is not None:
            flags |= _VALUES_FLAG

        if self.serial_consistency_level:
            flags |= _WITH_SERIAL_CONSISTENCY_FLAG

        if self.fetch_size:
            flags |= _PAGE_SIZE_FLAG
            if self.continuous_paging_options and self.continuous_paging_options.page_unit_bytes(
            ):
                flags |= _PAGE_SIZE_BYTES_FLAG

        if self.paging_state:
            flags |= _WITH_PAGING_STATE_FLAG

        if self.timestamp is not None:
            flags |= _PROTOCOL_TIMESTAMP_FLAG

        if self.continuous_paging_options:
            if ProtocolVersion.has_continuous_paging_support(protocol_version):
                flags |= _PAGING_OPTIONS_FLAG
            else:
                raise UnsupportedOperation(
                    "Continuous paging may only be used with protocol version "
                    "ProtocolVersion.DSE_V1 or higher. Consider setting Cluster.protocol_version to ProtocolVersion.DSE_V1."
                )

        if self.keyspace is not None:
            if ProtocolVersion.uses_keyspace_flag(protocol_version):
                flags |= _WITH_KEYSPACE_FLAG
            else:
                raise UnsupportedOperation(
                    "Keyspaces may only be set on queries with protocol version "
                    "DSE_V2 or higher. Consider setting Cluster.protocol_version to ProtocolVersion.DSE_V2."
                )

        if ProtocolVersion.uses_int_query_flags(protocol_version):
            write_uint(f, flags)
        else:
            write_byte(f, flags)

        if self.query_params is not None:
            write_short(f, len(self.query_params))
            for param in self.query_params:
                write_value(f, param)
        if self.fetch_size:
            write_int(f, self.fetch_size)
        if self.paging_state:
            write_longstring(f, self.paging_state)
        if self.serial_consistency_level:
            write_consistency_level(f, self.serial_consistency_level)
        if self.timestamp is not None:
            write_long(f, self.timestamp)
        if self.keyspace is not None:
            write_string(f, self.keyspace)
        if self.continuous_paging_options:
            self._write_paging_options(f, self.continuous_paging_options,
                                       protocol_version)