图表和版本控制
我有一个有向图数据结构,我试图为每个顶点实现单独的版本控制。这创造了一些有趣的场景,我非常感谢你们的任何想法。具体来说,我希望解决系统在遇到所述场景时的默认行为。
请参见下图: 图形版本
场景 1:“空指针悖论”
顶点 A已回滚至 1.0 版本。由于此回滚将向下级联其子图,因此 C 将不再指向 D。这可能会造成危险。行为应该是:
- 1.1:删除边 C -> D,创建损坏的图
- 1.2:删除 D,留下 E 孤立
- 1.3:删除 D 和 E
- 1.4:在删除所有指向 D 的边(在本例中为 E -> D)之前拒绝执行回滚
- 1. X:替代解决方案?
场景 2:“间接影响”
顶点 D 已更新,因此以下情况成立:
- D 现在是版本 1.2
- E 现在是版本 1.1
- C 现在是版本 1.3
- A 现在是版本 1.3
顶点 A 现在已滚动返回到版本 1.2,因此以下内容成立:
- A 现在是版本 1.2
- C 现在是版本 1.2
- D 现在是版本 1.1
默认行为应该是:
- 2.1:回滚 E 到 1.0
- 2.2:由于版本危险而拒绝回滚,实际上损害了功能
- 2.X:替代解决方案?
I have a directed graph data structure, where I am trying to implement individual version control for each vertex. This creates some interesting scenarios, and I would much appreciate any ideas that you guys have. Specifically, I am looking to resolve the default behavior of the system when encountering the stated scenarios.
See the following image: Graph versions
Scenario 1: "The Null Pointer Paradox"
Vertex A is rolled back to version 1.0. Since this rollback will cascade down its subgraph, C will no longer be pointing to D. This could create a hazard. Should the behavior be to:
- 1.1: Delete the edge C -> D, creating a broken graph
- 1.2: Delete D, leaving E orphaned
- 1.3: Delete D and E
- 1.4: Refuse to perform the rollback before all edges pointing to D (which would be E -> D in this case) are deleted
- 1.X: Alternative solutions?
Scenario 2: "Indirect Effects"
Vertex D is updated, so that the following holds:
- D is now version 1.2
- E is now version 1.1
- C is now version 1.3
- A is now version 1.3
Vertex A is now rolled back to version 1.2, so that the following holds:
- A is now version 1.2
- C is now version 1.2
- D is now version 1.1
Should the default behavior be to:
- 2.1: Roll back E to 1.0
- 2.2: Refuse to roll back due to version hazard, in effect impairing functionality
- 2.X: Alternative solutions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你正在处理的是一个非常复杂的问题,虽然我不知道专门针对这方面的重点研究项目,但我听到了一些解决这个问题的尝试。
基本上不可能找到一个快速而肮脏的解决方案。我可以向您指出我之前在这方面提出的问题(图表和版本控制):
我最终所做的是拒绝执行任何类型的修订控制,而是每次都创建具有新身份的新节点。我失去了回滚,我失去了任何类型的跟踪,但我保持了事情的可控性。
在实践中,您唯一能做的就是对整个图表进行修订控制。对于单个节点来说很难拥有它。您描述的所有问题都源于您跨越事务层的事实,在每个层中您都有在特定时刻形成的一致图表。如果您跨越这些层,允许顶点修订控制,您将面对沙丘大小的一堆蠕虫。
What you are handling is a very complex problem, and although I am not aware of focalized research projects specifically on this regard, I heard some attempts to manage the issue.
it's basically impossible to pull out a quick and dirty solution. I can point you to previous questions I asked on this regard (graphs and version control):
What I ended up doing was refusing to perform any kind of revision control, but instead created new nodes with new identities every time. I lose rollback, I lose any kind of tracking, but I kept the thing manageable.
In practice, the only thing you could do is to have revision control for the graph as a whole. It's very hard to have it for individual nodes. All the issues you describe arise from the fact that you are crossing-through transaction layers, where in each layer you have a consistent graph as formed in a specific moment in time. If you cross-through these layers, allowing vertex revision control, you are dealing with a can of worms, Dune sized.
在我看来,这里的粒度有些混乱。如果您仅对单个顶点进行版本控制而不对图形进行版本控制,则回滚单个顶点不应影响图形的其余部分。 OTOH,如果您想要回滚整个图表,那么您还应该对整个图表进行版本控制。
问题是,如果您只对单个顶点进行版本控制,那么您只能保证单个顶点的完整性,而不能保证整个图的完整性。因此,如果正如您所描述的那样,回滚单个顶点“波及”整个图(或至少是连接的子图),那么您不能保证最终处于一致的状态。
似乎最接近您正在尝试的研究是关于 XML 的版本控制,但是,它只处理强类型树(IOW 退化图),而不是一般图。
It seems to me that there is some confusion about the granularity here. If you only version individual vertices but not the graph, then rolling back an individual vertex should not affect the rest of the graph. If, OTOH, you want the whole graph to be rolled back, then you should also version the whole graph.
The problem is that if you only version individual vertices, then you only have integrity guarantees for individual vertices, but not for the graph as a whole. So, if, as you describe it, rolling back an individual vertex "ripples through" the whole graph (or at least the connected subgraph), then you are not guaranteed to end up in a consistent state.
The research that seems to be closest to what you are trying, is about version control for XML, which, however, only deals with strongly typed trees (IOW degenerate graphs), not general graphs.
Antiquity 是蓝图的版本化图形实现(因此它也适用于 neo4j),
看一下:https://github.com/asaf/antiquity
Antiquity is a versioned graph implementation for Blueprints (thus it works with neo4j too),
Take a look at: https://github.com/asaf/antiquity