public override void main() { IIteratorInstance <IKVPair <IString, ICliqueNode> > output = (IIteratorInstance <IKVPair <IString, ICliqueNode> >)Output_data.Instance; IIntegerInstance input_key = (IIntegerInstance)Input_key.Instance; ICliqueNodeInstance input_value = (ICliqueNodeInstance)Input_value.Instance; //Debug Start // string saida = ""; // IIntegerInstance I = input_key; // ICliqueNodeInstance N = input_value; // saida = "TaskRank="+this.Rank+" <" + I.Value + ", ["; // IEnumerator<int> neighbor = N.NeighborsInstance.GetEnumerator (); // while (neighbor.MoveNext ()) { // saida = saida + neighbor.Current + " "; // } // saida = saida + "]>"; // using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"./logCliqueMap"+Rank, true)){ // file.WriteLine(saida); // } //Debug End IEnumerator <int> iterator = input_value.NeighborsInstance.GetEnumerator(); while (iterator.MoveNext()) { IKVPairInstance <IString, ICliqueNode> KV = (IKVPairInstance <IString, ICliqueNode>)Output_data.createItem(); ((IStringInstance)KV.Key).Value = iterator.Current.ToString(); ((ICliqueNodeInstance)KV.Value).IdInstance = input_value.IdInstance; ((ICliqueNodeInstance)KV.Value).NeighborsInstance = input_value.NeighborsInstance; output.put(KV); } }
public IIntegerInstance newInstance(int i) { IIntegerInstance instance = (IIntegerInstance)newInstance(); instance.Value = i; return(instance); }
public override void main() { IIntegerInstance input_key = (IIntegerInstance)Input_key.Instance; IPageNodeInstance input_value = (IPageNodeInstance)Input_value.Instance; IIteratorInstance <IKVPair <IString, IDouble> > output = (IIteratorInstance <IKVPair <IString, IDouble> >)Output_data.Instance; double slice = input_value.PgrankInstance; int size = input_value.NeighborsInstance.Count; IEnumerator <int> iterator = input_value.NeighborsInstance.GetEnumerator(); while (iterator.MoveNext()) { string n = iterator.Current.ToString(); IKVPairInstance <IString, IDouble> kvpair = (IKVPairInstance <IString, IDouble>)Output_data.createItem(); ((IStringInstance)kvpair.Key).Value = n; ((IDoubleInstance)kvpair.Value).Value = slice / size; output.put(kvpair); } if (size == 0) { IKVPairInstance <IString, IDouble> kvpair = (IKVPairInstance <IString, IDouble>)Output_data.createItem(); ((IStringInstance)kvpair.Key).Value = "X"; ((IDoubleInstance)kvpair.Value).Value = slice; output.put(kvpair); } IKVPairInstance <IString, IDouble> KV = (IKVPairInstance <IString, IDouble>)Output_data.createItem(); ((IStringInstance)KV.Key).Value = input_key.Value.ToString(); ((IDoubleInstance)KV.Value).Value = 0.0; output.put(KV); }
public override void main() { Trace.WriteLine(Rank + ": START COMBINE FUNCTION #1"); IIteratorInstance <ORV> input_data_instance = (IIteratorInstance <ORV>)Input_data.Instance; IKVPairInstance <IInteger, IIterator <IPathInfo> > output_data_instance = (IKVPairInstance <IInteger, IIterator <IPathInfo> >)Output_data.Instance; Trace.WriteLine(Rank + ": START COMBINE FUNCTION #2"); IIntegerInstance done_flag = (IIntegerInstance)output_data_instance.Key; IIteratorInstance <IPathInfo> output_distances = (IIteratorInstance <IPathInfo>)output_data_instance.Value; Trace.WriteLine(Rank + ": START COMBINE FUNCTION #3"); bool done = true; object o; while (input_data_instance.fetch_next(out o)) { IKVPairInstance <IInteger, IIterator <IPathInfo> > kv = (IKVPairInstance <IInteger, IIterator <IPathInfo> >)o; IIntegerInstance k = (IIntegerInstance)kv.Key; Trace.WriteLine(Rank + ": LOOP #1 COMBINE FUNCTION " + k.Value); output_distances.putAll((IIteratorInstance <IPathInfo>)kv.Value); done = done && k.Value == 1; } output_distances.finish(); done_flag.Value = done ? 1 : 0; Trace.WriteLine(Rank + ": END COMBINE FUNCTION " + done); }
public override void main() { IVertexInstance input_vertex_instance = (IVertexInstance)Input_key.Instance; IIntegerInstance output_integer_instance = (IIntegerInstance)Output_key.Instance; int value = graph_partition_table[Math.Abs(input_vertex_instance.Id) - 1]; output_integer_instance.Value = value % NumberOfPartitions; }
public override void main() { int done = 0; IStringInstance input_data_instance = (IStringInstance)Input_data.Instance; IStringInstance output_data_instance = (IStringInstance)Output_data.Instance; IIntegerInstance termination_flag = (IIntegerInstance)Termination_flag.Instance; string setE = input_data_instance.Value; string setV = "1 c 0" + System.Environment.NewLine; IDictionary <int, int> vertices = new Dictionary <int, int>(); foreach (string edge in setE.Split(System.Environment.NewLine.ToCharArray())) { if (edge.Length > 0) { int vertex = edge [0]; if (!vertices.ContainsKey(vertex)) { setV += edge [0] + " d " + int.MaxValue + System.Environment.NewLine; vertices.Add(vertex, vertex); } } } input_data_instance.Value = setV + System.Environment.NewLine + setE; int count = 0; while (done == 0) { Console.WriteLine(Rank + ": ITERATION PATH_FLOW.GO ! - " + (++count)); this.Path_flow.go(); setV = output_data_instance.Value; Trace.WriteLine(Rank + ": --- setV = " + setV); done = setV.EndsWith("True") ? 1 : 0; termination_flag.Value = done; Set_termination_flag.go(); setV = setV.Remove(setV.IndexOf(done == 1 ? "True" : "False") - 2); Trace.WriteLine(Rank + ": --- END ITERATION PATH_FLOW.GO ! - " + count); input_data_instance.Value = setV; } Console.WriteLine(Rank + ": --- FINISH PATH_FLOW.GO !"); }
public override void main() { int done = 0; IStringInstance input_data_instance = (IStringInstance)Input_data.Instance; IStringInstance output_data_instance = (IStringInstance)Output_data.Instance; IIteratorInstance <IPathInfo> initial_data_instance = (IIteratorInstance <IPathInfo>)Initial_data.Instance; IKVPairInstance <IInteger, IIterator <IPathInfo> > final_distances_instance = (IKVPairInstance <IInteger, IIterator <IPathInfo> >)Final_distances.Instance; IIntegerInstance termination_flag = (IIntegerInstance)Termination_flag.Instance; string setE = input_data_instance.Value; string setV = "1 c 0" + System.Environment.NewLine; IDictionary <int, int> vertices = new Dictionary <int, int>(); foreach (string edge in setE.Split(System.Environment.NewLine.ToCharArray())) { if (edge.Length > 0) { int vertex = edge [0]; if (!vertices.ContainsKey(vertex)) { setV += edge [0] + " d " + int.MaxValue + System.Environment.NewLine; vertices.Add(vertex, vertex); } } } feedInitialData(setV + System.Environment.NewLine + setE, initial_data_instance); int count = 0; while (done == 0) { Console.WriteLine(Rank + ": ITERATION PATH_FLOW FAST GO ! - " + (++count)); this.Path_flow.go(); done = ((IIntegerInstance)final_distances_instance.Key).Value; termination_flag.Value = done; Set_termination_flag.go(); if (done == 0) { Trace.WriteLine(Rank + ": Exchange #1"); initial_data_instance.putAll((IIteratorInstance <IPathInfo>)final_distances_instance.Value); initial_data_instance.finish(); Trace.WriteLine(Rank + ": Exchange #2"); } } outputFinalDistances((IIteratorInstance <IPathInfo>)final_distances_instance.Value, output_data_instance); Trace.WriteLine(Rank + ": --- FINISH PATH_FLOW.GO !"); }
public override void main() { IStringInstance input_string_instance = (IStringInstance)Input_key.Instance; IIntegerInstance output_string_instance = (IIntegerInstance)Output_key.Instance; int value = Math.Abs(input_string_instance.Value.GetHashCode()); // Trace.WriteLine("PARTITION FUNCTION " + (value % NumberOfPartitions)); output_string_instance.Value = value % NumberOfPartitions; }
public override void main() { IIntegerInstance input_string_instance = (IIntegerInstance)Input_key.Instance; IIntegerInstance output_string_instance = (IIntegerInstance)Output_key.Instance; int value = (int)input_string_instance.Value; // Trace.WriteLine("BIN FUNCTION " + (value % NumberOfPartitions) + "value=" + value + ", npart=" + NumberOfPartitions); output_string_instance.Value = value % NumberOfPartitions; }
public override void main() { int done = 0; while (done == 0) { this.Path_flow.go(); this.Set_termination_flag.go(); IIntegerInstance termination_flag = (IIntegerInstance)Termination_flag.Instance; done = termination_flag.Value; Trace.WriteLine(Rank + "AFTER PATH ROW MAP LOOP " + done + " --- " + Termination_flag.Instance.GetHashCode()); } }
public override void main() { Console.WriteLine("################################*IAplicacaoImpl Start ###############################"); IDoubleInstance tDouble = (IDoubleInstance)T_double.Instance; IKVPairInstance <IString, IDouble> tKVPair = (IKVPairInstance <IString, IDouble>)T_kvpair.Instance; //.newInstance (); IIntegerInstance tInteger = (IIntegerInstance)T_integer.Instance; IIteratorInstance <IInteger> tIterator = (IIteratorInstance <IInteger>)T_iterator.Instance; //.newInstance (); IStringInstance tString = (IStringInstance)T_string.Instance; tDouble.Value = 0.8; tInteger.Value = 8; tString.Value = "Tipo String"; ((IStringInstance)tKVPair.Key).Value = tString.Value; ((IDoubleInstance)tKVPair.Value).Value = tDouble.Value; tIterator.put(tInteger); tIterator.finish(); object o; int count = 0; while (tIterator.fetch_next(out o)) { IIntegerInstance oI = (IIntegerInstance)o; Console.WriteLine("Item Iterator " + (count++) + ": " + oI.Value); } Console.WriteLine("tDouble.Value=" + tDouble.Value + " : " + "tInteger.Value=" + tInteger.Value + " : " + "tString.Value=" + tString.Value); Console.WriteLine("tKVPair.Key=" + ((IStringInstance)tKVPair.Key).Value + " : " + "tKVPair.Value=" + ((IDoubleInstance)tKVPair.Value).Value); IPageNodeInstance instance = (IPageNodeInstance)T_aplicacao_node.Instance; ((IIntegerInstance)instance.IdInstance).Value = 8; IIntegerInstance item = (IIntegerInstance)T_aplicacao_node.Edge_node.createItem(); item.Value = 7; instance.NeighborsInstance.put(item); instance.NeighborsInstance.put(((IIntegerInstance)instance.IdInstance)); instance.NeighborsInstance.finish(); while (instance.NeighborsInstance.fetch_next(out o)) { IIntegerInstance II = (IIntegerInstance)o; Console.WriteLine("%%%%%%%%%%%%%%%%%%%%%%%%%%%% Valor no Iterator=" + II.Value); } Console.WriteLine("%%%%%%%%%%%%%%%%%%%%%%%%%%%% Resultado Id_node=" + ((IIntegerInstance)instance.IdInstance).Value + " PGRank=" + instance.PgrankInstance.Value); Console.WriteLine("################################ IAplicacaoImpl End ###############################"); }
public void pull() { IKVPairInstance <IInteger, IIterator <IDataPGRANK> > input_values_instance = (IKVPairInstance <IInteger, IIterator <IDataPGRANK> >)Input_values.Instance; IIntegerInstance ikey = (IIntegerInstance)input_values_instance.Key; IIteratorInstance <IDataPGRANK> ivalues = (IIteratorInstance <IDataPGRANK>)input_values_instance.Value; object o; while (ivalues.fetch_next(out o)) { IDataPGRANKInstance VALUE = (IDataPGRANKInstance)o; foreach (KeyValuePair <int, float> kv in VALUE.Ranks) { messages [partition [kv.Key - 1]] [kv.Key] += kv.Value; } sum_nothings += VALUE.Slice; } }
public override void main() { IInputFormatInstance input_gif_instance = (IInputFormatInstance)Input_key.Instance; IIntegerInstance output_integer_instance = (IIntegerInstance)Output_key.Instance; int value = input_gif_instance.PARTID; //int value = graph_partition_table[((int) input_integer_instance.Value) -1]; //Trace.WriteLine("BIN FUNCTION " + (value % NumberOfPartitions) + "value=" + value + ", npart=" + NumberOfPartitions); output_integer_instance.Value = value % NumberOfPartitions; if (this.graph_partition_table == null) { this.graph_partition_table = input_gif_instance.PartitionTABLE; } Input_key.Instance = null; }
public void pull() { IKVPairInstance <IInteger, IIterator <IDataSSSP> > input_values_instance = (IKVPairInstance <IInteger, IIterator <IDataSSSP> >)Input_values.Instance; IIntegerInstance ikey = (IIntegerInstance)input_values_instance.Key; IIteratorInstance <IDataSSSP> ivalues = (IIteratorInstance <IDataSSSP>)input_values_instance.Value; object o; float distance_min; while (ivalues.fetch_next(out o)) { IDataSSSPInstance VALUE = (IDataSSSPInstance)o; halt_sum += VALUE.Halt; foreach (KeyValuePair <int, float> kv in VALUE.Path_size) { int v = kv.Key; float v_distance_min_candidate = kv.Value; Queue <int> queue = new Queue <int> (); if (!messages [partition [v - 1]].TryGetValue(v, out distance_min) || distance_min > v_distance_min_candidate) { messages [partition [v - 1]] [v] = v_distance_min_candidate; queue.Enqueue(v); while (queue.Count > 0) // Busca em profundidade { v = queue.Dequeue(); v_distance_min_candidate = messages [partition [v - 1]] [v]; IEnumerator <KeyValuePair <int, float> > vneighbors = g.iteratorVertexWeightOf(v); //g.iteratorOutgoingVertexWeightOf (v); while (vneighbors.MoveNext()) { int n = vneighbors.Current.Key; float n_distance_min_candidate = vneighbors.Current.Value + v_distance_min_candidate; if (!messages [partition [n - 1]].TryGetValue(n, out distance_min) || distance_min > n_distance_min_candidate) { messages [partition [n - 1]] [n] = n_distance_min_candidate; queue.Enqueue(n); emite [partition [n - 1]] = true; } } } } } } }
private void createPageNodes(string fileContent) { IIteratorInstance <IKVPair <IInteger, IPageNode> > output = (IIteratorInstance <IKVPair <IInteger, IPageNode> >)Output_data.Instance; IDictionary <int, IDictionary <int, IPageNodeInstance> > dictionary = new Dictionary <int, IDictionary <int, IPageNodeInstance> >(); IList <IKVPairInstance <IInteger, IPageNode> > PAGENODES = new List <IKVPairInstance <IInteger, IPageNode> >(); string[] lines = fileContent.Split(new char[] { System.Environment.NewLine[0] }); foreach (string line in lines) { if (!line.Trim().Equals("")) { IPageNodeInstance V, W, temp = null; IDictionary <int, IPageNodeInstance> referenceV, referenceW = null; int[] KEY = new int[2]; string[] vwID = line.Split(' '); for (int k = 0; k < 2; k++) { KEY [k] = int.Parse(vwID [k]); } if (!dictionary.TryGetValue(KEY [0], out referenceV)) { IKVPairInstance <IInteger, IPageNode> kvpair = (IKVPairInstance <IInteger, IPageNode>)Output_data.createItem(); V = (IPageNodeInstance)kvpair.Value; V.IdInstance = KEY [0]; ((IIntegerInstance)kvpair.Key).Value = V.IdInstance; referenceV = new Dictionary <int, IPageNodeInstance> (); dictionary [KEY [0]] = referenceV; referenceV [KEY [0]] = V; PAGENODES.Add(kvpair); } if (!dictionary.TryGetValue(KEY [1], out referenceW)) { IKVPairInstance <IInteger, IPageNode> kvpair = (IKVPairInstance <IInteger, IPageNode>)Output_data.createItem(); W = (IPageNodeInstance)kvpair.Value; W.IdInstance = KEY [1]; ((IIntegerInstance)kvpair.Key).Value = W.IdInstance; referenceW = new Dictionary <int, IPageNodeInstance> (); dictionary [KEY [1]] = referenceW; referenceW [KEY [1]] = W; PAGENODES.Add(kvpair); } if (!referenceV.TryGetValue(KEY [1], out temp)) { V = referenceV [KEY [0]]; W = referenceW [KEY [1]]; referenceV [KEY [1]] = W; V.NeighborsInstance.Add(W.IdInstance); } } } IEnumerator <IKVPairInstance <IInteger, IPageNode> > iterator = PAGENODES.GetEnumerator(); while (iterator.MoveNext()) { IKVPairInstance <IInteger, IPageNode> kvpair = iterator.Current; IIntegerInstance k = (IIntegerInstance)kvpair.Key; output.put(kvpair); dic [k.Value] = kvpair; } output.finish(); }
public override void main() { string[] string_iteracoes = readInput("/home/hpe/iteracoes").Split(new char[] { System.Environment.NewLine[0] }); int iteracoes = int.Parse(string_iteracoes [0]); int done = 0; IStringInstance input_data_instance = (IStringInstance)Input_data.Instance; IStringInstance output_data_instance = (IStringInstance)Output_data.Instance; IIntegerInstance termination_flag = (IIntegerInstance)Termination_flag.Instance; string setE = input_data_instance.Value; string setV = "1 c 0" + System.Environment.NewLine; string setVsetE = setV + setE; IDictionary <int, int> vertices = new Dictionary <int, int>(); foreach (string edge in setE.Split(System.Environment.NewLine.ToCharArray())) { if (edge.Length > 0) { int vertex = edge [0]; if (!vertices.ContainsKey(vertex)) { setV += edge [0] + " d " + int.MaxValue + System.Environment.NewLine; vertices.Add(vertex, vertex); } } } input_data_instance.Value = setV + System.Environment.NewLine + setE; int count = 0; while (count++ < iteracoes) //done == 0) { ////////Console.WriteLine (Rank + ": --- BEGIN ITERATION PATH_FLOW.GO ! - " + (++count) + System.Environment.NewLine + setV); ////////Console.WriteLine (Rank + ": iteration = " + count); long t0 = (long)(DateTime.UtcNow - (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc))).TotalMilliseconds; this.Path_bsp.go(); long t1 = (long)(DateTime.UtcNow - (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc))).TotalMilliseconds; writeFile("./outPathBspApp-" + Rank, "" + (t1 - t0)); // + getDateTime (), "" + (t1 - t0)); Console.WriteLine("Time: " + (t1 - t0) + " ms"); //writeFile ("./outPathBspApp-IT"+count, output_data_instance.Value);// + getDateTime (), "" + (t1 - t0)); //setV = output_data_instance.Value; ////////Trace.WriteLine (Rank + ": --- setV = " + setV); //done = setV.EndsWith ("True") ? 1 : 0; //termination_flag.Value = done; //Set_termination_flag.go (); //setV = setV.Remove (setV.IndexOf (done == 1 ? "True" : "False") - 2); ////////Trace.WriteLine (Rank + ": --- END ITERATION PATH_FLOW.GO ! - " + count); input_data_instance.Value = setVsetE; //setV; } ////////Console.WriteLine (Rank + ": --- FINISH PATH_FLOW.GO !"); }
public override void main() { int di = int.MaxValue; int dmin = int.MaxValue; int done = 1; Trace.WriteLine(Rank + ": START REDUCE FUNCTION"); IKVPairInstance <IInteger, IIterator <IPathInfo> > input_instance = (IKVPairInstance <IInteger, IIterator <IPathInfo> >)Input_values.Instance; IIntegerInstance k = (IIntegerInstance)input_instance.Key; IIteratorInstance <IPathInfo> v = (IIteratorInstance <IPathInfo>)input_instance.Value; int k_int = k.Value; if (!neighbours.ContainsKey(k_int)) { neighbours [k_int] = new Dictionary <int, int> (); } object o; while (v.fetch_next(out o)) { IPathInfoInstance item = (IPathInfoInstance)o; Info item_info = (Info)item.Value; Trace.WriteLine(Rank + ": REDUCE FUNCTION LOOP " + item_info); switch (item_info.info_type) { case Info.PATH_INFO_TYPE_DISTANCE_TRIAL: DistanceInfo distance_item_info_1 = (DistanceInfo)item_info; int tmp = distance_item_info_1.distance; dmin = (int)min(dmin, tmp); break; case Info.PATH_INFO_TYPE_DISTANCE_PARTIAL: DistanceInfo distance_item_info_2 = (DistanceInfo)item_info; di = distance_item_info_2.distance; break; case Info.PATH_INFO_TYPE_EDGE: EdgeInfo edge_item_info = (EdgeInfo)item_info; IDictionary <int, int> output_neibours = neighbours[k_int]; int n = edge_item_info.vertex_other; int d = 0; if (!output_neibours.TryGetValue(n, out d)) { output_neibours[n] = edge_item_info.weight; } else if (edge_item_info.weight < d) { output_neibours[n] = edge_item_info.weight; } break; } } Trace.WriteLine(Rank + ": REDUCE FUNCTION AFTER LOOP #1 "); IKVPairInstance <IInteger, IIterator <IPathInfo> > orv = (IKVPairInstance <IInteger, IIterator <IPathInfo> >)Output_value.newInstance(); IIteratorInstance <IPathInfo> buffer = (IIteratorInstance <IPathInfo>)orv.Value; Trace.WriteLine(Rank + ": REDUCE FUNCTION OUT LOOP #2 "); //IPathInfo path_info = buffer.createItem(); dmin = (int)min(dmin, di); if (dmin != di) { foreach (KeyValuePair <int, int> kv in neighbours[k_int]) { //IPathInfoInstance path_info_instance = (IPathInfoInstance) path_info.newInstance (); IPathInfoInstance path_info_instance = (IPathInfoInstance)buffer.createItem(); DistanceInfo distance_info = new DistanceInfo(); distance_info.info_type = Info.PATH_INFO_TYPE_DISTANCE_TRIAL; distance_info.vertex = kv.Key; distance_info.distance = kv.Value + dmin; path_info_instance.Value = distance_info; buffer.put(path_info_instance); Trace.WriteLine(Rank + ": REDUCE FUNCTION OTHER LOOP " + distance_info); } done = 0; } ((IIntegerInstance)orv.Key).Value = done; IPathInfoInstance path_info_instance_2 = (IPathInfoInstance)buffer.createItem(); DistanceInfo distance_info_2 = new DistanceInfo(); distance_info_2.info_type = Info.PATH_INFO_TYPE_DISTANCE_PARTIAL; distance_info_2.vertex = k.Value; distance_info_2.distance = dmin; path_info_instance_2.Value = distance_info_2; buffer.put(path_info_instance_2); Trace.WriteLine(Rank + ": REDUCE FUNCTION OTHER LOOP OUT " + distance_info_2); buffer.finish(); Trace.WriteLine(Rank + ": FINISH REDUCE FUNCTION"); }