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

52
LINES

< > BotCompany Repo | #1011416 // ai_invalidatedWebs - returns Set<S> - only verified information is counted

JavaX fragment (include)

1  
// the map is: invalidated id -> invalidators
2  
3  
static DependentCache<MultiMap<GlobalID>> ai_invalidatedWebs_cache = new DependentCache(f ai_invalidatedWebs_calc, f cachedNodeIndex /*_changeCount*/);
4  
5  
static Set<GlobalID> ai_invalidatedWebs() {
6  
  ret keys(ai_invalidatedWebs_cache!);
7  
}
8  
9  
static MultiMap<GlobalID> ai_invalidatedWebs_calc() {
10  
  //print("ai_invalidatedWebs_calc");
11  
  ai_onNewOrRemovedWeb(f ai_invalidatedWebs_onNewWeb, f ai_invalidatedWebs_onRemovedWeb);
12  
  ai_invalidatedWebs_cache.set(new MultiMap);
13  
  
14  
  // old method
15  
  //Collection<Web> webs = allWebsFromCachedNodeIndex_uncached();
16  
  //print("Have " + nWebs(webs));
17  
  //for (Web web : webs)
18  
  //  ai_invalidatedWebs_onNewWeb(web);
19  
  
20  
  // new method
21  
  new Matches m;
22  
  for (WebNode n : indexedNodes_withInvalids("invalid"))
23  
    for (WebRelation r : web_backwardRelations(n))
24  
      if (web_hasLabelIC(r, "is")
25  
        && web_match("Web *", r.a, m) && isGlobalID($1))
26  
        ai_invalidatedWebs_cache->put(asGlobalID($1), r.web.globalIDObj());
27  
28  
  print("ai_invalidatedWebs calc done with " + n2(ai_invalidatedWebs_cache->keysSize(), "invalidated web", "invalidated webs"));
29  
  ret ai_invalidatedWebs_cache!;
30  
}
31  
32  
svoid ai_invalidatedWebs_onNewWeb(Web web) {
33  
  if (web.unverified) ret;
34  
  lock ai_invalidatedWebs_cache.lock;
35  
  new Matches m;
36  
  for (WebNode n : web_search_dollarX(webFromTriple("$X", "is", "invalid"), web))
37  
    if (web_match("Web *", n, m) && isGlobalID($1))
38  
      ai_invalidatedWebs_cache->put(asGlobalID($1), web.globalIDObj());
39  
}
40  
41  
svoid ai_invalidatedWebs_onRemovedWeb(Web web) {
42  
  if (web.unverified) ret;
43  
  lock ai_invalidatedWebs_cache.lock;
44  
  new Matches m;
45  
  for (WebNode n : web_search_dollarX(webFromTriple("$X", "is", "invalid"), web))
46  
    if (web_match("Web *", n, m) && isGlobalID($1))
47  
      ai_invalidatedWebs_cache->remove(asGlobalID($1), web.globalIDObj());
48  
}
49  
50  
svoid ai_invalidatedWebs_cache_put(GlobalID a, GlobalID b) {
51  
  ai_invalidatedWebs_cache->put(a, b);
52  
}

Author comment

Began life as a copy of #1011311

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: #1011416
Snippet name: ai_invalidatedWebs - returns Set<S> - only verified information is counted
Eternal ID of this version: #1011416/21
Text MD5: f998490650cc95ec1178b46b46db743b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-15 00:03:13
Source code size: 2006 bytes / 52 lines
Pitched / IR pitched: No / No
Views / Downloads: 571 / 595
Version history: 20 change(s)
Referenced in: [show references]