Java 还原侧连接中的bloom过滤器
我目前正在探索布卢姆过滤器。我浏览了大多数关于bloom fitlers的博客,知道什么是,但仍然无法找到一个案例连接的例子 每篇文章都说它将减少网络I/O,但没有一篇文章说明如何减少网络I/O?特别的一个很好,但它看起来像我刚开始使用MapReduce一样复杂 有谁能帮助我在下面的示例中实现bloom过滤器ReduceSide join 2名绘图员读取用户记录和部门记录,并加入 用户记录 身份证,姓名 3738,里奇·戈尔 12946,Rony Sam 17556年,大卫·加特 3443,瑞秋·史密斯 5799,保罗·罗斯塔 部门记录 3738,销售 12946,市场营销 17556,市场营销 3738,销售 3738,销售 代码 和减速器Java 还原侧连接中的bloom过滤器,java,hadoop,mapreduce,bloom-filter,Java,Hadoop,Mapreduce,Bloom Filter,我目前正在探索布卢姆过滤器。我浏览了大多数关于bloom fitlers的博客,知道什么是,但仍然无法找到一个案例连接的例子 每篇文章都说它将减少网络I/O,但没有一篇文章说明如何减少网络I/O?特别的一个很好,但它看起来像我刚开始使用MapReduce一样复杂 有谁能帮助我在下面的示例中实现bloom过滤器ReduceSide join 2名绘图员读取用户记录和部门记录,并加入 用户记录 身份证,姓名 3738,里奇·戈尔 12946,Rony Sam 17556年,大卫·加特 3443,瑞秋
ublic class JoinReducer extends MapReduceBase implements Reducer<Text, Text, Text, Text> {
private Text tmp = new Text();
private ArrayList<Text> listA = new ArrayList<Text>();
private ArrayList<Text> listB = new ArrayList<Text>();
public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text>output, Reporter reporter) throws IOException {
listA.clear();
listB.clear();
while (values.hasNext()) {
tmp = values.next();
if (tmp.charAt(0) == 'A') {
listA.add(new Text(tmp.toString().substring(1)));
} else if (tmp.charAt(0) == 'B') {
listB.add(new Text(tmp.toString().substring(1)));
}
}
executejoinlogic(output);
}
private void executejoinlogic(OutputCollector<Text, Text> output) throws IOException {
if (!listA.isEmpty() && !listB.isEmpty()) {
for (Text A : listA) {
for (Text B : listB) {
output.collect(A, B);
}
}
}
}
}
在上述场景中是否可以实现bloom过滤器
如果是,请帮助我实现这一点 只有当两个输入表中的一个比另一个小得多时,才能在此处实现bloom过滤器。您需要遵循的流程如下: 在Mapper类的setup方法中初始化bloom过滤器过滤器过滤器对象本身应为全局对象,以便以后可以通过map方法访问: 过滤器=新的BloomFilterVECTOR\u大小、NB\u哈希、哈希类型 将较小的表格读入映射器的设置方法 将每个记录的ID添加到bloom筛选器: filter.addID 在映射方法本身中,对来自较大输入源的任何ID使用filter.membershipTestID。如果没有匹配项,您就知道该ID不存在于较小的数据集中,因此不应该传递给reducer 请记住,减速器中会出现误报,因此不要假设所有部件都会连接。
请原谅我再次提出一个老问题,但本的第五个问题是不正确的,我相信:我认为布卢姆过滤器不可能产生假阴性?假阳性,是的,但不是假阴性
ublic class JoinReducer extends MapReduceBase implements Reducer<Text, Text, Text, Text> {
private Text tmp = new Text();
private ArrayList<Text> listA = new ArrayList<Text>();
private ArrayList<Text> listB = new ArrayList<Text>();
public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text>output, Reporter reporter) throws IOException {
listA.clear();
listB.clear();
while (values.hasNext()) {
tmp = values.next();
if (tmp.charAt(0) == 'A') {
listA.add(new Text(tmp.toString().substring(1)));
} else if (tmp.charAt(0) == 'B') {
listB.add(new Text(tmp.toString().substring(1)));
}
}
executejoinlogic(output);
}
private void executejoinlogic(OutputCollector<Text, Text> output) throws IOException {
if (!listA.isEmpty() && !listB.isEmpty()) {
for (Text A : listA) {
for (Text B : listB) {
output.collect(A, B);
}
}
}
}
}