(
&self,
buf: &mut Vec<u8>,
node: Arc<dyn FileFormatFactory>,
)
| 269 | } |
| 270 | |
| 271 | fn try_encode_file_format( |
| 272 | &self, |
| 273 | buf: &mut Vec<u8>, |
| 274 | node: Arc<dyn FileFormatFactory>, |
| 275 | ) -> Result<()> { |
| 276 | let mut encoded_file_format = Vec::new(); |
| 277 | |
| 278 | let kind = if node.downcast_ref::<CsvFormatFactory>().is_some() { |
| 279 | file_formats::CsvLogicalExtensionCodec |
| 280 | .try_encode_file_format(&mut encoded_file_format, Arc::clone(&node))?; |
| 281 | protobuf::FileFormatKind::Csv |
| 282 | } else if node.downcast_ref::<JsonFormatFactory>().is_some() { |
| 283 | file_formats::JsonLogicalExtensionCodec |
| 284 | .try_encode_file_format(&mut encoded_file_format, Arc::clone(&node))?; |
| 285 | protobuf::FileFormatKind::Json |
| 286 | } else if node.downcast_ref::<ArrowFormatFactory>().is_some() { |
| 287 | file_formats::ArrowLogicalExtensionCodec |
| 288 | .try_encode_file_format(&mut encoded_file_format, Arc::clone(&node))?; |
| 289 | protobuf::FileFormatKind::Arrow |
| 290 | } else { |
| 291 | #[cfg(feature = "parquet")] |
| 292 | { |
| 293 | if node.downcast_ref::<ParquetFormatFactory>().is_some() { |
| 294 | file_formats::ParquetLogicalExtensionCodec.try_encode_file_format( |
| 295 | &mut encoded_file_format, |
| 296 | Arc::clone(&node), |
| 297 | )?; |
| 298 | protobuf::FileFormatKind::Parquet |
| 299 | } else { |
| 300 | return not_impl_err!( |
| 301 | "Unsupported FileFormatFactory type for DefaultLogicalExtensionCodec" |
| 302 | ); |
| 303 | } |
| 304 | } |
| 305 | #[cfg(not(feature = "parquet"))] |
| 306 | { |
| 307 | return not_impl_err!( |
| 308 | "Unsupported FileFormatFactory type for DefaultLogicalExtensionCodec" |
| 309 | ); |
| 310 | } |
| 311 | }; |
| 312 | |
| 313 | let proto = protobuf::FileFormatProto { |
| 314 | kind: kind as i32, |
| 315 | encoded_file_format, |
| 316 | }; |
| 317 | proto.encode(buf).map_err(|e| { |
| 318 | internal_datafusion_err!("Failed to encode FileFormatProto: {e}") |
| 319 | })?; |
| 320 | Ok(()) |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | #[macro_export] |
no test coverage detected