algeon_datafusion/native_exec/config/
source_reads.rs1use std::{
4 num::NonZeroU64,
5 path::{Path, PathBuf},
6};
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
10#[non_exhaustive]
11pub enum LakehouseByteCacheFill {
12 #[default]
14 Disabled,
15 ReadThrough,
17 FillBeforeRead,
19}
20
21#[derive(Debug, Clone, PartialEq, Eq)]
27pub struct LakehouseByteCache {
28 root: PathBuf,
29 serves_hits: bool,
30 fill: LakehouseByteCacheFill,
31 max_retained_bytes: Option<NonZeroU64>,
32}
33
34impl LakehouseByteCache {
35 pub fn new(root: impl Into<PathBuf>) -> Self {
37 Self { root: root.into(), serves_hits: true, fill: LakehouseByteCacheFill::Disabled, max_retained_bytes: None }
38 }
39
40 pub fn with_fill(mut self, fill: LakehouseByteCacheFill) -> Self {
42 self.fill = fill;
43 self
44 }
45
46 pub fn ignoring_hits(mut self) -> Self {
50 self.serves_hits = false;
51 self
52 }
53
54 pub fn with_max_retained_bytes(mut self, bytes: NonZeroU64) -> Self {
56 self.max_retained_bytes = Some(bytes);
57 self
58 }
59
60 pub(crate) fn root(&self) -> &Path {
61 &self.root
62 }
63
64 pub(crate) fn serves_hits(&self) -> bool {
65 self.serves_hits
66 }
67
68 pub(crate) fn fill(&self) -> LakehouseByteCacheFill {
69 self.fill
70 }
71
72 pub(crate) fn max_retained_bytes(&self) -> Option<NonZeroU64> {
73 self.max_retained_bytes
74 }
75}