fix the bug of region filtering
This commit is contained in:
parent
4911bdcd41
commit
c6c0ee954f
|
|
@ -178,6 +178,10 @@ public class Maker {
|
|||
|
||||
// apply the field filtering
|
||||
final String region = Util.regionFiltering(seg.region, fields);
|
||||
if (region.length() < 1) {
|
||||
throw new Exception("empty region info for segment `"+seg+"`");
|
||||
}
|
||||
|
||||
segments.add(new Segment(seg.startIP, seg.endIP, region));
|
||||
last = seg;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ public class Util
|
|||
}
|
||||
|
||||
sb.append(fs[idx]);
|
||||
if (sb.length() > 0 && i < tailing) {
|
||||
if (i < tailing) {
|
||||
sb.append("|");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,10 @@ public class UtilTest {
|
|||
public void testRegionFiltering() {
|
||||
final String[] regions = new String[]{
|
||||
"亚洲|中国|广东|深圳|宝安|电信|113.88311|22.55371|440306|0755|518100|Asia/Shanghai|CNY|11|CHXX0120",
|
||||
"大洲|国家|省份|城市|区县|ISP|经度|纬度|0|0|0|0|0"
|
||||
"大洲|国家|省份|城市|区县|ISP|经度|纬度|0|0|0|0|0",
|
||||
"||||||||||||",
|
||||
"亚洲|中国|||||||||||",
|
||||
"美国|加利福尼亚州|洛杉矶|专线用户|||||||||"
|
||||
};
|
||||
|
||||
final int[] fields = new int[] {1,2,3,4,6,7};
|
||||
|
|
|
|||
Loading…
Reference in New Issue