neo4j 中的基于时间的数据 [英] Time-based data in neo4j

查看:77
本文介绍了neo4j 中的基于时间的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个关于图数据库的问题,有人可以帮我吗?我是在mysql中处理相当多的数据,每天大约有500万条记录由一个发送路由器之类的设备、接入点、无线网桥.数据是通常是健康数据、gps 等……这些是车辆上的设备.怎么办您在图形数据库中处理基于时间的数据?有没有人申请neo4j 用于基于时间的数据?很高兴知道您如何查询间隔以及您将如何进行建模.

have a question on graph databases, can some one help me please? I'm handling quite a lot of data in mysql about 5M records a day sent by a router like device, access points, wireless bridges. The data is usually health data, gps etc... these are devices on vehicles. How do you handle time based data in graph databases? Has anyone applied neo4j for time-based data? It would be great to know how you query intervals and how you'd go about modelling.

我想我可以为每次接收数据时创建一个节点每次设置的属性都像改变了gps,健康?这将是一个时间基于图形 - 听起来对吗?有 500 万行 mysql 的表现并不差 - 但随着路由器变得新功能新数据通过,我需要创建新模型再一次,这还不错,但也不是很好.我想要一些半结构化的东西,使相关性不同诸如用户被踢出的原因是因为接入点关联到路由器已关闭.我通常的疑问是提出警告说其中一个设备已关闭或是否减少了吞吐量等.neo4j 会帮助我结合这些关系吗比mysql好吗?

I guess I can create a node for every single time i receive data with properties set each time like changed gps, health? It would be a time based graph - does that sound right? well with 5M rows mysql isn't performing bad - but as router gets new functionality new data comes through and I need to create new models again which isn't bad but not great. i want something which is semi structured and makes relating different things like why the user got kicked out is because of an access point associated to the router is down. My usual queries would be to raise alerts to say one of the device is down or if there is a reduced throughput etc. Would neo4j help me in marrying up these relationships better than mysql?

很想知道你们的想法,任何评论+想法赞赏.

Would love to know what you guys think, any comments + thoughts appreciated.

推荐答案

有关如何使用时间尺度进行基于时间的图形存储的教程,请参阅以下 GraphGist.

Please refer to the following GraphGist for a tutorial on how to do time-based graph storage using time scales.

http://gist.neo4j.org/?github-kbastani%2Fgists%2F%2Fmeta%2FTimeScaleEventMetaModel.adoc

在上面建模的时间尺度图中,从蓝色节点到透明颜色节点的最短路径遍历构成了以比特为单位的唯一时间标识.

In the time scale graph that is modeled above, a shortest path traversal from a blue colored node to the transparent colored node constitutes a unique time identity in bits.

红色路径追踪的身份是0→1→0→1→0→0.反向路径是 0→0→1→0→1→0 或简单的 001010,以比特为单位的唯一标识.

The identity traced by the red path is 0→1→0→1→0→0. The reverse path is 0→0→1→0→1→0 or simply 001010, a unique identity in bits.

MATCH p=shortestPath((n1:d)-[:child_of*]->(n2:y))
WHERE n1.key = 'd10'
RETURN DISTINCT reduce(s = '' , n IN nodes(p)| n.tempo + s) AS TimeIdentity
ORDER BY TimeIdentity

上面的 Cypher 查询模拟了从蓝色节点到透明颜色节点的最短路径遍历.这是一个位串,表示可以根据事件在时间尺度事件子图上的位置按事件排序的时间标识.

The Cypher query above models a shortest path traversal from blue colored node to transparent colored node. This is a bit string that represents a time identity that can be ordered by event depending on its position on the time scale event subgraph.

请看下面的时间尺度事件子图:

Please see the time scale event subgraph below:

上图表示与一系列事件(遇见)相关的时间尺度.事件在图像中表示为三角形节点,也连接到特征层次(John、Sally、Pam、Anne),然后进一步泛化为类(人).

The image above represents a time scale connected to a series of events (met). Events, represented as triangular nodes in the image, are also connected to a hierarchy of features (John, Sally, Pam, Anne) which are then further generalized into classes (Person).

现在您可以像我之前列出的那样运行 Cypher 查询,然后将事件按发生时间排序为位字符串.注意:您应该将时间戳应用于检索实际时间的节点.每个蓝色节点代表一个时间间隔事件,但不一定是实际时间,只是按顺序发生的事件的表示.

Now you can run a Cypher query like the one I listed earlier which will then order the events by time of occurrence as a bit string. Note: That you should apply a timestamp to the node that retrieves the actual time. Each blue node represents a time separated event but not necessarily the actual time, just a representation of events that happened in an order.

MATCH p=(p0:person)-[:event]->(ev)-[:event]->(p1:person)
WITH p, ev
MATCH time_identity = (d0:d)<-[:event]-(ev)
WITH d0, p
MATCH p1=(d0)-[:child_of*]->(y0:y)
RETURN extract(x IN nodes(p)| coalesce(x.name, x.future)) AS Interaction, reduce(s = '' , n IN nodes(p1)| n.tempo + s) AS TimeIdentity
ORDER BY TimeIdentity

时间尺度中的层次结构允许您对事件进行分组并查看更高级别的表示.因此,选择橙色节点下方的所有绿色节点将选择 4 个可能的事件(由蓝色节点表示).

The hierarchies in the time scale allow you to group events and to see representations at higher levels. So selecting all green nodes below an orange node selects 4 possible events (represented by blue nodes).

如果您有任何问题,请告诉我,并确保访问 GraphGist 以查看时间尺度事件子图的更多详细信息和实际示例.

Let me know if you have any questions, and be sure to visit the GraphGist to see more details and actual live examples of the time scale event subgraph.

这篇关于neo4j 中的基于时间的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆