Warning: session_start(): open(/var/lib/php/sessions/sess_q28chngl2rsgge363i1r530m57, 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 ActualThoughtSpace extends AbstractThoughtSpace implements AutoCloseable {
new TripleIndex index;
int limit; // 0 = no limit
Map blocked = newWeakHashMap();
Set blockedA, blockedB;
*() {}
*(int *limit) {}
*(AbstractThoughtSpace parent) { super(parent); }
// existence of triple has already been checked
public GlobalID postTriple(T3 t) {
if (limitReached()) fail("Thought space limit reached");
TripleWeb w = tripleWeb(t);
index.addTriple(w);
ret w.globalID();
}
bool limitReached() {
ret limit > 0 && size() >= limit;
}
L> get(Symbol s) {
ret ai_triplesToTripleRefs_lazyList(s, getTriples(s));
}
L> get(Symbol s, int position) {
ret ai_triplesToTripleRefs_lazyList(s, getTriples(s, position));
}
L getTriples(Symbol s) {
L l = filterNonBlockedTriples_lazy(parent.getTriples(s));
ret combineLists(l, index.getTriples(ai_shortenForIndex(s)));
}
L getTriples(Symbol s, int position) {
L l = filterNonBlockedTriples_lazy(parent.getTriples(s, position));
ret combineLists(l, index.getTriples(ai_shortenForIndex(s), position));
}
L filterNonBlockedTriples_lazy(final L l) {
class FilterList extends LazyList {
final int n = l(l);
public int size() { ret n; }
public TripleWeb get(int i) {
TripleWeb w = syncGet(l, i);
if (w != null && isBlocked(w)) null;
ret w;
}
}
ret new FilterList;
}
L filterNonBlockedTriples(L l) {
if (empty(blockedA) && empty(blockedB)) ret l;
L out = emptyListWithCapacity(l);
for (TripleWeb w : l)
if (!isBlocked(w))
out.add(w);
ret out;
}
bool isBlocked(TripleWeb t) {
ret contains(blockedA, t.a) || contains(blockedB, t.b);
}
int size() { ret index.size(); }
public void close() {
thoughtSpaceDone(this);
}
Collection allTriples() { ret index.allTriples(); }
void setBlockedA(Collection extends CharSequence> l) {
blockedA = asSymbolSet(allToSymbol(l));
}
}