Skip to content

Commit b249bff

Browse files
committed
metadata: rename CassResultData -> CassResultMetadata
1 parent 2f50cd0 commit b249bff

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

scylla-rust-wrapper/src/prepared.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
argconv::*,
66
cass_error::CassError,
77
cass_types::{get_column_type, CassDataType},
8-
query_result::CassResultData,
8+
query_result::CassResultMetadata,
99
statement::{CassStatement, Statement},
1010
types::size_t,
1111
};
@@ -18,7 +18,7 @@ pub struct CassPrepared {
1818

1919
// Cached result metadata. Arc'ed since we want to share it
2020
// with result metadata after execution.
21-
pub result_metadata: Arc<CassResultData>,
21+
pub result_metadata: Arc<CassResultMetadata>,
2222
pub statement: PreparedStatement,
2323
}
2424

@@ -30,7 +30,7 @@ impl CassPrepared {
3030
.map(|col_spec| Arc::new(get_column_type(col_spec.typ())))
3131
.collect();
3232

33-
let result_metadata = Arc::new(CassResultData::from_column_specs(
33+
let result_metadata = Arc::new(CassResultMetadata::from_column_specs(
3434
statement.get_result_set_col_specs(),
3535
));
3636

scylla-rust-wrapper/src/query_result.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ use uuid::Uuid;
1818

1919
pub struct CassResult {
2020
pub rows: Option<Vec<CassRow>>,
21-
pub metadata: Arc<CassResultData>,
21+
pub metadata: Arc<CassResultMetadata>,
2222
pub tracing_id: Option<Uuid>,
2323
pub paging_state_response: PagingStateResponse,
2424
}
2525

2626
#[derive(Debug)]
27-
pub struct CassResultData {
27+
pub struct CassResultMetadata {
2828
pub col_specs: Vec<CassColumnSpec>,
2929
}
3030

31-
impl CassResultData {
32-
pub fn from_column_specs(col_specs: &[ColumnSpec<'_>]) -> CassResultData {
31+
impl CassResultMetadata {
32+
pub fn from_column_specs(col_specs: &[ColumnSpec<'_>]) -> CassResultMetadata {
3333
let col_specs = col_specs
3434
.iter()
3535
.map(|col_spec| {
@@ -40,15 +40,15 @@ impl CassResultData {
4040
})
4141
.collect();
4242

43-
CassResultData { col_specs }
43+
CassResultMetadata { col_specs }
4444
}
4545
}
4646

4747
/// The lifetime of CassRow is bound to CassResult.
4848
/// It will be freed, when CassResult is freed.(see #[cass_result_free])
4949
pub struct CassRow {
5050
pub columns: Vec<CassValue>,
51-
pub result_metadata: Arc<CassResultData>,
51+
pub result_metadata: Arc<CassResultMetadata>,
5252
}
5353

5454
pub enum Value {
@@ -1395,7 +1395,9 @@ mod tests {
13951395
session::create_cass_rows_from_rows,
13961396
};
13971397

1398-
use super::{cass_result_column_count, cass_result_column_type, CassResult, CassResultData};
1398+
use super::{
1399+
cass_result_column_count, cass_result_column_type, CassResult, CassResultMetadata,
1400+
};
13991401

14001402
fn col_spec(name: &'static str, typ: ColumnType<'static>) -> ColumnSpec<'static> {
14011403
ColumnSpec::borrowed(name, typ, TableSpec::borrowed("ks", "tbl"))
@@ -1405,7 +1407,7 @@ mod tests {
14051407
const SECOND_COLUMN_NAME: &str = "varint_col";
14061408
const THIRD_COLUMN_NAME: &str = "list_double_col";
14071409
fn create_cass_rows_result() -> CassResult {
1408-
let metadata = Arc::new(CassResultData::from_column_specs(&[
1410+
let metadata = Arc::new(CassResultMetadata::from_column_specs(&[
14091411
col_spec(FIRST_COLUMN_NAME, ColumnType::BigInt),
14101412
col_spec(SECOND_COLUMN_NAME, ColumnType::Varint),
14111413
col_spec(
@@ -1520,7 +1522,7 @@ mod tests {
15201522
}
15211523

15221524
fn create_non_rows_cass_result() -> CassResult {
1523-
let metadata = Arc::new(CassResultData::from_column_specs(&[]));
1525+
let metadata = Arc::new(CassResultMetadata::from_column_specs(&[]));
15241526
CassResult {
15251527
rows: None,
15261528
metadata,

scylla-rust-wrapper/src/session.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::metadata::create_table_metadata;
1010
use crate::metadata::{CassKeyspaceMeta, CassMaterializedViewMeta, CassSchemaMeta};
1111
use crate::prepared::CassPrepared;
1212
use crate::query_result::Value::{CollectionValue, RegularValue};
13-
use crate::query_result::{CassResult, CassResultData, CassRow, CassValue, Collection, Value};
13+
use crate::query_result::{CassResult, CassResultMetadata, CassRow, CassValue, Collection, Value};
1414
use crate::statement::CassStatement;
1515
use crate::statement::Statement;
1616
use crate::types::{cass_uint64_t, size_t};
@@ -220,7 +220,7 @@ pub unsafe extern "C" fn cass_session_execute_batch(
220220
match query_res {
221221
Ok(_result) => Ok(CassResultValue::QueryResult(Arc::new(CassResult {
222222
rows: None,
223-
metadata: Arc::new(CassResultData::from_column_specs(&[])),
223+
metadata: Arc::new(CassResultMetadata::from_column_specs(&[])),
224224
tracing_id: None,
225225
paging_state_response: PagingStateResponse::NoMorePages,
226226
}))),
@@ -300,7 +300,7 @@ pub unsafe extern "C" fn cass_session_execute(
300300
// Since `query.query` is consumed, we cannot match the statement
301301
// after execution, to retrieve the cached metadata in case
302302
// of prepared statements.
303-
Option<Arc<CassResultData>>,
303+
Option<Arc<CassResultMetadata>>,
304304
),
305305
QueryError,
306306
>;
@@ -329,7 +329,7 @@ pub unsafe extern "C" fn cass_session_execute(
329329
}
330330
Statement::Prepared(prepared) => {
331331
// Clone result metadata, so we don't need to construct it from scratch in
332-
// `CassResultData::from_column_specs` - it requires a lot of allocations for complex types.
332+
// `CassResultMetadata::from_column_specs` - it requires a lot of allocations for complex types.
333333
let maybe_result_metadata = Some(Arc::clone(&prepared.result_metadata));
334334

335335
if paging_enabled {
@@ -358,7 +358,7 @@ pub unsafe extern "C" fn cass_session_execute(
358358
// - Some(_) for prepared statements
359359
// - None for unprepared statements
360360
let metadata = maybe_result_metadata.unwrap_or_else(|| {
361-
Arc::new(CassResultData::from_column_specs(result.col_specs()))
361+
Arc::new(CassResultMetadata::from_column_specs(result.col_specs()))
362362
});
363363
let cass_rows = result
364364
.rows
@@ -386,7 +386,7 @@ pub unsafe extern "C" fn cass_session_execute(
386386

387387
pub(crate) fn create_cass_rows_from_rows(
388388
rows: Vec<Row>,
389-
metadata: &Arc<CassResultData>,
389+
metadata: &Arc<CassResultMetadata>,
390390
) -> Vec<CassRow> {
391391
rows.into_iter()
392392
.map(|r| CassRow {
@@ -396,7 +396,7 @@ pub(crate) fn create_cass_rows_from_rows(
396396
.collect()
397397
}
398398

399-
fn create_cass_row_columns(row: Row, metadata: &Arc<CassResultData>) -> Vec<CassValue> {
399+
fn create_cass_row_columns(row: Row, metadata: &Arc<CassResultMetadata>) -> Vec<CassValue> {
400400
row.columns
401401
.into_iter()
402402
.zip(metadata.col_specs.iter())

0 commit comments

Comments
 (0)