Fork me on GitHub
#xtdb
<
2020-08-20
>
Nejc08:08:52

Hi guys, I'm new to crux and Clojure (btw, loving both, great work) and I'm struggling with initializing Crux node with Kafka topology from Java. Everything works as expected I even get documents into Kafka if I leave crux.kv/db-dir default (not setting it). However I would like to use the same index db dir eac time but I'm unable to get it working if I put this into my config:

static {
        Clojure.var("clojure.core", "require")
            .invoke(Clojure.read(""));

        final String nodeConfig = "{:crux.node/topology [crux.kafka/topology crux.kv.rocksdb/kv-store]\n" +
            ":crux.kafka/bootstrap-servers \"localhost:9092\"\n" +
            ":crux.kv/db-dir ( \"/tmp/crux-store\" \"indexes\")" +
            "}";

        node = Crux.startNode((Map<Keyword, ?>) Clojure.read(nodeConfig));
        node.sync(Duration.ofSeconds(30)); // Become consistent for a max of 30s
    }
The exception is:
Caused by: java.lang.IllegalArgumentException: Arg :crux.kv/db-dir invalid: nil - failed: (instance? java.nio.file.Path %) spec: :crux.config/path
The same initialization config works if I'm using Clojure. Can someone give me a hint how to initialize file in the config please.

👀 3
jarohen08:08:49

first thing I'd try would be to pass the file as a raw string instead, just in case it's the part going wrong - ":crux.kv/db-dir \"/tmp/crux-store/indexes\""?

3
Nejc08:08:01

It seems that I overcomplicated it...exactly

Nejc08:08:35

just tried this: ":crux.kv/db-dir \"/tmp/crux-storage/indexes\"" + an it works.

Nejc08:08:37

Thank you @U050V1N74. I needed to take a break, to try the simplest option 😅

jarohen08:08:00

no worries - often the way 🙂

Nejc08:08:39

while I'm here.. can I ask you another question @U050V1N74 regarding upcoming functionalities. I'm translating some Cypher (Neo4j) queries into Crux/Datalog and I'm looking for equivalent of OPTIONAL MATCH which is in fact an OUTER JOIN. If I understand correctly this could be achieved by get-else which is not yet supported by Crux ATM. Is there any road map on this? I couldn't find any Github issue/task on this matter. Could I achieve "outer join" in any other way? Possibly by custom predicate function call as the docs suggests.

jarohen08:08:08

it's currently an internal implementation detail, so might change between releases - but you could try get-attr

{:find [name]
 :where [[e :crux.db/id :foo]
         [(get-attr e :name "default") name]]}

Nejc08:08:24

Thanks! will do.

jarohen08:08:28

I should say - "default" is optional - you can leave it out and it'll return null instead

👍 3