public void createSingletons() { int counter = 0; foreach (var currentTier in tiers) { foreach (var currentQuery in listOfQueries.Where(x => x.queryTier == currentTier)) { Cluster c = new Cluster("Cluster" + counter, currentTier, currentQuery.queryPredictedTime, currentQuery.queryPredictedTime, currentQuery.queryPredictedTime, currentQuery.queryPredictedTime); c.setSingleton(); c.addQuery(currentQuery); c.clusterTier = currentTier; clusterList.Add(c); counter++; } } }
/* * Determines whether one cluster subsumes another */ public bool subsumes(Cluster other) { var thisClusterRoots = this.getRootQueries(); var OtherClusterRoots = other.getRootQueries(); //if both clusters are in the same configuration if (this.clusterTier == other.clusterTier) { return ((other.clusterMax >= this.clusterMin && other.clusterMax <= this.clusterMax) || (other.clusterMin <= this.clusterMax && other.clusterMin >= this.clusterMax)); } else { if (this.clusterTier < other.clusterTier) { //if other cluster is within bounds if (other.clusterMin >= this.clusterIntervalLow && other.clusterMax <= this.clusterIntervalHigh) { /*comparison of queries from both clusters, if flagged then "this" cluster does not subsume "other"*/ foreach (var otherRoot in OtherClusterRoots) { bool subsumed = false; foreach (var thisRoot in thisClusterRoots) { if (thisRoot.SubsumesOrEqual(otherRoot)) { subsumed = true; } } if (!subsumed) return false; } return true; } else //not within bounds { return false; } } else //this cluster config is larger { return false; } } }
public ClusterPair(Cluster d, Cluster s) { foreach (var c in clusterList) { this.cluster1 = d; this.cluster2 = s; } }
public void intraClusterCompression(int tier) { if (clusterList.Where(l => l.clusterTier == tier).Select(l => l.clusterMax).Count() == 0) return; //no more queries in this configuration var maxValue = clusterList.Where(l => l.clusterTier == tier).Select(l => l.clusterMax).Max(); int[] humanIntervals = new int[] { 0, 10, 60, 300, 600, 1800, 3600, 7200 }; int intervalMarker = 1; int counter = 0; var highInterval = humanIntervals[intervalMarker]; int i = humanIntervals[intervalMarker - 1]; bool done = false; while (!done) { var currentInterval = (from l in clusterList where l.clusterTier == tier && l.clusterMax >= i && l.clusterMax < highInterval select l).ToList(); if (currentInterval.Count() > 0) { Cluster c = new Cluster("Cluster" + counter, tier, currentInterval.Select(l => l.clusterMax).Min(), currentInterval.Select(l => l.clusterMax).Max(), i, highInterval); counter++; foreach (var q in currentInterval) { foreach (var qInner in q.getAllQueries()) { c.addQuery(qInner); } clusterList.Remove(q); } clusterList.Add(c); c.findRoots(); } //check if finished if (highInterval > maxValue) { done = true; } else { intervalMarker++; i = humanIntervals[intervalMarker - 1]; highInterval = humanIntervals[intervalMarker]; } } }