I need to maintain a tree which contains nodes with attributes which are usually or strings, new attributes can be added to a node at runtime, etc. So a graph database like Neo4j is an obvious solution. But there is a slight twist: when an attribute is changed, I need to keep a record of its old value, and be able to efficiently query these old values (in particular, queries like "give me up 25 values of attribute X of node Y, starting from time Z" to support paging, and obviously "get latest value" needs to be efficient as well). What would be a good way to represent this?
问问题
805 次
1 回答
1
TimelineIndex
除了限制点击次数外,几乎可以满足我的需求。但是从 JavaDocIndexHits
看来,如果我迭代尽可能多的我需要然后关闭迭代器,这似乎并不重要。
所以一个解决方案看起来像这样:将我需要历史记录的每个属性表示为节点;所以而不是
Sensor
-----
name = "battery"
measurement = 1
我有
Sensor attr
----- -+--> name = "measurement"
name = "battery" | value = 1
| timestamp = 100000000
|
+--> name = "measurement"
| value = 2
| timestamp = 100000001
|
+--> name = "measurement"
value = 1
timestamp = 100000002
然后我TimelineIndex
为每个Sensor
节点和每个带有历史的属性维护一个。
于 2012-05-09T22:33:03.837 回答