简体   繁体   English

对帐-是否有任何基于Java的库?

[英]Reconcillation - any java based library?

I am coding a java based component to do some reconcilliation of about a million data items (hence performance is of paramount importance). 我正在编码一个基于Java的组件来对大约一百万个数据项进行协调(因此性能至关重要)。

The two sources of data are 1. A table in a database 2. A flat file. 数据的两个来源是1.数据库中的表2.平面文件。

There are a couple of columns in the database, that should match up to the a couple of columns in the file. 数据库中有两列,应该与文件中的两列匹配。 The data are not sorted or anything. 数据未排序或其他任何内容。 So each data item (lets say it is a name and corresponding phone number) should be same in the database and in the flat file. 因此,数据库和平面文件中的每个数据项(可以说这是一个名称和相应的电话号码)都应该相同。 Eg if one of the rows in database says for "john" the number is "220 343 123" then the row in the flat file for "john" must have number as "220 343 123". 例如,如果数据库中的某一行说“ john”,则数字是“ 220 343 123”,则平面文件中“ john”的行必须具有“ 220 343 123”。 If not, I report a break and move on. 如果没有,我报告休息并继续前进。

Of course I could pick up each row (from database) and try to match it to some row in the file (horrible persformance). 当然,我可以从数据库中选取每一行,然后尝试将其与文件中的某一行进行匹配(性能差)。 Or I could, sort the table and the file (somehow) before I do that (still clunky) Or ... something else 或者我可以(在某种程度上)对表格和文件进行排序(仍然很笨拙),或者...其他

The question to the forum is, do you know of any library / tool (in java world) that could be leveraged for this? 论坛的问题是,您知道在Java世界中可以利用的任何库/工具吗?

Thanks. 谢谢。

You could read the flat file and put the data in some kind of Map structure. 您可以读取平面文件,并将数据放入某种Map结构中。 Next, you iterate through the database lines and compare with the values in the Map . 接下来,您遍历数据库行并与Map的值进行比较。

This way you only iterate both sources of data once... 这样,您只需要迭代两个数据源一次...

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

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