【面经】360大数据开发面经

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。

在这里插入图片描述

反问
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值