Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primitive stats #66

Merged
merged 7 commits into from
Mar 5, 2024
Merged

Primitive stats #66

merged 7 commits into from
Mar 5, 2024

Conversation

gatesn
Copy link
Contributor

@gatesn gatesn commented Mar 5, 2024

Fixes #58
Closes #53

@gatesn gatesn requested a review from robert3005 March 5, 2024 11:12
@gatesn gatesn enabled auto-merge (squash) March 5, 2024 11:33
Comment on lines +47 to +79
let first_non_null = self
.1
.iter()
.enumerate()
.skip_while(|(_, valid)| !*valid)
.map(|(idx, _)| values[idx])
.next();

if first_non_null.is_none() {
return Ok(StatsSet::from(HashMap::from([
(Stat::Min, NullableScalar::None(T::PTYPE.into()).boxed()),
(Stat::Max, NullableScalar::None(T::PTYPE.into()).boxed()),
(Stat::IsConstant, true.into()),
(Stat::IsSorted, true.into()),
(Stat::IsStrictSorted, true.into()),
(Stat::RunCount, 1.into()),
(Stat::NullCount, 1.into()),
(
Stat::BitWidthFreq,
ListScalarVec(vec![0; size_of::<T>() * 8 + 1]).into(),
),
])));
}
};

let mut stats = StatsAccumulator::new(first_non_null.unwrap());
values
.iter()
.zip(self.1.iter())
.skip(1)
.map(|(next, valid)| valid.then_some(*next))
.for_each(|next| stats.nullable_next(next));
Ok(stats.into_set())
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a way to make this nicer but can leave for later

@gatesn gatesn merged commit db705e1 into develop Mar 5, 2024
2 checks passed
@gatesn gatesn deleted the ngates/primitive-stats branch March 5, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Primitive stats to respect validity
2 participants