Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

38
LINES

< > BotCompany Repo | #1012453 // webs_readTripleFileAsTriples_parallel

JavaX fragment (include)

please include function webs_readTripleFileAsTriples.

static L<TripleWeb> webs_readTripleFileAsTriples_parallel(File f) ctex {
  if (!f.exists()) ret ll();
  Iterator<S> it = linesFromFile(f);
  final new L<S> names;
  while (it.hasNext()) {
    S s = trim(it.next());
    if (empty(s)) break;
    names.add(intern(unquote(s)));
  }
  
  final new L<Pair<TripleWeb, Int>> triples;
  
  int poolSize = numberOfCores(), queueSize = 10000;
  NotifyingBlockingThreadPoolExecutor e = new(poolSize, queueSize, 15, TimeUnit.SECONDS);
  print("Using " + poolSize + " cores.");
  
  try {
    int i = 0;
    for (fS s : iterable(it)) {
      ++i;
      final int _i = i;
      e.execute(r { pcall {
        TripleWeb t = webs_readTripleFileAsTriples_line(s, names);
        if (t != null) synchronized(triples) {
          triples.add(pair(t, _i));
        }
      }});
    }
    e.shutdown();
    e.awaitTermination(1, TimeUnit.DAYS);
  } finally {
    e.shutdown();
  }
  
  ret firstOfPairs(sortBySecondOfPairs_inPlace(triples));
}

Author comment

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: 360 / 352
Version history: 6 change(s)
Referenced in: [show references]