Skip to content

Commit a4bf12d

Browse files
committed
Remove AxesIteratorHandle and related axes iterator functionality
1 parent 48cd583 commit a4bf12d

7 files changed

Lines changed: 9 additions & 329 deletions

File tree

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

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -620,58 +620,6 @@ MoveElementData MoveIteratorHandle::next() {
620620
return data;
621621
}
622622

623-
// ============================================================================
624-
// AxesIteratorHandle implementation
625-
// ============================================================================
626-
627-
AxesIteratorHandle::AxesIteratorHandle(fdb5::AxesIterator&& it) : impl_(std::move(it)) {}
628-
629-
AxesIteratorHandle::~AxesIteratorHandle() = default;
630-
631-
bool AxesIteratorHandle::hasNext() {
632-
if (exhausted_) {
633-
return false;
634-
}
635-
if (has_current_) {
636-
return true;
637-
}
638-
639-
if (impl_.next(current_)) {
640-
has_current_ = true;
641-
return true;
642-
}
643-
else {
644-
exhausted_ = true;
645-
return false;
646-
}
647-
}
648-
649-
AxesElementData AxesIteratorHandle::next() {
650-
if (!has_current_ && !hasNext()) {
651-
throw std::runtime_error("Iterator exhausted");
652-
}
653-
654-
has_current_ = false;
655-
656-
AxesElementData data;
657-
658-
// Extract the database key
659-
data.db_key = from_fdb_key(current_.key());
660-
661-
// Extract all axes from the IndexAxis
662-
auto axes_map = current_.axes().map();
663-
for (const auto& [axis_name, values_set] : axes_map) {
664-
AxisEntry entry;
665-
entry.key = rust::String(axis_name);
666-
for (const auto& v : values_set) {
667-
entry.values.push_back(rust::String(v));
668-
}
669-
data.axes.push_back(std::move(entry));
670-
}
671-
672-
return data;
673-
}
674-
675623
// ============================================================================
676624
// Library metadata functions
677625
// ============================================================================
@@ -787,13 +735,6 @@ rust::Vec<AxisEntry> axes(FdbHandle& handle, rust::Str request, int32_t level) {
787735
return result;
788736
}
789737

790-
std::unique_ptr<AxesIteratorHandle> axes_iterator(FdbHandle& handle, rust::Str request, int32_t level) {
791-
std::string request_str{request};
792-
auto tool_request = make_tool_request(request_str);
793-
auto it = handle.inner().axesIterator(tool_request, level);
794-
return std::make_unique<AxesIteratorHandle>(std::move(it));
795-
}
796-
797738
// ============================================================================
798739
// Dump functions
799740
// ============================================================================

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

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ catch (...) {
5757
} // namespace rust::behavior
5858

5959
#include "fdb5/api/FDB.h"
60-
#include "fdb5/api/helpers/AxesIterator.h"
6160
#include "fdb5/api/helpers/ControlIterator.h"
6261
#include "fdb5/api/helpers/DumpIterator.h"
6362
#include "fdb5/api/helpers/ListIterator.h"
@@ -89,7 +88,6 @@ struct StatsElementData;
8988
struct ControlElementData;
9089
struct MoveElementData;
9190
struct ConfigData;
92-
struct AxesElementData;
9391

9492
// ============================================================================
9593
// Wrapper classes for opaque C++ types
@@ -388,30 +386,6 @@ class MoveIteratorHandle {
388386
bool exhausted_ = false;
389387
};
390388

391-
/// Wrapper around fdb5::AxesIterator.
392-
class AxesIteratorHandle {
393-
public:
394-
395-
explicit AxesIteratorHandle(fdb5::AxesIterator&& it);
396-
~AxesIteratorHandle();
397-
398-
AxesIteratorHandle(const AxesIteratorHandle&) = delete;
399-
AxesIteratorHandle& operator=(const AxesIteratorHandle&) = delete;
400-
AxesIteratorHandle(AxesIteratorHandle&&) = default;
401-
AxesIteratorHandle& operator=(AxesIteratorHandle&&) = default;
402-
403-
// Methods exposed to Rust via cxx
404-
bool hasNext();
405-
AxesElementData next();
406-
407-
private:
408-
409-
fdb5::AxesIterator impl_;
410-
fdb5::AxesElement current_;
411-
bool has_current_ = false;
412-
bool exhausted_ = false;
413-
};
414-
415389
// ============================================================================
416390
// Initialization functions
417391
// ============================================================================
@@ -490,9 +464,6 @@ std::unique_ptr<ListIteratorHandle> list(FdbHandle& handle, rust::Str request, b
490464
/// Get axes for a request.
491465
rust::Vec<AxisEntry> axes(FdbHandle& handle, rust::Str request, int32_t level);
492466

493-
/// Get an axes iterator.
494-
std::unique_ptr<AxesIteratorHandle> axes_iterator(FdbHandle& handle, rust::Str request, int32_t level);
495-
496467
// ============================================================================
497468
// Dump functions
498469
// ============================================================================

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

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ 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-
#[track_cpp_api("fdb5/api/FDB.h", class = "FDB", ignore = ["inspect", "reindex"])]
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"])]
4346
#[cxx::bridge(namespace = "fdb::ffi")]
4447
mod ffi {
4548
// =========================================================================
@@ -94,15 +97,6 @@ mod ffi {
9497
pub values: Vec<String>,
9598
}
9699

97-
/// Data from axes iteration - contains a database key and all its axes.
98-
#[derive(Debug, Clone, Default)]
99-
pub struct AxesElementData {
100-
/// Database key entries
101-
pub db_key: Vec<KeyValue>,
102-
/// All axes for this database
103-
pub axes: Vec<AxisEntry>,
104-
}
105-
106100
/// Aggregate FDB statistics.
107101
#[derive(Debug, Clone, Default)]
108102
pub struct FdbStatsData {
@@ -398,19 +392,6 @@ mod ffi {
398392
/// Get the next element from the iterator.
399393
fn next(self: Pin<&mut MoveIteratorHandle>) -> Result<MoveElementData>;
400394

401-
// =====================================================================
402-
// AxesIteratorHandle
403-
// =====================================================================
404-
405-
/// Wrapper around fdb5::AxesIterator
406-
type AxesIteratorHandle;
407-
408-
/// Check if the iterator has more elements.
409-
fn hasNext(self: Pin<&mut AxesIteratorHandle>) -> Result<bool>;
410-
411-
/// Get the next element from the iterator.
412-
fn next(self: Pin<&mut AxesIteratorHandle>) -> Result<AxesElementData>;
413-
414395
// =====================================================================
415396
// Initialization (free functions)
416397
// =====================================================================
@@ -506,13 +487,6 @@ mod ffi {
506487
/// Get axes (available metadata dimensions) for a request.
507488
fn axes(handle: Pin<&mut FdbHandle>, request: &str, level: i32) -> Result<Vec<AxisEntry>>;
508489

509-
/// Get an axes iterator for streaming axes results.
510-
fn axes_iterator(
511-
handle: Pin<&mut FdbHandle>,
512-
request: &str,
513-
level: i32,
514-
) -> Result<UniquePtr<AxesIteratorHandle>>;
515-
516490
// =====================================================================
517491
// Dump operations (free functions)
518492
// =====================================================================

rust/crates/fdb/src/handle.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use parking_lot::Mutex;
1010
use crate::datareader::DataReader;
1111
use crate::error::Result;
1212
use crate::iterator::{
13-
AxesIterator, ControlIterator, DumpIterator, ListIterator, MoveIterator, PurgeIterator,
14-
StatsIterator, StatusIterator, WipeIterator,
13+
ControlIterator, DumpIterator, ListIterator, MoveIterator, PurgeIterator, StatsIterator,
14+
StatusIterator, WipeIterator,
1515
};
1616
use crate::key::Key;
1717
use crate::request::Request;
@@ -320,22 +320,6 @@ impl Fdb {
320320
Ok(axes.into_iter().map(|a| (a.key, a.values)).collect())
321321
}
322322

323-
/// Get an axes iterator for streaming axes results.
324-
///
325-
/// # Arguments
326-
///
327-
/// * `request` - The request to query axes for
328-
/// * `depth` - Index depth to traverse (1=database, 2=index, 3=full)
329-
///
330-
/// # Errors
331-
///
332-
/// Returns an error if the query fails.
333-
pub fn axes_iter(&self, request: &Request, depth: i32) -> Result<AxesIterator> {
334-
let it =
335-
self.with_handle(|h| fdb_sys::axes_iterator(h, &request.to_request_string(), depth))?;
336-
Ok(AxesIterator::new(it))
337-
}
338-
339323
/// Dump database structure.
340324
///
341325
/// # Arguments

rust/crates/fdb/src/iterator.rs

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! FDB iterator wrappers.
22
3-
use std::collections::HashMap;
4-
53
use fdb_sys::UniquePtr;
64

75
use crate::error::Result;
@@ -123,81 +121,6 @@ impl ListElement {
123121
}
124122
}
125123

126-
// =============================================================================
127-
// AxesIterator
128-
// =============================================================================
129-
130-
/// An iterator over FDB axes results.
131-
pub struct AxesIterator {
132-
handle: UniquePtr<fdb_sys::AxesIteratorHandle>,
133-
exhausted: bool,
134-
}
135-
136-
impl AxesIterator {
137-
/// Create a new iterator from a cxx handle.
138-
pub(crate) const fn new(handle: UniquePtr<fdb_sys::AxesIteratorHandle>) -> Self {
139-
Self {
140-
handle,
141-
exhausted: false,
142-
}
143-
}
144-
}
145-
146-
impl Iterator for AxesIterator {
147-
type Item = Result<AxesElement>;
148-
149-
fn next(&mut self) -> Option<Self::Item> {
150-
if self.exhausted {
151-
return None;
152-
}
153-
match self.handle.pin_mut().hasNext() {
154-
Ok(false) => {
155-
self.exhausted = true;
156-
return None;
157-
}
158-
Err(e) => {
159-
self.exhausted = true;
160-
return Some(Err(e.into()));
161-
}
162-
Ok(true) => {}
163-
}
164-
165-
match self.handle.pin_mut().next() {
166-
Ok(data) => Some(Ok(AxesElement::from_cxx(data))),
167-
Err(e) => {
168-
self.exhausted = true;
169-
Some(Err(e.into()))
170-
}
171-
}
172-
}
173-
}
174-
175-
// SAFETY: AxesIterator can be sent to another thread because:
176-
// 1. The C++ fdb5::AxesIterator contains a snapshot of index data taken at construction
177-
// 2. It does not hold references back to the FDB handle after creation
178-
// 3. Access is exclusive via &mut self (Pin<&mut> in the FFI layer)
179-
// 4. The iterator has no thread-local state or thread-affine resources
180-
#[allow(clippy::non_send_fields_in_send_ty)]
181-
unsafe impl Send for AxesIterator {}
182-
183-
/// An axes element containing database key and available axes.
184-
#[derive(Debug, Clone)]
185-
pub struct AxesElement {
186-
/// Database-level key entries.
187-
pub db_key: Vec<(String, String)>,
188-
/// Available axes (key -> values mapping).
189-
pub axes: HashMap<String, Vec<String>>,
190-
}
191-
192-
impl AxesElement {
193-
fn from_cxx(data: fdb_sys::AxesElementData) -> Self {
194-
Self {
195-
db_key: key_values_to_vec(data.db_key),
196-
axes: data.axes.into_iter().map(|a| (a.key, a.values)).collect(),
197-
}
198-
}
199-
}
200-
201124
// =============================================================================
202125
// DumpIterator
203126
// =============================================================================

rust/crates/fdb/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ pub use datareader::DataReader;
3333
pub use error::{Error, Result};
3434
pub use handle::{ArchiveCallbackData, Fdb, FdbConfig, FdbStats};
3535
pub use iterator::{
36-
AxesElement, AxesIterator, ControlElement, ControlIterator, DumpElement, DumpIterator,
37-
ListElement, ListIterator, MoveElement, MoveIterator, PurgeElement, PurgeIterator,
38-
StatsElement, StatsIterator, StatusElement, StatusIterator, WipeElement, WipeIterator,
36+
ControlElement, ControlIterator, DumpElement, DumpIterator, ListElement, ListIterator,
37+
MoveElement, MoveIterator, PurgeElement, PurgeIterator, StatsElement, StatsIterator,
38+
StatusElement, StatusIterator, WipeElement, WipeIterator,
3939
};
4040
pub use key::Key;
4141
pub use request::Request;

0 commit comments

Comments
 (0)