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

Method get_opts

datafusion/core/tests/sql/path_partition.rs:677–722  ·  view source on GitHub ↗
(
        &self,
        location: &Path,
        options: GetOptions,
    )

Source from the content-addressed store, hash-verified

675 }
676
677 async fn get_opts(
678 &self,
679 location: &Path,
680 options: GetOptions,
681 ) -> object_store::Result<GetResult> {
682 self.files.iter().find(|x| *x == location).unwrap();
683 let path = std::path::PathBuf::from(&self.mirrored_file);
684 let file = File::open(&path).unwrap();
685 let metadata = file.metadata().unwrap();
686
687 let meta = ObjectMeta {
688 location: location.clone(),
689 last_modified: metadata.modified().map(chrono::DateTime::from).unwrap(),
690 size: metadata.len(),
691 e_tag: None,
692 version: None,
693 };
694
695 let payload = if options.head {
696 // no content for head requests
697 GetResultPayload::Stream(stream::empty().boxed())
698 } else if let Some(range) = options.range {
699 let GetRange::Bounded(range) = range else {
700 unimplemented!("Unbounded range not supported in MirroringObjectStore");
701 };
702 let mut file = File::open(path).unwrap();
703 file.seek(SeekFrom::Start(range.start)).unwrap();
704
705 let to_read = range.end - range.start;
706 let to_read: usize = to_read.try_into().unwrap();
707 let mut data = Vec::with_capacity(to_read);
708 let read = file.take(to_read as u64).read_to_end(&mut data).unwrap();
709 assert_eq!(read, to_read);
710 let stream = stream::once(async move { Ok(Bytes::from(data)) }).boxed();
711 GetResultPayload::Stream(stream)
712 } else {
713 GetResultPayload::File(file, path)
714 };
715
716 Ok(GetResult {
717 range: 0..meta.size,
718 payload,
719 meta,
720 attributes: Attributes::default(),
721 })
722 }
723
724 fn list(
725 &self,

Callers

nothing calls this directly

Calls 8

FileClass · 0.85
emptyFunction · 0.50
iterMethod · 0.45
metadataMethod · 0.45
cloneMethod · 0.45
mapMethod · 0.45
lenMethod · 0.45
takeMethod · 0.45

Tested by

no test coverage detected