From afaa954270b2360ce44fb25a478c04dbe409e035 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 17 Apr 2023 18:40:40 -0400 Subject: [PATCH] fix: Remove unused most_recent_n_in_shards function --- iox_catalog/src/interface.rs | 28 ---------------------------- iox_catalog/src/mem.rs | 16 ---------------- iox_catalog/src/metrics.rs | 1 - iox_catalog/src/postgres.rs | 15 --------------- iox_catalog/src/sqlite.rs | 18 ------------------ 5 files changed, 78 deletions(-) diff --git a/iox_catalog/src/interface.rs b/iox_catalog/src/interface.rs index 63ee00c05d..06e81d0556 100644 --- a/iox_catalog/src/interface.rs +++ b/iox_catalog/src/interface.rs @@ -536,13 +536,6 @@ pub trait PartitionRepo: Send + Sync { /// Return the N most recently created partitions. async fn most_recent_n(&mut self, n: usize) -> Result>; - /// Return the N most recently created partitions for the specified shards. - async fn most_recent_n_in_shards( - &mut self, - n: usize, - shards: &[ShardId], - ) -> Result>; - /// Select partition for cold/warm/hot compaction /// These are partitions with files created recently (aka created after the specified time_in_the_past) /// These files include all levels of compaction files @@ -2002,27 +1995,6 @@ pub(crate) mod test_helpers { .expect("should list most recent"); assert_eq!(recent.len(), 2); - let recent = repos - .partitions() - .most_recent_n_in_shards(10, &[shard.id, other_shard.id]) - .await - .expect("should list most recent"); - assert_eq!(recent.len(), 3); - - let recent = repos - .partitions() - .most_recent_n_in_shards(10, &[shard.id]) - .await - .expect("should list most recent"); - assert_eq!(recent.len(), 2); - - let recent2 = repos - .partitions() - .most_recent_n_in_shards(10, &[shard.id, ShardId::new(42)]) - .await - .expect("should list most recent"); - assert_eq!(recent, recent2); - repos .namespaces() .soft_delete("namespace_partition_test") diff --git a/iox_catalog/src/mem.rs b/iox_catalog/src/mem.rs index 29f87e54a2..03c1974013 100644 --- a/iox_catalog/src/mem.rs +++ b/iox_catalog/src/mem.rs @@ -904,22 +904,6 @@ impl PartitionRepo for MemTxn { Ok(stage.partitions.iter().rev().take(n).cloned().collect()) } - async fn most_recent_n_in_shards( - &mut self, - n: usize, - shards: &[ShardId], - ) -> Result> { - let stage = self.stage(); - Ok(stage - .partitions - .iter() - .rev() - .filter(|p| shards.contains(&p.shard_id)) - .take(n) - .cloned() - .collect()) - } - async fn partitions_with_recent_created_files( &mut self, time_in_the_past: Timestamp, diff --git a/iox_catalog/src/metrics.rs b/iox_catalog/src/metrics.rs index 74afc844fe..97ad9b2714 100644 --- a/iox_catalog/src/metrics.rs +++ b/iox_catalog/src/metrics.rs @@ -238,7 +238,6 @@ decorate!( "partition_list_skipped_compactions" = list_skipped_compactions(&mut self) -> Result>; "partition_delete_skipped_compactions" = delete_skipped_compactions(&mut self, partition_id: PartitionId) -> Result>; "partition_most_recent_n" = most_recent_n(&mut self, n: usize) -> Result>; - "partition_most_recent_n_in_shards" = most_recent_n_in_shards(&mut self, n: usize, shards: &[ShardId]) -> Result>; "partitions_with_recent_created_files" = partitions_with_recent_created_files(&mut self, time_in_the_past: Timestamp, max_num_partitions: usize) -> Result>; "partitions_new_file_between" = partitions_new_file_between(&mut self, minimum_time: Timestamp, maximum_time: Option) -> Result>; "get_in_skipped_compaction" = get_in_skipped_compaction(&mut self, partition_id: PartitionId) -> Result>; diff --git a/iox_catalog/src/postgres.rs b/iox_catalog/src/postgres.rs index e78e50e89f..ed30f81dc6 100644 --- a/iox_catalog/src/postgres.rs +++ b/iox_catalog/src/postgres.rs @@ -1436,21 +1436,6 @@ RETURNING * .map_err(|e| Error::SqlxError { source: e }) } - async fn most_recent_n_in_shards( - &mut self, - n: usize, - shards: &[ShardId], - ) -> Result> { - sqlx::query_as( - r#"SELECT * FROM partition WHERE shard_id IN (SELECT UNNEST($1)) ORDER BY id DESC LIMIT $2;"#, - ) - .bind(shards.iter().map(|v| v.get()).collect::>()) - .bind(n as i64) - .fetch_all(&mut self.inner) - .await - .map_err(|e| Error::SqlxError { source: e }) - } - async fn partitions_with_recent_created_files( &mut self, time_in_the_past: Timestamp, diff --git a/iox_catalog/src/sqlite.rs b/iox_catalog/src/sqlite.rs index f88461d4b3..7aa07847ab 100644 --- a/iox_catalog/src/sqlite.rs +++ b/iox_catalog/src/sqlite.rs @@ -1254,24 +1254,6 @@ RETURNING * .collect()) } - async fn most_recent_n_in_shards( - &mut self, - n: usize, - shards: &[ShardId], - ) -> Result> { - Ok(sqlx::query_as::<_, PartitionPod>( - r#"SELECT * FROM partition WHERE shard_id IN (SELECT value FROM json_each($1)) ORDER BY id DESC LIMIT $2;"#, - ) - .bind(&Json(shards.iter().map(|v| v.get()).collect::>())) - .bind(n as i64) - .fetch_all(self.inner.get_mut()) - .await - .map_err(|e| Error::SqlxError { source: e })? - .into_iter() - .map(Into::into) - .collect()) - } - async fn partitions_with_recent_created_files( &mut self, time_in_the_past: Timestamp,