Skip to content

Commit af8525b

Browse files
committed
Review fixes: add pxd declaration, clean up error path, fix typo
- Add unpack_col_encrypted_row declaration to RowParser base class in parsing.pxd and NotImplementedError stub in parsing.pyx, for consistency with unpack_plain_row and to enable C-level dispatch. - Split the error-handling path in protocol.py to avoid building unnecessary col_descs when column_encryption_policy is not set. - Fix 'otherwsise' typo in obj_parser.pyx docstring.
1 parent 9fcfc04 commit af8525b

4 files changed

Lines changed: 24 additions & 12 deletions

File tree

cassandra/obj_parser.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ cdef class TupleRowParser(RowParser):
6363
6464
(obj1, ..., objN)
6565
If CE (Column encryption) policy is enabled - use unpack_col_encrypted_row(),
66-
otherwsise use unpack_plain_row()
66+
otherwise use unpack_plain_row()
6767
"""
6868

6969
@cython.boundscheck(False)

cassandra/parsing.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ cdef class ColumnParser:
2929

3030
cdef class RowParser:
3131
cpdef unpack_plain_row(self, BytesIOReader reader, ParseDesc desc)
32+
cpdef unpack_col_encrypted_row(self, BytesIOReader reader, ParseDesc desc)
3233

cassandra/parsing.pyx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,9 @@ cdef class RowParser:
4444
Unpack a single row of data in a ResultMessage.
4545
"""
4646
raise NotImplementedError
47+
48+
cpdef unpack_col_encrypted_row(self, BytesIOReader reader, ParseDesc desc):
49+
"""
50+
Unpack a single row of data in a ResultMessage, with column encryption support.
51+
"""
52+
raise NotImplementedError

cassandra/protocol.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -742,19 +742,24 @@ def decode_row(row):
742742
try:
743743
self.parsed_rows = [decode_row(row) for row in rows]
744744
except Exception:
745-
if not column_encryption_policy:
746-
col_descs = [ColDesc(md[0], md[1], md[2]) for md in column_metadata]
747-
for row in rows:
748-
for val, col_md, col_desc in zip(row, column_metadata, col_descs):
749-
try:
750-
if column_encryption_policy:
745+
if column_encryption_policy:
746+
for row in rows:
747+
for val, col_md, col_desc in zip(row, column_metadata, col_descs):
748+
try:
751749
decode_val(val, col_md, col_desc)
752-
else:
750+
except Exception as e:
751+
raise DriverException('Failed decoding result column "%s" of type %s: %s' % (col_md[2],
752+
col_md[3].cql_parameterized_type(),
753+
str(e)))
754+
else:
755+
for row in rows:
756+
for val, col_md in zip(row, column_metadata):
757+
try:
753758
col_md[3].from_binary(val, protocol_version)
754-
except Exception as e:
755-
raise DriverException('Failed decoding result column "%s" of type %s: %s' % (col_md[2],
756-
col_md[3].cql_parameterized_type(),
757-
str(e)))
759+
except Exception as e:
760+
raise DriverException('Failed decoding result column "%s" of type %s: %s' % (col_md[2],
761+
col_md[3].cql_parameterized_type(),
762+
str(e)))
758763

759764
def recv_results_prepared(self, f, protocol_version, protocol_features, user_type_map):
760765
self.query_id = read_binary_string(f)

0 commit comments

Comments
 (0)