Merge pull request #254 from influxdata/cn/further-improvement

refactor: Improve InputPath to InputReader conversion
pull/24376/head
Carol (Nichols || Goulding) 2020-07-22 10:31:10 -04:00 committed by GitHub
commit c7380dbe79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -328,7 +328,10 @@ impl InputPath {
Ok(Self { files })
}
pub fn files(&self) -> &[PathBuf] {
&self.files
pub fn input_readers(&self) -> impl Iterator<Item = Result<InputReader>> + '_ {
self.files
.iter()
.rev()
.map(|p| InputReader::new(&p.to_string_lossy()))
}
}

View File

@ -49,12 +49,7 @@ pub async fn stats(config: &StatsConfig) -> Result<()> {
let mut builder = FileSetStatsBuilder::default();
for input_reader in input_path
.files()
.iter()
.rev()
.map(|p| InputReader::new(&p.to_string_lossy()))
{
for input_reader in input_path.input_readers() {
let input_reader = input_reader.context(OpenInput)?;
let file_stats = stats_for_file(config, input_reader).await?;