This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-21
Channels
- # announcements (9)
- # beginners (222)
- # boot (11)
- # calva (40)
- # cider (1)
- # clj-kondo (10)
- # cljs-dev (1)
- # cljsrn (8)
- # clojars (4)
- # clojure (50)
- # clojure-dev (4)
- # clojure-ecuador (1)
- # clojure-europe (4)
- # clojure-italy (3)
- # clojure-madison (2)
- # clojure-nl (26)
- # clojure-spec (86)
- # clojure-uk (34)
- # clojurescript (11)
- # clr (1)
- # cursive (46)
- # datomic (19)
- # emacs (4)
- # events (1)
- # fulcro (22)
- # graalvm (4)
- # graphql (2)
- # jobs-discuss (40)
- # leiningen (10)
- # luminus (6)
- # nrepl (7)
- # off-topic (18)
- # onyx (6)
- # overtone (1)
- # pedestal (2)
- # planck (1)
- # re-frame (5)
- # reagent (3)
- # reitit (8)
- # rewrite-clj (2)
- # shadow-cljs (139)
- # sql (4)
- # tools-deps (42)
I'm wondering if it's possible to do a stateful select or update in postgres. Similar to a stateful transducer, I want to map over each row keeping some state to derive a new value for each row. For context I'm simulating how much energy would be consumed if a battery and solar exists. So using data where there is no battery, at each point in time (for example 30 mins) I calculate energy consumption by adding excess/unused solar to the current battery state (Charging battery). Then when there isn't sufficient solar I pull the excess from the battery while it has charge. Then finally if there isn't sufficient solar or battery charge I pull energy from the grid. I need to calculate the energy flow in and out of battery, solar and grid for each point in time. To do this I believe I need to keep some state of the battery's charge level as I iterate through. I'm already calculating this in clojure fine but I have to read and write the entire timeseries data set. So if I can do this in sql I believe It might be faster.
Not an answer to your question directly. But what you want to do might be easier/faster using crux, https://github.com/juxt/crux.
Interesting thanks!
there are individual operations like sum