Closed HuwCampbell closed 5 years ago
So it's clear what this is doing, here's the code output for the flatten stage:
With this query
feature injury ~> windowed between 3 weeks and 6 weeks ~> count 1
Before this change the flattened avalanche was this
conv-2 : Time =
TIME
conv-3 : Int =
MAX_MAP_SIZE
acc-c-conv-4 =i 0 : Int
for_facts conv-1 : Time
, conv-0-simpflat-4 : Error
, conv-0-simpflat-5 : Bool
, conv-0-simpflat-6 : String
, conv-0-simpflat-7 : String
, conv-0-simpflat-8 : Double
, conv-0-simpflat-9 : Time {
simpflat-0 = Time_minusDays# conv-2 42
simpflat-1 = ge# conv-1 simpflat-0
simpflat-2 = Time_minusDays# conv-2 21
simpflat-3 = ge# simpflat-2 conv-1
if (and# simpflat-1 simpflat-3)
{
acc-c-conv-4 =r acc-c-conv-4
acc-c-conv-4 =w add# acc-c-conv-4 1
}
}
c-conv-4 =r acc-c-conv-4
output repl:output : Int
After
conv-2 : Time =
TIME
conv-3 : Int =
MAX_MAP_SIZE
conv-5 = Time_minusDays# conv-2 42
conv-6 = Time_minusDays# conv-2 21
acc-c-conv-4 =i 0 : Int
for_facts conv-1 : Time
, conv-0-simpflat-0 : Error
, conv-0-simpflat-1 : Bool
, conv-0-simpflat-2 : String
, conv-0-simpflat-3 : String
, conv-0-simpflat-4 : Double
, conv-0-simpflat-5 : Time {
anf-1 = ge# conv-1 conv-5
anf-0 = ge# conv-6 conv-1
if (and# anf-1 anf-0)
{
acc-c-conv-4 =r acc-c-conv-4
acc-c-conv-4 =w add# acc-c-conv-4 1
}
}
c-conv-4 =r acc-c-conv-4
output repl:output : Int =
c-conv-4 : Int
Without bubble-gum on the horizon, having a window primitive in Core doesn't make very much sense, and causes a small inefficiency, as the edges of the windows should be precomputations, and not calculated for each fact.