InMemAggregateZeroOpt.yql 974 B

123456789101112131415161718192021222324
  1. (
  2. #comment
  3. (let config (DataSource 'config))
  4. (let world (Configure! world config 'PureDataSource 'yt))
  5. (let init_min (lambda '(x) (Member x 'value)))
  6. (let init_count (lambda '(x) (Uint64 '1)))
  7. (let update_min (lambda '(x y) (Min (Member x 'value) y)))
  8. (let update_count (lambda '(x y) (+ y (Uint64 '1))))
  9. (let id (lambda '(x) x))
  10. (let merge_min (lambda '(x y) (Min x y)))
  11. (let merge_count (lambda '(x y) (+ x y)))
  12. (let list (AsList
  13. (AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '2))))
  14. ))
  15. (let list (Take list (Uint64 '0)))
  16. (let min (AggregationTraits (ListItemType (TypeOf list)) init_min update_min id id merge_min id (Null)))
  17. (let count (AggregationTraits (ListItemType (TypeOf list)) init_count update_count id id merge_count id (Uint64 '0)))
  18. (let resAll (Aggregate list '() '('('minvalue min) '('count count))))
  19. (let res_sink (DataSink 'result))
  20. (let world (Write! world res_sink (Key) resAll '('('type))))
  21. (let world (Commit! world res_sink))
  22. (return world)
  23. )