Fork me on GitHub
#xtdb
<
2022-04-28
>
Martynas Maciulevičius12:04:07

Why is [(identity v) v1] different from [v v1] in or-join? What does identity do? Does it magically produce a set from v?

refset14:04:48

Hey @U028ART884X what is the wider example here? [(identity v) v1] forces an evaluation order that is otherwise ambiguous if you were to use [(== v v1)]

Martynas Maciulevičius14:04:53

I got it from you originally: https://clojurians.slack.com/archives/CG3AM2F7V/p1648633699555599 So if I could use == there why didn't you favor that instead?

Martynas Maciulevičius15:04:40

Also what does it mean to force the order? As I understand the call to [(identity x) y] would evaluate the first argument. But then what would the expression [x y] mean inside or-join?

refset16:04:10

Oh I see 😅 So in the context of that kind or-join I think either approach will work the same. Like it's essentially a performing a union of two sets either way. As for your question about [x y] ...are you referring to the first argument of the or-join? If so, well that is simply acting as an kind of variable scoping boundary as values get passed from outside to inside the or-join and back out again, i.e. it is not a regular Datalog clause

refset16:04:26

Maybe I'm misunderstanding something though 🙂

emccue18:04:54

Im puzzling through some architecture stuff - Why is it that queries can't/aren't run locally as with datomic?

Steven Deobald18:04:09

In general, they are (at least if you're using xtdb embedded with Clojure). It's possible I'm misunderstanding your question, though?

emccue18:04:36

I might also be misunderstanding how the libraries work

refset18:04:41

The embedded API is the default and queries are run in the calling thread

emccue18:04:19

so the HTTP api is the only one where queries are run remote?

👍 1
emccue18:04:48

what is causing a deal of the confusion is this line in the docs

emccue18:04:55

> Datomic peers lazily read from the global index and therefore automatically cache their dynamic working sets. XTDB does not use a global index and currently does not offer any node-level sharding either so each node must contain the full database. In other words, each XTDB node is like an unpartitioned replica of the entire database,

emccue18:04:56

So datomic will lazily stream in data, but xtdb will store all the data in memory?

Steven Deobald19:04:09

Hm. So, by my understanding, these are two separate issues. One issue is where the data lives relative to your application, relative to the query boundary. In both xt and Datomic, if you are using the Clojure libs the data it operates on is local to the calling thread, as Jeremy mentioned above. Datomic doesn't provide a remote API (that I'm aware of, anyway) and XTDB provides the HTTP and http client which make the node "remote" relative to your application — not only out of thread, but out of process. That's the first issue, which doesn't relate to that comment in the docs. This comment in the docs is referring to how the database itself stores data. Datomic can store data remotely in a sharded configuration. When you query Datomic in this setup, you are still querying a node (I'm not sure if that's the right terminology, mind you — I haven't looked at Datomic in ~8 years) local to your app but that node can go grab data it lacks in its local cache from remote shards. The sharding will be transparent to you, I think. As of 1.21, xtdb doesn't have sharding or other separation of storage from compute features. All data is local to your node, but on disk (not in memory). If you want a second node, that node will also have all the data on disk. I'm not sure if that clears things up?

Hukka03:04:59

Just the indexes, though, not all all, right?

👍 1
refset09:04:50

That's true, yes, indexes only store small top level field values, anything large will be retrieved from the doc store as needed (with an in-memory cache in front)

dumrat19:04:53

Does tx/submit-tx only throw IllegalArgumentException ?

refset19:04:03

it shouldn't 🙂 what args are you passing? what's the full error / stack trace?

dumrat19:04:04

No, actually wondering which exceptions I have to handle

refset19:04:07

If you mean 'are there other kinds of errors that could be thrown', then I think the answer to that would be 'yes', like if tx-log or doc-store rejects the requests or throw timeouts

👍 1
refset19:04:03

Snap 😅 I guess another example would be if the disk was full. I don't think we've comprehensively analyzed all the ways that it can fail before. XT doesn't attempt to handle or wrap any of those examples currently

dumrat19:04:09

Got it thanks

🙏 1
Hukka03:04:13

Yeah, the surprises in exceptions can be nasty, and no static typing to help with that either 😞 Especially when some of them are recoverable with retries