sharding (data): Add SHARDID condition.

This commit is contained in:
2021-12-22 10:34:34 +02:00
parent f3cf4fcb5a
commit d498673020

View File

@@ -70,5 +70,17 @@ class Constant(Condition):
conditions.append("{} {}".format(key, self.value)) conditions.append("{} {}".format(key, self.value))
class SHARDID(Condition):
__slots__ = ('shardid', 'shard_count')
def __init__(self, shardid, shard_count):
self.shardid = shardid
self.shard_count = shard_count
def apply(self, key, values, conditions):
conditions.append("({} >> 22) %% {} = {}".format(key, self.shard_count, _replace_char))
values.append(self.shardid)
NULL = Constant('IS NULL') NULL = Constant('IS NULL')
NOTNULL = Constant('IS NOT NULL') NOTNULL = Constant('IS NOT NULL')