Skip to content

Commit d42b9a7

Browse files
committed
Store raw size in DeserializedMetadataAndRawRows
We want to switch driver to deserialize metadata eagerly. One thing that driver does with RawMetadataAndRawRows is logging the raw size of metadata and raw rows. In order to keep it doing that, we need to store the size in the deserialized metadata result.
1 parent ff31720 commit d42b9a7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scylla-cql/src/frame/response/result.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ pub struct DeserializedMetadataAndRawRows {
666666
metadata: ResultMetadataHolder,
667667
rows_count: usize,
668668
raw_rows: Bytes,
669+
raw_metadata_and_rows_bytes_size: usize,
669670
}
670671

671672
impl DeserializedMetadataAndRawRows {
@@ -695,6 +696,12 @@ impl DeserializedMetadataAndRawRows {
695696
self.raw_rows.len()
696697
}
697698

699+
/// Returns the serialized size of the raw metadata and raw rows.
700+
#[inline]
701+
pub fn metadata_and_rows_bytes_size(&self) -> usize {
702+
self.raw_metadata_and_rows_bytes_size
703+
}
704+
698705
/// Creates an empty [DeserializedMetadataAndRawRows].
699706
// Preferred to implementing Default, because users shouldn't be encouraged to create
700707
// empty DeserializedMetadataAndRawRows.
@@ -706,6 +713,7 @@ impl DeserializedMetadataAndRawRows {
706713
),
707714
rows_count: 0,
708715
raw_rows: Bytes::new(),
716+
raw_metadata_and_rows_bytes_size: 0,
709717
}
710718
}
711719

@@ -1070,6 +1078,7 @@ impl RawMetadataAndRawRows {
10701078
pub fn deserialize_metadata(
10711079
self,
10721080
) -> StdResult<DeserializedMetadataAndRawRows, ResultMetadataAndRowsCountParseError> {
1081+
let raw_metadata_and_rows_bytes_size = self.metadata_and_rows_bytes_size();
10731082
let (metadata_deserialized, row_count_and_raw_rows) = match self.cached_metadata {
10741083
Some(cached) if self.no_metadata => {
10751084
// Server sent no metadata, but we have metadata cached. This means that we asked the server
@@ -1120,6 +1129,7 @@ impl RawMetadataAndRawRows {
11201129
metadata: metadata_deserialized,
11211130
rows_count,
11221131
raw_rows: frame_slice.to_bytes(),
1132+
raw_metadata_and_rows_bytes_size,
11231133
})
11241134
}
11251135
}
@@ -1461,6 +1471,7 @@ mod test_utils {
14611471
metadata: ResultMetadataHolder::SharedCached(Arc::new(metadata)),
14621472
rows_count,
14631473
raw_rows,
1474+
raw_metadata_and_rows_bytes_size: 0,
14641475
}
14651476
}
14661477
}

0 commit comments

Comments
 (0)