use of model.Person in project compss by bsc-wdc.
the class Internal method testMergeReduce.
public static void testMergeReduce() {
// Init
Person[] people = new Person[4];
for (int i = 0; i < people.length; ++i) {
String id = "person_" + UUID.randomUUID().toString();
System.out.println("[LOG][PSCO_MR] Person " + i + " BeginId = " + id);
people[i] = new Person("PName" + i, i, i);
people[i].makePersistent(id);
}
// Map
for (int i = 0; i < people.length; ++i) {
people[i] = InternalImpl.taskMap("NewName" + i, people[i]);
}
// Reduce
LinkedList<Integer> q = new LinkedList<Integer>();
for (int i = 0; i < people.length; i++) {
q.add(i);
}
int x = 0;
while (!q.isEmpty()) {
x = q.poll();
int y;
if (!q.isEmpty()) {
y = q.poll();
people[x] = InternalImpl.taskReduce(people[x], people[y]);
q.add(x);
}
}
// Get (sync) and write result
Person p1 = people[0];
String name = p1.getName();
int age = p1.getAge();
int numC = p1.getNumComputers();
System.out.println("[LOG][PSCO_MR] Person " + name + " with age " + age + " has " + numC + " computers");
System.out.println("[LOG][PSCO_MR] EndId = " + p1.getID());
}
Aggregations