From db7e6335ca2a416cc3120f87ce1441bd4f60b03f Mon Sep 17 00:00:00 2001 From: Marko Mikulicic Date: Fri, 27 Jan 2023 18:16:54 +0100 Subject: [PATCH] feat(ingester2): New objecstore paths will have no shard id (#6735) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- parquet_file/src/lib.rs | 43 +++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/parquet_file/src/lib.rs b/parquet_file/src/lib.rs index ef37c9d1f1..1fe4daba91 100644 --- a/parquet_file/src/lib.rs +++ b/parquet_file/src/lib.rs @@ -24,6 +24,9 @@ use data_types::{NamespaceId, ParquetFile, ParquetFileParams, PartitionId, Shard use object_store::path::Path; use uuid::Uuid; +// Ingester2 creates partitions in this shard. +const TRANSITION_SHARD_ID: ShardId = ShardId::new(1234); + /// Location of a Parquet file within a namespace's object store. /// The exact format is an implementation detail and is subject to change. #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd)] @@ -62,14 +65,22 @@ impl ParquetFilePath { partition_id, object_store_id, } = self; - - Path::from_iter([ - namespace_id.to_string().as_str(), - table_id.to_string().as_str(), - shard_id.to_string().as_str(), - partition_id.to_string().as_str(), - &format!("{}.parquet", object_store_id), - ]) + if shard_id == &TRANSITION_SHARD_ID { + Path::from_iter([ + namespace_id.to_string().as_str(), + table_id.to_string().as_str(), + partition_id.to_string().as_str(), + &format!("{}.parquet", object_store_id), + ]) + } else { + Path::from_iter([ + namespace_id.to_string().as_str(), + table_id.to_string().as_str(), + shard_id.to_string().as_str(), + partition_id.to_string().as_str(), + &format!("{}.parquet", object_store_id), + ]) + } } /// Get object store ID. @@ -147,4 +158,20 @@ mod tests { "1/2/3/4/00000000-0000-0000-0000-000000000000.parquet".to_string(), ); } + + #[test] + fn parquet_file_without_shard_id() { + let pfp = ParquetFilePath::new( + NamespaceId::new(1), + TableId::new(2), + TRANSITION_SHARD_ID, + PartitionId::new(4), + Uuid::nil(), + ); + let path = pfp.object_store_path(); + assert_eq!( + path.to_string(), + "1/2/4/00000000-0000-0000-0000-000000000000.parquet".to_string(), + ); + } }