ccorcos / triplestore-repl

2 stars 0 forks source link

Tutorial clarifications #4

Open stevekrouse opened 2 years ago

stevekrouse commented 2 years ago
  1. It took me a while to feel comfortable with this syntax filter ?person color ?color. It wasn't immediately obvious to me that the first "color" is the attribute name and the second one is the variable name (and can be anything).
  2. When you filter (=, >) does it only work on the first value? What if you want to do a comparison on the second or third values?
ccorcos commented 2 years ago
  1. yeah, this syntax is by no means "stable". The actual triplestore typescript API is quite cumbersome so this was just a quick and dirty something to play with. I don't plan on actually using this REPL here beyond demos.
  2. you can use an entire tuple for the comparators. For example, to get chet's feed after a certain datetime:
    filter ?user follows ?person, ?post author ?person, ?post datetime ?datetime, ?post text ?text | index feed ?user ?datetime ?person ?text
    scan feed >chet "2021-2021-10-18 12:04" <chet MAX

    So you can do comparisons for deeper fields and it will component-wise sort.

stevekrouse commented 2 years ago
  1. Ok, cool!
  2. I'm quite confused by this syntax! >chet date <chet MAX... huh?!
ccorcos commented 2 years ago

The following tuples are in the correct order.

[]
[a]
[a, a]
[a, b]
[b]
[b, a]
[b, b]

If I scan this index with >a !1 then I'm not going to get [b], I'm going to get [a, a]! So if I want to get the first tuple that doesn't start with a, then I need to say "greater than the last tuple that starts with a", that is [a, MAX]. Sure, I could use z instead of MAX, but even that isn't entirely correct. I'd need to use \xff but that's going to be encoding-dependent. Because what if I store numbers after strings... Then after [a, \xff] is going to be [a, -12]... Thus MAX basically indicates the largest possible value.

stevekrouse commented 2 years ago

I think I finally get it. I should parse >chet "2021-2021-10-18 12:04" <chet MAX as

>[chet, "2021-2021-10-18 12:04"] and <[chet, MAX], where you do the comparison on each element of the tuple in left-to-right order.

So it's saying get me all the elements in the index after [chet, "2021-2021-10-18 12:04"] but before [chet, MAX].

Is that right? If so, the lack of grouping is confusing!

ccorcos commented 2 years ago

Exactly

On Thu, Oct 14, 2021 at 08:10 Steve Krouse @.***> wrote:

I think I finally get it. I should parse >chet "2021-2021-10-18 12:04" <chet MAX as

[chet, "2021-2021-10-18 12:04"] and <[chet, MAX], where you do the comparison on each element of the tuple in left-to-right order.

So it's saying get me all the elements in the index after [chet, "2021-2021-10-18 12:04"] but before [chet, MAX].

Is that right? If so, the lack of grouping is confusing!

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ccorcos/triplestore-repl/issues/4#issuecomment-943452214, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANWDXZEAZL6EUE7CJ2IGHTUG3XFFANCNFSM5F4QTCIA .