Skip to content

Commit

Permalink
feat: Implement Deserialize for Catalog
Browse files Browse the repository at this point in the history
This was fairly easy all things considered. We needed to turn on the
serde feature for parking_lot, remove the Serialize impl, derive both it
and Deserialize, and add the flatten attribute and we're all set. The
output for the tests changed, but only the order of fields, not the
actual content so it's fine that we updated them. This change will allow
us to deserialize the Catalog in the future if need be without running
into issues around the fact that it can't implement it.

Closes #25574
  • Loading branch information
mgattozzi committed Jan 2, 2025
1 parent 237ab35 commit b389c92
Showing 6 changed files with 11 additions and 18 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -83,7 +83,7 @@ mockito = { version = "1.4.0", default-features = false }
mockall = { version = "0.13.0" }
num_cpus = "1.16.0"
object_store = "0.11.1"
parking_lot = "0.12.1"
parking_lot = { version = "0.12.1", features = ["serde"] }
paste = "1.0.15"
parquet = { version = "53.0.0", features = ["object_store"] }
pbjson = "0.6.0"
14 changes: 3 additions & 11 deletions influxdb3_catalog/src/catalog.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ use iox_time::Time;
use observability_deps::tracing::{debug, info};
use parking_lot::RwLock;
use schema::{InfluxColumnType, InfluxFieldType, Schema, SchemaBuilder};
use serde::{Deserialize, Serialize, Serializer};
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use std::cmp::Ordering;
use std::collections::BTreeMap;
@@ -159,8 +159,9 @@ impl CatalogSequenceNumber {
}
}

#[derive(Debug)]
#[derive(Debug, Deserialize, Serialize)]
pub struct Catalog {
#[serde(flatten)]
inner: RwLock<InnerCatalog>,
}

@@ -170,15 +171,6 @@ impl PartialEq for Catalog {
}
}

impl Serialize for Catalog {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
self.inner.read().serialize(serializer)
}
}

impl Catalog {
/// Limit for the number of Databases that InfluxDB 3.0 OSS can have
pub(crate) const NUM_DBS_LIMIT: usize = 5;
Original file line number Diff line number Diff line change
@@ -269,8 +269,8 @@ snapshot_kind: text
}
]
],
"sequence": 0,
"db_map": [],
"host_id": "sample-host-id",
"instance_id": "instance-id",
"db_map": []
"sequence": 0
}
Original file line number Diff line number Diff line change
@@ -120,8 +120,8 @@ snapshot_kind: text
}
]
],
"sequence": 0,
"db_map": [],
"host_id": "sample-host-id",
"instance_id": "instance-id",
"db_map": []
"sequence": 0
}
Original file line number Diff line number Diff line change
@@ -104,8 +104,8 @@ snapshot_kind: text
}
]
],
"sequence": 0,
"db_map": [],
"host_id": "sample-host-id",
"instance_id": "instance-id",
"db_map": []
"sequence": 0
}

0 comments on commit b389c92

Please sign in to comment.