Fork me on GitHub
#datomic
<
2018-01-24
>
kenny00:01:01

I'm trying to create a Nippy serializer for a datom. Is there a way to construct a Datum object with the added field? I see the Datum constructor takes values for e, a, v, and tOp but not added. And it looks like the added field is defined as final, so I'm not sure how that's set (unless reflection is used). Technically I could just deserialize into a vector but it's a tad annoying that the serializer and deserializer are not symmetric.

kenny01:01:46

I guess I could create a Datum record that looks and acts like a datomic.db.Datum. Still a tad annoying that it isn't symmetric 🙃

kenny01:01:27

Ohhhh, I misunderstood. This is how the added field is defined 🙂 Makes sense now!

public boolean isAssertion() {
        return Numbers.isPos(this.tOp & 1L);
    }

kenny01:01:47

For those interested...

(nippy/extend-freeze Datum ::datom
  [^Datum datom ^DataOutputStream data-output]
  (nippy/freeze-to-out!
    data-output
    [(.-e datom) (.-a datom) (.-v datom) (.-tOp datom)]))

(nippy/extend-thaw ::datom
  [^DataInputStream data-input]
  (let [[e a v tOp] (nippy/thaw-from-in! data-input)]
    (Datum. e a v tOp)))

val_waeselynck07:01:09

Updated the README of Datomock - I hope this makes the use cases more clear, and that it shows how powerful datomic.api/with is https://github.com/vvvvalvalval/datomock

val_waeselynck08:01:24

@U053032QC related to our previous discussion

conan10:01:18

I'm really excited to try this out!

steveb8n12:01:40

I've been using this to great effect to make tests run fast. I'm sad to lose it with cloud/peer API but c'est la vie. Thanks Val, this is a great lib

val_waeselynck15:01:31

@U0510KXTU curious about how you used it - only to make tests run fast? I find the most rewarding aspects to be more workflow-related (debugging, dev etc.)

uwo15:01:28

this has been a godsend for our development workflow

souenzzo17:01:12

@U06GS6P1N I'm also using for test's something like

(let [root-conn (d/connect "mem")]
  (install-schema! root-conn)
  (reset! test-conn (dm/fork-conn root-conn)))
(defn test-fixtures
  [f]
  ;; no more install schema each fixture !!!
  (reset! system/conn (dm/fork-conn @test-conn))
  (f))

steveb8n21:01:33

@U06GS6P1N same as @U2J4FRT2T for fixtures run once but used in N tests

stuarthalloway14:01:26

@denik With Datomic Cloud, all data and processing lives in your account, and so you can choose if and how it is exposed to the internet. That said, the defaults (and our development efforts) are pointed at the secure deployment of data-of-record systems.

stuarthalloway14:01:24

@kenny out of curiosity, why do you need to serialize concrete Datoms?

kenny18:01:52

We have a series of Onyx tasks that publish segments to a Kafka topic. In order to publish to a Kafka topic you need to have serializable data. We need to publish the :tx-data off of the transaction report for running business logic. The options were either: - Write our own version do transact and transact-async that modify the returned transaction report such that :tx-data was serializable. Then require anyone who transacts data to Datomic to use that interface and know that the interface is slightly different that the Datomic one they were used to. - Write a function that serializes :tx-data in the transactions report and require that all developers remember to call that function before returning their segment. - Write a Datom serializer that allows devs to use the same Datomic API they've been using without needing to remember to call a function or use a special Datomic API only when working with Onyx.

stuarthalloway20:01:52

makes sense, thanks for sharing!