use of edu.iu.dsc.tws.dataset.DataObjectImpl in project twister2 by DSC-SPIDAL.
the class TaskWorkerDataLoader method showAllUnits.
public void showAllUnits(DataObject<Object> dataPointsObject) {
for (int i = 0; i < dataPointsObject.getPartitions().length; i++) {
DataPartition<Object> values = dataPointsObject.getPartitions()[i];
DataPartitionConsumer<Object> dataPartitionConsumer = values.getConsumer();
// LOG.info("Final Receive : " + dataPartitionConsumer.hasNext());
while (dataPartitionConsumer.hasNext()) {
LOG.info(String.format("Id1[%d], Type: %s", i, dataPartitionConsumer.next().getClass().getName()));
Object object = dataPartitionConsumer.next();
if (object instanceof DataObjectImpl<?>) {
DataObjectImpl<?> dataObjectImpl = (DataObjectImpl<?>) object;
LOG.info(String.format("Id1[%d], Partition Count : %d", i, dataObjectImpl.getPartitionCount()));
int numpar = dataObjectImpl.getPartitions().length;
LOG.info("Number of Partitions : " + numpar);
for (int j = 0; j < dataObjectImpl.getPartitions().length; j++) {
DataPartition<?> values1 = dataObjectImpl.getPartitions()[j];
Object object1 = values1.getConsumer().next();
LOG.info(String.format("Ids[%d,%d] , Received Object : %s ", i, j, object1.getClass().getName()));
if (object1 instanceof Iterator<?>) {
Iterator<?> itr = (Iterator<?>) object1;
while (itr.hasNext()) {
Object object2 = itr.next();
if (object2 instanceof String) {
LOG.info(String.format("Ids[%d,%d] , Worker Id %d / %d, Data : %s", i, j, workerId, workers, String.valueOf(object2)));
}
}
}
}
}
}
}
}
use of edu.iu.dsc.tws.dataset.DataObjectImpl in project twister2 by DSC-SPIDAL.
the class TaskExecutor method collectData.
/**
* This method collects all the output from the provided {@link ExecutionPlan}.
* The partition IDs will be assigned just before adding the partitions to the {@link DataObject}
*/
public static void collectData(Config cfg, ExecutionPlan executionPlan, Map<String, DataObject> dataMap) {
Map<Integer, INodeInstance> nodes = executionPlan.getNodes();
Map<String, DataObject> dataObjectMapForPlan = new HashMap<>();
if (nodes != null) {
nodes.forEach((taskId, node) -> {
INode task = node.getNode();
if (task instanceof Collector) {
Set<String> collectibleNames = ((Collector) task).getCollectibleNames();
collectibleNames.forEach(name -> {
DataPartition partition = ((Collector) task).get(name);
// if this task outs only one partition and user has implemented no arg get() method
if (collectibleNames.size() == 1 && partition == null) {
partition = ((Collector) task).get();
}
if (partition != null) {
partition.setId(node.getIndex());
dataObjectMapForPlan.computeIfAbsent(name, n -> new DataObjectImpl<>(cfg)).addPartition(partition);
} else {
LOG.warning(String.format("Task index %d of task %d returned null for data %s", node.getIndex(), node.getId(), name));
}
});
}
});
}
dataMap.putAll(dataObjectMapForPlan);
}
Aggregations