datalevin

fs42 2024-08-15T22:41:26.499809Z

Ok... I did some more testing and for integer and string keys as :data it seemed to work - after :put values in, a get-range yielded for longs and strings: [[-4 4] [-1 1] [2 2] [3 3]] [["1" 1] ["2" 2] ["3" 3] ["4" 4]] -- that's what I based my assumptions on before last night. I did the same tests with slightly different values and it yielded: [[2 2] [3 3] [-11 1] [-444 4]] [["333" 3] ["44444444444" 4] ["111111111111" 1] ["222222222222222" 2]] -- Guess it convincingly shows that very simple test cases may sometimes be too simple to reveal correct usage issues 🫤 The conclusion is: don't use :data for keys in the kv-store!

fs42 2024-08-15T22:46:45.142429Z

When I re-did those examples with the explicit scalar data types, it all works as expected. The one thing I discovered was that I could use the get-range function with a defined range like: (d/get-range db dbi [:closed java.lang.Long/MIN_VALUE java.lang.Long/MAX_VALUE] :long :data) to obtain all the kv's with a :long key as a sorted list. Not sure if there is another recommended range definition to retrieve the equivalent (?)

fs42 2024-08-16T07:08:45.074259Z

:db.value/sysMin and db.value/sysMax
only seem to work as the key value in a tuple,
and not as a scalar value...
Is that correct?

Huahai 2024-08-16T07:15:32.557349Z

no, they are the default range boundary for any type of scalar value

Huahai 2024-08-16T07:18:39.862779Z

ok, they are for Datalog store, so may not work in a kv store, for the translation is not done

Huahai 2024-08-16T07:22:18.129739Z

In any case, if you are already doing complex indexing things in a KV context, you should consider whether or not Datalog store is relevant for your use case, because you might be re-implementing features that Datalog store already offer.

Huahai 2024-08-16T07:25:58.127769Z

My recommendation is to start with Datalog features to see if they solve your problem, unless you are only interested in low level KV features, or have custom needs that the Datalog store does not meet.

fs42 2024-08-16T17:30:26.872069Z

Appreciate your suggestion. My goal was/is to use the kv-store as the raw db for some live data feeds. I'm planning to use the datalog-db for slicing and querying but it requires a bit of fine tuning how to model that data in the db. Having all the raw data in the kv-store allows me to blow-away and rebuild the db easily... So a basic kv-store functionality should be enough - I just got tripped up by a couple of misunderstandings on my part how datalevin's kv-store works... I'll use the coming days to come to my own conclusion whether it is a viable approach or now... or whether I should just use the datalog db as a raw kv-store and from there refine the data model in a separate datalog db... dunno what's best.

Huahai 2024-08-17T02:14:05.137139Z

👍

Huahai 2024-08-16T01:51:03.032989Z

:db.value/sysMin and db.value/sysMax work for any type

fs42 2024-08-16T03:23:32.961829Z

Cool! (Did i miss that somewhere in the documentation?)

Huahai 2024-08-16T03:24:00.460679Z

Not documented

👍 1
fs42 2024-08-15T22:53:02.780569Z

It also works with strings in a [:keywork :string] tuple as key: (d/get-range db dbi [:closed [:abc MIN_UNICODE_STRING_CHAR] [:abc MAX_UNICODE_STRING_CHAR]] [:keyword :string] :data) -- Defining a range like that allows you to find the number of items with a key of [:abc "a-str"], and the first and last item in that list. Anyway, guess my comprehension level of the datalevin KV-store has progressed from a 101 to 201 over the last days 😉

👍 1