在 OLAP 多维数据集中,可以对大量聚合数据进行非常快速的查找。造成这种情况的主要原因是在易于向上组合的操作中预先聚合数据(主要是 +、-、mean、std、max、min 等)。
如何在 clojure 中获得这种“反懒惰”行为?
我正在考虑类似的事情
(def world-population {:africa 4e8 ;;this is an aggregation!
:africa/liberia 3.4e6
:africa/ethiopia 7.4e7
...})
如何更新这样的数据结构并确保实体的父级也更新?是否必须推出自己的重新实现?
最佳答案
通过将数据存储在原子中,您可以添加监视 - 本质上是原子更新时的回调
类似这样的事情:
(def world-population (atom {:africa 4e8
:africa/liberia 3.4e6
...}))
(add-watch word-population :population-change-key
(fn [key ref old new]
(prn "population change")))
您可以在此基础上构建一些事件传播逻辑。
关于clojure - clojure 中的预聚合数据结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9670172/