!7 sclass SubSpace implements AI_PostHandler, AI_CacheChecker { new MultiMap index; new HashMap websByID; // existence of triple has already been checked public S postTriple(T3 t) { Web web = webFromTriple(t); websByID.put(web.globalID, web); for (WebNode node : web_nodesAndRelations(web)) for (S text : asSet(node.texts())) index.put(ai_shortenForIndex(text), node); ret web.globalID; } public bool hasTriple(S a, S b, S c) { L webs = ai_withoutInvalidWebs(nodesToWebs(shortestList3( index.get(a), index.get(b), index.get(c)))); ret webs_search_noVar_bool(webFromTriples(a, b, c), webs); } } static SubSpace subSpace; p { final new MultiMap bigCache; ai_addWebToIndex_noNotify(bigCache, webFromTriple("a", "b", "c")); cachedNodeIndex2_cache.set(bigCache); assertTrue(func { ai_hasTriple("a", "b", "c") }); assertFalse(func { ai_hasTriple("love", "is", "nice") }); ai_setPostHandler(subSpace); ai_postTriple("love", "is", "nice"); assertTrue(func { subSpace.index.containsKey("nice") }); assertTrue(func { ai_hasTriple("a", "b", "c") }); assertFalse(func { bigCache.containsKey("nice") }); print("OK"); }