简体   繁体   English

收集和过滤大量数据

[英]Collecting & filtering a large amount of data

I have little JAVA coding experience (some classes at university) but none in the area of data collecting. 我几乎没有JAVA编码经验(大学里有一些课程),但是在数据收集方面却没有。

I want to monitor all the messages send on a CAN bus & store these temporarily to filter them afterwords so I can isolate some specific messages. 我想监视在CAN总线上发送的所有消息,并临时存储这些消息以过滤后缀,以便隔离某些特定消息。

This means I have to store a maximum of 17543 messages of 1 byte every second. 这意味着我必须每秒存储最多1个字节的17543条消息。 I would like to store - at least - a couple of tens of seconds. 我想存储-至少-几十秒。

What the best way to do this? 最好的方法是什么?

Can I just store all of these in an array? 我可以将所有这些存储在一个数组中吗? Would it be better to use a database (such as Hibernate)? 使用数据库(例如Hibernate)会更好吗?

I know this is rather open-ended but I would like to get an idea of what's possible and what's the best direction to handle this. 我知道这是开放性的,但是我想知道什么是可能的,什么是处理此问题的最佳方向。

So, you get (at most) 17,543 messages per second, each of which is only 1 byte, and you'll want to store a couple of tens of seconds? 因此,您每秒最多(最多)获得17,543条消息,每条消息只有1个字节,并且您想存储几十秒?

That's not a lot of data, and you can easily store that in an array in memory. 这不是很多数据,您可以轻松地将其存储在内存中的数组中。 Suppose you want to store the messages of 1 minute, that would be 17,543 x 60 seconds = less than 1 MB of data. 假设您要存储1分钟的消息,即17,543 x 60秒=少于1 MB的数据。 That's peanuts on modern computers. 那是现代计算机上的花生。 A database would be overkill. 数据库将是过大的。

Hibernate is not a database. Hibernate不是数据库。 It's an ORM. 这是一个ORM。

20 seconds = 20 * 17543 bytes 
           = 350860 bytes
           = 350 KB 
           = nothing. 

Storing everything in memory wouldn't be a problem for such a small amount of data. 对于如此少量的数据,将所有内容存储在内存中都不是问题。

I have to store a maximum of 17543 messages of 1 byte every second. 我必须每秒存储最多1个字节的17543条消息。 I would like to store - at least - a couple of tens of seconds. 我想存储-至少-几十秒。

It might make sense to store the messages in a circular buffer . 将消息存储在循环缓冲区中可能很有意义。 This can be easily implemented using an array. 这可以使用数组轻松实现。

30 seconds worth of data will require ~500KB of storage. 价值30秒的数据将需要约500KB的存储空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM