1 import Base 2 import ./chunk_column.bend as Column 3 import ./execution_composer_layout.bend as L 4 import ./execution_query_store.bend as Store 5 import ./execution_query_schema.bend as Schema 6 import ./execution_query_matches.bend as Match 7 import ./execution_query_recipe.bend as Recipe 8 import ./execution_query_admission.bend as Admission 9 import ./owner_product.bend as Product 10 import ./lifecycle.bend as Life 11 import ./change_tick.bend as Tick 12 13 def whole_left(~S:Data,-left:L.Layout,-right:L.Layout,other:L.columns(~S,right),result:L.columns(~S,left) & Life.Stamp) -> L.columns(~S,L.LayoutPair{left,right}) & Life.Stamp: 14 match result: 15 case (owner,stamp):(Product.Owner{owner,other},stamp) 16 def whole_right(~S:Data,-left:L.Layout,-right:L.Layout,other:L.columns(~S,left),result:L.columns(~S,right) & Life.Stamp) -> L.columns(~S,L.LayoutPair{left,right}) & Life.Stamp: 17 match result: 18 case (owner,stamp):(Product.Owner{other,owner},stamp) 19 def whole_cached(-S:Data,-P:Type,-V:Data,-key:String,-origin:L.Layout,index:U32,result:Column.Column> & List<&2,Match.Row>) -> L.ColumnSlot,key,origin> & Life.Stamp: 20 match result: 21 case (column,rows):(L.ColumnSlot{column},Store.cached_stamp(V,rows,index)) 22 def whole_stamp(~S:Data,layout:L.Layout,route:L.Route,owner:L.columns(~S,layout),index:U32) -> L.columns(~S,layout) & Life.Stamp: 23 match layout route owner: 24 case L.LayoutLeaf{P,V,refresh,key,policy} L.AtLeaf{} L.ColumnSlot{column}:whole_cached(S,P,V,key,L.LayoutLeaf{P,V,refresh,key,policy},index,Schema.cache_column(S,P,V,column,0)) 25 case L.ClassifiedLayoutLeaf{P,V,refresh,key,kind,policy} L.AtLeaf{} L.ColumnSlot{column}:whole_cached(S,P,V,key,L.ClassifiedLayoutLeaf{P,V,refresh,key,kind,policy},index,Schema.cache_column(S,P,V,column,0)) 26 case L.LayoutPair{left,right} L.InLeft{path} Product.Owner{l,r}:whole_left(~S,left,right,r,whole_stamp(~S,left,path,l,index)) 27 case L.LayoutPair{left,right} L.InRight{path} Product.Owner{l,r}:whole_right(~S,left,right,l,whole_stamp(~S,right,path,r,index)) 28 case _ _ owner:(owner,Life.Stamp{None{},None{}}) 29 def whole_changed(~S:Data,~layout:L.Layout,prior:Maybe<&2,Tick.Tick>,tick:Tick.Tick,result:L.columns(~S,layout) & Life.Stamp) -> L.columns(~S,layout) & Bool: 30 match result: 31 case (owner,stamp):(owner,Life.changed(stamp,prior,tick)) 32 def whole_combine(~S:Data,~layout:L.Layout,left:Bool,and:Bool,result:L.columns(~S,layout) & Bool) -> L.columns(~S,layout) & Bool: 33 match and result: 34 case True{}, (owner,right):(owner,Bool.and(left,right)) 35 case False{}, (owner,right):(owner,Bool.or(left,right)) 36 def whole_rest(~S:Data,~layout:L.Layout,and:Bool,next:L.columns(~S,layout) -> L.columns(~S,layout) & Bool,result:L.columns(~S,layout) & Bool) -> L.columns(~S,layout) & Bool: 37 match result: 38 case (owner,left):whole_combine(~S,~layout,left,and,next(owner)) 39 def whole_bound(~S:Data,~layout:L.Layout,+info:List<&2,Schema.Info>,selection:Recipe.Bound,+index:U32,+prior:Maybe<&2,Tick.Tick>,+tick:Tick.Tick,owner:L.columns(~S,layout)) -> L.columns(~S,layout) & Bool: 40 match selection: 41 case Recipe.Changed{route}:whole_changed(~S,~layout,prior,tick,whole_stamp(~S,layout,route,owner,index)) 42 case Recipe.And{left,right}:whole_rest(~S,~layout,True{},(owner => whole_bound(~S,~layout,info,right,index,prior,tick,owner)),whole_bound(~S,~layout,info,left,index,prior,tick,owner)) 43 case Recipe.Or{left,right}:whole_rest(~S,~layout,False{},(owner => whole_bound(~S,~layout,info,right,index,prior,tick,owner)),whole_bound(~S,~layout,info,left,index,prior,tick,owner)) 44 case selection:(owner,Admission.bound(info,selection,index))