| 939 | self.keyspace = keyspace |
| 940 | |
| 941 | def send_body(self, f, protocol_version): |
| 942 | write_byte(f, self.batch_type.value) |
| 943 | write_short(f, len(self.queries)) |
| 944 | for prepared, string_or_query_id, params in self.queries: |
| 945 | if not prepared: |
| 946 | write_byte(f, 0) |
| 947 | write_longstring(f, string_or_query_id) |
| 948 | else: |
| 949 | write_byte(f, 1) |
| 950 | write_short(f, len(string_or_query_id)) |
| 951 | f.write(string_or_query_id) |
| 952 | write_short(f, len(params)) |
| 953 | for param in params: |
| 954 | write_value(f, param) |
| 955 | |
| 956 | write_consistency_level(f, self.consistency_level) |
| 957 | if protocol_version >= 3: |
| 958 | flags = 0 |
| 959 | if self.serial_consistency_level: |
| 960 | flags |= _WITH_SERIAL_CONSISTENCY_FLAG |
| 961 | if self.timestamp is not None: |
| 962 | flags |= _PROTOCOL_TIMESTAMP_FLAG |
| 963 | if self.keyspace: |
| 964 | if ProtocolVersion.uses_keyspace_flag(protocol_version): |
| 965 | flags |= _WITH_KEYSPACE_FLAG |
| 966 | else: |
| 967 | raise UnsupportedOperation( |
| 968 | "Keyspaces may only be set on queries with protocol version " |
| 969 | "5 or higher. Consider setting Cluster.protocol_version to 5.") |
| 970 | |
| 971 | if ProtocolVersion.uses_int_query_flags(protocol_version): |
| 972 | write_int(f, flags) |
| 973 | else: |
| 974 | write_byte(f, flags) |
| 975 | |
| 976 | if self.serial_consistency_level: |
| 977 | write_consistency_level(f, self.serial_consistency_level) |
| 978 | if self.timestamp is not None: |
| 979 | write_long(f, self.timestamp) |
| 980 | |
| 981 | if ProtocolVersion.uses_keyspace_flag(protocol_version): |
| 982 | if self.keyspace is not None: |
| 983 | write_string(f, self.keyspace) |
| 984 | |
| 985 | |
| 986 | known_event_types = frozenset(( |