1 | please include function webs_readTripleFileAsTriples. |
2 | |
3 | static L<TripleWeb> webs_readTripleFileAsTriples_parallel(File f) ctex {
|
4 | if (!f.exists()) ret ll(); |
5 | Iterator<S> it = linesFromFile(f); |
6 | final new L<S> names; |
7 | while (it.hasNext()) {
|
8 | S s = trim(it.next()); |
9 | if (empty(s)) break; |
10 | names.add(intern(unquote(s))); |
11 | } |
12 | |
13 | final new L<Pair<TripleWeb, Int>> triples; |
14 | |
15 | int poolSize = numberOfCores(), queueSize = 10000; |
16 | NotifyingBlockingThreadPoolExecutor e = new(poolSize, queueSize, 15, TimeUnit.SECONDS); |
17 | print("Using " + poolSize + " cores.");
|
18 | |
19 | try {
|
20 | int i = 0; |
21 | for (fS s : iterable(it)) {
|
22 | ++i; |
23 | final int _i = i; |
24 | e.execute(r { pcall {
|
25 | TripleWeb t = webs_readTripleFileAsTriples_line(s, names); |
26 | if (t != null) synchronized(triples) {
|
27 | triples.add(pair(t, _i)); |
28 | } |
29 | }}); |
30 | } |
31 | e.shutdown(); |
32 | e.awaitTermination(1, TimeUnit.DAYS); |
33 | } finally {
|
34 | e.shutdown(); |
35 | } |
36 | |
37 | ret firstOfPairs(sortBySecondOfPairs_inPlace(triples)); |
38 | } |
Began life as a copy of #1012446
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1012453 |
| Snippet name: | webs_readTripleFileAsTriples_parallel |
| Eternal ID of this version: | #1012453/7 |
| Text MD5: | 347a86abdf3127fa2df4b36b79b4fd09 |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-12-03 16:58:25 |
| Source code size: | 1063 bytes / 38 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 651 / 652 |
| Version history: | 6 change(s) |
| Referenced in: | [show references] |