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

Minor add more docs to equivalence class code #6461

Merged
merged 1 commit into from
May 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions datafusion/physical-expr/src/equivalence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ use std::collections::{HashMap, HashSet};
use std::hash::Hash;
use std::sync::Arc;

/// Equivalence Properties is a vec of EquivalentClass.
/// Represents a collection of [`EquivalentClass`] (equivalences
/// between columns in relations)
///
/// This is used to represent both:
///
/// 1. Equality conditions (like `A=B`), when `T` = [`Column`]
/// 2. Ordering (like `A ASC = B ASC`), when `T` = [`OrderedColumn`]
#[derive(Debug, Clone)]
pub struct EquivalenceProperties<T = Column> {
classes: Vec<EquivalentClass<T>>,
Expand All @@ -40,6 +46,7 @@ impl<T: Eq + Hash + Clone> EquivalenceProperties<T> {
}
}

/// return the set of equivalences
pub fn classes(&self) -> &[EquivalentClass<T>] {
&self.classes
}
Expand All @@ -48,6 +55,7 @@ impl<T: Eq + Hash + Clone> EquivalenceProperties<T> {
self.schema.clone()
}

/// Add the [`EquivalentClass`] from `iter` to this list
pub fn extend<I: IntoIterator<Item = EquivalentClass<T>>>(&mut self, iter: I) {
for ec in iter {
self.classes.push(ec)
Expand Down Expand Up @@ -187,7 +195,9 @@ impl<T: Eq + Hash + Clone> EquivalentClass<T> {
}
}

/// This object represents a [`Column`] with a definite ordering.
/// This object represents a [`Column`] with a definite ordering, for
/// example `A ASC` and is used to represent equivalent orderings in
/// the optimizer.
#[derive(Debug, Hash, PartialEq, Eq, Clone)]
pub struct OrderedColumn {
pub col: Column,
Expand Down