From 0b316cbabab0e98d973f66ab85ca9af3ecb673cc Mon Sep 17 00:00:00 2001 From: Yuchen Liang Date: Tue, 20 Feb 2024 15:06:02 -0500 Subject: [PATCH] format Signed-off-by: Yuchen Liang --- optd-core/src/cascades/memo.rs | 15 ++++++++++++--- optd-core/src/cascades/optimizer.rs | 6 +++++- optd-core/src/rel_node.rs | 7 +++++-- optd-datafusion-bridge/src/lib.rs | 2 +- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/optd-core/src/cascades/memo.rs b/optd-core/src/cascades/memo.rs index 2309d21a..e96fd743 100644 --- a/optd-core/src/cascades/memo.rs +++ b/optd-core/src/cascades/memo.rs @@ -11,7 +11,9 @@ use std::any::Any; use crate::{ cost::Cost, property::PropertyBuilderAny, - rel_node::{RelNode, RelNodeMeta, RelNodeMetaMap, RelNodeRef, RelNodeRefPtr, RelNodeTyp, Value}, + rel_node::{ + RelNode, RelNodeMeta, RelNodeMetaMap, RelNodeRef, RelNodeRefPtr, RelNodeTyp, Value, + }, }; use super::optimizer::{ExprId, GroupId}; @@ -441,7 +443,11 @@ impl Memo { } /// Gets the best group binding with metadata collected. - pub fn get_best_group_binding_with_meta(&self, group_id: GroupId, meta: &mut RelNodeMetaMap) -> Result> { + pub fn get_best_group_binding_with_meta( + &self, + group_id: GroupId, + meta: &mut RelNodeMetaMap, + ) -> Result> { let info = self.get_group_info(group_id); if let Some(winner) = info.winner { if !winner.impossible { @@ -450,7 +456,10 @@ impl Memo { let mut children = Vec::with_capacity(expr.children.len()); for child in &expr.children { children.push(self.get_best_group_binding_with_meta(*child, meta)?); - meta.insert(RelNodeRefPtr(children.last().unwrap()), RelNodeMeta::new(*child)); + meta.insert( + RelNodeRefPtr(children.last().unwrap()), + RelNodeMeta::new(*child), + ); } let node = Arc::new(RelNode { typ: expr.typ.clone(), diff --git a/optd-core/src/cascades/optimizer.rs b/optd-core/src/cascades/optimizer.rs index ff69ba63..e8efe2f6 100644 --- a/optd-core/src/cascades/optimizer.rs +++ b/optd-core/src/cascades/optimizer.rs @@ -209,7 +209,11 @@ impl CascadesOptimizer { Ok(group_id) } - pub fn step_get_optimize_rel_with_meta(&self, group_id: GroupId, meta: &mut RelNodeMetaMap) -> Result> { + pub fn step_get_optimize_rel_with_meta( + &self, + group_id: GroupId, + meta: &mut RelNodeMetaMap, + ) -> Result> { let rel = self.memo.get_best_group_binding_with_meta(group_id, meta)?; meta.insert(RelNodeRefPtr(&rel), RelNodeMeta::new(group_id)); Ok(rel) diff --git a/optd-core/src/rel_node.rs b/optd-core/src/rel_node.rs index a07d967a..2e5929ec 100644 --- a/optd-core/src/rel_node.rs +++ b/optd-core/src/rel_node.rs @@ -2,7 +2,10 @@ //! the internal representation of the plan nodes. use std::{ - collections::HashMap, fmt::{Debug, Display}, hash::Hash, sync::Arc + collections::HashMap, + fmt::{Debug, Display}, + hash::Hash, + sync::Arc, }; use ordered_float::OrderedFloat; @@ -203,7 +206,7 @@ impl RelNodeMeta { } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct RelNodeRefPtr(pub * const RelNodeRef); +pub struct RelNodeRefPtr(pub *const RelNodeRef); unsafe impl Send for RelNodeRefPtr {} diff --git a/optd-datafusion-bridge/src/lib.rs b/optd-datafusion-bridge/src/lib.rs index 09db0f3e..91066f3f 100644 --- a/optd-datafusion-bridge/src/lib.rs +++ b/optd-datafusion-bridge/src/lib.rs @@ -230,7 +230,7 @@ impl OptdQueryPlanner { let mut optimizer = self.optimizer.lock().unwrap().take().unwrap(); let (group_id, optimized_rel, meta) = optimizer.optimize(optd_rel)?; - meta.iter().for_each(|(k,v)| { + meta.iter().for_each(|(k, v)| { println!("(rel@{:?}, group_id={:?})", k, v); });