Skip to content

Commit cdf7f84

Browse files
Lorak-mmkwprzytula
andcommitted
Metadata: Use Vecs for intermediate representation of pk and ck
HashMap was used before, but it provides no benefit over a Vec here. Vec will make it easier to verify that we received all of pk and ck columns, which the next commits will do. Co-authored-by: Wojciech Przytuła <[email protected]>
1 parent cbf73f5 commit cdf7f84

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

scylla/src/cluster/metadata.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,21 +1573,21 @@ async fn query_tables_schema(
15731573
.entry((keyspace_name, table_name))
15741574
.or_insert(Ok((
15751575
HashMap::new(), // columns
1576-
HashMap::new(), // partition key
1577-
HashMap::new(), // clustering key
1576+
Vec::new(), // partition key
1577+
Vec::new(), // clustering key
15781578
)))
15791579
else {
15801580
// This table was previously marked as broken, no way to insert anything.
15811581
return Ok::<_, MetadataError>(());
15821582
};
15831583

15841584
if kind == ColumnKind::PartitionKey || kind == ColumnKind::Clustering {
1585-
let key_map = if kind == ColumnKind::PartitionKey {
1585+
let key_list: &mut Vec<(i32, String)> = if kind == ColumnKind::PartitionKey {
15861586
entry.1.borrow_mut()
15871587
} else {
15881588
entry.2.borrow_mut()
15891589
};
1590-
key_map.insert(position, column_name.clone());
1590+
key_list.push((position, column_name.clone()));
15911591
}
15921592

15931593
entry.0.insert(
@@ -1609,7 +1609,12 @@ async fn query_tables_schema(
16091609
for ((keyspace_name, table_name), table_result) in tables_schema {
16101610
let keyspace_and_table_name = (keyspace_name, table_name);
16111611

1612-
let (columns, partition_key_columns, clustering_key_columns) = match table_result {
1612+
#[allow(clippy::type_complexity)]
1613+
let (columns, partition_key_columns, clustering_key_columns): (
1614+
HashMap<String, Column>,
1615+
Vec<(i32, String)>,
1616+
Vec<(i32, String)>,
1617+
) = match table_result {
16131618
Ok(table) => table,
16141619
Err(e) => {
16151620
let _ = result.insert(keyspace_and_table_name, Err(e));

0 commit comments

Comments
 (0)