MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / reduce

Method reduce

src/transform/src/analysis.rs:1805–1823  ·  view source on GitHub ↗
(
            &self,
            group_key: &Vec<MirScalarExpr>,
            expected_group_size: &Option<u64>,
            input: CardinalityEstimate,
        )

Source from the content-addressed store, hash-verified

1803 }
1804
1805 fn reduce(
1806 &self,
1807 group_key: &Vec<MirScalarExpr>,
1808 expected_group_size: &Option<u64>,
1809 input: CardinalityEstimate,
1810 ) -> CardinalityEstimate {
1811 // TODO(mgree): if no `group_key` is present, we can do way better
1812
1813 if let Some(expected_group_size) = expected_group_size {
1814 // if expected group size is 0, treat it as 1 (to avoid DBZ/+inf estimates)
1815 let group_size = u64::max(*expected_group_size, 1);
1816 input / f64::cast_lossy(group_size)
1817 } else if group_key.is_empty() {
1818 CardinalityEstimate::from(1.0)
1819 } else {
1820 // in the worst case, every row is its own group
1821 input
1822 }
1823 }
1824
1825 fn topk(
1826 &self,

Callers 9

applyMethod · 0.45
deriveMethod · 0.45
actionMethod · 0.45
optimizeFunction · 0.45
expandMethod · 0.45
minimize_onceMethod · 0.45

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected