import "UI/Progress"
+import "Simantics/DB"
importJava "org.simantics.scl.db.SCLFunctions" where
collectClusters :: <Proc> ()
+ countQueries :: <ReadGraph> Integer
+ """
+ restrictQueries amount step maxTimeInMs
+
+ Collects some DB queries. Tries to reach at maximum 'amount' queries.
+ Uses at maximum 'maxTimeInMs' milliseconds in 'step' millisecond stints.
+ """
+ restrictQueries :: Integer -> Integer -> Integer -> <ReadGraph> ()
importJava "org.simantics.db.layer0.util.Layer0Utils" where
@JavaName emptyTrashBin
import org.simantics.db.layer0.variable.Variables;
import org.simantics.db.request.Read;
import org.simantics.db.service.ClusterControl;
+import org.simantics.db.service.QueryControl;
import org.simantics.db.service.SerialisationSupport;
import org.simantics.db.service.VirtualGraphSupport;
import org.simantics.layer0.utils.triggers.IActivationManager;
return value;
}
+ public static void restrictQueries(ReadGraph graph, int amount, int step, int maxTimeInMs) {
+
+ QueryControl qc = graph.getService(QueryControl.class);
+ long start = System.currentTimeMillis();
+ while(true) {
+ int current = qc.count();
+ if(current < amount) return;
+ qc.gc(graph, step);
+ long duration = System.currentTimeMillis() - start;
+ if(duration > maxTimeInMs) return;
+ }
+
+ }
+
+ public static int countQueries(ReadGraph graph) {
+
+ QueryControl qc = graph.getService(QueryControl.class);
+ return qc.count();
+
+ }
+
}