Warning: session_start(): open(/var/lib/php/sessions/sess_4td5eqoqp8udjte3uapahmf1ic, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass TripleIndex extends VirtualNodeIndex {
SyncListMultiMap index = caseInsensitiveSyncListMultiMap();
new CompactHashSet websByID;
bool activated; // are we the main index (see tripleIndex())
int numWebs() { ret l(websByID); }
int numTerms() { ret index.keysSize(); }
Collection indexedTerms() { ret keys(index); }
L get(S query) {
ret ai_triplesToWebNodes_lazyList(query, index.get(query));
}
bool hasShortTerm(S s) { ret index.containsKey(s); }
Web getWeb(GlobalID id) {
ret webFromTriple(websByID.find(dummyTripleWebWithGlobalID(id)));
}
void addWeb(Web web) {
if (web == null) ret;
addTriple(ai_webToTripleWeb(web));
}
void addTriple(TripleWeb w) {
if (w == null)
fail("Skipping non-tripelizable web: " + webToStringShort(web));
synchronized(index) {
for (S s : sortedInPlace(ll(w.a, w.b, w.c)))
index.put(s, w);
// for (S s : lithashset(w.a, w.b, w.c)) index.put(s, w); // only once
}
websByID.add(w);
}
void removeWeb(Web web) {
if (web == null) ret;
TripleWeb w = ai_webToTripleWeb(web);
if (w == null) ret;
GlobalID id = w.globalID();
websByID.remove(dummyTripleWebWithGlobalID(id));
indexRemove(w.a, id);
indexRemove(w.b, id);
indexRemove(w.c, id);
}
// internal
void indexRemove(S term, GlobalID globalID) {
L l = index.get(term);
for i over l:
if (eq(l.get(i).globalID(), globalID)) {
index.remove(term, l.get(i));
ret;
}
}
void clear() {
index.clear();
websByID.clear();
}
void activate {
if (!activated) {
activated = true;
ai_onNewOrRemovedWeb(func(Web web) {
addWeb(web);
false;
}, func(Web web) {
removeWeb(web);
false;
});
}
}
}