Node node = null;
while (!workQueue.isEmpty()) {
Node processingNode = workQueue.remove();
if (!GraphUtil.isAllInputsConnected(processingNode)) {
throw new XBayaRuntimeException(
"Disconnedted node inputs during labeling");
}
if (GraphUtil.isAllInputsLabeled(processingNode)) {
String sameLabel = GraphUtil.isSameLabeledInput(processingNode);
if (null != sameLabel) {
// same label so its a regular node
if (GraphUtil.isRegulerNode(processingNode)) {
processingNode.setLabel(sameLabel);
String nodeLabel = processingNode.getLabel();
List<DataPort> outputPorts = processingNode
.getOutputPorts();
for (DataPort dataPort : outputPorts) {
List<DataEdge> edges = dataPort.getEdges();
for (DataEdge dataEdge : edges) {
dataEdge.setLabel(nodeLabel);
}
workQueue.addAll(dataPort.getToNodes());
}
} else {
processingNode.inventLabel(GraphUtil
.getEncodedInputLabels(processingNode));
String nodeOutLabel = processingNode.getLabel()
+ "_out";
List<DataPort> outputPorts = processingNode
.getOutputPorts();
for (DataPort dataPort : outputPorts) {
List<DataEdge> edges = dataPort.getEdges();
for (DataEdge dataEdge : edges) {
dataEdge.setLabel(nodeOutLabel);
}
workQueue.addAll(dataPort.getToNodes());
}
}
} else {
// may need to introduce a join
// if its CEP node we assume it doesnt require
// joins
// Its hard to determine if the CEP node would
// resolve the joins
if (!GraphUtil.isCEPNode(processingNode)) {
processingNode.setRequireJoin(true);
}
processingNode.inventLabel(GraphUtil
.getEncodedInputLabels(processingNode));
String nodeOutLabel = processingNode.getLabel() + "_out";
List<DataPort> outputPorts = processingNode
.getOutputPorts();
for (DataPort dataPort : outputPorts) {
List<DataEdge> edges = dataPort.getEdges();
for (DataEdge dataEdge : edges) {
dataEdge.setLabel(nodeOutLabel);
}
workQueue.addAll(dataPort.getToNodes());
}
}
} else {
workQueue.add(processingNode);
}
}
// if work queue is empty yet all are not labeled graph is not connected
// !!
List<EdgeImpl> edges = this.getEdges();
for (EdgeImpl edge : edges) {
if (null == edge.getLabel()) {
throw new XBayaRuntimeException(
"Some edges were not labeled after labeling algorithm. Possibly partitioned graph");
}
System.out.println(edge.getLabel());
System.out.println(edge);
}