@Test public void getKnownCompleteChildren() { MockPersistenceStorageEngine engine = new MockPersistenceStorageEngine(); engine.disableTransactionCheck = true; TrackedQueryManager manager = newManager(engine, null); assertEquals(Collections.<ChildKey>emptySet(), manager.getKnownCompleteChildren(path("foo"))); manager.setQueryActive(defaultQueryAt("foo/a")); manager.setQueryCompleteIfExists(defaultQueryAt("foo/a")); manager.setQueryActive(defaultQueryAt("foo/not-included")); manager.setQueryActive(defaultQueryAt("foo/deep/not-included")); manager.setQueryCompleteIfExists(defaultQueryAt("foo/deep/not-included")); manager.setQueryActive(SAMPLE_FOO_QUERY); TrackedQuery trackedQuery = manager.findTrackedQuery(SAMPLE_FOO_QUERY); engine.saveTrackedQueryKeys(trackedQuery.id, asSet(ck("d"), ck("e"))); assertEquals(asSet(ck("a"), ck("d"), ck("e")), manager.getKnownCompleteChildren(path("foo"))); assertEquals(Collections.<ChildKey>emptySet(), manager.getKnownCompleteChildren(path(""))); assertEquals( Collections.<ChildKey>emptySet(), manager.getKnownCompleteChildren(path("foo/baz"))); }
public Set<ChildKey> getKnownCompleteChildren(Path path) { hardAssert( !this.isQueryComplete(QuerySpec.defaultQueryAtPath(path)), "Path is fully complete."); Set<ChildKey> completeChildren = new HashSet<ChildKey>(); Set<Long> queryIds = filteredQueryIdsAtPath(path); if (!queryIds.isEmpty()) { completeChildren.addAll(storageLayer.loadTrackedQueryKeys(queryIds)); } for (Map.Entry<ChildKey, ImmutableTree<Map<QueryParams, TrackedQuery>>> childEntry : this.trackedQueryTree.subtree(path).getChildren()) { ChildKey childKey = childEntry.getKey(); ImmutableTree<Map<QueryParams, TrackedQuery>> childTree = childEntry.getValue(); if (childTree.getValue() != null && HAS_DEFAULT_COMPLETE_PREDICATE.evaluate(childTree.getValue())) { completeChildren.add(childKey); } } return completeChildren; }
TrackedQueryManager { public Set<ChildKey> getKnownCompleteChildren(Path path) { hardAssert( !this.isQueryComplete(QuerySpec.defaultQueryAtPath(path)), "Path is fully complete."); Set<ChildKey> completeChildren = new HashSet<ChildKey>(); Set<Long> queryIds = filteredQueryIdsAtPath(path); if (!queryIds.isEmpty()) { completeChildren.addAll(storageLayer.loadTrackedQueryKeys(queryIds)); } for (Map.Entry<ChildKey, ImmutableTree<Map<QueryParams, TrackedQuery>>> childEntry : this.trackedQueryTree.subtree(path).getChildren()) { ChildKey childKey = childEntry.getKey(); ImmutableTree<Map<QueryParams, TrackedQuery>> childTree = childEntry.getValue(); if (childTree.getValue() != null && HAS_DEFAULT_COMPLETE_PREDICATE.evaluate(childTree.getValue())) { completeChildren.add(childKey); } } return completeChildren; } }
TrackedQueryManager { public Set<ChildKey> getKnownCompleteChildren(Path path) { hardAssert( !this.isQueryComplete(QuerySpec.defaultQueryAtPath(path)), "Path is fully complete."); Set<ChildKey> completeChildren = new HashSet<ChildKey>(); Set<Long> queryIds = filteredQueryIdsAtPath(path); if (!queryIds.isEmpty()) { completeChildren.addAll(storageLayer.loadTrackedQueryKeys(queryIds)); } for (Map.Entry<ChildKey, ImmutableTree<Map<QueryParams, TrackedQuery>>> childEntry : this.trackedQueryTree.subtree(path).getChildren()) { ChildKey childKey = childEntry.getKey(); ImmutableTree<Map<QueryParams, TrackedQuery>> childTree = childEntry.getValue(); if (childTree.getValue() != null && HAS_DEFAULT_COMPLETE_PREDICATE.evaluate(childTree.getValue())) { completeChildren.add(childKey); } } return completeChildren; } TrackedQueryManager(
      PersistenceStorageEngine storageLayer, LogWrapper logger, Clock clock); }
TrackedQueryManager { public Set<ChildKey> getKnownCompleteChildren(Path path) { hardAssert( !this.isQueryComplete(QuerySpec.defaultQueryAtPath(path)), "Path is fully complete."); Set<ChildKey> completeChildren = new HashSet<ChildKey>(); Set<Long> queryIds = filteredQueryIdsAtPath(path); if (!queryIds.isEmpty()) { completeChildren.addAll(storageLayer.loadTrackedQueryKeys(queryIds)); } for (Map.Entry<ChildKey, ImmutableTree<Map<QueryParams, TrackedQuery>>> childEntry : this.trackedQueryTree.subtree(path).getChildren()) { ChildKey childKey = childEntry.getKey(); ImmutableTree<Map<QueryParams, TrackedQuery>> childTree = childEntry.getValue(); if (childTree.getValue() != null && HAS_DEFAULT_COMPLETE_PREDICATE.evaluate(childTree.getValue())) { completeChildren.add(childKey); } } return completeChildren; } TrackedQueryManager(
      PersistenceStorageEngine storageLayer, LogWrapper logger, Clock clock); TrackedQuery findTrackedQuery(QuerySpec query); void removeTrackedQuery(QuerySpec query); void setQueryActive(QuerySpec query); void setQueryInactive(QuerySpec query); void setQueryCompleteIfExists(QuerySpec query); void setQueriesComplete(Path path); boolean isQueryComplete(QuerySpec query); PruneForest pruneOldQueries(CachePolicy cachePolicy); Set<ChildKey> getKnownCompleteChildren(Path path); void ensureCompleteTrackedQuery(Path path); boolean hasActiveDefaultQuery(Path path); long countOfPrunableQueries(); }
TrackedQueryManager { public Set<ChildKey> getKnownCompleteChildren(Path path) { hardAssert( !this.isQueryComplete(QuerySpec.defaultQueryAtPath(path)), "Path is fully complete."); Set<ChildKey> completeChildren = new HashSet<ChildKey>(); Set<Long> queryIds = filteredQueryIdsAtPath(path); if (!queryIds.isEmpty()) { completeChildren.addAll(storageLayer.loadTrackedQueryKeys(queryIds)); } for (Map.Entry<ChildKey, ImmutableTree<Map<QueryParams, TrackedQuery>>> childEntry : this.trackedQueryTree.subtree(path).getChildren()) { ChildKey childKey = childEntry.getKey(); ImmutableTree<Map<QueryParams, TrackedQuery>> childTree = childEntry.getValue(); if (childTree.getValue() != null && HAS_DEFAULT_COMPLETE_PREDICATE.evaluate(childTree.getValue())) { completeChildren.add(childKey); } } return completeChildren; } TrackedQueryManager(
      PersistenceStorageEngine storageLayer, LogWrapper logger, Clock clock); TrackedQuery findTrackedQuery(QuerySpec query); void removeTrackedQuery(QuerySpec query); void setQueryActive(QuerySpec query); void setQueryInactive(QuerySpec query); void setQueryCompleteIfExists(QuerySpec query); void setQueriesComplete(Path path); boolean isQueryComplete(QuerySpec query); PruneForest pruneOldQueries(CachePolicy cachePolicy); Set<ChildKey> getKnownCompleteChildren(Path path); void ensureCompleteTrackedQuery(Path path); boolean hasActiveDefaultQuery(Path path); long countOfPrunableQueries();  }