Skip to content

Commit c119702

Browse files
committed
(improvement)Remove CQL binary protocol v3
It's not needed. v4 or above is supported everywhere. Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
1 parent 3050cf6 commit c119702

55 files changed

Lines changed: 418 additions & 681 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cassandra/__init__.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,6 @@ class ProtocolVersion(object):
136136
Defines native protocol versions supported by this driver.
137137
"""
138138

139-
V3 = 3
140-
"""
141-
v3, supported in Cassandra 2.1-->3.x+;
142-
added support for protocol-level client-side timestamps (see :attr:`.Session.use_client_timestamp`),
143-
serial consistency levels for :class:`~.BatchStatement`, and an improved connection pool.
144-
"""
145-
146139
V4 = 4
147140
"""
148141
v4, supported in Cassandra 2.2-->3.x+;
@@ -170,9 +163,9 @@ class ProtocolVersion(object):
170163
DSE private protocol v2, supported in DSE 6.0+
171164
"""
172165

173-
SUPPORTED_VERSIONS = (V5, V4, V3)
166+
SUPPORTED_VERSIONS = (V5, V4)
174167
"""
175-
A tuple of all supported protocol versions for ScyllaDB, including future v5 version.
168+
A tuple of all supported protocol versions for ScyllaDB.
176169
"""
177170

178171
BETA_VERSIONS = (V6,)

cassandra/cluster.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -735,12 +735,7 @@ def auth_provider(self, value):
735735
try:
736736
self._auth_provider_callable = value.new_authenticator
737737
except AttributeError:
738-
if self.protocol_version > 1:
739-
raise TypeError("auth_provider must implement the cassandra.auth.AuthProvider "
740-
"interface when protocol_version >= 2")
741-
elif not callable(value):
742-
raise TypeError("auth_provider must be callable when protocol_version == 1")
743-
self._auth_provider_callable = value
738+
raise TypeError("auth_provider must implement the cassandra.auth.AuthProvider interface")
744739

745740
self._auth_provider = value
746741

@@ -1557,7 +1552,7 @@ def register_user_type(self, keyspace, user_type, klass):
15571552
15581553
Example::
15591554
1560-
cluster = Cluster(protocol_version=3)
1555+
cluster = Cluster()
15611556
session = cluster.connect()
15621557
session.set_keyspace('mykeyspace')
15631558
session.execute("CREATE TYPE address (street text, zipcode int)")
@@ -1582,11 +1577,6 @@ def __init__(self, street, zipcode):
15821577
print(row.id, row.location.street, row.location.zipcode)
15831578
15841579
"""
1585-
if self.protocol_version < 3:
1586-
log.warning("User Type serialization is only supported in native protocol version 3+ (%d in use). "
1587-
"CQL encoding for simple statements will still work, but named tuples will "
1588-
"be returned when reading type %s.%s.", self.protocol_version, keyspace, user_type)
1589-
15901580
self._user_types[keyspace][user_type] = klass
15911581
for session in tuple(self.sessions):
15921582
session.user_type_registered(keyspace, user_type, klass)
@@ -2442,8 +2432,6 @@ def default_serial_consistency_level(self):
24422432
The default :class:`~ConsistencyLevel` for serial phase of conditional updates executed through
24432433
this session. This default may be overridden by setting the
24442434
:attr:`~.Statement.serial_consistency_level` on individual statements.
2445-
2446-
Only valid for ``protocol_version >= 2``.
24472435
"""
24482436
return self._default_serial_consistency_level
24492437

@@ -2954,11 +2942,6 @@ def _create_response_future(self, query, parameters, trace, custom_payload,
29542942
continuous_paging_options=continuous_paging_options,
29552943
result_metadata_id=prepared_statement.result_metadata_id)
29562944
elif isinstance(query, BatchStatement):
2957-
if self._protocol_version < 2:
2958-
raise UnsupportedOperation(
2959-
"BatchStatement execution is only supported with protocol version "
2960-
"2 or higher (supported in Cassandra 2.0 and higher). Consider "
2961-
"setting Cluster.protocol_version to 2 to support this operation.")
29622945
statement_keyspace = query.keyspace if ProtocolVersion.uses_keyspace_flag(self._protocol_version) else None
29632946
message = BatchMessage(
29642947
query.batch_type, query._statements_and_parameters, cl,
@@ -3097,7 +3080,7 @@ def prepare(self, query, custom_payload=None, keyspace=None):
30973080
prepared_keyspace = keyspace if keyspace else None
30983081
prepared_statement = PreparedStatement.from_message(
30993082
response.query_id, response.bind_metadata, response.pk_indexes, self.cluster.metadata, query, prepared_keyspace,
3100-
self._protocol_version, response.column_metadata, response.result_metadata_id, response.is_lwt, self.cluster.column_encryption_policy)
3083+
response.column_metadata, response.result_metadata_id, response.is_lwt, self.cluster.column_encryption_policy)
31013084
prepared_statement.custom_payload = future.custom_payload
31023085

31033086
self.cluster.add_prepared(response.query_id, prepared_statement)
@@ -4637,10 +4620,9 @@ def _set_result(self, host, connection, pool, response):
46374620
self._custom_payload = getattr(response, 'custom_payload', None)
46384621

46394622
if self._custom_payload and self.session.cluster.control_connection._tablets_routing_v1 and 'tablets-routing-v1' in self._custom_payload:
4640-
protocol = self.session.cluster.protocol_version
46414623
info = self._custom_payload.get('tablets-routing-v1')
46424624
ctype = types.lookup_casstype('TupleType(LongType, LongType, ListType(TupleType(UUIDType, Int32Type)))')
4643-
tablet_routing_info = ctype.from_binary(info, protocol)
4625+
tablet_routing_info = ctype.from_binary(info)
46444626
first_token = tablet_routing_info[0]
46454627
last_token = tablet_routing_info[1]
46464628
tablet_replicas = tablet_routing_info[2]

cassandra/cqlengine/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,8 @@ def __str__(self):
422422
', '.join('{0}={1}'.format(k, getattr(self, k)) for k in self._primary_keys.keys()))
423423

424424
@classmethod
425-
def _routing_key_from_values(cls, pk_values, protocol_version):
426-
return cls._key_serializer(pk_values, protocol_version)
425+
def _routing_key_from_values(cls, pk_values):
426+
return cls._key_serializer(pk_values)
427427

428428
@classmethod
429429
def _discover_polymorphic_submodels(cls):
@@ -948,10 +948,10 @@ def _transform_column(col_name, col_obj):
948948
key_cols = [c for c in partition_keys.values()]
949949
partition_key_index = dict((col.db_field_name, col._partition_key_index) for col in key_cols)
950950
key_cql_types = [c.cql_type for c in key_cols]
951-
key_serializer = staticmethod(lambda parts, proto_version: [t.to_binary(p, proto_version) for t, p in zip(key_cql_types, parts)])
951+
key_serializer = staticmethod(lambda parts: [t.to_binary(p) for t, p in zip(key_cql_types, parts)])
952952
else:
953953
partition_key_index = {}
954-
key_serializer = staticmethod(lambda parts, proto_version: None)
954+
key_serializer = staticmethod(lambda parts: None)
955955

956956
# setup partition key shortcut
957957
if len(partition_keys) == 0:

cassandra/cqlengine/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ def _execute_statement(model, statement, consistency_level, timeout, connection=
15231523
if model._partition_key_index:
15241524
key_values = statement.partition_key_values(model._partition_key_index)
15251525
if not any(v is None for v in key_values):
1526-
parts = model._routing_key_from_values(key_values, conn.get_cluster(connection).protocol_version)
1526+
parts = model._routing_key_from_values(key_values)
15271527
s.routing_key = parts
15281528
s.keyspace = model._get_keyspace()
15291529
connection = connection or model._get_connection()

0 commit comments

Comments
 (0)