Skip to content

Commit 9613292

Browse files
committed
Remove FDB configuration methods and related data structures to simplify API
1 parent c9957a7 commit 9613292

File tree

6 files changed

+15
-198
lines changed

6 files changed

+15
-198
lines changed

rust/crates/fdb-sys/cpp/fdb_bridge.cpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -174,47 +174,6 @@ rust::String FdbHandle::name() const {
174174
return rust::String(impl_.name());
175175
}
176176

177-
ConfigData FdbHandle::config() const {
178-
ConfigData data;
179-
const auto& cfg = impl_.config();
180-
data.schema_path = rust::String(cfg.schemaPath().asString());
181-
data.config_path = rust::String(cfg.configPath().asString());
182-
return data;
183-
}
184-
185-
rust::String FdbHandle::config_string(rust::Str key) const {
186-
const auto& cfg = impl_.config();
187-
std::string key_str{key};
188-
if (cfg.has(key_str)) {
189-
return rust::String(cfg.getString(key_str));
190-
}
191-
return rust::String("");
192-
}
193-
194-
int64_t FdbHandle::config_int(rust::Str key) const {
195-
const auto& cfg = impl_.config();
196-
std::string key_str{key};
197-
if (cfg.has(key_str)) {
198-
return cfg.getLong(key_str);
199-
}
200-
return 0;
201-
}
202-
203-
bool FdbHandle::config_bool(rust::Str key) const {
204-
const auto& cfg = impl_.config();
205-
std::string key_str{key};
206-
if (cfg.has(key_str)) {
207-
return cfg.getBool(key_str);
208-
}
209-
return false;
210-
}
211-
212-
bool FdbHandle::config_has(rust::Str key) const {
213-
const auto& cfg = impl_.config();
214-
std::string key_str{key};
215-
return cfg.has(key_str);
216-
}
217-
218177
// ============================================================================
219178
// DataReaderHandle implementation
220179
// ============================================================================

rust/crates/fdb-sys/cpp/fdb_bridge.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ struct PurgeElementData;
8787
struct StatsElementData;
8888
struct ControlElementData;
8989
struct MoveElementData;
90-
struct ConfigData;
9190

9291
// ============================================================================
9392
// Wrapper classes for opaque C++ types
@@ -136,21 +135,6 @@ class FdbHandle {
136135
/// Get the FDB type name.
137136
rust::String name() const;
138137

139-
/// Get the FDB configuration data.
140-
ConfigData config() const;
141-
142-
/// Get a string value from the FDB configuration.
143-
rust::String config_string(rust::Str key) const;
144-
145-
/// Get an integer value from the FDB configuration.
146-
int64_t config_int(rust::Str key) const;
147-
148-
/// Get a boolean value from the FDB configuration.
149-
bool config_bool(rust::Str key) const;
150-
151-
/// Check if a key exists in the FDB configuration.
152-
bool config_has(rust::Str key) const;
153-
154138
private:
155139

156140
fdb5::FDB impl_;

rust/crates/fdb-sys/src/lib.rs

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,18 @@ pub struct FlushCallbackBox(Box<dyn FlushCallback>);
3939
/// Opaque wrapper for archive callbacks (used internally by cxx bridge).
4040
pub struct ArchiveCallbackBox(Box<dyn ArchiveCallback>);
4141

42-
// `axesIterator` is intentionally not exposed: it is an internal detail of
43-
// the multi-FDB implementation (DistFDB / SelectFDB) and not meaningful at
44-
// the user API. The synchronous `axes()` method is the supported entry point.
45-
#[track_cpp_api("fdb5/api/FDB.h", class = "FDB", ignore = ["inspect", "reindex", "axesIterator"])]
42+
// Methods intentionally not exposed:
43+
// - `axesIterator`: internal detail of the multi-FDB implementation
44+
// (DistFDB / SelectFDB), not meaningful at the user API. The synchronous
45+
// `axes()` method is the supported entry point.
46+
// - `config`: returns the same configuration the user just supplied to
47+
// `Fdb::from_yaml(...)`. The user already has it; round-tripping it back
48+
// through the FFI adds no information.
49+
#[track_cpp_api(
50+
"fdb5/api/FDB.h",
51+
class = "FDB",
52+
ignore = ["inspect", "reindex", "axesIterator", "config"]
53+
)]
4654
#[cxx::bridge(namespace = "fdb::ffi")]
4755
mod ffi {
4856
// =========================================================================
@@ -171,15 +179,6 @@ mod ffi {
171179
pub destination: String,
172180
}
173181

174-
/// FDB configuration data.
175-
#[derive(Debug, Clone, Default)]
176-
pub struct ConfigData {
177-
/// Path to the schema file.
178-
pub schema_path: String,
179-
/// Path to the config file.
180-
pub config_path: String,
181-
}
182-
183182
// Bind to existing fdb5::ControlAction / fdb5::ControlIdentifier C++ enums.
184183
// The shared enum + extern type pattern tells CXX to use the existing
185184
// C++ enum and generate static assertions to verify the values match.
@@ -248,21 +247,6 @@ mod ffi {
248247
/// Get the FDB type name (e.g., "local", "remote").
249248
fn name(self: &FdbHandle) -> String;
250249

251-
/// Get the FDB configuration data (schema path, config path).
252-
fn config(self: &FdbHandle) -> ConfigData;
253-
254-
/// Get a string value from the FDB configuration.
255-
fn config_string(self: &FdbHandle, key: &str) -> String;
256-
257-
/// Get an integer value from the FDB configuration.
258-
fn config_int(self: &FdbHandle, key: &str) -> i64;
259-
260-
/// Get a boolean value from the FDB configuration.
261-
fn config_bool(self: &FdbHandle, key: &str) -> bool;
262-
263-
/// Check if a key exists in the FDB configuration.
264-
fn config_has(self: &FdbHandle, key: &str) -> bool;
265-
266250
// =====================================================================
267251
// DataReaderHandle - For reading retrieved data
268252
// =====================================================================

rust/crates/fdb/src/handle.rs

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -461,60 +461,6 @@ impl Fdb {
461461
self.with_handle_ref(|h| h.enabled(identifier))
462462
}
463463

464-
/// Get the FDB configuration data.
465-
#[must_use]
466-
pub fn config(&self) -> FdbConfig {
467-
self.with_handle_ref(|h| {
468-
let data = h.config();
469-
FdbConfig {
470-
schema_path: data.schema_path,
471-
config_path: data.config_path,
472-
}
473-
})
474-
}
475-
476-
/// Get a string value from the FDB configuration.
477-
///
478-
/// Returns `None` if the key doesn't exist.
479-
#[must_use]
480-
pub fn config_string(&self, key: &str) -> Option<String> {
481-
if self.config_has(key) {
482-
Some(self.with_handle_ref(|h| h.config_string(key)))
483-
} else {
484-
None
485-
}
486-
}
487-
488-
/// Get an integer value from the FDB configuration.
489-
///
490-
/// Returns `None` if the key doesn't exist.
491-
#[must_use]
492-
pub fn config_int(&self, key: &str) -> Option<i64> {
493-
if self.config_has(key) {
494-
Some(self.with_handle_ref(|h| h.config_int(key)))
495-
} else {
496-
None
497-
}
498-
}
499-
500-
/// Get a boolean value from the FDB configuration.
501-
///
502-
/// Returns `None` if the key doesn't exist.
503-
#[must_use]
504-
pub fn config_bool(&self, key: &str) -> Option<bool> {
505-
if self.config_has(key) {
506-
Some(self.with_handle_ref(|h| h.config_bool(key)))
507-
} else {
508-
None
509-
}
510-
}
511-
512-
/// Check if a key exists in the FDB configuration.
513-
#[must_use]
514-
pub fn config_has(&self, key: &str) -> bool {
515-
self.with_handle_ref(|h| h.config_has(key))
516-
}
517-
518464
/// Register a callback to be invoked on flush.
519465
pub fn on_flush<F>(&self, callback: F)
520466
where
@@ -551,14 +497,5 @@ pub struct FdbStats {
551497
pub num_flush: u64,
552498
}
553499

554-
/// FDB configuration data.
555-
#[derive(Debug, Clone, Default)]
556-
pub struct FdbConfig {
557-
/// Path to the schema file.
558-
pub schema_path: String,
559-
/// Path to the config file.
560-
pub config_path: String,
561-
}
562-
563500
/// Re-export callback data type.
564501
pub use fdb_sys::ArchiveCallbackData;

rust/crates/fdb/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mod request;
3131

3232
pub use datareader::DataReader;
3333
pub use error::{Error, Result};
34-
pub use handle::{ArchiveCallbackData, Fdb, FdbConfig, FdbStats};
34+
pub use handle::{ArchiveCallbackData, Fdb, FdbStats};
3535
pub use iterator::{
3636
ControlElement, ControlIterator, DumpElement, DumpIterator, ListElement, ListIterator,
3737
MoveElement, MoveIterator, PurgeElement, PurgeIterator, StatsElement, StatsIterator,

rust/crates/fdb/tests/fdb_integration.rs

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -526,29 +526,16 @@ fn test_fdb_dirty_flag() {
526526

527527
#[test]
528528
#[ignore = "requires FDB libraries"]
529-
fn test_fdb_config_methods() {
529+
fn test_fdb_id_and_name() {
530530
let tmpdir = tempfile::tempdir().expect("failed to create temp dir");
531531
let config = create_test_config(tmpdir.path());
532532

533533
let fdb = Fdb::from_yaml(&config).expect("failed to create FDB from YAML");
534534

535-
// Test config()
536-
let cfg = fdb.config();
537-
println!(
538-
"Config: schema_path={}, config_path={}",
539-
cfg.schema_path, cfg.config_path
540-
);
541-
542-
// Test id() and name()
543535
let id = fdb.id();
544536
let name = fdb.name();
545537
println!("FDB id={id}, name={name}");
546538
assert!(!name.is_empty(), "expected non-empty FDB name");
547-
548-
// Test config_has
549-
// Note: available keys depend on the configuration
550-
let has_type = fdb.config_has("type");
551-
println!("config_has('type') = {has_type}");
552539
}
553540

554541
#[test]
@@ -960,14 +947,10 @@ spaces:
960947

961948
let fdb = Fdb::from_yaml(&config).expect("failed to create FDB from YAML");
962949

963-
// Verify config was parsed
950+
// Verify the FDB handle came up cleanly with the YAML we built.
964951
let name = fdb.name();
965952
assert!(!name.is_empty(), "expected non-empty FDB name");
966953
println!("FDB type/name: {name}");
967-
968-
// Test config accessors
969-
let has_type = fdb.config_has("type");
970-
println!("config_has('type') = {has_type}");
971954
}
972955

973956
#[test]
@@ -1226,36 +1209,6 @@ fn test_fdb_control_lock_unlock() {
12261209
}
12271210
}
12281211

1229-
#[test]
1230-
#[ignore = "requires FDB libraries"]
1231-
fn test_fdb_config_accessors() {
1232-
let tmpdir = tempfile::tempdir().expect("failed to create temp dir");
1233-
let config = create_test_config(tmpdir.path());
1234-
1235-
let fdb = Fdb::from_yaml(&config).expect("failed to create FDB from YAML");
1236-
1237-
// Test config_string - try to get a string config value
1238-
let type_str = fdb.config_string("type");
1239-
println!("config_string('type') = {type_str:?}");
1240-
1241-
// Test config_int - returns None if key doesn't exist
1242-
let some_int = fdb.config_int("nonexistent_key");
1243-
assert!(some_int.is_none(), "nonexistent key should return None");
1244-
println!("config_int('nonexistent_key') = {some_int:?}");
1245-
1246-
// Test config_bool - returns None if key doesn't exist
1247-
let some_bool = fdb.config_bool("nonexistent_key");
1248-
assert!(some_bool.is_none(), "nonexistent key should return None");
1249-
println!("config_bool('nonexistent_key') = {some_bool:?}");
1250-
1251-
// Test config_has for various keys
1252-
let has_type = fdb.config_has("type");
1253-
let has_schema = fdb.config_has("schema");
1254-
let has_nonexistent = fdb.config_has("definitely_not_a_key");
1255-
println!("config_has: type={has_type}, schema={has_schema}, nonexistent={has_nonexistent}");
1256-
assert!(!has_nonexistent, "nonexistent key should return false");
1257-
}
1258-
12591212
#[test]
12601213
#[ignore = "requires FDB libraries"]
12611214
fn test_fdb_enabled_identifiers() {

0 commit comments

Comments
 (0)