Language for specifying Predicate Group mapping

I was thinking about how we could specify this. Initially, a JSON file could work for us. We specify comma separated predicate prefixes with a group number.

{
     "type.object.name, film.actor.film" : 2,
     "film.performance.film" : 3
}

Internally, these can be mapped to a map[string]int. We can reserve group no. 0 and group no. 1 for the cluster-wide and the default group respectively.

Then we can have the following APIs

  1. getPredicates(group int) - To know which predicates to transfer to a new node which is part of the group.
  2. getGroup(predicate string) - To know which group to send queries and mutations to.

Would love to get your advise on this @mrjn.

We’d also need to have the modulos, where we say fp(predicate) % N + k = groupId, for some N and some k. I think for such cases JSON might not be ideal.

Given that we’d be using modulos, we won’t be able to get predicates given a group id. We can only go from predicate -> group id, not the other way round.

So do we have both the options for the user here? Like he can specify the groupIds or we calculate them using modulos?

Yes, we do have both the options. And we process the rules in the order they’re specified. So, if some predicate matches a condition listed higher, that’s the group id it would belong to.

Okay, if I understand correctly the N and k would be some sort of globals that he’d specify as part of the config?

A JSON format could still work here, instead of supplying an int, we just need a way for the user to specify that he wants the group to be calculated using modulos. Maybe he can use % .

{
     "default" : {
       "numGroups" : 100,
       "offset": 2
     },
     "predicates" : {
       "type.object.name, film.actor.film" : "2",
       "film.performance.film" : "3",
     }
}

More like,

0: _uid_
1: type.object.name.en
2: type.object.name*, film.performance.*
default: fp % 100 + 3

So, we use star as a way to depict prefixes, and use exact matches otherwise. Yeah, I think a JSON would still work.

1 Like

Thanks, I will get this done in a bit.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.