1 import Base 2 import ./execution_query_matches.bend as Q 3 import ./lifecycle.bend as Life 4 5 type Lookup<-V:Data> is Data: 6 OutsideDomain{} 7 Known{view:Maybe<&2,V>} 8 def cached_lookup_here(-V:Data,view:Maybe<&2,V>,next:Lookup,found:Bool) -> Lookup: 9 match found: 10 case False{}:next 11 case True{}:Known{view} 12 def cached_lookup(-V:Data,rows:List<&2,Q.Row>,+offset:U32) -> Lookup: 13 match rows: 14 case []:OutsideDomain{} 15 case +row <> rest:cached_lookup_here(V,Q.row_view(V,row),cached_lookup(V,rest,offset),U32.is_eq(Q.row_offset(V,row),offset)) 16 def cached_stamp(-V:Data,rows:List<&2,Q.Row>,+index:U32) -> Life.Stamp: 17 match rows: 18 case []:Life.Stamp{None{},None{}} 19 case +row <> rest:Life.choose(U32.is_eq(index,Q.row_offset(V,row)),Q.row_stamp(V,row),cached_stamp(V,rest,index))