30 分钟,不做题。
欢迎点击此处关注公众号,每天分享大数据开发面经
介绍实习项目
会涉及平台开发吗
平时常用的语言
回答了 Java。
Python 用过吗
Java 实现一个单例要注意什么
懒汉式:
public class Singleton {
private static Singleton singleton;
private Singleton(){} // 注意要用 private
public static Singleton getInstance() {
if (singleton == null) {
singleton = new Singleton();
}
return singleton;
}
}
多线程情况下保证只创建一个对象:
public class Singleton {
private static Singleton singleton;
private Singleton(){}
public static Singleton getInstance() {
// 线程A和线程B同时看到singleton = null,如果不为null,则直接返回singleton
if (singleton == null) {
// 线程A或线程B获得该锁进行初始化
synchronized(Singleton.class) {
// 其中一个线程进入该分支,另外一个线程则不会进入该分支
if (singleton == null) {
singleton = new Singleton();
}
}
}
return singleton;
}
}
数仓分了哪些层次
你的工作是哪一部分
做过实时吗
ES 用来干什么
场景题
问:两个很大的文件,一个文件里存储的 id 和 phone,一个文件里存储的 id 和 name。两个文件里的 id 是对应关系。用大数据的 MR 来处理这两个文件,得到 phone 和 name 的对应关系应该怎么做。
一道常考题,如何用 MapReduce 实现 join 操作。基本原理:
- map 阶段同时读取两个文件 file1 和 file2;
- 处理成 key-value 的形式:
- 对于 file1,key 为 id,value 为 phone;
- 对于 file2,key 为 id,value 为 name;
- 为了区分数据来自哪个文件,在 value 中做 tag 标记:
- 对于 file1,key 为 id,value 为 phone,value 中增加 tag 标记 a;
- 对于 file2,key 为 id,value 为 name,value 中增加 tag 标记 b;
- 通过 key 计算 hash 值,reduce 去拉去,相同的 key 一定会进入同一个 reduce 中处理。
- reduce 中根据 tag 区分是哪一个文件中的数据,将两个文件中的数据做笛卡尔积,此时得到的 key 为 id,value 为 phone,name。