本套系列博客從真實商業環境抽取案例進行總結和分享,並給出Spark源碼解讀及商業實戰指導,請持續關注本套博客。版權聲明:本套Spark源碼解讀及商業實戰歸做者(秦凱新)全部,禁止轉載,歡迎學習。app
週期內時長統計學習
table-->behavior_user_app_201809
rowKey-->userid:20180904
columnfamily-->timeLen
column --> appName (包名爲多個)
value --> long值
String tableName = "behavior_user_app_" + DateUtils.getMonthByHour(model.getHour());
Table table = HBaseClient.getInstance(this.props).getTable(tableName);
String rowKey = model.getUserId()+":"+DateUtils.getDayByHour(model.getHour());
table.incrementColumnValue(Bytes.toBytes(rowKey), Bytes.toBytes("timeLen"), Bytes.toBytes(model.getPackageName()), model.getTimeLen());
複製代碼
一天中不一樣時段的玩機趨勢this
table-->behavior_user_hour_time_201809
rowKey-->userid:20180904
columnfamily-->timeLen
column --> 12 13 14 ... ...(小時24個)
value --> long值
String tableName = "behavior_user_hour_time_" + DateUtils.getMonthByHour(model.getHour());
Table table = HBaseClient.getInstance(this.props).getTable(tableName);
String rowKey = model.getUserId()+":"+DateUtils.getDayByHour(model.getHour());
table.incrementColumnValue(Bytes.toBytes(rowKey), Bytes.toBytes("timeLen"), Bytes.toBytes(DateUtils.getOnlyHourByHour(model.getHour())), model.getTimeLen());
複製代碼
一個月中不一樣天數的玩機趨勢spa
table-->behavior_user_day_time_201809
rowKey-->userid
columnfamily-->timeLen
column --> 1 2 3 ... ...(天數:31)
value --> long值
String tableName = "behavior_user_day_time_" + DateUtils.getMonthByHour(model.getHour());
Table table = HBaseClient.getInstance(this.props).getTable(tableName);
String rowKey = String.valueOf(model.getUserId());
table.incrementColumnValue(Bytes.toBytes(rowKey), Bytes.toBytes("timeLen"), Bytes.toBytes(DateUtils.getOnlyDayByHour(model.getHour())), model.getTimeLen());
複製代碼
table-->behavior_user_day_app_time_201809
rowKey-->userid:day:packageName
columnfamily-->timeLen
column --> 12 13 14 ... ...(小時24個)
value --> long值
String tableName = "behavior_user_day_app_time_" + DateUtils.getMonthByHour(model.getHour());
Table table = HBaseClient.getInstance(this.props).getTable(tableName);
String rowKey = model.getUserId()+":"+DateUtils.getDayByHour(model.getHour())+":"+model.getPackageName();
table.incrementColumnValue(Bytes.toBytes(rowKey), Bytes.toBytes("timeLen"), Bytes.toBytes(DateUtils.getOnlyHourByHour(model.getHour())), model.getTimeLen());
複製代碼
table-->behavior_user_day_time_201809
rowKey-->userid:packageName
columnfamily-->timeLen
column --> 1 2 3 ... ...(天數:31)
value --> long值
String tableName = "behavior_user_day_app_time_" + DateUtils.getMonthByHour(model.getHour());
Table table = HBaseClient.getInstance(this.props).getTable(tableName);
String rowKey = model.getUserId()+":"+model.getPackageName();
table.incrementColumnValue(Bytes.toBytes(rowKey), Bytes.toBytes("timeLen"), Bytes.toBytes(DateUtils.getOnlyDayByHour(model.getHour())), model.getTimeLen());
複製代碼
秦凱新 於深圳code