Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchuyaya committed Jan 7, 2025
1 parent 237ea2e commit 06844f6
Showing 1 changed file with 145 additions and 145 deletions.
290 changes: 145 additions & 145 deletions hydro_lang/src/rewrites/persist_pullup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,174 +16,174 @@ fn persist_pullup_node(
persist_pulled_tees: &mut HashSet<*const RefCell<HydroNode>>,
) {
*node = match_box::match_box! {
match std::mem::replace(node, HydroNode::Placeholder) {
HydroNode::Unpersist { inner: mb!(* HydroNode::Persist { inner: mb!(* behind_persist), .. }), .. } => behind_persist,

HydroNode::Delta { inner: mb!(* HydroNode::Persist { inner: mb!(* behind_persist), .. }), .. } => behind_persist,

// TODO: Figure out if persist needs to copy its metadata or can just use original metadata here. If it can just use original, figure out where that is
HydroNode::Tee { inner, metadata } => {
if persist_pulled_tees.contains(&(inner.0.as_ref() as *const RefCell<HydroNode>)) {
HydroNode::Persist {
inner: Box::new(HydroNode::Tee {
inner: TeeNode(inner.0.clone()),
metadata: metadata.clone(),
}),
metadata: copy_metadata_without_id(&metadata),
}
} else if matches!(*inner.0.borrow(), HydroNode::Persist { .. }) {
persist_pulled_tees.insert(inner.0.as_ref() as *const RefCell<HydroNode>);
if let HydroNode::Persist { inner: behind_persist, .. } =
inner.0.replace(HydroNode::Placeholder)
{
*inner.0.borrow_mut() = *behind_persist;
} else {
unreachable!()
}

HydroNode::Persist {
inner: Box::new(HydroNode::Tee {
inner: TeeNode(inner.0.clone()),
metadata: metadata.clone(),
}),
metadata: copy_metadata_without_id(&metadata),
}
match std::mem::replace(node, HydroNode::Placeholder) {
HydroNode::Unpersist { inner: mb!(* HydroNode::Persist { inner: mb!(* behind_persist), .. }), .. } => behind_persist,

HydroNode::Delta { inner: mb!(* HydroNode::Persist { inner: mb!(* behind_persist), .. }), .. } => behind_persist,

// TODO: Figure out if persist needs to copy its metadata or can just use original metadata here. If it can just use original, figure out where that is
HydroNode::Tee { inner, metadata } => {
if persist_pulled_tees.contains(&(inner.0.as_ref() as *const RefCell<HydroNode>)) {
HydroNode::Persist {
inner: Box::new(HydroNode::Tee {
inner: TeeNode(inner.0.clone()),
metadata: metadata.clone(),
}),
metadata: copy_metadata_without_id(&metadata),
}
} else if matches!(*inner.0.borrow(), HydroNode::Persist { .. }) {
persist_pulled_tees.insert(inner.0.as_ref() as *const RefCell<HydroNode>);
if let HydroNode::Persist { inner: behind_persist, .. } =
inner.0.replace(HydroNode::Placeholder)
{
*inner.0.borrow_mut() = *behind_persist;
} else {
HydroNode::Tee { inner, metadata }
unreachable!()
}

HydroNode::Persist {
inner: Box::new(HydroNode::Tee {
inner: TeeNode(inner.0.clone()),
metadata: metadata.clone(),
}),
metadata: copy_metadata_without_id(&metadata),
}
} else {
HydroNode::Tee { inner, metadata }
}
}

HydroNode::Map {
HydroNode::Map {
f,
input: mb!(* HydroNode::Persist { inner: behind_persist, .. }),
metadata,
} => HydroNode::Persist {
inner: Box::new(HydroNode::Map {
f,
input: mb!(* HydroNode::Persist { inner: behind_persist, .. }),
metadata,
} => HydroNode::Persist {
inner: Box::new(HydroNode::Map {
f,
input: behind_persist,
metadata: metadata.clone(),
}),
metadata: copy_metadata_without_id(&metadata),
},

HydroNode::FilterMap {
input: behind_persist,
metadata: metadata.clone(),
}),
metadata: copy_metadata_without_id(&metadata),
},

HydroNode::FilterMap {
f,
input: mb!(* HydroNode::Persist { inner: behind_persist, .. }),
metadata,
} => HydroNode::Persist {
inner: Box::new(HydroNode::FilterMap {
f,
input: mb!(* HydroNode::Persist { inner: behind_persist, .. }),
metadata,
} => HydroNode::Persist {
inner: Box::new(HydroNode::FilterMap {
f,
input: behind_persist,
metadata: metadata.clone(),
}),
metadata: copy_metadata_without_id(&metadata)
},

HydroNode::FlatMap {
input: behind_persist,
metadata: metadata.clone(),
}),
metadata: copy_metadata_without_id(&metadata)
},

HydroNode::FlatMap {
f,
input: mb!(* HydroNode::Persist { inner: behind_persist, .. }),
metadata,
} => HydroNode::Persist {
inner: Box::new(HydroNode::FlatMap {
f,
input: mb!(* HydroNode::Persist { inner: behind_persist, .. }),
metadata,
} => HydroNode::Persist {
inner: Box::new(HydroNode::FlatMap {
f,
input: behind_persist,
metadata: metadata.clone(),
}),
metadata: copy_metadata_without_id(&metadata)
},

HydroNode::Filter {
input: behind_persist,
metadata: metadata.clone(),
}),
metadata: copy_metadata_without_id(&metadata)
},

HydroNode::Filter {
f,
input: mb!(* HydroNode::Persist { inner: behind_persist, .. }),
metadata,
} => HydroNode::Persist {
inner: Box::new(HydroNode::Filter {
f,
input: mb!(* HydroNode::Persist { inner: behind_persist, .. }),
metadata,
} => HydroNode::Persist {
inner: Box::new(HydroNode::Filter {
f,
input: behind_persist,
metadata: metadata.clone(),
}),
metadata: copy_metadata_without_id(&metadata)
},

HydroNode::Network {
input: behind_persist,
metadata: metadata.clone(),
}),
metadata: copy_metadata_without_id(&metadata)
},

HydroNode::Network {
from_location,
from_key,
to_location,
to_key,
serialize_fn,
instantiate_fn,
deserialize_fn,
input: mb!(* HydroNode::Persist { inner: behind_persist, .. }),
metadata,
} => HydroNode::Persist {
inner: Box::new(HydroNode::Network {
from_location,
from_key,
to_location,
to_key,
serialize_fn,
instantiate_fn,
deserialize_fn,
input: mb!(* HydroNode::Persist { inner: behind_persist, .. }),
metadata,
} => HydroNode::Persist {
inner: Box::new(HydroNode::Network {
from_location,
from_key,
to_location,
to_key,
serialize_fn,
instantiate_fn,
deserialize_fn,
input: behind_persist,
input: behind_persist,
metadata: metadata.clone()
}),
metadata: copy_metadata_without_id(&metadata),
},

HydroNode::Chain {
first: mb!(* HydroNode::Persist { inner: first, metadata: persist_metadata }),
second: mb!(* HydroNode::Persist { inner: second, .. }),
metadata
} => HydroNode::Persist {
inner: Box::new(HydroNode::Chain { first, second, metadata }),
metadata: persist_metadata
},

HydroNode::CrossProduct {
left: mb!(* HydroNode::Persist { inner: left, metadata: left_metadata }),
right: mb!(* HydroNode::Persist { inner: right, metadata: right_metadata }),
metadata
} => HydroNode::Persist {
inner: Box::new(HydroNode::Delta {
inner: Box::new(HydroNode::CrossProduct {
left: Box::new(HydroNode::Persist { inner: left, metadata: left_metadata }),
right: Box::new(HydroNode::Persist { inner: right, metadata: right_metadata }),
metadata: metadata.clone()
}),
metadata: copy_metadata_without_id(&metadata),
},

HydroNode::Chain {
first: mb!(* HydroNode::Persist { inner: first, metadata: persist_metadata }),
second: mb!(* HydroNode::Persist { inner: second, .. }),
metadata
} => HydroNode::Persist {
inner: Box::new(HydroNode::Chain { first, second, metadata }),
metadata: persist_metadata
},

HydroNode::CrossProduct {
left: mb!(* HydroNode::Persist { inner: left, metadata: left_metadata }),
right: mb!(* HydroNode::Persist { inner: right, metadata: right_metadata }),
metadata
} => HydroNode::Persist {
inner: Box::new(HydroNode::Delta {
inner: Box::new(HydroNode::CrossProduct {
left: Box::new(HydroNode::Persist { inner: left, metadata: left_metadata }),
right: Box::new(HydroNode::Persist { inner: right, metadata: right_metadata }),
metadata: metadata.clone()
}),
metadata: copy_metadata_without_id(&metadata),
}),
metadata: copy_metadata_without_id(&metadata),
},
HydroNode::Join {
left: mb!(* HydroNode::Persist { inner: left, metadata: left_metadata }),
right: mb!(* HydroNode::Persist { inner: right, metadata: right_metadata }),
metadata
} => HydroNode::Persist {
inner: Box::new(HydroNode::Delta {
inner: Box::new(HydroNode::Join {
left: Box::new(HydroNode::Persist { inner: left, metadata: left_metadata }),
right: Box::new(HydroNode::Persist { inner: right, metadata: right_metadata }),
metadata: metadata.clone()
}),
metadata: copy_metadata_without_id(&metadata),
},
HydroNode::Join {
left: mb!(* HydroNode::Persist { inner: left, metadata: left_metadata }),
right: mb!(* HydroNode::Persist { inner: right, metadata: right_metadata }),
metadata
} => HydroNode::Persist {
inner: Box::new(HydroNode::Delta {
inner: Box::new(HydroNode::Join {
left: Box::new(HydroNode::Persist { inner: left, metadata: left_metadata }),
right: Box::new(HydroNode::Persist { inner: right, metadata: right_metadata }),
metadata: metadata.clone()
}),
metadata: copy_metadata_without_id(&metadata),
}),
metadata: copy_metadata_without_id(&metadata),
},

HydroNode::Unique { input: mb!(* HydroNode::Persist {inner, metadata: persist_metadata } ), metadata } => HydroNode::Persist {
inner: Box::new(HydroNode::Delta {
inner: Box::new(HydroNode::Unique {
input: Box::new(HydroNode::Persist { inner, metadata: persist_metadata }),
metadata: metadata.clone()
}),
metadata: copy_metadata_without_id(&metadata),
},
}),
metadata: copy_metadata_without_id(&metadata)
},

HydroNode::Unique { input: mb!(* HydroNode::Persist {inner, metadata: persist_metadata } ), metadata } => HydroNode::Persist {
inner: Box::new(HydroNode::Delta {
inner: Box::new(HydroNode::Unique {
input: Box::new(HydroNode::Persist { inner, metadata: persist_metadata }),
metadata: metadata.clone()
}),
metadata: copy_metadata_without_id(&metadata),
}),
metadata: copy_metadata_without_id(&metadata)
},

node => node,
}
};
node => node,
}
};
}

pub fn persist_pullup(ir: Vec<HydroLeaf>) -> Vec<HydroLeaf> {
Expand Down

0 comments on commit 06844f6

Please sign in to comment.