Fork me on GitHub
#xtdb
<
2020-01-28
>
hairfire16:01:33

Given: (defn crux-standalone-in-memory-start [] (def ^crux.api.ICruxAPI node (crux/start-node {:crux.node/topology 'crux.standalone/topology :crux.node/kv-store 'crux.kv.memdb/kv :crux.kv/db-dir "data/db-dir-1" :crux.standalone/event-log-dir "data/eventlog-1" :crux.standalone/event-log-kv-store 'crux.kv.memdb/kv})) node) (def node (crux-standalone-in-memory-start)) executing: (crux/status node) works as documented in https://github.com/juxt/crux/blob/master/docs/clojure_api.adoc, but executing: (crux/sync node) results in the following error: Syntax error (IllegalArgumentException) compiling crux/sync at (src/crux_rbac/rbac_crux.clj:70:3). No single method: sync of interface: crux.api.PCruxNode found for function: sync of protocol: PCruxNode Any thoughts?

refset16:01:27

Hi again, we haven't quite released the zero-arity version of sync yet as it only got added last week 🙂 See: https://github.com/juxt/crux/commit/2e9653f1777bd71d2101c572c55c28f4c848be51 ...I guess the docs are currently out-of-sync in this regard! We will also need to add it to the Changelog before the next release, which should be within the next week or so. The simplest thing for you to do as it stands is add a timeout duration argument.

refset16:01:42

And sorry for the confusion!

hairfire17:01:44

The docs say "timeout" can be nil for the default. What's the syntax for a duration?

refset17:01:10

Ah yes, a nil should work. A timeout looks like: (sync node Duration/ofMillis 10000))

refset17:01:08

(you also need (:import java.time.Duration) at the top of your ns)

dharrigan20:01:04

I'm exploring some options for a requirement to have some type of bitemporal database in our architecture

dharrigan20:01:18

so, initially looking at Crux and Datomic

dharrigan20:01:45

I'm just after reading this article, written in 2017 wrt Datomic and accessing revisions of a document

dharrigan20:01:54

It suggests that if attributes are added to a model at a point in time, then you can't query for entities added before the new attributes have been added

dharrigan20:01:23

Is this something that Crux supports? (I definitely have a usecase where the model will evolve over time)

augustl21:01:01

more specifically - you can't query for the non-existence of an attribute, which means you have to query on an attribute that existed at some point in time to query for it 🙂

augustl21:01:07

(in Datomic)

augustl21:01:21

in other words, if you want to find "person by name" or something like that, you can't query for "person by name" and expect to find data that doesn't include that attribute because it didn't exist in the system yet

augustl21:01:31

but you can do what you would typically do in any other db - when you add a new attribute, you can put data in the database for all pre-existing entities

augustl21:01:46

(sorry, don't know the answer for crux, just felt like clarifying the Datomic part)

dharrigan21:01:33

right right, I see 🙂

refset21:01:40

Hey @dharrigan yep in Crux you can update an entity with new attributes (as a new document version) at any point in the ("valid") timeline and still query the old versions of that entity

dharrigan21:01:48

makes sense of course, can't query for something that didn't exist before then.

dharrigan21:01:35

Hi Jeremy - from augustl's explaination, it seems that datomic has similar, i.e., if I add a new attribute to a model, I can only query upon that model for that attribute up to when that attribute came in existance. Would that be the same in Crux, i.e., if I query on an attribute that was added today, then the query would only find entities up to today (if that attribute is part of the query) - hope that make sense 🙂

dharrigan21:01:29

If I strip out that attribute from the query, then both crux and datomic would resolve more entities (because it finds more entities without that attribute in the past)

refset21:01:48

Okay yeah I guess there's fundamentally no getting around the task of updating the database "for all pre-existing entities" if you want to be able to run the new queries against the existing data. One workaround is to add a bunch of extra clauses in your datalog to allow for attributes that optionally exist: https://github.com/juxt/crux/blob/master/crux-test/test/crux/query_test.clj#L491 ...but I can't comment on how practical this is as a long-term strategy! Maybe it is enough.

dharrigan21:01:16

Sure, thank you. It's very helpful. I guess it's analogous to adding a new nullable field in a RDBMS, then maybe defaulting the value, so that from that point onwards, you can query all the existing rows in the table for the value of the field

👍 4
dharrigan21:01:48

(even if it doesn't make real sense for prior rows, at least you can query from this point onwards for interesting values)

dharrigan21:01:18

Thank you @taylor.jeremydavid and @augustl for clarifying! Exciting stuff!

🙏 4
🎉 4