大容量可查询和可遍历的数据结构
我正在构建一个应用程序,需要一个可以查询和遍历的互连对象的数据结构。对象之间的连接可以是任意的,并且不一定事先已知。我需要这个数据结构是可查询的(通常的 SQL 提供的)并且也是可遍历的(像 Neo4j 这样的新图形数据库提供的)。我正在尝试找到一种既能同时完成这两个任务又能有效地处理非常大的数据集的东西。我们称这个数据结构为dao。我需要以下原始方法:
// dealing with the objects
dao.save(s);
Something s = dao.load(Something.class, 5);
dao.update(s);
dao.delete(s);
// dealing with the relations
dao.relate(s, t);
dao.unrelate(s, t);
// the tricky methods
dao.querier(Something.class).filter(...).sort(...).values();
dao.traverser(Something.class).start(s).path(...).filter(...).sort(...).values();
filter 类似于 sql where 子句,sort 类似于 sql order 子句,start< /strong> 将是遍历的起始节点,路径 将定义 BFS 和 DFS 遍历以及何时停止搜索等内容。
我尝试将其建模为带有邻接列表的顶点,但必须有更好的方法。有什么想法吗?
I'm building an application and need a data structure of interconnected objects that can be queried and traversed. The connections between objects can be arbitrary and not necessarily known before hand. I need this data structure to be queryable (what usual SQL provides) and also traversable (what new graph database like neo4j provide). I'm trying to get something that does both and works with very large data sets efficiently. Let's call this data structure dao. I would need the following primitive methods:
// dealing with the objects
dao.save(s);
Something s = dao.load(Something.class, 5);
dao.update(s);
dao.delete(s);
// dealing with the relations
dao.relate(s, t);
dao.unrelate(s, t);
// the tricky methods
dao.querier(Something.class).filter(...).sort(...).values();
dao.traverser(Something.class).start(s).path(...).filter(...).sort(...).values();
The filter would be something like the sql where clause, the sort would be something like the sql order clause, the start would be the starting node for the traversal, and the path would define things like BFS and DFS traversing as well as when to stop searching.
I've tried to model this as vertices with an adjacency list but there must be a better way. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,Neo4j 将是一个不错的选择。除了 Java 的原始用法之外,Jo4neo 还为您的对象模型提供基于注释的持久性图形。对于查询,您可以使用 Neo4j 高速 Java Traversers,或者使用诸如 JRuby Wrapper 之类的东西,它确实为来自 JRuby 的查询提供了非常方便的抽象。此外,Gremlin 专门用于深度图遍历,但尚未针对速度进行优化。
Yes, Neo4j would be a good option. Beside the raw usage from Java, Jo4neo provides annotation-based persistence for your object model onto the graph. For querying, you either can use the Neo4j high speed Java Traversers, or use things like the JRuby Wrapper that does provide very convenient abstractions for queries from JRuby. Also, Gremlin is specialized on deep graph traversals, but not yet optimized for speed.
也许使用 Neo4j 的 sparql 查询引擎?
maybe using the sparql query engine for neo4j?