1use std::collections::BTreeSet;
2use std::fmt::{Debug, Display, Formatter};
3use std::sync::Arc;
4
5use arcref::ArcRef;
6use vortex_array::ArrayContext;
7use vortex_dtype::FieldMask;
8use vortex_error::VortexResult;
9
10use crate::segments::SegmentSource;
11use crate::{Layout, LayoutId, LayoutReader};
12
13pub type LayoutVTableRef = ArcRef<dyn LayoutVTable>;
15
16pub trait LayoutVTable: Debug + Send + Sync {
17 fn id(&self) -> LayoutId;
19
20 fn reader(
24 &self,
25 layout: Layout,
26 segment_source: &Arc<dyn SegmentSource>,
27 ctx: &ArrayContext,
28 ) -> VortexResult<Arc<dyn LayoutReader>>;
29
30 fn register_splits(
40 &self,
41 layout: &Layout,
42 field_mask: &[FieldMask],
43 row_offset: u64,
44 splits: &mut BTreeSet<u64>,
45 ) -> VortexResult<()>;
46}
47
48impl PartialEq for dyn LayoutVTable + '_ {
49 fn eq(&self, other: &Self) -> bool {
50 self.id() == other.id()
51 }
52}
53
54impl Eq for dyn LayoutVTable + '_ {}
55
56impl Display for dyn LayoutVTable + '_ {
57 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
58 Display::fmt(&self.id(), f)
59 }
60}