gpt4 book ai didi

java - 如何在 Java 中存储类似 Matrix 或 Table 的数据并有效地从中检索?

转载 作者:行者123 更新时间:2023-11-29 03:47:55 25 4
gpt4 key购买 nike

我必须存储具有大约 1000 万行和多个列的大型数据表。我需要做的事情可以总结如下:

1.Based on the values in columns I need to select some of the rows.

示例:

第 500 行:|10|3|4|5|100|314|45|

第 501 行:|13|5|7|4|160|210|40|

第 501 行:|24|3|8|6|260|810|50|

第 602 行:|34|7|9|6|350|760|10|

在这里,第一列的值可以认为是行ID。这里的 ID 是 10,13,24,34

假设我正在搜索第 4 列中值 >=5 的那些行。因此,过滤后的输出将是:

第 500 行:|10|3|4|5|100|314|45|

第 501 行:|24|3|8|6|260|810|50|

第 602 行:|34|7|9|6|350|760|10|

2.In the second step i need to compare between them in a column-wise fashion. Suppose, row 500 has values 3 and 4 respectively in its 2nd and 3rd column , which(3-4) also falls in the range (3-8). But this range does not coincide with (7-9)

所以第 500 行和第 501 行之间存在关系。输出将是:

10 24

24 34

3.Suppose i am given the value 10. Then i need to find row having 10 in its first column and reduce the value in the 7th column by 5. So the row will now look like:

第 500 行:|10|3|4|5|100|314|40|

到目前为止,我使用 Matlab 非常容易地使用 Matlab 库函数进行这些操作。但是我需要用 Java 转换整个代码。一种方法是使用大型数组并使用 for 循环访问每一行。这么大的阵列会有效率吗?请在这方面帮助我。

最佳答案

首先,我建议使用内存中的 RDBS,如 SQLLite , HyperSQL , JavaDB

在那之后你可以看看Table在谷歌的 Guava 库中。

使用 HashBasedTable 进行基于行的查找最快和 TreeBasedTable , 但您可能需要考虑 ArrayTable因为看起来您的数据并不稀疏。

最后看看this question .

关于java - 如何在 Java 中存储类似 Matrix 或 Table 的数据并有效地从中检索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10061654/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com