Skip to content

Commit

Permalink
Merge #696
Browse files Browse the repository at this point in the history
696: Add rollup functionality to frequency aggregates r=WireBaron a=WireBaron

This change implements adds in rollup functions for frequency aggregates.

Note that while the rollup of a set of frequency aggregates will not necessarily be identical to computing a single aggregate over the underlying data (may not have the exact same upper and lower bounds on frequency), the rollup maintains the same invariants and will be able to identify most common elements as long as the frequency is different enough.

Fixes #685 

Co-authored-by: Brian Rowe <brian@timescale.com>
  • Loading branch information
bors[bot] and Brian Rowe authored Feb 6, 2023
2 parents d3b1fe1 + a03dfce commit 0488e76
Show file tree
Hide file tree
Showing 3 changed files with 451 additions and 15 deletions.
8 changes: 8 additions & 0 deletions extension/src/aggregate_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ pub unsafe fn get_collation(fcinfo: pg_sys::FunctionCallInfo) -> Option<pg_sys::
}
}

pub fn get_collation_or_default(fcinfo: pg_sys::FunctionCallInfo) -> Option<pg_sys::Oid> {
if fcinfo.is_null() {
Some(100) // TODO: default OID, there should be a constant for this
} else {
unsafe { get_collation(fcinfo) }
}
}

pub unsafe fn in_aggregate_context<T, F: FnOnce() -> T>(
fcinfo: pg_sys::FunctionCallInfo,
f: F,
Expand Down
6 changes: 1 addition & 5 deletions extension/src/datum_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,7 @@ impl DatumHashBuilder {

impl Clone for DatumHashBuilder {
fn clone(&self) -> Self {
Self {
info: self.info,
type_id: self.type_id,
collation: self.collation,
}
unsafe { DatumHashBuilder::from_type_id(self.type_id, Some(self.collation)) }
}
}

Expand Down
Loading

0 comments on commit 0488e76

Please sign in to comment.