Skip to content

Commit c9ae99d

Browse files
committed
Filter: all-included default scenario for filtering + simplify execution engine
1 parent 2f391c7 commit c9ae99d

File tree

6 files changed

+56
-17
lines changed

6 files changed

+56
-17
lines changed

backend/shared/src/binding_box/mod.rs

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub mod expand_step;
77
#[cfg(test)]
88
pub mod test;
99

10-
use std::{collections::HashSet, fs::File, io::BufWriter, time::Instant};
10+
use std::{collections::HashSet, env::remove_var, fs::File, io::BufWriter, time::Instant};
1111

1212
use chrono::DateTime;
1313
use itertools::Itertools;
@@ -215,17 +215,54 @@ pub fn filter_ocel_box_tree(tree: BindingBoxTree, ocel: &IndexLinkedOCEL) -> Opt
215215
if skipped_bindings {
216216
println!("Bindings were skipped!");
217217
}
218+
let assume_all_included = !tree.nodes.iter().any(|node| {
219+
let node_as_box = node.as_box().unwrap();
220+
node_as_box
221+
.ob_var_labels
222+
.iter()
223+
.any(|(_, l)| matches!(l, structs::FilterLabel::INCLUDED))
224+
|| node_as_box
225+
.ev_var_labels
226+
.iter()
227+
.any(|(_, l)| matches!(l, structs::FilterLabel::INCLUDED))
228+
});
218229
// Filter/Export
219230
let filter_now = Instant::now();
220-
let mut ob_included_indices: HashSet<ObjectIndex> = HashSet::new();
221-
let mut ev_included_indices: HashSet<EventIndex> = HashSet::new();
231+
let mut ob_included_indices: HashSet<ObjectIndex> = if assume_all_included {
232+
ocel.get_all_obs_ref().copied().collect()
233+
} else {
234+
HashSet::new()
235+
};
236+
let mut ev_included_indices: HashSet<EventIndex> = if assume_all_included {
237+
ocel.get_all_evs_ref().copied().collect()
238+
} else {
239+
HashSet::new()
240+
};
241+
222242
let mut ob_excluded_indices: HashSet<ObjectIndex> = HashSet::new();
223243
let mut ev_excluded_indices: HashSet<EventIndex> = HashSet::new();
224244

225-
let mut e2o_rels_included: HashSet<(EventIndex, ObjectIndex, Option<String>)> = HashSet::new();
245+
let mut e2o_rels_included: HashSet<(EventIndex, ObjectIndex, Option<String>)> =
246+
if assume_all_included {
247+
ocel.get_all_evs_ref()
248+
.map(|e| ocel.get_e2o(e).map(|r| (*e, *r.1, Some(r.0.to_string()))))
249+
.flatten()
250+
.collect()
251+
} else {
252+
HashSet::new()
253+
};
226254
let mut e2o_rels_excluded: HashSet<(EventIndex, ObjectIndex, Option<String>)> = HashSet::new();
227255

228-
let mut o2o_rels_included: HashSet<(ObjectIndex, ObjectIndex, Option<String>)> = HashSet::new();
256+
let mut o2o_rels_included: HashSet<(ObjectIndex, ObjectIndex, Option<String>)> =
257+
if assume_all_included {
258+
ocel.get_all_obs_ref()
259+
.map(|o| ocel.get_o2o(o).map(|r| (*o, *r.1, Some(r.0.to_string()))))
260+
.flatten()
261+
.collect()
262+
} else {
263+
HashSet::new()
264+
};
265+
229266
let mut o2o_rels_excluded: HashSet<(ObjectIndex, ObjectIndex, Option<String>)> = HashSet::new();
230267

231268
for (index, binding, _viol) in evaluation_results_flat {

backend/shared/src/binding_box/step_order.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn get_expected_relation_count(
1515
bbox: &BindingBox,
1616
parent_binding_opt: Option<&Binding>,
1717
ocel: &IndexLinkedOCEL,
18-
) -> Option<usize> {
18+
) -> Option<i32> {
1919
let mut bound_by_types = Vec::new();
2020
// First check if bound_by is already bound by parent
2121
if let Some(bound_by_index) = parent_binding_opt.and_then(|b| b.get_any_index(bound_by)) {
@@ -46,7 +46,7 @@ pub fn get_expected_relation_count(
4646
.collect(),
4747
}
4848
}
49-
let res = bound_by_types
49+
let res: usize = bound_by_types
5050
.into_iter()
5151
.map(|bound_by_type| {
5252
// Previously this was based on the average relations of an object/event
@@ -65,8 +65,8 @@ pub fn get_expected_relation_count(
6565
}
6666
})
6767
.sum();
68-
println!("{res} for {bound_by:?}");
69-
Some(res)
68+
// println!("{res} for {bound_by:?}");
69+
Some((res as i32))
7070
}
7171
impl BindingStep {
7272
/// Get a binding order from a binding box
@@ -253,10 +253,10 @@ impl BindingStep {
253253
.find(|(x, _q, _filter_index, _reversed)| x == var)
254254
.map(|t| (v, t))
255255
})
256-
.sorted_by_cached_key(|(bound_by_var, (_v, _q, _filter_index, _reversed))| {
257-
get_expected_relation_count(bound_by_var, bbox, parent_binding_opt, ocel)
258-
.unwrap_or(10)
259-
})
256+
// .sorted_by_cached_key(|(bound_by_var, (_v, _q, _filter_index, _reversed))| {
257+
// get_expected_relation_count(bound_by_var, bbox, parent_binding_opt, ocel)
258+
// .unwrap_or(10)
259+
// })
260260
.next()
261261
{
262262
// `var` can be bound based on `v`!

backend/shared/src/binding_box/structs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ impl BindingBoxTreeNode {
363363
// Evaluate Child
364364
tree.nodes[*c].evaluate(*c, b.clone(), tree, ocel);
365365
child_res.insert(c_name, violations);
366-
if children.len() * c_res.len() * expanded_len > 100_000_000 {
366+
if children.len() * c_res.len() * expanded_len > 150_000_000 {
367367
x.cancel();
368368
println!(
369369
"Too much too handle! {}*{}*{}={}",

frontend/src/components/binding-table/PaginatedBindingTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function DataTablePagination<TData, TValue>({
4949
initialState: {
5050
pagination: {
5151
pageIndex: 0,
52-
pageSize: 10,
52+
pageSize: 20,
5353
},
5454
},
5555
});
@@ -66,7 +66,7 @@ export function DataTablePagination<TData, TValue>({
6666
}, [initialMode]);
6767
return (
6868
<div className="w-full">
69-
<div className="rounded-md border w-full max-h-[70vh] overflow-auto">
69+
<div className="rounded-md border w-full max-h-[73vh] overflow-auto">
7070
<Table>
7171
<TableHeader>
7272
{table.getHeaderGroups().map((headerGroup) => (

frontend/src/routes/visual-editor/VisualEditor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,7 @@ export default function VisualEditor(props: VisualEditorProps) {
953953
error: "Evaluation failed",
954954
},
955955
);
956+
console.log(res.bindingsSkipped);
956957
if (res.bindingsSkipped) {
957958
toast.error(
958959
(x) => (

frontend/src/routes/visual-editor/helper/box/variable-names.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { VisualEditorContext } from "../VisualEditorContext";
33
import { MdEvent } from "react-icons/md";
44
import { LuBox } from "react-icons/lu";
55
import type { Variable } from "@/types/generated/Variable";
6+
import clsx from "clsx";
67

78
export function getEvVarName(eventVar: number) {
89
return function GetEvVarName() {
@@ -30,7 +31,7 @@ export function ObVarName({ obVar, disabledStyle }: { obVar: number, disabledSty
3031
const { getVarName } = useContext(VisualEditorContext);
3132
const varInfo = getVarName(obVar, "object");
3233
return (
33-
<span className="font-mono font-semibold" style={{ color: disabledStyle === true ? "darkgray" :varInfo.color }}>
34+
<span className={clsx("font-mono font-semibold", disabledStyle === true && "text-stone-400")} style={{ color: disabledStyle === true ? undefined : varInfo.color }}>
3435
<LuBox className="inline-block -mr-1.5" /> {varInfo.name}
3536
</span>
3637
);

0 commit comments

Comments
 (0)