Skip to content

Commit

Permalink
Merge pull request #1 from sharma-shray/upd
Browse files Browse the repository at this point in the history
upd
  • Loading branch information
sharma-shray authored Dec 21, 2024
2 parents 029a2ff + 7bdae32 commit 0b5857f
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions lib/enrichment/src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,24 @@ fn fmt_enrichment_table(
name: &'static str,
tables: &Arc<ArcSwap<Option<TableMap>>>,
) -> std::fmt::Result {
// Load the current state of the tables (this is a lock-free operation).
let tables = tables.load();
match **tables {
Some(ref tables) => {
let mut tables = tables.iter().fold(String::from("("), |mut s, (key, _)| {
s.push_str(key);
s.push_str(", ");
s
});

tables.truncate(std::cmp::max(tables.len(), 0));
tables.push(')');

write!(f, "{} {}", name, tables)
// Check if the tables are loaded or still in the loading state.
match &**tables {
Some(ref tables) => {
// Map the keys to &str and join them with a comma.
let table_names = tables
.keys()
.map(|s| s.as_str())
.collect::<Vec<_>>()
.join(", ");
write!(f, "{} ({})", name, table_names)
}
None => {
// If the tables are still loading, indicate the loading state.
write!(f, "{} loading", name)
}
None => write!(f, "{} loading", name),
}
}

Expand Down

0 comments on commit 0b5857f

Please sign in to comment.