1use std::sync::Arc;
16
17use arrow::datatypes::{Field, Schema, SchemaRef};
18use exon_common::DEFAULT_BATCH_SIZE;
19use object_store::ObjectStore;
20
21pub struct FCSConfig {
23 pub batch_size: usize,
25 pub object_store: Arc<dyn ObjectStore>,
27 pub file_schema: Arc<arrow::datatypes::Schema>,
29 pub projection: Option<Vec<usize>>,
31}
32
33impl FCSConfig {
34 pub fn new(object_store: Arc<dyn ObjectStore>, file_schema: SchemaRef) -> Self {
36 Self {
37 batch_size: DEFAULT_BATCH_SIZE,
38 object_store,
39 file_schema,
40 projection: None,
41 }
42 }
43
44 pub fn with_batch_size(mut self, batch_size: usize) -> Self {
46 self.batch_size = batch_size;
47 self
48 }
49
50 pub fn with_projection(mut self, projection: Vec<usize>) -> Self {
52 self.projection = Some(projection);
53 self
54 }
55}
56
57#[derive(Debug, Default)]
58pub struct FCSSchemaBuilder {
59 file_fields: Vec<Field>,
60 partition_fields: Vec<Field>,
61}
62
63impl FCSSchemaBuilder {
64 pub fn new() -> Self {
65 Self {
66 file_fields: vec![],
67 partition_fields: vec![],
68 }
69 }
70
71 pub fn add_file_fields(&mut self, fields: Vec<Field>) {
72 self.file_fields.extend(fields)
73 }
74
75 pub fn add_partition_fields(&mut self, fields: Vec<Field>) {
77 self.partition_fields.extend(fields)
78 }
79
80 pub fn build(self) -> (Schema, Vec<usize>) {
82 let mut fields = self.file_fields.clone();
83 fields.extend(self.partition_fields);
84
85 let schema = Schema::new(fields);
86
87 let projection = (0..self.file_fields.len()).collect();
88
89 (schema, projection)
90 }
91}