ignite - Apache Ignite .Net 2.8.1:与 QueryEntity 的亲和搭配
问题描述
我在 Windows 10 机器上使用 Apache Ignite v.2.8.1 .Net。
我正在尝试在启用查询的缓存上使用亲和力搭配。我存储在缓存中的实体有一个名为“Id”的主键和一个名为“PartnerId”的关联键。两个键都是 Int32 类型。我将缓存定义如下:
new CacheConfiguration("BespokeCharge")
{
KeyConfiguration = new[]
{
new CacheKeyConfiguration()
{
AffinityKeyFieldName = "PartnerId",
TypeName = typeof(BespokeCharge).Name
}
}
};
接下来我使用以下代码添加数据:
var cache = Ignite.GetCache<AffinityKey, BespokeCharge>("BespokeCharge")
cache.Put(new AffinityKey(entity.Id, entity.PartnerId), entity)
到目前为止,一切都很好。因为我希望能够使用 SQL 来搜索定制费用,所以我还添加了一个 QueryEntity 配置:
new CacheConfiguration("BespokeCharge",
new QueryEntity(typeof(AffinityKey), typeof(BespokeCharge))
{
KeyFieldName = "Id",
TableName = "BespokeCharge"
})
{
KeyConfiguration = new[]
{
new CacheKeyConfiguration()
{
AffinityKeyFieldName = "PartnerId",
TypeName = typeof(BespokeCharge).Name
}
}
};
当我运行代码时,Ignite 和我的应用程序都崩溃了,并且记录了以下错误:
由于失败,JVM 将立即停止:[failureCtx=FailureContext [type=CRITICAL_ERROR, err=class oaiiprocessors.cache.persistence.tree.CorruptedTreeException: B+Tree is corrupted [pages(groupId, pageId)=[IgniteBiTuple [val1= 1565129718, val2=844420635164729]], cacheId=-1278247946, cacheName=BESPOKECHARGES, indexName=BESPOKECHARGES_ID_ASC_IDX, msg=行上运行时失败: Row@29db2fbe[键: AffinityKey [idHash=8137191, hash=7839key=94447 2], val: UtilityClick.BillValidation.Shared.InMemory.Model.BespokeCharge [idHash=889383506, hash=-399638125, BespokeChargeTypeId=4, ChargeValue=100.0000, ChargeValueIncCommission=100.0000, Id=3, PartnerId=2, QuoteRecordId=5] ][ 4, 100.0000, 100.0000, , 2, 5 ]]]]
当我尝试使用 int 而不是 AffinityKey 的键类型定义 QueryEntity 时,我得到了一个具有相同结果的不同错误——崩溃。
由于失败,JVM 将立即停止:[failureCtx=FailureContext [type=CRITICAL_ERROR, err=java.lang.ClassCastException: class oaicache.affinity.AffinityKey cannot be cast to class java.lang.Integer (oaicache.affinity.AffinityKey is在加载程序“app”的未命名模块中;java.lang.Integer 在加载程序“bootstrap”的模块 java.base 中)]]
我究竟做错了什么?谢谢您的帮助!
解决方案
KeyFieldName = "Id"
设置是问题。它将Id
字段设置为用作缓存键,即int
,但随后我们将AffinityKey
其用作缓存键,这会导致类型不匹配。
在这种情况下,我认为我们根本不需要KeyFieldName
,删除它可以解决问题,并且SELECT
查询不应受到此更改的影响。
推荐阅读
- ios - 如何在不发送请求的情况下拦截 Moya 请求并返回失败响应
- javascript - 如何通过 Suitescript 2.0 在已保存搜索中应用多个过滤器?
- node.js - 抱歉,nodist 有问题。尝试启动新的 npm 项目时
- mysql - mySql SELECT GROUP_CONCAT 查询不返回长文本单元格中的所有数据
- java - JPA EntityManger 事务提交错误
- javascript - Core-js,如何仅包含所需的 polyfill
- lua - 无法让 PlayerSay 在 Gmod lua 插件中工作
- security - 如何处理用户输入文件(图像/视频)?
- odoo - Paypal在ODOO 12中从报价到销售订单
- python - 如何修复多处理方法的重复输出?