datafusion_datasource/
file_meta.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18use std::sync::Arc;
19
20use object_store::{path::Path, ObjectMeta};
21
22use crate::FileRange;
23
24/// A single file or part of a file that should be read, along with its schema, statistics
25pub struct FileMeta {
26    /// Path for the file (e.g. URL, filesystem path, etc)
27    pub object_meta: ObjectMeta,
28    /// An optional file range for a more fine-grained parallel execution
29    pub range: Option<FileRange>,
30    /// An optional field for user defined per object metadata
31    pub extensions: Option<Arc<dyn std::any::Any + Send + Sync>>,
32    /// Size hint for the metadata of this file
33    pub metadata_size_hint: Option<usize>,
34}
35
36impl FileMeta {
37    /// The full path to the object
38    pub fn location(&self) -> &Path {
39        &self.object_meta.location
40    }
41}
42
43impl From<ObjectMeta> for FileMeta {
44    fn from(object_meta: ObjectMeta) -> Self {
45        Self {
46            object_meta,
47            range: None,
48            extensions: None,
49            metadata_size_hint: None,
50        }
51    }
52}