rdettai commented on a change in pull request #950: URL: https://github.com/apache/arrow-datafusion/pull/950#discussion_r697226770
########## File path: datafusion/src/datasource/object_store/mod.rs ########## @@ -0,0 +1,127 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Object Store abstracts access to an underlying file/object storage. + +pub mod local; + +use std::collections::HashMap; +use std::fmt::Debug; +use std::pin::Pin; +use std::sync::{Arc, RwLock}; + +use async_trait::async_trait; +use futures::{AsyncRead, Stream}; + +use local::LocalFileSystem; + +use crate::error::{DataFusionError, Result}; +use chrono::Utc; + +/// Object Reader for one file in a object store +#[async_trait] +pub trait ObjectReader { + /// Get reader for a part [start, start + length] in the file asynchronously + async fn get_reader(&self, start: u64, length: usize) -> Result<Arc<dyn AsyncRead>>; + + /// Get length for the file asynchronously + async fn length(&self) -> Result<u64>; +} + +/// File meta we got from object store +pub struct FileMeta { + /// Path of the file + pub path: String, + /// Last time the file was modified in UTC + pub last_modified: Option<chrono::DateTime<Utc>>, + /// File size in total + pub size: Option<u64>, Review comment: You are right that technically the S3 API says the `size` field is optional in the list response. I couldn't find why. It might make sense when the `Object` is a prefix and not an actual object (for exemple if you list the memsql-tpch-dataset bucket, you will get entries for `sf_100/`, `sf_100/customer/`...), but actually with Rusoto, even in that case the `size` field is set to `Some(0)` 🙃. My argument is that _we can expect from any system that provides the list of filenames to also reliably provide the file sizes_. With this assumption, avoiding an optional field helps simplifying consumers that do use that information. For instance for parquet you will need to read from the end. As the `ObjectReader` works using the (start, length) tuple, we critically need the length to get the end of the file. This means that if the `size` provided from the listing is optional, every implementation of `ObjectReader.length` will need to have a branch with the case where the size was provided, in which case it uses it directly, and another branch where it fetches the size from the store. I find this adds some complexity. For me the true question is whether the assumption _we can expect from any system that provides the list of filenames to also reliably provide the file sizes_ holds. I am pretty sure it does, but if you don't think so we can definitively pay the price of `Option<>` 😉 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org