Fork me on GitHub

How would you create a class for a “pojo” with getters and setters from clojure, similar to the EventGridEvent class here .


That is just a map


So on general, unless required for some other reason, you wouldn't make such a thing


Right. I'm trying to let the azure function framework coerce a message into this event map. The blobinput annotation expects this sort of class. Tbh it looks like writing the clojure to avoid this annotation is easier than working with the java event class


I am not familiar with the azure libraries, but the way this kind of thing is often structured there is a high level layer with pojos and annotations for persistence, and then a lower layer which is more data oriented and closer to the actual wire format, which is usually nicer to use from clojure


Ok, thanks. I’ll dig into the docs for the lower layer.


Hi! I've started using hugSQL in Luminus and now I'm running some tests, but the tests are accessing my actual DB instead of using some kind of test-only fixture DB is there some standard code someone has that I can use to setup and teardown a separate postgres db to use just for running my tests which create and query db rows?


if the sql queries don't use any specific postgres features, you can use h2 in memory. But it's a bit like mocking, with all the associated pitfalls

👍 1
Ben Wadsworth12:07:33

Good point, we had done some H2 investigation as well. We do use some of those features which tie us to postgres specific items. As a note, when implementing embedded-postgres, you likely want to also look into using for lifecycle management during tests

Jim Strieter09:07:30

What is the time complexity for contains? to check if a map contains a key? I would think O(1) but I just want to be sure. (Sorry in advance if the answer's in some place I should look. I googled but didn't see anything that was obviously the answer.)


in the docstring for contains? there is a line “‘contains?’ operates constant or logarithmic time; it will not perform a linear search for a value.”

Tomasz Kalisiak09:07:15

It will be constant for hash-map and logarithmic for sorted-map.

Jim Strieter10:07:00

Sweet! Thank you guys! 🙂

Jim Strieter10:07:10

If you check for equality* between two sets, is that O(N)? Or is there a faster way to do that? *By "equality" I mean they contain the same elements

delaguardo10:07:38 from ^ this guide Both arguments are sets (including Java sets implementing java.util.Set), with = elements, ignoring order. It sounds like O(N) to me

🙌 1

naive benchmark:

(let [s1 (into #{} (range 1000))
        s1' (into #{} (range 1000))
        s2 (into #{} (range 100000))
        s2' (into #{} (range 100000))]
     (dotimes [_ 1000]
       (= s1 s1')))
     (dotimes [_ 1000]
       (= s2 s2'))))
  ;; => "Elapsed time: 42.390333 msecs"
  ;; => "Elapsed time: 5667.525708 msecs"

🙌 1
💯 1
Jim Strieter10:07:36

yeah that's what I thought

Jim Strieter10:07:44

the two times are a bit more than 100x apart, same as the size of the sets in the two trials

Jim Strieter10:07:53

Thanks for showing me that! 🙂


How do I set nested property in js object using clojurescript? Say, I have (def obj #js {:nested {:a 1 :b 2}}) When I try (set! (-> obj .-nested .-a) 2) or (set! (.. obj -nested -a) 2) , REPL responds with 2 but obj is not actually being mutated.


#js tagged literal is not recursive. you have to use it everywhere you want to make JS data stricture instead of Clojure.

(def obj #js {:nested #js {:a 1 :b 2}})

(set! (-> .-nested .-a) 2) ;; => 2

obj ;; => #js {:nested #js {:a 2 :b 2}}

👍 1

or use clj->js instead of #js

(clj->js {:nested {:a 1 :b 2}})
;; => #js {:nested #js {:a 1 :b 2}}

👏 1

Now I see, interop is more tricky than I thought:) Thanks for pointing out!