From a42a00b6f258ee055c761b41e01679dfc1525fe1 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Fri, 15 Sep 2023 14:05:00 -0400 Subject: [PATCH] refactor: Consistently order max tables first, then max columns I can't handle it. --- compactor/src/components/namespaces_source/mock.rs | 2 +- data_types/src/lib.rs | 10 +++++----- gossip_schema/src/lib.rs | 4 ++-- ingester_test_ctx/src/lib.rs | 2 +- router/benches/namespace_schema_cache.rs | 2 +- router/benches/partitioner.rs | 2 +- router/benches/schema_validator.rs | 2 +- router/src/gossip/anti_entropy/mst/mod.rs | 4 ++-- router/src/gossip/mod.rs | 2 +- router/src/gossip/namespace_cache.rs | 8 ++++---- router/src/lib.rs | 2 +- router/src/namespace_cache/memory.rs | 10 +++++----- router/src/namespace_cache/metrics.rs | 2 +- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/compactor/src/components/namespaces_source/mock.rs b/compactor/src/components/namespaces_source/mock.rs index acce99f164..8e266da901 100644 --- a/compactor/src/components/namespaces_source/mock.rs +++ b/compactor/src/components/namespaces_source/mock.rs @@ -194,8 +194,8 @@ mod tests { schema: NamespaceSchema { id, tables, - max_columns_per_table: MaxColumnsPerTable::new(10), max_tables: MaxTables::new(42), + max_columns_per_table: MaxColumnsPerTable::new(10), retention_period_ns: None, partition_template: Default::default(), }, diff --git a/data_types/src/lib.rs b/data_types/src/lib.rs index beeaf6bd6b..27ff6a274e 100644 --- a/data_types/src/lib.rs +++ b/data_types/src/lib.rs @@ -302,10 +302,10 @@ pub struct NamespaceSchema { pub id: NamespaceId, /// the tables in the namespace by name pub tables: BTreeMap, - /// the number of columns per table this namespace allows - pub max_columns_per_table: MaxColumnsPerTable, /// The maximum number of tables permitted in this namespace. pub max_tables: MaxTables, + /// the number of columns per table this namespace allows + pub max_columns_per_table: MaxColumnsPerTable, /// The retention period in ns. /// None represents infinite duration (i.e. never drop data). pub retention_period_ns: Option, @@ -330,8 +330,8 @@ impl NamespaceSchema { Self { id, tables: BTreeMap::new(), - max_columns_per_table, max_tables, + max_columns_per_table, retention_period_ns, partition_template: partition_template.clone(), } @@ -2647,8 +2647,8 @@ mod tests { let schema1 = NamespaceSchema { id: NamespaceId::new(1), tables: BTreeMap::from([]), - max_columns_per_table: MaxColumnsPerTable::new(4), max_tables: MaxTables::new(42), + max_columns_per_table: MaxColumnsPerTable::new(4), retention_period_ns: None, partition_template: Default::default(), }; @@ -2662,8 +2662,8 @@ mod tests { partition_template: Default::default(), }, )]), - max_columns_per_table: MaxColumnsPerTable::new(4), max_tables: MaxTables::new(42), + max_columns_per_table: MaxColumnsPerTable::new(4), retention_period_ns: None, partition_template: Default::default(), }; diff --git a/gossip_schema/src/lib.rs b/gossip_schema/src/lib.rs index a802cbae1d..195d9849cb 100644 --- a/gossip_schema/src/lib.rs +++ b/gossip_schema/src/lib.rs @@ -209,8 +209,8 @@ mod tests { .unwrap() .clone(), ), - max_columns_per_table: 1, max_tables: 2, + max_columns_per_table: 1, retention_period_ns: Some(1234), }); @@ -240,8 +240,8 @@ mod tests { namespace_name: "bananas".to_string(), namespace_id: 4242, partition_template: None, - max_columns_per_table: 1, max_tables: 2, + max_columns_per_table: 1, retention_period_ns: Some(1234), }); diff --git a/ingester_test_ctx/src/lib.rs b/ingester_test_ctx/src/lib.rs index 8b39bf8f81..8d9dd770e5 100644 --- a/ingester_test_ctx/src/lib.rs +++ b/ingester_test_ctx/src/lib.rs @@ -236,8 +236,8 @@ where NamespaceSchema { id: ns.id, tables: Default::default(), - max_columns_per_table: Default::default(), max_tables: Default::default(), + max_columns_per_table: Default::default(), retention_period_ns, partition_template: partition_template.unwrap_or_default(), }, diff --git a/router/benches/namespace_schema_cache.rs b/router/benches/namespace_schema_cache.rs index 74138845e1..7bb2f79cd8 100644 --- a/router/benches/namespace_schema_cache.rs +++ b/router/benches/namespace_schema_cache.rs @@ -156,8 +156,8 @@ fn generate_namespace_schema(tables: usize, columns_per_table: usize) -> Namespa (format!("table{i}"), schema) }) .collect::>(), - max_columns_per_table: MaxColumnsPerTable::new(i32::MAX), max_tables: MaxTables::new(i32::MAX), + max_columns_per_table: MaxColumnsPerTable::new(i32::MAX), retention_period_ns: None, partition_template, } diff --git a/router/benches/partitioner.rs b/router/benches/partitioner.rs index f9f2373639..8ba08583e3 100644 --- a/router/benches/partitioner.rs +++ b/router/benches/partitioner.rs @@ -166,8 +166,8 @@ fn bench( let schema = Arc::new(NamespaceSchema { id: NamespaceId::new(42), tables: Default::default(), - max_columns_per_table: MaxColumnsPerTable::new(1000), max_tables: MaxTables::new(1000), + max_columns_per_table: MaxColumnsPerTable::new(1000), retention_period_ns: None, partition_template: partition_template.clone(), }); diff --git a/router/benches/schema_validator.rs b/router/benches/schema_validator.rs index 19c3a24a8d..cf3d523e8c 100644 --- a/router/benches/schema_validator.rs +++ b/router/benches/schema_validator.rs @@ -51,8 +51,8 @@ fn bench(group: &mut BenchmarkGroup, tables: usize, columns_per_table: let namespace_schema = NamespaceSchema { id: NamespaceId::new(42), tables: Default::default(), - max_columns_per_table: MaxColumnsPerTable::new(42), max_tables: MaxTables::new(42), + max_columns_per_table: MaxColumnsPerTable::new(42), retention_period_ns: None, partition_template: Default::default(), }; diff --git a/router/src/gossip/anti_entropy/mst/mod.rs b/router/src/gossip/anti_entropy/mst/mod.rs index 240abe9d59..5a89ddbc1b 100644 --- a/router/src/gossip/anti_entropy/mst/mod.rs +++ b/router/src/gossip/anti_entropy/mst/mod.rs @@ -83,16 +83,16 @@ mod tests { arbitrary_table_schema(), (0, 10) // Set size range ), - max_columns_per_table in any::(), max_tables in any::(), + max_columns_per_table in any::(), retention_period_ns in any::>(), ) -> NamespaceSchema { let tables = tables.into_iter().map(|(k, v)| (k.to_string(), v)).collect(); NamespaceSchema { id: NamespaceId::new(namespace_id), tables, - max_columns_per_table: MaxColumnsPerTable::new(max_columns_per_table as i32), max_tables: MaxTables::new(max_tables as i32), + max_columns_per_table: MaxColumnsPerTable::new(max_columns_per_table as i32), retention_period_ns, partition_template: Default::default(), } diff --git a/router/src/gossip/mod.rs b/router/src/gossip/mod.rs index a0cdf2ceb3..7a34e631ec 100644 --- a/router/src/gossip/mod.rs +++ b/router/src/gossip/mod.rs @@ -64,8 +64,8 @@ pub(crate) fn namespace_created( namespace_name: namespace_name.into(), namespace_id: schema.id.get(), partition_template: schema.partition_template.as_proto().cloned(), - max_columns_per_table: schema.max_columns_per_table.get() as u64, max_tables: schema.max_tables.get() as u64, + max_columns_per_table: schema.max_columns_per_table.get() as u64, retention_period_ns: schema.retention_period_ns, } } diff --git a/router/src/gossip/namespace_cache.rs b/router/src/gossip/namespace_cache.rs index d116276f58..fe6b5f2a83 100644 --- a/router/src/gossip/namespace_cache.rs +++ b/router/src/gossip/namespace_cache.rs @@ -164,8 +164,8 @@ where }) => { debug!( namespace_id = note.namespace_id, - max_columns_per_table = note.max_columns_per_table, max_tables = note.max_tables, + max_columns_per_table = note.max_columns_per_table, retention_period_ns = note.retention_period_ns, ?partition_template, "discovered new namespace via gossip" @@ -180,10 +180,10 @@ where NamespaceSchema { id: NamespaceId::new(note.namespace_id), tables: Default::default(), + max_tables: MaxTables::new(note.max_tables as i32), max_columns_per_table: MaxColumnsPerTable::new( note.max_columns_per_table as i32, ), - max_tables: MaxTables::new(note.max_tables as i32), retention_period_ns: note.retention_period_ns, partition_template, }, @@ -412,8 +412,8 @@ mod tests { // attribute checked separately) fn assert_namespace_attributes_eq(left: &NamespaceSchema, right: &NamespaceSchema) { assert_eq!(left.id, right.id); - assert_eq!(left.max_columns_per_table, right.max_columns_per_table); assert_eq!(left.max_tables, right.max_tables); + assert_eq!(left.max_columns_per_table, right.max_columns_per_table); assert_eq!(left.retention_period_ns, right.retention_period_ns); assert_eq!(left.partition_template, right.partition_template); } @@ -888,8 +888,8 @@ mod tests { // But these fields can change. // // They will be ignored, and the local values used instead. - max_columns_per_table: 123456, max_tables: 123456, + max_columns_per_table: 123456, retention_period_ns: Some(123456), ..namespace_created(NAMESPACE_NAME, &DEFAULT_NAMESPACE) }), diff --git a/router/src/lib.rs b/router/src/lib.rs index 4d9417fe5d..c53171a44c 100644 --- a/router/src/lib.rs +++ b/router/src/lib.rs @@ -160,8 +160,8 @@ pub(crate) mod test_helpers { NamespaceSchema { id: NamespaceId::new(id), tables: BTreeMap::new(), - max_columns_per_table: MaxColumnsPerTable::const_default(), max_tables: MaxTables::const_default(), + max_columns_per_table: MaxColumnsPerTable::const_default(), retention_period_ns: None, partition_template: DEFAULT_NAMESPACE_PARTITION_TEMPLATE, } diff --git a/router/src/namespace_cache/memory.rs b/router/src/namespace_cache/memory.rs index 4bfcf0393c..8b41532f06 100644 --- a/router/src/namespace_cache/memory.rs +++ b/router/src/namespace_cache/memory.rs @@ -186,8 +186,8 @@ mod tests { NamespaceSchema { id: TEST_NAMESPACE_ID, tables: Default::default(), - max_columns_per_table: MaxColumnsPerTable::new(50), max_tables: MaxTables::new(24), + max_columns_per_table: MaxColumnsPerTable::new(50), retention_period_ns: Some(876), partition_template: Default::default(), } @@ -198,8 +198,8 @@ mod tests { NamespaceSchema { id: TEST_NAMESPACE_ID, tables: Default::default(), - max_columns_per_table: MaxColumnsPerTable::new(10), max_tables: MaxTables::new(42), + max_columns_per_table: MaxColumnsPerTable::new(10), retention_period_ns: Some(876), partition_template: Default::default(), } @@ -484,16 +484,16 @@ mod tests { arbitrary_table_schema(), (0, 10) // Set size range ), - max_columns_per_table in any::(), max_tables in any::(), + max_columns_per_table in any::(), retention_period_ns in any::>(), ) -> NamespaceSchema { let tables = tables.into_iter().map(|(k, v)| (k.to_string(), v)).collect(); NamespaceSchema { id: TEST_NAMESPACE_ID, tables, - max_columns_per_table: MaxColumnsPerTable::new(max_columns_per_table as i32), max_tables: MaxTables::new(max_tables as i32), + max_columns_per_table: MaxColumnsPerTable::new(max_columns_per_table as i32), retention_period_ns, partition_template: Default::default(), } @@ -577,8 +577,8 @@ mod tests { // Assert the "last writer wins" in terms of all other namespace // values. - assert_eq!(got.max_columns_per_table, b.max_columns_per_table); assert_eq!(got.max_tables, b.max_tables); + assert_eq!(got.max_columns_per_table, b.max_columns_per_table); assert_eq!(got.retention_period_ns, b.retention_period_ns); } } diff --git a/router/src/namespace_cache/metrics.rs b/router/src/namespace_cache/metrics.rs index aa3249d5fe..d2577a82ba 100644 --- a/router/src/namespace_cache/metrics.rs +++ b/router/src/namespace_cache/metrics.rs @@ -164,8 +164,8 @@ mod tests { NamespaceSchema { id: NamespaceId::new(42), tables, - max_columns_per_table: MaxColumnsPerTable::new(100), max_tables: MaxTables::new(42), + max_columns_per_table: MaxColumnsPerTable::new(100), retention_period_ns: None, partition_template: Default::default(), }