MCPcopy Create free account
hub / github.com/apache/datafusion / partitioned_file_groups

Function partitioned_file_groups

datafusion/core/src/test/mod.rs:116–202  ·  view source on GitHub ↗

Returns file groups [`Vec `] for scanning `partitions` of `filename`

(
    path: &str,
    filename: &str,
    partitions: usize,
    file_format: &Arc<dyn FileFormat>,
    file_compression_type: FileCompressionType,
    work_dir: &Path,
)

Source from the content-addressed store, hash-verified

114
115/// Returns file groups [`Vec<FileGroup>`] for scanning `partitions` of `filename`
116pub fn partitioned_file_groups(
117 path: &str,
118 filename: &str,
119 partitions: usize,
120 file_format: &Arc<dyn FileFormat>,
121 file_compression_type: FileCompressionType,
122 work_dir: &Path,
123) -> Result<Vec<FileGroup>> {
124 let path = format!("{path}/{filename}");
125
126 let mut writers = vec![];
127 let mut files = vec![];
128 for i in 0..partitions {
129 let filename = format!(
130 "partition-{}{}",
131 i,
132 file_format
133 .get_ext_with_compression(&file_compression_type)
134 .unwrap()
135 );
136 let filename = work_dir.join(filename);
137
138 let file = File::create(&filename).unwrap();
139
140 let encoder: Box<dyn Write + Send> = match file_compression_type.to_owned() {
141 FileCompressionType::UNCOMPRESSED => Box::new(file),
142 #[cfg(feature = "compression")]
143 FileCompressionType::GZIP => {
144 Box::new(GzEncoder::new(file, GzCompression::default()))
145 }
146 #[cfg(feature = "compression")]
147 FileCompressionType::XZ => Box::new(XzEncoder::new(file, 9)),
148 #[cfg(feature = "compression")]
149 FileCompressionType::ZSTD => {
150 let encoder = ZstdEncoder::new(file, 0)
151 .map_err(|e| DataFusionError::External(Box::new(e)))?
152 .auto_finish();
153 Box::new(encoder)
154 }
155 #[cfg(feature = "compression")]
156 FileCompressionType::BZIP2 => {
157 Box::new(BzEncoder::new(file, BzCompression::default()))
158 }
159 #[cfg(not(feature = "compression"))]
160 FileCompressionType::GZIP
161 | FileCompressionType::BZIP2
162 | FileCompressionType::XZ
163 | FileCompressionType::ZSTD => {
164 panic!("Compression is not supported in this build")
165 }
166 };
167
168 let writer = BufWriter::new(encoder);
169 writers.push(writer);
170 files.push(filename);
171 }
172
173 let f = File::open(path)?;

Callers 9

prepare_storeFunction · 0.85
test_additional_storesFunction · 0.85
csv_exec_with_projectionFunction · 0.85
csv_exec_with_limitFunction · 0.85
csv_exec_with_partitionFunction · 0.85
test_additional_storesFunction · 0.85
scan_partitioned_csvFunction · 0.85

Calls 9

createFunction · 0.85
newFunction · 0.85
joinMethod · 0.45
pushMethod · 0.45
get_extMethod · 0.45
write_allMethod · 0.45
into_iterMethod · 0.45
flushMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…