mod apply;
mod batch;
mod holder;
mod lifecycle;
mod preview;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use crate::common::universal_io::UniversalRead;
use parking_lot::RwLock;
use rayon::ThreadPool;
use crate::segment::types::SegmentConfig;
use uuid::Uuid;
pub use self::apply::UpdateBatchOutcome;
pub use self::batch::{PointUpdates, UpdateBatchPlan};
use self::holder::UpdateOnlySegmentHolder;
pub use self::preview::{PointAction, PointCopy, PointPreview, UpdateBatchPreview};
pub struct UpdateOnlyEdgeShard<S: UniversalRead + 'static> {
path: PathBuf,
#[expect(dead_code)]
fs: S::Fs,
segments: RwLock<UpdateOnlySegmentHolder<S>>,
pool: Arc<ThreadPool>,
}
pub struct SegmentConfigInfo {
pub uuid: Uuid,
pub is_write_target: bool,
pub config: SegmentConfig,
}
impl<S: UniversalRead + 'static> UpdateOnlyEdgeShard<S> {
pub fn path(&self) -> &Path {
&self.path
}
pub fn segments_count(&self) -> usize {
self.segments.read().len()
}
pub fn segment_configs(&self) -> Vec<SegmentConfigInfo> {
let segments = self.segments.read();
let write_target = segments.write_target_uuid();
segments
.iter()
.map(|(uuid, segment)| SegmentConfigInfo {
uuid,
is_write_target: Some(uuid) == write_target,
config: segment.read().segment_config.clone(),
})
.collect()
}
}