This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-24
Channels
- # aws (7)
- # aws-lambda (3)
- # beginners (65)
- # boot (43)
- # cider (7)
- # cljs-dev (12)
- # cljsrn (15)
- # clojure (284)
- # clojure-austin (32)
- # clojure-brasil (4)
- # clojure-dusseldorf (4)
- # clojure-germany (1)
- # clojure-italy (40)
- # clojure-spec (21)
- # clojure-uk (69)
- # clojurescript (97)
- # core-async (11)
- # cursive (19)
- # data-science (1)
- # datascript (6)
- # datomic (30)
- # dirac (2)
- # emacs (4)
- # events (2)
- # fulcro (76)
- # graphql (38)
- # juxt (1)
- # lein-figwheel (1)
- # leiningen (6)
- # luminus (4)
- # lumo (13)
- # mount (4)
- # off-topic (24)
- # om (28)
- # onyx (32)
- # other-languages (1)
- # parinfer (40)
- # pedestal (1)
- # portkey (47)
- # re-frame (21)
- # reagent (4)
- # ring (4)
- # ring-swagger (3)
- # rum (1)
- # shadow-cljs (115)
- # spacemacs (5)
- # sql (14)
- # unrepl (1)
- # yada (3)
and emerging from the void, @paulspencerwilliams asserts "I exist"
any love for my code review request? https://clojurians.slack.com/archives/C064BA6G2/p1508792205000218
Absolutely. 👍
@otfrom it sounds a bit like a group-by
@peterwestmacott it is a bit, but I want it to work with larger sequences. The stream should already be sorted.
are the time periods regular?
@tcoupland losing the 9 from the data is fine as we just want a subset of the data. We could give in a lazy seq for the template (which is probably how it will work) and then do a take
I wonder if a specific solution would be better than a general parameterised one
http://clojuredocs.org/clojure.core/split-with can replace separate uses of take/drop while perhaps.
@peterwestmacott the periods aren't always regular (tho usually will be)
@tcoupland I think that's where it will go in the transducer version. I've not puzzled my way through that yet
@tcoupland fair point
I had a look through the cgrand lib, and if the time periods were regular you could use, https://github.com/cgrand/xforms/blob/master/src/net/cgrand/xforms.cljc#L502-L562 but I can't see anything for your use case exactly
also that's a bit more involved ^. Definitely not concise!
@otfrom I mention it only because I've not read the source of split-with, if it is naive my point is moot, if it's smart about not wasting effort then it might be valuable. It's a little more concise I suppose.
@danieleneal I'd looked at that and got a bit confused by the doc (esp the steps), so had a go myself. I need to make sure it deals with the empty periods properly.
I think the steps you'd pass just 1 for n usually
but looks like it wouldn't fit your needs anyway
empty periods at the start/middle/end were the bit that drove me to write code as I hadn't found something that had done that
ah I see
I think you could do this with plain partition-by if you assume the data is sorted. Your partitioning function would be something like #(first (filter (fn [template] (<= template %)) [1 2 3]))
Morning
@tcoupland you hinted at a stateful transducer?
i havn't got anything that does specifically what your looking for, got some fairly light ones that cld provide a base to work from perhaps
@otfrom had some trouble reconstructing the thread, are you asking about partitioning of maps with timestamps by time periods (e.g. every minute)?
@reborg yes, but with some time periods having no data in them and some possibly having multiples
Couldn't you align to the nearest minute?
(import '[java.util Date])
(def times [{:a "a" :t (Date.)} {:a "b" :t (Date.)} {:a "c" :t (Date.)}])
(partition-by #(quot (.getTime (:t %)) 60000) times)
@reborg I think the problem is that I don't get the empty time periods with partition-by (tho I might have to re-check to be sure)
a rethink could be, to not having the empties at this phase, create these views on all streams, and create the empties when you combine them. If that makes sense
filling the gaps approach
(def times [20 32 49 50 99])
(take 10
(let [buckets (group-by #(quot % 12) times)]
(map #(get buckets % []) (iterate inc 0))))
;; ([] [20] [32] [] [49 50] [] [] [] [99] [])
@otfrom sorry for coming in late to this, but the guys at imin have this sort of thing I think
Sorry these guys https://www.imin.co/
They have an open protocol for sending event data, which is close to my understanding of your use case
@reborg that is an interesting solution and would work with things out of order as long as they fit into memory
Hopefully your events could just be a timestamp and an id during buckets construction, you can then fetch the rest on demand. But yeah, the map (as is) should fit in memory
I’ve had a look around and can’t find a Clojure one, so… Is there a Java library out there that anyone might know of and / or recommend for administering PostgreSQL? I need to provide functionality to copy tables from one DB to another and would like to do it without weird edge-case SQL…
…if possible without JDBC at all in fact, just a native connection to PostgreSQL for administrative commands only.
@maleghast Without completely understanding the problem is not using Postgres create table
from SQL do the trick?
create table my_new_table as select * from my_existing_table
` for example.@jasonbell - Yeah that kind of thing, but I want to take tables from several DBs and put them into the same DB, so I may__ need to prepend table names with something
@jasonbell - So I am hoping to figure out a way to talk natively to PostgreSQL instead of having to use SQL