diff --git a/trustfall_core/src/interpreter/execution.rs b/trustfall_core/src/interpreter/execution.rs index a5f43876..f3492732 100644 --- a/trustfall_core/src/interpreter/execution.rs +++ b/trustfall_core/src/interpreter/execution.rs @@ -317,10 +317,53 @@ fn get_max_fold_count_limit(carrier: &mut QueryCarrier, fold: &IRFold) -> Option result } +/// If this IRFold has a filter on the folded element count, and that filter imposes +/// a min size that can be statically determined, return that min size so it can +/// be used for further optimizations. Otherwise, return None. +fn get_min_fold_count_limit(carrier: &mut QueryCarrier, fold: &IRFold) -> Option { + let mut result: Option = None; + + let query_arguments = &carrier.query.as_ref().expect("query was not returned").arguments; + for post_fold_filter in fold.post_filters.iter() { + let next_limit = match post_fold_filter { + Operation::GreaterThanOrEqual( + FoldSpecificFieldKind::Count, + Argument::Variable(var_ref), + ) => { + let variable_value = + usize_from_field_value(&query_arguments[&var_ref.variable_name]) + .expect("for field value to be coercible to usize"); + Some(variable_value) + } + Operation::GreaterThan(FoldSpecificFieldKind::Count, Argument::Variable(var_ref)) => { + let variable_value = + usize_from_field_value(&query_arguments[&var_ref.variable_name]) + .expect("for field value to be coercible to usize"); + Some(variable_value.saturating_add(1)) + } + // If we don't know how many elements of the fold are required + // to satisfy this filter, fail early. + _ => return None, + }; + + match (result, next_limit) { + (None, _) => result = next_limit, + (Some(l), Some(r)) if l < r => result = next_limit, + _ => {} + } + } + + result +} + fn collect_fold_elements<'query, Vertex: Clone + Debug + 'query>( mut iterator: ContextIterator<'query, Vertex>, max_fold_count_limit: &Option, + min_fold_count_limit: &Option, ) -> Option>> { + // If we must collect the fold up to our upperbound of `max_fold_count_limit`, + // then we won't use our lowerbound of `min_fold_count_limit`, as by definition + // the upperbound will be larger than the lowerbound. if let Some(max_fold_count_limit) = max_fold_count_limit { // If this fold has more than `max_fold_count_limit` elements, // it will get filtered out by a post-fold filter. @@ -350,9 +393,16 @@ fn collect_fold_elements<'query, Vertex: Clone + Debug + 'query>( Some(fold_elements) } else { - // We weren't able to find any early-termination condition for materializing the fold, - // so materialize the whole thing and return it. - Some(iterator.collect()) + let collected = match min_fold_count_limit { + // Some queries may be able to be optimized by only partially expanding the fold, + // just enough to check any filters that may be applied to the fold count. + Some(min_fold_count_limit) => iterator.take(*min_fold_count_limit).collect(), + // We weren't able to find any early-termination condition for materializing the fold, + // so materialize the whole thing and return it. + _ => iterator.collect(), + }; + + Some(collected) } } @@ -443,6 +493,41 @@ fn compute_fold<'query, AdapterT: Adapter<'query> + 'query>( let fold_component = fold.component.clone(); let fold_eid = fold.eid; let max_fold_size = get_max_fold_count_limit(carrier, fold.as_ref()); + + // Queries that do not observe the fold count nor any fold contents may be able to + // be optimized by only partially expanding the fold, just enough to check any filters + // that may be applied to the fold count. + // + // For example, if `@filter(op: ">", value: ["$ten"])` is our only filter on the count + // of the fold, we can stop computing the rest of the fold after seeing we have 11 elements. + let min_fold_size = + if let Some(min_fold_size) = get_min_fold_count_limit(carrier, fold.as_ref()) { + let no_outputs_in_fold = fold.component.outputs.is_empty(); + let has_output_on_fold_count = + fold.fold_specific_outputs.values().any(|x| *x == FoldSpecificFieldKind::Count); + let has_tag_on_fold_count = parent_component.vertices.values().any(|vertex| { + vertex.filters.iter().any(|filter| { + let Some(Argument::Tag(FieldRef::FoldSpecificField(tagged_fold_count))) = + filter.right() + else { + return false; + }; + + tagged_fold_count.fold_root_vid == fold.to_vid + && tagged_fold_count.fold_eid == fold.eid + && tagged_fold_count.kind == FoldSpecificFieldKind::Count + }) + }); + + if no_outputs_in_fold && !has_output_on_fold_count && !has_tag_on_fold_count { + Some(min_fold_size) + } else { + None + } + } else { + None + }; + let moved_fold = fold.clone(); let folded_iterator = edge_iterator.filter_map(move |(mut context, neighbors)| { let imported_tags = context.imported_tags.clone(); @@ -466,7 +551,7 @@ fn compute_fold<'query, AdapterT: Adapter<'query> + 'query>( let fold_elements = if fold_exists { // N.B.: Note the `?` at the end here! // This lets us early-discard folds that failed a post-processing filter. - Some(collect_fold_elements(computed_iterator, &max_fold_size)?) + Some(collect_fold_elements(computed_iterator, &max_fold_size, &min_fold_size)?) } else { None }; diff --git a/trustfall_core/test_data/tests/valid_queries/fold_with_no_outputs.trace.ron b/trustfall_core/test_data/tests/valid_queries/fold_with_no_outputs.trace.ron index da959b02..2c56bda8 100644 --- a/trustfall_core/test_data/tests/valid_queries/fold_with_no_outputs.trace.ron +++ b/trustfall_core/test_data/tests/valid_queries/fold_with_no_outputs.trace.ron @@ -118,16 +118,6 @@ TestInterpreterOutputTrace( ), Opid(15): TraceOp( opid: Opid(15), - parent_opid: Some(Opid(12)), - content: YieldFrom(ResolveNeighborsInner(2, Prime(PrimeNumber(5)))), - ), - Opid(16): TraceOp( - opid: Opid(16), - parent_opid: Some(Opid(12)), - content: OutputIteratorExhausted, - ), - Opid(17): TraceOp( - opid: Opid(17), parent_opid: Some(Opid(4)), content: YieldInto(SerializableContext( active_vertex: Some(Composite(CompositeNumber(30, [ @@ -156,18 +146,12 @@ TestInterpreterOutputTrace( Vid(2): Some(Prime(PrimeNumber(3))), }, ), - SerializableContext( - active_vertex: Some(Prime(PrimeNumber(5))), - vertices: { - Vid(2): Some(Prime(PrimeNumber(5))), - }, - ), ]), }, )), ), - Opid(18): TraceOp( - opid: Opid(18), + Opid(16): TraceOp( + opid: Opid(16), parent_opid: Some(Opid(4)), content: YieldFrom(ResolveProperty(SerializableContext( active_vertex: Some(Composite(CompositeNumber(30, [ @@ -196,70 +180,64 @@ TestInterpreterOutputTrace( Vid(2): Some(Prime(PrimeNumber(3))), }, ), - SerializableContext( - active_vertex: Some(Prime(PrimeNumber(5))), - vertices: { - Vid(2): Some(Prime(PrimeNumber(5))), - }, - ), ]), }, ), Int64(30))), ), - Opid(19): TraceOp( - opid: Opid(19), + Opid(17): TraceOp( + opid: Opid(17), parent_opid: None, content: ProduceQueryResult({ "value": Int64(30), }), ), + Opid(18): TraceOp( + opid: Opid(18), + parent_opid: Some(Opid(4)), + content: AdvanceInputIterator, + ), + Opid(19): TraceOp( + opid: Opid(19), + parent_opid: Some(Opid(3)), + content: AdvanceInputIterator, + ), Opid(20): TraceOp( opid: Opid(20), - parent_opid: Some(Opid(4)), + parent_opid: Some(Opid(2)), content: AdvanceInputIterator, ), Opid(21): TraceOp( opid: Opid(21), - parent_opid: Some(Opid(3)), - content: AdvanceInputIterator, + parent_opid: Some(Opid(1)), + content: OutputIteratorExhausted, ), Opid(22): TraceOp( opid: Opid(22), parent_opid: Some(Opid(2)), - content: AdvanceInputIterator, + content: InputIteratorExhausted, ), Opid(23): TraceOp( opid: Opid(23), - parent_opid: Some(Opid(1)), + parent_opid: Some(Opid(2)), content: OutputIteratorExhausted, ), Opid(24): TraceOp( opid: Opid(24), - parent_opid: Some(Opid(2)), + parent_opid: Some(Opid(3)), content: InputIteratorExhausted, ), Opid(25): TraceOp( opid: Opid(25), - parent_opid: Some(Opid(2)), + parent_opid: Some(Opid(3)), content: OutputIteratorExhausted, ), Opid(26): TraceOp( opid: Opid(26), - parent_opid: Some(Opid(3)), + parent_opid: Some(Opid(4)), content: InputIteratorExhausted, ), Opid(27): TraceOp( opid: Opid(27), - parent_opid: Some(Opid(3)), - content: OutputIteratorExhausted, - ), - Opid(28): TraceOp( - opid: Opid(28), - parent_opid: Some(Opid(4)), - content: InputIteratorExhausted, - ), - Opid(29): TraceOp( - opid: Opid(29), parent_opid: Some(Opid(4)), content: OutputIteratorExhausted, ), diff --git a/trustfall_core/test_data/tests/valid_queries/fold_with_no_outputs_elided_braces.trace.ron b/trustfall_core/test_data/tests/valid_queries/fold_with_no_outputs_elided_braces.trace.ron index da959b02..2c56bda8 100644 --- a/trustfall_core/test_data/tests/valid_queries/fold_with_no_outputs_elided_braces.trace.ron +++ b/trustfall_core/test_data/tests/valid_queries/fold_with_no_outputs_elided_braces.trace.ron @@ -118,16 +118,6 @@ TestInterpreterOutputTrace( ), Opid(15): TraceOp( opid: Opid(15), - parent_opid: Some(Opid(12)), - content: YieldFrom(ResolveNeighborsInner(2, Prime(PrimeNumber(5)))), - ), - Opid(16): TraceOp( - opid: Opid(16), - parent_opid: Some(Opid(12)), - content: OutputIteratorExhausted, - ), - Opid(17): TraceOp( - opid: Opid(17), parent_opid: Some(Opid(4)), content: YieldInto(SerializableContext( active_vertex: Some(Composite(CompositeNumber(30, [ @@ -156,18 +146,12 @@ TestInterpreterOutputTrace( Vid(2): Some(Prime(PrimeNumber(3))), }, ), - SerializableContext( - active_vertex: Some(Prime(PrimeNumber(5))), - vertices: { - Vid(2): Some(Prime(PrimeNumber(5))), - }, - ), ]), }, )), ), - Opid(18): TraceOp( - opid: Opid(18), + Opid(16): TraceOp( + opid: Opid(16), parent_opid: Some(Opid(4)), content: YieldFrom(ResolveProperty(SerializableContext( active_vertex: Some(Composite(CompositeNumber(30, [ @@ -196,70 +180,64 @@ TestInterpreterOutputTrace( Vid(2): Some(Prime(PrimeNumber(3))), }, ), - SerializableContext( - active_vertex: Some(Prime(PrimeNumber(5))), - vertices: { - Vid(2): Some(Prime(PrimeNumber(5))), - }, - ), ]), }, ), Int64(30))), ), - Opid(19): TraceOp( - opid: Opid(19), + Opid(17): TraceOp( + opid: Opid(17), parent_opid: None, content: ProduceQueryResult({ "value": Int64(30), }), ), + Opid(18): TraceOp( + opid: Opid(18), + parent_opid: Some(Opid(4)), + content: AdvanceInputIterator, + ), + Opid(19): TraceOp( + opid: Opid(19), + parent_opid: Some(Opid(3)), + content: AdvanceInputIterator, + ), Opid(20): TraceOp( opid: Opid(20), - parent_opid: Some(Opid(4)), + parent_opid: Some(Opid(2)), content: AdvanceInputIterator, ), Opid(21): TraceOp( opid: Opid(21), - parent_opid: Some(Opid(3)), - content: AdvanceInputIterator, + parent_opid: Some(Opid(1)), + content: OutputIteratorExhausted, ), Opid(22): TraceOp( opid: Opid(22), parent_opid: Some(Opid(2)), - content: AdvanceInputIterator, + content: InputIteratorExhausted, ), Opid(23): TraceOp( opid: Opid(23), - parent_opid: Some(Opid(1)), + parent_opid: Some(Opid(2)), content: OutputIteratorExhausted, ), Opid(24): TraceOp( opid: Opid(24), - parent_opid: Some(Opid(2)), + parent_opid: Some(Opid(3)), content: InputIteratorExhausted, ), Opid(25): TraceOp( opid: Opid(25), - parent_opid: Some(Opid(2)), + parent_opid: Some(Opid(3)), content: OutputIteratorExhausted, ), Opid(26): TraceOp( opid: Opid(26), - parent_opid: Some(Opid(3)), + parent_opid: Some(Opid(4)), content: InputIteratorExhausted, ), Opid(27): TraceOp( opid: Opid(27), - parent_opid: Some(Opid(3)), - content: OutputIteratorExhausted, - ), - Opid(28): TraceOp( - opid: Opid(28), - parent_opid: Some(Opid(4)), - content: InputIteratorExhausted, - ), - Opid(29): TraceOp( - opid: Opid(29), parent_opid: Some(Opid(4)), content: OutputIteratorExhausted, ), diff --git a/trustfall_core/test_data/tests/valid_queries/fold_with_no_outputs_transform_and_filter_greater_than.trace.ron b/trustfall_core/test_data/tests/valid_queries/fold_with_no_outputs_transform_and_filter_greater_than.trace.ron index fdd02c22..22223938 100644 --- a/trustfall_core/test_data/tests/valid_queries/fold_with_no_outputs_transform_and_filter_greater_than.trace.ron +++ b/trustfall_core/test_data/tests/valid_queries/fold_with_no_outputs_transform_and_filter_greater_than.trace.ron @@ -118,16 +118,6 @@ TestInterpreterOutputTrace( ), Opid(15): TraceOp( opid: Opid(15), - parent_opid: Some(Opid(12)), - content: YieldFrom(ResolveNeighborsInner(2, Prime(PrimeNumber(5)))), - ), - Opid(16): TraceOp( - opid: Opid(16), - parent_opid: Some(Opid(12)), - content: OutputIteratorExhausted, - ), - Opid(17): TraceOp( - opid: Opid(17), parent_opid: Some(Opid(4)), content: YieldInto(SerializableContext( active_vertex: Some(Composite(CompositeNumber(30, [ @@ -156,18 +146,12 @@ TestInterpreterOutputTrace( Vid(2): Some(Prime(PrimeNumber(3))), }, ), - SerializableContext( - active_vertex: Some(Prime(PrimeNumber(5))), - vertices: { - Vid(2): Some(Prime(PrimeNumber(5))), - }, - ), ]), }, )), ), - Opid(18): TraceOp( - opid: Opid(18), + Opid(16): TraceOp( + opid: Opid(16), parent_opid: Some(Opid(4)), content: YieldFrom(ResolveProperty(SerializableContext( active_vertex: Some(Composite(CompositeNumber(30, [ @@ -196,70 +180,64 @@ TestInterpreterOutputTrace( Vid(2): Some(Prime(PrimeNumber(3))), }, ), - SerializableContext( - active_vertex: Some(Prime(PrimeNumber(5))), - vertices: { - Vid(2): Some(Prime(PrimeNumber(5))), - }, - ), ]), }, ), Int64(30))), ), - Opid(19): TraceOp( - opid: Opid(19), + Opid(17): TraceOp( + opid: Opid(17), parent_opid: None, content: ProduceQueryResult({ "value": Int64(30), }), ), + Opid(18): TraceOp( + opid: Opid(18), + parent_opid: Some(Opid(4)), + content: AdvanceInputIterator, + ), + Opid(19): TraceOp( + opid: Opid(19), + parent_opid: Some(Opid(3)), + content: AdvanceInputIterator, + ), Opid(20): TraceOp( opid: Opid(20), - parent_opid: Some(Opid(4)), + parent_opid: Some(Opid(2)), content: AdvanceInputIterator, ), Opid(21): TraceOp( opid: Opid(21), - parent_opid: Some(Opid(3)), - content: AdvanceInputIterator, + parent_opid: Some(Opid(1)), + content: OutputIteratorExhausted, ), Opid(22): TraceOp( opid: Opid(22), parent_opid: Some(Opid(2)), - content: AdvanceInputIterator, + content: InputIteratorExhausted, ), Opid(23): TraceOp( opid: Opid(23), - parent_opid: Some(Opid(1)), + parent_opid: Some(Opid(2)), content: OutputIteratorExhausted, ), Opid(24): TraceOp( opid: Opid(24), - parent_opid: Some(Opid(2)), + parent_opid: Some(Opid(3)), content: InputIteratorExhausted, ), Opid(25): TraceOp( opid: Opid(25), - parent_opid: Some(Opid(2)), + parent_opid: Some(Opid(3)), content: OutputIteratorExhausted, ), Opid(26): TraceOp( opid: Opid(26), - parent_opid: Some(Opid(3)), + parent_opid: Some(Opid(4)), content: InputIteratorExhausted, ), Opid(27): TraceOp( opid: Opid(27), - parent_opid: Some(Opid(3)), - content: OutputIteratorExhausted, - ), - Opid(28): TraceOp( - opid: Opid(28), - parent_opid: Some(Opid(4)), - content: InputIteratorExhausted, - ), - Opid(29): TraceOp( - opid: Opid(29), parent_opid: Some(Opid(4)), content: OutputIteratorExhausted, ), diff --git a/trustfall_core/test_data/tests/valid_queries/nested_fold_with_no_outputs.trace.ron b/trustfall_core/test_data/tests/valid_queries/nested_fold_with_no_outputs.trace.ron index 291201b1..2c9246d1 100644 --- a/trustfall_core/test_data/tests/valid_queries/nested_fold_with_no_outputs.trace.ron +++ b/trustfall_core/test_data/tests/valid_queries/nested_fold_with_no_outputs.trace.ron @@ -231,28 +231,23 @@ TestInterpreterOutputTrace( ), Opid(32): TraceOp( opid: Opid(32), - parent_opid: Some(Opid(29)), - content: OutputIteratorExhausted, + parent_opid: Some(Opid(14)), + content: AdvanceInputIterator, ), Opid(33): TraceOp( opid: Opid(33), - parent_opid: Some(Opid(14)), + parent_opid: Some(Opid(13)), content: AdvanceInputIterator, ), Opid(34): TraceOp( opid: Opid(34), - parent_opid: Some(Opid(13)), - content: AdvanceInputIterator, - ), - Opid(35): TraceOp( - opid: Opid(35), parent_opid: Some(Opid(12)), content: YieldFrom(ResolveNeighborsInner(3, Composite(CompositeNumber(8, [ 2, ])))), ), - Opid(36): TraceOp( - opid: Opid(36), + Opid(35): TraceOp( + opid: Opid(35), parent_opid: Some(Opid(13)), content: YieldInto(SerializableContext( active_vertex: Some(Composite(CompositeNumber(8, [ @@ -261,8 +256,8 @@ TestInterpreterOutputTrace( vertices: {}, )), ), - Opid(37): TraceOp( - opid: Opid(37), + Opid(36): TraceOp( + opid: Opid(36), parent_opid: Some(Opid(13)), content: YieldFrom(ResolveCoercion(SerializableContext( active_vertex: Some(Composite(CompositeNumber(8, [ @@ -271,8 +266,8 @@ TestInterpreterOutputTrace( vertices: {}, ), true)), ), - Opid(38): TraceOp( - opid: Opid(38), + Opid(37): TraceOp( + opid: Opid(37), parent_opid: Some(Opid(14)), content: YieldInto(SerializableContext( active_vertex: Some(Composite(CompositeNumber(8, [ @@ -285,8 +280,8 @@ TestInterpreterOutputTrace( }, )), ), - Opid(39): TraceOp( - opid: Opid(39), + Opid(38): TraceOp( + opid: Opid(38), parent_opid: Some(Opid(14)), content: YieldFrom(ResolveNeighborsOuter(SerializableContext( active_vertex: Some(Composite(CompositeNumber(8, [ @@ -299,260 +294,18 @@ TestInterpreterOutputTrace( }, ))), ), + Opid(39): TraceOp( + opid: Opid(39), + parent_opid: Some(Opid(38)), + content: YieldFrom(ResolveNeighborsInner(0, Neither(NeitherNumber(1)))), + ), Opid(40): TraceOp( opid: Opid(40), - parent_opid: Some(Opid(39)), - content: YieldFrom(ResolveNeighborsInner(0, Neither(NeitherNumber(1)))), + parent_opid: Some(Opid(38)), + content: YieldFrom(ResolveNeighborsInner(1, Prime(PrimeNumber(2)))), ), Opid(41): TraceOp( opid: Opid(41), - parent_opid: Some(Opid(39)), - content: YieldFrom(ResolveNeighborsInner(1, Prime(PrimeNumber(2)))), - ), - Opid(42): TraceOp( - opid: Opid(42), - parent_opid: Some(Opid(39)), - content: YieldFrom(ResolveNeighborsInner(2, Composite(CompositeNumber(4, [ - 2, - ])))), - ), - Opid(43): TraceOp( - opid: Opid(43), - parent_opid: Some(Opid(39)), - content: OutputIteratorExhausted, - ), - Opid(44): TraceOp( - opid: Opid(44), - parent_opid: Some(Opid(14)), - content: AdvanceInputIterator, - ), - Opid(45): TraceOp( - opid: Opid(45), - parent_opid: Some(Opid(13)), - content: AdvanceInputIterator, - ), - Opid(46): TraceOp( - opid: Opid(46), - parent_opid: Some(Opid(12)), - content: YieldFrom(ResolveNeighborsInner(4, Composite(CompositeNumber(16, [ - 2, - ])))), - ), - Opid(47): TraceOp( - opid: Opid(47), - parent_opid: Some(Opid(13)), - content: YieldInto(SerializableContext( - active_vertex: Some(Composite(CompositeNumber(16, [ - 2, - ]))), - vertices: {}, - )), - ), - Opid(48): TraceOp( - opid: Opid(48), - parent_opid: Some(Opid(13)), - content: YieldFrom(ResolveCoercion(SerializableContext( - active_vertex: Some(Composite(CompositeNumber(16, [ - 2, - ]))), - vertices: {}, - ), true)), - ), - Opid(49): TraceOp( - opid: Opid(49), - parent_opid: Some(Opid(14)), - content: YieldInto(SerializableContext( - active_vertex: Some(Composite(CompositeNumber(16, [ - 2, - ]))), - vertices: { - Vid(2): Some(Composite(CompositeNumber(16, [ - 2, - ]))), - }, - )), - ), - Opid(50): TraceOp( - opid: Opid(50), - parent_opid: Some(Opid(14)), - content: YieldFrom(ResolveNeighborsOuter(SerializableContext( - active_vertex: Some(Composite(CompositeNumber(16, [ - 2, - ]))), - vertices: { - Vid(2): Some(Composite(CompositeNumber(16, [ - 2, - ]))), - }, - ))), - ), - Opid(51): TraceOp( - opid: Opid(51), - parent_opid: Some(Opid(50)), - content: YieldFrom(ResolveNeighborsInner(0, Neither(NeitherNumber(1)))), - ), - Opid(52): TraceOp( - opid: Opid(52), - parent_opid: Some(Opid(50)), - content: YieldFrom(ResolveNeighborsInner(1, Prime(PrimeNumber(2)))), - ), - Opid(53): TraceOp( - opid: Opid(53), - parent_opid: Some(Opid(50)), - content: YieldFrom(ResolveNeighborsInner(2, Composite(CompositeNumber(4, [ - 2, - ])))), - ), - Opid(54): TraceOp( - opid: Opid(54), - parent_opid: Some(Opid(50)), - content: YieldFrom(ResolveNeighborsInner(3, Composite(CompositeNumber(8, [ - 2, - ])))), - ), - Opid(55): TraceOp( - opid: Opid(55), - parent_opid: Some(Opid(50)), - content: OutputIteratorExhausted, - ), - Opid(56): TraceOp( - opid: Opid(56), - parent_opid: Some(Opid(14)), - content: AdvanceInputIterator, - ), - Opid(57): TraceOp( - opid: Opid(57), - parent_opid: Some(Opid(13)), - content: AdvanceInputIterator, - ), - Opid(58): TraceOp( - opid: Opid(58), - parent_opid: Some(Opid(12)), - content: YieldFrom(ResolveNeighborsInner(5, Composite(CompositeNumber(32, [ - 2, - ])))), - ), - Opid(59): TraceOp( - opid: Opid(59), - parent_opid: Some(Opid(13)), - content: YieldInto(SerializableContext( - active_vertex: Some(Composite(CompositeNumber(32, [ - 2, - ]))), - vertices: {}, - )), - ), - Opid(60): TraceOp( - opid: Opid(60), - parent_opid: Some(Opid(13)), - content: YieldFrom(ResolveCoercion(SerializableContext( - active_vertex: Some(Composite(CompositeNumber(32, [ - 2, - ]))), - vertices: {}, - ), true)), - ), - Opid(61): TraceOp( - opid: Opid(61), - parent_opid: Some(Opid(14)), - content: YieldInto(SerializableContext( - active_vertex: Some(Composite(CompositeNumber(32, [ - 2, - ]))), - vertices: { - Vid(2): Some(Composite(CompositeNumber(32, [ - 2, - ]))), - }, - )), - ), - Opid(62): TraceOp( - opid: Opid(62), - parent_opid: Some(Opid(14)), - content: YieldFrom(ResolveNeighborsOuter(SerializableContext( - active_vertex: Some(Composite(CompositeNumber(32, [ - 2, - ]))), - vertices: { - Vid(2): Some(Composite(CompositeNumber(32, [ - 2, - ]))), - }, - ))), - ), - Opid(63): TraceOp( - opid: Opid(63), - parent_opid: Some(Opid(62)), - content: YieldFrom(ResolveNeighborsInner(0, Neither(NeitherNumber(1)))), - ), - Opid(64): TraceOp( - opid: Opid(64), - parent_opid: Some(Opid(62)), - content: YieldFrom(ResolveNeighborsInner(1, Prime(PrimeNumber(2)))), - ), - Opid(65): TraceOp( - opid: Opid(65), - parent_opid: Some(Opid(62)), - content: YieldFrom(ResolveNeighborsInner(2, Composite(CompositeNumber(4, [ - 2, - ])))), - ), - Opid(66): TraceOp( - opid: Opid(66), - parent_opid: Some(Opid(62)), - content: YieldFrom(ResolveNeighborsInner(3, Composite(CompositeNumber(8, [ - 2, - ])))), - ), - Opid(67): TraceOp( - opid: Opid(67), - parent_opid: Some(Opid(62)), - content: YieldFrom(ResolveNeighborsInner(4, Composite(CompositeNumber(16, [ - 2, - ])))), - ), - Opid(68): TraceOp( - opid: Opid(68), - parent_opid: Some(Opid(62)), - content: OutputIteratorExhausted, - ), - Opid(69): TraceOp( - opid: Opid(69), - parent_opid: Some(Opid(14)), - content: AdvanceInputIterator, - ), - Opid(70): TraceOp( - opid: Opid(70), - parent_opid: Some(Opid(13)), - content: AdvanceInputIterator, - ), - Opid(71): TraceOp( - opid: Opid(71), - parent_opid: Some(Opid(12)), - content: OutputIteratorExhausted, - ), - Opid(72): TraceOp( - opid: Opid(72), - parent_opid: Some(Opid(13)), - content: InputIteratorExhausted, - ), - Opid(73): TraceOp( - opid: Opid(73), - parent_opid: Some(Opid(13)), - content: OutputIteratorExhausted, - ), - Opid(74): TraceOp( - opid: Opid(74), - parent_opid: Some(Opid(14)), - content: InputIteratorExhausted, - ), - Opid(75): TraceOp( - opid: Opid(75), - parent_opid: Some(Opid(14)), - content: OutputIteratorExhausted, - ), - Opid(76): TraceOp( - opid: Opid(76), parent_opid: Some(Opid(4)), content: YieldInto(SerializableContext( active_vertex: Some(Composite(CompositeNumber(64, [ @@ -614,118 +367,6 @@ TestInterpreterOutputTrace( Vid(3): Some(Prime(PrimeNumber(2))), }, ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(4, [ - 2, - ]))), - vertices: { - Vid(3): Some(Composite(CompositeNumber(4, [ - 2, - ]))), - }, - ), - ]), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(16, [ - 2, - ]))), - vertices: { - Vid(2): Some(Composite(CompositeNumber(16, [ - 2, - ]))), - }, - folded_contexts: { - Eid(2): Some([ - SerializableContext( - active_vertex: Some(Neither(NeitherNumber(1))), - vertices: { - Vid(3): Some(Neither(NeitherNumber(1))), - }, - ), - SerializableContext( - active_vertex: Some(Prime(PrimeNumber(2))), - vertices: { - Vid(3): Some(Prime(PrimeNumber(2))), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(4, [ - 2, - ]))), - vertices: { - Vid(3): Some(Composite(CompositeNumber(4, [ - 2, - ]))), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(8, [ - 2, - ]))), - vertices: { - Vid(3): Some(Composite(CompositeNumber(8, [ - 2, - ]))), - }, - ), - ]), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(32, [ - 2, - ]))), - vertices: { - Vid(2): Some(Composite(CompositeNumber(32, [ - 2, - ]))), - }, - folded_contexts: { - Eid(2): Some([ - SerializableContext( - active_vertex: Some(Neither(NeitherNumber(1))), - vertices: { - Vid(3): Some(Neither(NeitherNumber(1))), - }, - ), - SerializableContext( - active_vertex: Some(Prime(PrimeNumber(2))), - vertices: { - Vid(3): Some(Prime(PrimeNumber(2))), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(4, [ - 2, - ]))), - vertices: { - Vid(3): Some(Composite(CompositeNumber(4, [ - 2, - ]))), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(8, [ - 2, - ]))), - vertices: { - Vid(3): Some(Composite(CompositeNumber(8, [ - 2, - ]))), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(16, [ - 2, - ]))), - vertices: { - Vid(3): Some(Composite(CompositeNumber(16, [ - 2, - ]))), - }, - ), ]), }, ), @@ -733,8 +374,8 @@ TestInterpreterOutputTrace( }, )), ), - Opid(77): TraceOp( - opid: Opid(77), + Opid(42): TraceOp( + opid: Opid(42), parent_opid: Some(Opid(4)), content: YieldFrom(ResolveProperty(SerializableContext( active_vertex: Some(Composite(CompositeNumber(64, [ @@ -796,118 +437,6 @@ TestInterpreterOutputTrace( Vid(3): Some(Prime(PrimeNumber(2))), }, ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(4, [ - 2, - ]))), - vertices: { - Vid(3): Some(Composite(CompositeNumber(4, [ - 2, - ]))), - }, - ), - ]), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(16, [ - 2, - ]))), - vertices: { - Vid(2): Some(Composite(CompositeNumber(16, [ - 2, - ]))), - }, - folded_contexts: { - Eid(2): Some([ - SerializableContext( - active_vertex: Some(Neither(NeitherNumber(1))), - vertices: { - Vid(3): Some(Neither(NeitherNumber(1))), - }, - ), - SerializableContext( - active_vertex: Some(Prime(PrimeNumber(2))), - vertices: { - Vid(3): Some(Prime(PrimeNumber(2))), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(4, [ - 2, - ]))), - vertices: { - Vid(3): Some(Composite(CompositeNumber(4, [ - 2, - ]))), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(8, [ - 2, - ]))), - vertices: { - Vid(3): Some(Composite(CompositeNumber(8, [ - 2, - ]))), - }, - ), - ]), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(32, [ - 2, - ]))), - vertices: { - Vid(2): Some(Composite(CompositeNumber(32, [ - 2, - ]))), - }, - folded_contexts: { - Eid(2): Some([ - SerializableContext( - active_vertex: Some(Neither(NeitherNumber(1))), - vertices: { - Vid(3): Some(Neither(NeitherNumber(1))), - }, - ), - SerializableContext( - active_vertex: Some(Prime(PrimeNumber(2))), - vertices: { - Vid(3): Some(Prime(PrimeNumber(2))), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(4, [ - 2, - ]))), - vertices: { - Vid(3): Some(Composite(CompositeNumber(4, [ - 2, - ]))), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(8, [ - 2, - ]))), - vertices: { - Vid(3): Some(Composite(CompositeNumber(8, [ - 2, - ]))), - }, - ), - SerializableContext( - active_vertex: Some(Composite(CompositeNumber(16, [ - 2, - ]))), - vertices: { - Vid(3): Some(Composite(CompositeNumber(16, [ - 2, - ]))), - }, - ), ]), }, ), @@ -915,60 +444,60 @@ TestInterpreterOutputTrace( }, ), Int64(64))), ), - Opid(78): TraceOp( - opid: Opid(78), + Opid(43): TraceOp( + opid: Opid(43), parent_opid: None, content: ProduceQueryResult({ "value": Int64(64), }), ), - Opid(79): TraceOp( - opid: Opid(79), + Opid(44): TraceOp( + opid: Opid(44), parent_opid: Some(Opid(4)), content: AdvanceInputIterator, ), - Opid(80): TraceOp( - opid: Opid(80), + Opid(45): TraceOp( + opid: Opid(45), parent_opid: Some(Opid(3)), content: AdvanceInputIterator, ), - Opid(81): TraceOp( - opid: Opid(81), + Opid(46): TraceOp( + opid: Opid(46), parent_opid: Some(Opid(2)), content: AdvanceInputIterator, ), - Opid(82): TraceOp( - opid: Opid(82), + Opid(47): TraceOp( + opid: Opid(47), parent_opid: Some(Opid(1)), content: OutputIteratorExhausted, ), - Opid(83): TraceOp( - opid: Opid(83), + Opid(48): TraceOp( + opid: Opid(48), parent_opid: Some(Opid(2)), content: InputIteratorExhausted, ), - Opid(84): TraceOp( - opid: Opid(84), + Opid(49): TraceOp( + opid: Opid(49), parent_opid: Some(Opid(2)), content: OutputIteratorExhausted, ), - Opid(85): TraceOp( - opid: Opid(85), + Opid(50): TraceOp( + opid: Opid(50), parent_opid: Some(Opid(3)), content: InputIteratorExhausted, ), - Opid(86): TraceOp( - opid: Opid(86), + Opid(51): TraceOp( + opid: Opid(51), parent_opid: Some(Opid(3)), content: OutputIteratorExhausted, ), - Opid(87): TraceOp( - opid: Opid(87), + Opid(52): TraceOp( + opid: Opid(52), parent_opid: Some(Opid(4)), content: InputIteratorExhausted, ), - Opid(88): TraceOp( - opid: Opid(88), + Opid(53): TraceOp( + opid: Opid(53), parent_opid: Some(Opid(4)), content: OutputIteratorExhausted, ),