在java中实现不含数据库的不同类型的联接 [英] Implementing different types of joins without database in java
本文介绍了在java中实现不含数据库的不同类型的联接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个CSV文件,每个文件包含50条记录。现在我必须从这些CSV文件中读取值,并执行不同的连接操作(完全外连接,左外连接等)。
I have 2 CSV files which contain 50 records of each. Now I have to read values from these CSV files and perform different join operation (full outer join, left outer join, etc). How do I do this?
推荐答案
在内存中加载这两个文件,并使用循环:
Load those two files in memory, and use loops:
private List<TwoRecords> innerJoin(List<Record1> list1, List<Record2> list2) {
List<TwoRecords> result = new ArrayList<TwoRecords>();
for (Record1 r1 : list1) {
for (Record2 r2 : list2) {
if (r1.getSomeField() != null
&& r1.getSomeField().equals(r2.getSomeField())) {
result.add(new TwoRecords(r1, r2));
}
}
}
return result;
}
这篇关于在java中实现不含数据库的不同类型的联接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文