Clickhouse分布式表按照offfset分区

2023-04-18  本文已影响0人  和平菌

bitShiftRight(offset, 20)

public static long getShardNumByOffset(long offset) {
        long shardKey = offset >> 20;
        int totalWeight = 20;
        long divider = Integer.toUnsignedLong(totalWeight);
        long shardNum = (long) shardKey - (long) shardKey / divider * totalWeight + 1;
        return shardNum;
    }
上一篇 下一篇

猜你喜欢

热点阅读