62,615
社区成员
发帖
与我相关
我的任务
分享
while ((s1 = br.readLine()) != null)
{
Set<String> usrSet = new HashSet<String>();
try
{
LOG.info("[INFO] The "+count+" ID.");
count++;
// 获取一个用户id
String id = s1;
// 根据id获取用户行为记录
HashMap<String, String> usrlog_hashmap = new HashMap<String, String>();
usrlog_hashmap = logDBOperation.queryUserIDInDateRange(id, timeStamp, 7);//logDBOperation.queryByUsrID(id);//queryUserIDInDateRange(id, "2014061900000", 500);//;queryUserIDInDateRange
int tempcount = 0;
// 循环读取用户行为
for (Entry<String, String> entry : usrlog_hashmap.entrySet())
{
//System.out.println(entry.getValue() + "\n");
String[] usrlog = entry.getValue().split("!");
for(String tem : usrlog)
{
//System.out.println(tem + "\n");
tempcount++;
countUserLog++;
//匹配
Matcher matcher = pattern.matcher(tem);
if(matcher.find())
{
//System.out.println(tem + "\n");
countUsefulLog++;
String postid = matcher.group(1);
String leftStr = matcher.group(2);
//System.out.println("postid "+postid);
Item item = null;
boolean flag = true;
while(flag)
{
try
{
item = itemop.get(postid);
flag = false;
}
catch(Exception e)
{
LOG.error("[ERROR] Get item failed.");
continue;
}
}
String channel = "";
try{
channel = channelsParser.getInstance(ItemOperation.ItemType.APPITEM).getTransChannelByItem(item,0);
}
catch(java.lang.NoClassDefFoundError e)
{
LOG.error("[ERROR] Get channel failed.");
continue;
}
if(channel == null || channel == "" || channel == " ")
{
Matcher matcher1 = pattern1.matcher(leftStr);
if(matcher1.find())
{
channel = matcher1.group(1);
System.out.println("channel: "+channel);
countref++;
}
}
//System.out.println("channel: "+channel);
String[] row = channel.split("-");
for(int i = 1; i < row.length; i++)
{
row[i] = row[i-1]+"-"+row[i];
}
for(int j = 0; j < row.length; j++)
{
System.out.println("row[j] "+ row[j]);
usrSet.add(row[j]);
System.out.println("usrSet.size() "+usrSet.size());
}
//String[] channelclass = channel.split("/");
}
}
}
System.out.println("usrSet.size() "+usrSet.size());
}
catch(Exception e)
{
LOG.error("Something wrong with me.");
continue;
}
}