refactor: Consistently order max tables first, then max columns

I can't handle it.
pull/24376/head
Carol (Nichols || Goulding) 2023-09-15 14:05:00 -04:00
parent d56217a8f6
commit a42a00b6f2
No known key found for this signature in database
GPG Key ID: E907EE5A736F87D4
13 changed files with 26 additions and 26 deletions

View File

@ -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(),
},

View File

@ -302,10 +302,10 @@ pub struct NamespaceSchema {
pub id: NamespaceId,
/// the tables in the namespace by name
pub tables: BTreeMap<String, TableSchema>,
/// 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<i64>,
@ -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(),
};

View File

@ -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),
});

View File

@ -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(),
},

View File

@ -156,8 +156,8 @@ fn generate_namespace_schema(tables: usize, columns_per_table: usize) -> Namespa
(format!("table{i}"), schema)
})
.collect::<BTreeMap<_, _>>(),
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,
}

View File

@ -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(),
});

View File

@ -51,8 +51,8 @@ fn bench(group: &mut BenchmarkGroup<WallTime>, 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(),
};

View File

@ -83,16 +83,16 @@ mod tests {
arbitrary_table_schema(),
(0, 10) // Set size range
),
max_columns_per_table in any::<usize>(),
max_tables in any::<usize>(),
max_columns_per_table in any::<usize>(),
retention_period_ns in any::<Option<i64>>(),
) -> 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(),
}

View File

@ -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,
}
}

View File

@ -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)
}),

View File

@ -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,
}

View File

@ -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::<usize>(),
max_tables in any::<usize>(),
max_columns_per_table in any::<usize>(),
retention_period_ns in any::<Option<i64>>(),
) -> 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);
}
}

View File

@ -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(),
}