-
Notifications
You must be signed in to change notification settings - Fork 1
/
CountDupSrcTxs.java
46 lines (39 loc) · 1.31 KB
/
CountDupSrcTxs.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
// time java CountDupSrcTxs SrcDestTxsRingCTAll
public class CountDupSrcTxs {
private static final Set<String> dups = new HashSet<>();
private static final Set<String> unique = new HashSet<>();
public static void main(String[] args) throws Exception {
String srcDestFile = args[0];
process(srcDestFile);
}
private static void process(String file) throws Exception {
int count = 0;
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
for (String line; (line = br.readLine()) != null; ) {
String[] parts = line.split(" ");
String src = parts[0];
if (dups.contains(src) || unique.contains(src)) {
unique.remove(src);
dups.add(src);
} else {
unique.add(src);
}
count++;
if (count % 100 == 0) {
System.err.println("Processed " + count + " dests.");
}
}
System.err.println("Processed " + count + " dests.");
}
System.out.println("Num unique: " + unique.size());
System.out.println("Num dup: " + dups.size());
}
}