使用set出现问题,size有时变为0
但是后面那条size就变为0了,这是为什么?
关键是还不是所有数据都这样
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;
}
}
相关推荐
C++中set的使用
• set的声明如下,T就是set底层关键字的类型• set默认要求T⽀持⼩于⽐较,如果不⽀持或者想按⾃⼰的需求⾛可以⾃⾏实现仿函数传给第⼆个模版参数• set底层存储数据的内存是从空间配置器申请的,如果需要可以⾃⼰实现内存池,传给第三个参数。• ⼀般情况下,我们都不需要传后两个模版参数。• set底层是⽤红⿊树实现,增删查效率是 O(logN) ,迭代器遍历是⾛的搜索树的中序,所以是有序的。
pcap_set_buffer_size()函数
【代码】pcap_set_buffer_size()函数。pcap_set_buffer_size()函数主要用于设置数据包捕获的内核缓冲区大小。这个缓冲区是操作系统内核用于临时存储捕获到的数据包的区域。通过调整缓冲区大小,可以在一定程度上优化数据包捕获的性能,特别是在高流量网络环境或者需要长时间捕获数据包的场景中。
使用split_size优化的ODPS SQL的场景
使用split_size优化的ODPS SQL的场景 首先有两个大背景需要说明如下: 说明1:split_size,设定一个map的最大数据输入量,单位M,默认256M。用户可以通过控制这个变量,从而达到对map端输入的控制。设置语句:set odps.sql.mapper.split.size=256。一般在调整这个设置时,往往是发现一个map instance处理的数据行数太多。 说明2:...
STL Set使用总结
C++ STL 之所以得到广泛的赞誉,也被很多人使用,不只是提供了像vector, string, list等方便的容器,更重要的是STL封装了许多复杂的数据结构算法和大量常用数据结构操作。vector封装数组,list封装了链表,map和set封装了二叉树等,在封装这些数据结构的时候,STL按照程序员的使用习惯,以成员函数方式提供的常用操作,如:插入、排序、删除、查找等。让用户在STL使用过程中,并不会感到陌生。 今天我们说说STL的set,必须说明的是set关联式容...
前端开发组件示例源码_f1b6a91d详解
前端开发组件示例源码_f1b6a91d,内容包含源码/脚本与使用说明文档,结构清晰、注释完整,适合学习参考与二次开发,下载解压即可查看。


Java SE
