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
25#[derive(Debug, Clone)]
26pub struct FileMeta {
27    /// Path for the file (e.g. URL, filesystem path, etc)
28    pub object_meta: ObjectMeta,
29    /// An optional file range for a more fine-grained parallel execution
30    pub range: Option<FileRange>,
31    /// An optional field for user defined per object metadata
32    pub extensions: Option<Arc<dyn std::any::Any + Send + Sync>>,
33    /// Size hint for the metadata of this file
34    pub metadata_size_hint: Option<usize>,
35}
36
37impl FileMeta {
38    /// The full path to the object
39    pub fn location(&self) -> &Path {
40        &self.object_meta.location
41    }
42}
43
44impl From<ObjectMeta> for FileMeta {
45    fn from(object_meta: ObjectMeta) -> Self {
46        Self {
47            object_meta,
48            range: None,
49            extensions: None,
50            metadata_size_hint: None,
51        }
52    }
53}