Repository: influxdata/influxdb
File: influxdb3_catalog/src/catalog.rs (Rust)

Code before:
    pub fn triggers(&self) -> Vec<(String, String)> {
        let inner = self.inner.read();
        let result = inner
            .databases
            .values()
            .flat_map(|schema| {
                schema
                    .processing_engine_triggers
                    .iter()
                    .filter_map(move |(key, trigger)| {
                        if trigger.disabled {
                            None
                        } else {
                            Some((schema.name.to_string(), key.to_string()))
                        }
                    })
            })
            .collect();
        result
    }

    pub fn inner(&self) -> &RwLock<InnerCatalog> {
        &self.inner
    }

    pub fn table_id(&self, db_id: &DbId, table_name: Arc<str>) -> Option<TableId> {
        let inner = self.inner.read();
        inner.databases.get(db_id).and_then(|db| {
            db.table_name_to_id(table_name)
        })
    }
}

#[serde_with::serde_as]
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone, Default)]
pub struct InnerCatalog {
    /// The catalog is a map of databases with their table schemas
    databases: SerdeVecMap<DbId, Arc<DatabaseSchema>>,
    sequence: CatalogSequenceNumber,
    /// The `writer_id` is the prefix that is passed in when starting up
    /// (`writer_identifier_prefix`)
    writer_id: Arc<str>,
    /// The instance_id uniquely identifies the instance that generated the catalog
    instance_id: Arc<str>,
    /// If true, the catalog has been updated since the last time it was serialized
    #[serde(skip)]
    updated: bool,
    #[serde_as(as = "DbMapAsArray")]
    db_map: BiHashMap<DbId, Arc<str>>,
}


Review comment (bug):
This is not really used in the test or the code change, but it was useful to get the parquet files (as `get_files` method needed db_id and table_id) when debugging. I can remove it, just left it there as it might be handy.

Code after:
    pub fn triggers(&self) -> Vec<(String, String)> {
        let inner = self.inner.read();
        let result = inner
            .databases
            .values()
            .flat_map(|schema| {
                schema
                    .processing_engine_triggers
                    .iter()
                    .filter_map(move |(key, trigger)| {
                        if trigger.disabled {
                            None
                        } else {
                            Some((schema.name.to_string(), key.to_string()))
                        }
                    })
            })
            .collect();
        result
    }

    pub fn inner(&self) -> &RwLock<InnerCatalog> {
        &self.inner
    }

    pub fn table_id(&self, db_id: &DbId, table_name: Arc<str>) -> Option<TableId> {
        let inner = self.inner.read();
        inner
            .databases
            .get(db_id)
            .and_then(|db| db.table_name_to_id(table_name))
    }
}

#[serde_with::serde_as]
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone, Default)]
pub struct InnerCatalog {
    /// The catalog is a map of databases with their table schemas
    databases: SerdeVecMap<DbId, Arc<DatabaseSchema>>,
    sequence: CatalogSequenceNumber,
    /// The `writer_id` is the prefix that is passed in when starting up
    /// (`writer_identifier_prefix`)
    writer_id: Arc<str>,
    /// The instance_id uniquely identifies the instance that generated the catalog
    instance_id: Arc<str>,
    /// If true, the catalog has been updated since the last time it was serialized
    #[serde(skip)]
    updated: bool,
    #[serde_as(as = "DbMapAsArray")]
    db_map: BiHashMap<DbId, Arc<str>>,
}