ignite - Apache 点燃.Net 2.8.1 : Affinity collocation with QueryEntity

标签 ignite

我在 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 will be halted immediately due to the failure: [failureCtx=FailureContext [type=CRITICAL_ERROR, err=class o.a.i.i.processors.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=Runtime failure on row: Row@29db2fbe[ key: AffinityKey [idHash=8137191, hash=783909474, key=3, affKey=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 will be halted immediately due to the failure: [failureCtx=FailureContext [type=CRITICAL_ERROR, err=java.lang.ClassCastException: class o.a.i.cache.affinity.AffinityKey cannot be cast to class java.lang.Integer (o.a.i.cache.affinity.AffinityKey is in unnamed module of loader 'app'; java.lang.Integer is in module java.base of loader 'bootstrap')]]

我做错了什么?感谢您的帮助!

最佳答案

KeyFieldName = "Id" 设置是问题所在。它设置了 Id 字段作为缓存键,该字段为 int,但是随后我们使用 AffinityKey 作为缓存键,这会导致类型不匹配。

在这种情况下,我认为我们根本不需要 KeyFieldName,删除它可以解决问题,并且 SELECT 查询不应受到此更改的影响。

关于ignite - Apache 点燃.Net 2.8.1 : Affinity collocation with QueryEntity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64452502/

相关文章:

c# - Apache ignite 缓存查看器(如 Redis 桌面管理器)

java - 关于 Ignite AffinityKey 的严重问题

java - 单个 Ignite 节点不会停止 TCP 发现

java - 如何使用JAVA SQL语句在每个Apache ignite缓存中创建表?

ignite:使用 igniteCache 时 strip 池中可能出现饥饿

.net - apache ignite .net 计划任务

java - Ignite集群不同启动时间

c# - Apache Ignite .Net 客户端服务器连接

xml - 无法使用WSL将第二个节点加入Apache Ignite集群

java - 点燃连续查询: Failed to initialize a remote filter