Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix wrong word in the code and state.update bug #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static void putData(String tablename, String rowkey, String famliyname,St
* @param column 列名
* @throws Exception
*/
public static void increamColumn(String tablename, String rowkey, String famliyname,String column) throws Exception {
public static void increaseColumn(String tablename, String rowkey, String famliyname,String column) throws Exception {
String val = getData(tablename, rowkey, famliyname, column);
int res = 1;
if (val != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public String map(String s) throws Exception {
while (rst.next()){
String productId = String.valueOf(log.getProductId());
String sex = rst.getString("sex");
HbaseClient.increamColumn("prod",productId,"sex",sex);
HbaseClient.increaseColumn("prod",productId,"sex",sex);
String age = rst.getString("age");
HbaseClient.increamColumn("prod",productId,"age", AgeUtil.getAgeType(age));
HbaseClient.increaseColumn("prod",productId,"age", AgeUtil.getAgeType(age));
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class UserHistoryMapFunction implements MapFunction<String, String> {
public String map(String s) throws Exception {
LogEntity log = LogToEntity.getLog(s);
if (null != log){
HbaseClient.increamColumn("u_history",String.valueOf(log.getUserId()),"p",String.valueOf(log.getProductId()));
HbaseClient.increamColumn("p_history",String.valueOf(log.getProductId()),"p",String.valueOf(log.getUserId()));
HbaseClient.increaseColumn("u_history",String.valueOf(log.getUserId()),"p",String.valueOf(log.getProductId()));
HbaseClient.increaseColumn("p_history",String.valueOf(log.getProductId()),"p",String.valueOf(log.getUserId()));
}
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ public String map(LogEntity logEntity) throws Exception {
int times = 1;
// 如果用户没有操作 则为state创建值
if (actionLastTime == null) {
actionLastTime = actionThisTime;
//actionLastTime = actionThisTime;
state.update(actionThisTime);
saveToHBase(logEntity, 1);
}else{
times = getTimesByRule(actionLastTime, actionThisTime);
saveToHBase(logEntity, times);
}
saveToHBase(logEntity, times);

// 如果用户的操作为3(购物),则清除这个key的state
if (actionThisTime.getType().equals("3")){
Expand Down Expand Up @@ -71,7 +72,7 @@ private void saveToHBase(LogEntity log, int times) throws Exception {
if (log != null){
for (int i = 0; i < times; i++) {

HbaseClient.increamColumn("u_interest",String.valueOf(log.getUserId()),"p",String.valueOf(log.getProductId()));
HbaseClient.increaseColumn("u_interest",String.valueOf(log.getUserId()),"p",String.valueOf(log.getProductId()));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public String map(String s) throws Exception {
String userId = String.valueOf(log.getUserId());

String country = rst.getString("country");
HbaseClient.increamColumn("user",userId,"country",country);
HbaseClient.increaseColumn("user",userId,"country",country);
String color = rst.getString("color");
HbaseClient.increamColumn("user",userId,"color",color);
HbaseClient.increaseColumn("user",userId,"color",color);
String style = rst.getString("style");
HbaseClient.increamColumn("user",userId,"style",style);
HbaseClient.increaseColumn("user",userId,"style",style);
}

}
Expand Down