refactor: Minor cleanup of retention predicate code (#6211)
* refactor: Minor cleanup of retention predicate code * fix: use cowpull/24376/head
parent
dd1755b23a
commit
f89d542715
|
@ -19,6 +19,7 @@ use predicate::Predicate;
|
||||||
use schema::Schema;
|
use schema::Schema;
|
||||||
use sharder::JumpHash;
|
use sharder::JumpHash;
|
||||||
use snafu::{ResultExt, Snafu};
|
use snafu::{ResultExt, Snafu};
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -234,8 +235,7 @@ impl QuerierTable {
|
||||||
"Fetching all chunks"
|
"Fetching all chunks"
|
||||||
);
|
);
|
||||||
|
|
||||||
let (predicate_with_retention, retention_delete_pred) =
|
let (predicate, retention_delete_pred) = match self.namespace_retention_period {
|
||||||
match self.namespace_retention_period {
|
|
||||||
// The retention is not fininte, add predicate to filter out data outside retention period
|
// The retention is not fininte, add predicate to filter out data outside retention period
|
||||||
Some(retention_period) => {
|
Some(retention_period) => {
|
||||||
let retention_time_ns = self
|
let retention_time_ns = self
|
||||||
|
@ -247,7 +247,7 @@ impl QuerierTable {
|
||||||
- retention_period.as_nanos() as i64;
|
- retention_period.as_nanos() as i64;
|
||||||
|
|
||||||
// Add predicate to only keep chunks inside the retention period: time >= retention_period
|
// Add predicate to only keep chunks inside the retention period: time >= retention_period
|
||||||
let predicate = Some(predicate.clone().with_retention(retention_time_ns));
|
let predicate = predicate.clone().with_retention(retention_time_ns);
|
||||||
|
|
||||||
// Expression used to add to delete predicate to delete data older than retention period
|
// Expression used to add to delete predicate to delete data older than retention period
|
||||||
// time < retention_time
|
// time < retention_time
|
||||||
|
@ -255,15 +255,10 @@ impl QuerierTable {
|
||||||
retention_time_ns,
|
retention_time_ns,
|
||||||
));
|
));
|
||||||
|
|
||||||
(predicate, retention_delete_pred)
|
(Cow::Owned(predicate), retention_delete_pred)
|
||||||
}
|
}
|
||||||
// inifite retention, no need to add predicate
|
// inifite retention, no need to add predicate
|
||||||
None => (None, None),
|
None => (Cow::Borrowed(predicate), None),
|
||||||
};
|
|
||||||
let predicate = if predicate_with_retention.is_some() {
|
|
||||||
predicate_with_retention.as_ref().unwrap()
|
|
||||||
} else {
|
|
||||||
predicate
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let catalog_cache = self.chunk_adapter.catalog_cache();
|
let catalog_cache = self.chunk_adapter.catalog_cache();
|
||||||
|
@ -272,7 +267,7 @@ impl QuerierTable {
|
||||||
// contents at the same time to pre-warm cache
|
// contents at the same time to pre-warm cache
|
||||||
let (partitions, _parquet_files, _tombstones) = join!(
|
let (partitions, _parquet_files, _tombstones) = join!(
|
||||||
self.ingester_partitions(
|
self.ingester_partitions(
|
||||||
predicate,
|
&predicate,
|
||||||
span_recorder.child_span("ingester partitions"),
|
span_recorder.child_span("ingester partitions"),
|
||||||
projection
|
projection
|
||||||
),
|
),
|
||||||
|
@ -365,7 +360,7 @@ impl QuerierTable {
|
||||||
let keeps = match prune_summaries(
|
let keeps = match prune_summaries(
|
||||||
Arc::clone(&cached_table.schema),
|
Arc::clone(&cached_table.schema),
|
||||||
&basic_summaries,
|
&basic_summaries,
|
||||||
predicate,
|
&predicate,
|
||||||
) {
|
) {
|
||||||
Ok(keeps) => keeps,
|
Ok(keeps) => keeps,
|
||||||
Err(reason) => {
|
Err(reason) => {
|
||||||
|
@ -426,7 +421,7 @@ impl QuerierTable {
|
||||||
self.table_name(),
|
self.table_name(),
|
||||||
Arc::clone(&self.schema),
|
Arc::clone(&self.schema),
|
||||||
chunks,
|
chunks,
|
||||||
predicate,
|
&predicate,
|
||||||
)
|
)
|
||||||
.context(ChunkPruningSnafu)?;
|
.context(ChunkPruningSnafu)?;
|
||||||
debug!(%predicate, num_initial_chunks, num_final_chunks=chunks.len(), "pruned with pushed down predicates");
|
debug!(%predicate, num_initial_chunks, num_final_chunks=chunks.len(), "pruned with pushed down predicates");
|
||||||
|
|
Loading…
Reference in New Issue