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

Three way merge #134

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
implemented 3-way-merge
  • Loading branch information
likelion committed May 17, 2023
commit b8d35e591519ebd7334c4590b8258410a17799f0
45 changes: 26 additions & 19 deletions src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,29 +232,36 @@ impl StoreLayerBuilder {
others: Vec<&StoreLayer>,
merge_base: &StoreLayer,
) -> Result<(), io::Error> {
println!("{:?}", others);
println!("{:?}", merge_base);
rayon::join(
|| {
merge_base.triples().par_bridge().for_each(|b| {
if let Some(t) = merge_base.id_triple_to_string(&b) {
if others
.iter()
.par_bridge()
.any(|o| !o.value_triple_exists(&t))
{
self.remove_value_triple(t).unwrap();
}
}
});
},
|| {
others.iter().par_bridge().for_each(|os| {
os.triples().par_bridge().for_each(|o| {
if let Some(t) = os.id_triple_to_string(&o) {
if !merge_base.value_triple_exists(&t) {
self.add_value_triple(t).unwrap();
}
}
})
})
},
);
Ok(())
}
}

// TODO: remove later
impl core::fmt::Debug for StoreLayer {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("StoreLayer")
.field("layer", &name_to_string(self.layer.name()))
.finish()
}
}

pub fn name_to_string(name: [u32; 5]) -> String {
format!(
"{:08x}{:08x}{:08x}{:08x}{:08x}",
name[0], name[1], name[2], name[3], name[4]
)
}
// TODO: end of remove

/// A layer that keeps track of the store it came out of, allowing the creation of a layer builder on top of this layer.
///
/// This type of layer supports querying what was added and what was
Expand Down