refactor: derive ParquetFilePath from IoxMetadata

Allow directly converting an IoxMetadata to a ParquetFilePath.
pull/24376/head
Dom Dwyer 2022-05-20 12:22:09 +01:00
parent b9a745d42d
commit 302301659e
2 changed files with 13 additions and 8 deletions

View File

@ -72,6 +72,18 @@ impl From<&Self> for ParquetFilePath {
}
}
impl From<&crate::metadata::IoxMetadata> for ParquetFilePath {
fn from(m: &crate::metadata::IoxMetadata) -> Self {
Self {
namespace_id: m.namespace_id,
table_id: m.table_id,
sequencer_id: m.sequencer_id,
partition_id: m.partition_id,
object_store_id: m.object_store_id,
}
}
}
#[cfg(test)]
mod tests {
use super::*;

View File

@ -117,14 +117,7 @@ impl ParquetStorage {
IoxParquetMetaData::try_from(parquet_file_meta).map_err(UploadError::Metadata)?;
// Derive the correct object store path from the metadata.
let path = ParquetFilePath::new(
meta.namespace_id,
meta.table_id,
meta.sequencer_id,
meta.partition_id,
meta.object_store_id,
)
.object_store_path();
let path = ParquetFilePath::from(meta).object_store_path();
let file_size = data.len();
self.object_store.put(&path, Bytes::from(data)).await?;