【发布时间】:2021-03-01 21:59:55
【问题描述】:
根据很多地方的建议,我正在使用 FNV-1 方法为具有 5 个分区的 Service Fabric 群集生成分区键,如下所示:
[
{
"lowKey": -5534023222112865000,
"highKey": -1844674407370955300,
"id": "92b4c32e-cb3c-432f-aea0-4579fc72850c",
"kind": 2
},
{
"lowKey": 5534023222112865000,
"highKey": 9223372036854776000,
"id": "dd9b084d-88fa-4773-94d9-f634d22a2c03",
"kind": 2
},
{
"lowKey": -9223372036854776000,
"highKey": -5534023222112865000,
"id": "d7322e52-cf1e-47c2-b713-e983f443b533",
"kind": 2
},
{
"lowKey": -1844674407370955300,
"highKey": 1844674407370955300,
"id": "dfe2f994-bdc7-4b32-b54f-78a0245e4c4c",
"kind": 2
},
{
"lowKey": 1844674407370955300,
"highKey": 5534023222112865000,
"id": "6ad81ffb-5f3c-48ba-91d9-e65b23c528a4",
"kind": 2
}
]
我想检查我的数据分布情况。
但是,我不知道该怎么做,因为数字太大了。
我假设我必须为此使用 LowKey="-9223372036854775808" HighKey="9223372036854775807"?
如果是这样,这些数字太大/太小,我无法在 SQL 或 C# 中处理(C# 因为常量太大)。
有没有办法解决这个问题?如果我尝试将这些值保存在我的数据库中,我会遇到溢出问题。
我使用的是 SQL Server 2017。
DECLARE @tbl TABLE(LowKey BIGINT, HighKey BIGINT, TotalITems INT)
INSERT INTO @tbl(LowKey, HighKey, TotalITems) VALUES (5534023222112865000, 9223372036854776000, 0)
INSERT INTO @tbl(LowKey, HighKey, TotalITems) VALUES (-9223372036854776000, -5534023222112865000, 0)
INSERT INTO @tbl(LowKey, HighKey, TotalITems) VALUES (-5534023222112865000, -1844674407370955300, 0)
INSERT INTO @tbl(LowKey, HighKey, TotalITems) VALUES (-1844674407370955300, 1844674407370955300, 0)
INSERT INTO @tbl(LowKey, HighKey, TotalITems) VALUES (1844674407370955300, 5534023222112865000, 0)
前两行因错误而失败
Msg 8115, Level 16, State 2, Line 168
Arithmetic overflow error converting expression to data type bigint.
这是我用来查看分区的逻辑:
[ActionName("GetPartitions")]
public async Task<ActionResult> GetPartitionsAsync()
{
var result = new List<ServicePartitionInformation>();
ServicePartitionList partitions = await FabricClient.QueryManager.GetPartitionListAsync(FullServiceName).ConfigureAwait(false);
foreach (var partition in partitions)
{
result.Add(partition.PartitionInformation);
}
return new JsonResult(result);
}
保罗
【问题讨论】:
标签: c# azure hash azure-service-fabric service-fabric-stateful