Skip to content

Commit

Permalink
[WIP] Stats
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkiel committed Sep 14, 2023
1 parent bd98bdb commit 6a0d639
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
7 changes: 7 additions & 0 deletions modules/cql/src/blaze/elm/compiler/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
(defprotocol Expression
(-static [expression])
(-attach-cache [expression cache])
(-patient-count [expression])
(-resolve-refs [expression expression-defs])
(-resolve-params [expression parameters])
(-eval [expression context resource scope]
Expand All @@ -37,6 +38,8 @@
true)
(-attach-cache [expr _]
expr)
(-patient-count [_]
0)
(-resolve-refs [expr _]
expr)
(-resolve-params [expr _]
Expand All @@ -51,6 +54,8 @@
true)
(-attach-cache [expr _]
expr)
(-patient-count [_]
0)
(-resolve-refs [expr _]
expr)
(-resolve-params [expr _]
Expand All @@ -65,6 +70,8 @@
true)
(-attach-cache [expr _]
expr)
(-patient-count [_]
0)
(-resolve-refs [expr _]
expr)
(-resolve-params [expr _]
Expand Down
16 changes: 15 additions & 1 deletion modules/cql/src/blaze/elm/compiler/logical_operators.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
false)
(-attach-cache [_ cache]
(and-nil-op (core/-attach-cache x cache)))
(-patient-count [_]
0)
(-resolve-refs [_ expression-defs]
(and-nil-op (core/-resolve-refs x expression-defs)))
(-resolve-params [_ parameters]
Expand Down Expand Up @@ -42,6 +44,8 @@
false)
(-attach-cache [_ cache]
(and-op (core/-attach-cache a cache) (core/-attach-cache b cache)))
(-patient-count [_]
(min (core/-patient-count a) (core/-patient-count b)))
(-resolve-refs [_ expression-defs]
(and-op (core/-resolve-refs a expression-defs)
(core/-resolve-refs b expression-defs)))
Expand Down Expand Up @@ -102,6 +106,8 @@
false)
(-attach-cache [_ cache]
(or-nil-op (core/-attach-cache x cache)))
(-patient-count [_]
(core/-patient-count x))
(-resolve-refs [_ expression-defs]
(or-nil-op (core/-resolve-refs x expression-defs)))
(-resolve-params [_ parameters]
Expand All @@ -128,7 +134,15 @@
(-static [_]
false)
(-attach-cache [_ cache]
(or-op (core/-attach-cache a cache) (core/-attach-cache b cache)))
(let [a (core/-attach-cache a cache)
b (core/-attach-cache b cache)
a-count (core/-patient-count a)
b-count (core/-patient-count b)]
(if (< a-count b-count)
(or-op b a)
(or-op a b))))
(-patient-count [_]
(max (core/-patient-count a) (core/-patient-count b)))
(-resolve-refs [_ expression-defs]
(or-op (core/-resolve-refs a expression-defs)
(core/-resolve-refs b expression-defs)))
Expand Down
6 changes: 6 additions & 0 deletions modules/cql/src/blaze/elm/compiler/macros.clj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
~operand ~elm-expr)
`(~(symbol (str name "-caching-op"))
~operand))))
(~'-patient-count [~'_]
(::bloom-filter/patient-count ~bloom-filter))
(~'-resolve-refs [~'_ ~'expression-defs]
~(if elm-expr-binding
`(~(symbol (str name "-caching-op"))
Expand Down Expand Up @@ -131,6 +133,8 @@
~operand ~elm-expr)
`(~(symbol (str name "-caching-op"))
~operand))))
(~'-patient-count [~'_]
0)
(~'-resolve-refs [~'_ ~'expression-defs]
~(if elm-expr-binding
`(~(symbol (str name "-caching-op"))
Expand Down Expand Up @@ -171,6 +175,8 @@
(core/-attach-cache ~operand ~'cache) ~elm-expr)
`(~(symbol (str name "-op"))
(core/-attach-cache ~operand ~'cache))))
(~'-patient-count [~'_]
0)
(~'-resolve-refs [~'_ ~'expression-defs]
~(if elm-expr-binding
`(~(symbol (str name "-op"))
Expand Down

0 comments on commit 6a0d639

Please sign in to comment.