尚硅谷大数据技术之电信客服

3.3.3 环境准备

1) 新建module:ct_analysis

pom文件配置:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"

         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.atguigu</groupId>

    <artifactId>ct_analysis</artifactId>

    <version>1.0-SNAPSHOT</version>

    <properties>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    </properties>

    <dependencies>

        <dependency>

            <groupId>junit</groupId>

            <artifactId>junit</artifactId>

            <version>4.12</version>

            <scope>test</scope>

        </dependency>

<dependency>
           <groupId>org.apache.hbase</groupId>
           <artifactId>hbase-client</artifactId>
           <version>1.3.1</version>
        </dependency>        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-server</artifactId>
            <version>1.3.1</version>
        </dependency>

        <dependency>

            <groupId>mysql</groupId>

            <artifactId>mysql-connector-java</artifactId>

            <version>5.1.27</version>

        </dependency>

    </dependencies>

</project>

2) 创建包结构,根包:com.atguigu(不同颜色代表不同层级的递进)

表11

analysis

constants

utils

analysis.converter

 

 

analysis.format

analysis.kv

analysis.mapper

analysis.reducer

analysis.runner

analysis.converter.impl

 

 

analysis.kv.base

analysis.kv.impl

3) 类表

12

类名

备注

CountDurationMapper

数据分析的Mapper类,继承自TableMapper

CountDurationReducer

数据分析的Reducer类,继承自Reduccer

CountDurationRunner

数据分析的驱动类,组装Job

MySQLOutputFormat

自定义Outputformat,对接Mysql

BaseDimension

维度(key)基类

BaseValue

值(value)基类

ComDimension

时间维度+联系人维度的组合维度

ContactDimension

联系人维度

DateDimension

时间维度

CountDurationValue

通话次数与通话时长的封装

JDBCUtil

连接Mysql的工具类

JDBCCacheBean

单例JDBCConnection

IConverter

转化接口,用于根据传入的维度对象,得到该维度对象对应的数据库主键id

DimensionConverter

IConverter实现类,负责实际的维度转id功能

LRUCache

用于缓存已知的维度id,减少对mysql的操作次数,提高效率

Constants

常量类