indexing - 基于父子索引点燃 CacheQuery
问题描述
使用点燃 2.9.x
我有两个 BinaryObject 缓存,一个用作父级,另一个用作子级,具有与父级的关联键,这样我可以将所有相关记录放在同一个节点上。
然后我想根据父键选择所有子记录。目前基于 3 节点集群,搜索时间随着我添加新的父子记录而线性增长(每个父子记录是固定的(1000))。
我想知道是否有办法在子缓存父属性(资产)上添加索引,以便扫描更有效地扩展。
生产..>资产(资产)
- 我可以使用父键资产在生产缓存上定义索引吗?
- 这个配置会是什么样子?
- 查询将如何变化?
- 在这种情况下我应该使用 AffinityKey(如何)?
IgniteCache<Integer, BinaryObject> productions = ignite.cache("productions").withKeepBinary();
Map<LocalDate, Double> totals = new HashMap<>();
try (QueryCursor<Cache.Entry<BinaryObject, BinaryObject>> cursor =
productions.query(
new ScanQuery<BinaryObject, BinaryObject>().setLocal(true).setFilter(this::apply))) {
for (Cache.Entry<BinaryObject, BinaryObject> entry : cursor) {
OffsetDateTime timestamp = entry.getValue().field("timestamp");
double productionMwh = entry.getValue().field("productionMwh");
totals.computeIfPresent(
timestamp.toLocalDate().withDayOfMonth(1),
(localDate, aDouble) -> aDouble + productionMwh);
totals.computeIfAbsent(
timestamp.toLocalDate().withDayOfMonth(1), localDate -> productionMwh);
}
}
private boolean apply(BinaryObject id, BinaryObject production) {
return key == ((Integer) production.field("asset"));
}
解决方案
实现有效的父->子链接的唯一方法是为您的数据定义SQL 表和 SQL 索引。您仍然可以在亲和列上搭配此类数据。
推荐阅读
- javascript - 如何为 D3 图表启用静态链接
- python - 如何使用 Skimage 调整训练数据的大小?
- c# - 创建 3D 阵列意见系统
- list - Haskell:如何创建一个空列表作为数据类型的选项?
- javascript - 在 SVG 路径中移动到鼠标单击 (d3.js)
- deep-learning - 推理时间短的分类模型
- php - 如何进行批量操作以将文件复制到谷歌驱动器,php?
- python-3.x - 在使用 Pandas Dataframe 生成的 CSV 中添加自定义页眉和页脚
- server - 将主 OPC UA 服务器连接到辅助 OPC UA 服务器
- amazon-web-services - 如何将 AWS Shield Advance 保护添加到我的堆栈?