1 # A work partition is independent of its element representation and ownership. 2 # Storage remains in the leaf payload; offset/span describe its logical range. 3 import Base 4 5 type Tree is Kind(ownership): 6 Leaf{data: Block,offset: U32,span: U32,details: Details} 7 Fork{left: Tree,right: Tree} 8 9 def gather(~ownership: Quant,~Output: Kind(ownership),~copy: U32 -> U32 -> U32 -> U32 -> Output -> Output -> Output, 10 partitions: Tree,output: Output,+positions: U32) -> Output: 11 match partitions: 12 case Leaf{input,offset,span,rows}: copy(rows,offset,positions,span,input,output) 13 case Fork{left,right}: gather(~ownership,~Output,~copy,right,gather(~ownership,~Output,~copy,left,output,positions),positions)