@hpcc-js/comms
Version:
hpcc-js - Communications
759 lines • 29.9 kB
JavaScript
// Ported from: https://github.com/hpcc-systems/HPCC-Platform/blob/f0ed9dbeca49c39fb55aa28fec295c89407ac663/esp/src/src/ESPGraph.ts
import { __extends, __spreadArray } from "tslib";
export function safeAssign(obj, key, value) {
if (key === "__proto__" || key === "constructor" || key === "prototype")
return;
obj[key] = value;
}
function xmlEncode(str) {
str = "" + str;
return str.replace(/&/g, "&")
.replace(/"/g, """)
.replace(/'/g, "'")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/\n/g, " ")
.replace(/\r/g, " ");
}
function espTime2Seconds(duration) {
if (!duration) {
return 0;
}
else if (!isNaN(+duration)) {
return parseFloat(duration);
}
var re = /(?:(?:(\d+).days.)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+\.\d+|\d+)s))|(?:(\d+\.\d+|\d+)ms|(\d+\.\d+|\d+)us|(\d+\.\d+|\d+)ns)/;
var match = re.exec(duration);
if (!match)
return 0;
var days = +match[1] || 0;
var hours = +match[2] || 0;
var mins = +match[3] || 0;
var secs = +match[4] || 0;
var ms = +match[5] || 0;
var us = +match[6] || 0;
var ns = +match[7] || 0;
return (days * 24 * 60 * 60) + (hours * 60 * 60) + (mins * 60) + secs + ms / 1000 + us / 1000000 + ns / 1000000000;
}
function unitTest(size, unit) {
var nsIndex = size.indexOf(unit);
if (nsIndex !== -1) {
return parseFloat(size.substring(0, nsIndex));
}
return -1;
}
function espSize2Bytes(size) {
if (!size) {
return 0;
}
else if (!isNaN(+size)) {
return parseFloat(size);
}
var retVal = unitTest(size, "Kb");
if (retVal >= 0) {
return retVal * 1024;
}
retVal = unitTest(size, "Mb");
if (retVal >= 0) {
return retVal * Math.pow(1024, 2);
}
retVal = unitTest(size, "Gb");
if (retVal >= 0) {
return retVal * Math.pow(1024, 3);
}
retVal = unitTest(size, "Tb");
if (retVal >= 0) {
return retVal * Math.pow(1024, 4);
}
retVal = unitTest(size, "Pb");
if (retVal >= 0) {
return retVal * Math.pow(1024, 5);
}
retVal = unitTest(size, "Eb");
if (retVal >= 0) {
return retVal * Math.pow(1024, 6);
}
retVal = unitTest(size, "Zb");
if (retVal >= 0) {
return retVal * Math.pow(1024, 7);
}
retVal = unitTest(size, "b");
if (retVal >= 0) {
return retVal;
}
return 0;
}
function espSkew2Number(skew) {
if (!skew) {
return 0;
}
return parseFloat(skew);
}
var GRAPH_TYPE;
(function (GRAPH_TYPE) {
GRAPH_TYPE[GRAPH_TYPE["UNKNOWN"] = 0] = "UNKNOWN";
GRAPH_TYPE[GRAPH_TYPE["GRAPH"] = 1] = "GRAPH";
GRAPH_TYPE[GRAPH_TYPE["SUBGRAPH"] = 2] = "SUBGRAPH";
GRAPH_TYPE[GRAPH_TYPE["VERTEX"] = 3] = "VERTEX";
GRAPH_TYPE[GRAPH_TYPE["EDGE"] = 4] = "EDGE";
GRAPH_TYPE[GRAPH_TYPE["LAST"] = 5] = "LAST";
})(GRAPH_TYPE || (GRAPH_TYPE = {}));
var GRAPH_TYPE_STRING;
(function (GRAPH_TYPE_STRING) {
GRAPH_TYPE_STRING["UNKNOWN"] = "Unknown";
GRAPH_TYPE_STRING["GRAPH"] = "Graph";
GRAPH_TYPE_STRING["SUBGRAPH"] = "Cluster";
GRAPH_TYPE_STRING["VERTEX"] = "Vertex";
GRAPH_TYPE_STRING["EDGE"] = "Edge";
GRAPH_TYPE_STRING["LAST"] = "Last";
})(GRAPH_TYPE_STRING || (GRAPH_TYPE_STRING = {}));
var LocalisedXGMMLWriter = /** @class */ (function () {
function LocalisedXGMMLWriter(graph) {
this.graph = graph;
this.m_xgmml = "";
this.m_visibleSubgraphs = {};
this.m_visibleVertices = {};
this.m_semiVisibleVertices = {};
this.m_visibleEdges = {};
}
LocalisedXGMMLWriter.prototype.calcVisibility = function (items, localisationDepth, localisationDistance, noSpills) {
var _this = this;
this.noSpills = noSpills;
items.forEach(function (item) {
if (_this.graph.isVertex(item)) {
_this.calcInVertexVisibility(item, localisationDistance);
_this.calcOutVertexVisibility(item, localisationDistance);
}
else if (_this.graph.isEdge(item)) {
_this.calcInVertexVisibility(item.getSource(), localisationDistance - 1);
_this.calcOutVertexVisibility(item.getTarget(), localisationDistance - 1);
}
else if (_this.graph.isSubgraph(item)) {
_this.m_visibleSubgraphs[item.__hpcc_id] = item;
_this.calcSubgraphVisibility(item, localisationDepth - 1);
}
});
this.calcVisibility2();
};
LocalisedXGMMLWriter.prototype.calcInVertexVisibility = function (vertex, localisationDistance) {
var _this = this;
if (this.noSpills && vertex.isSpill()) {
localisationDistance++;
}
this.m_visibleVertices[vertex.__hpcc_id] = vertex;
if (localisationDistance > 0) {
vertex.getInEdges().forEach(function (edge) {
_this.calcInVertexVisibility(edge.getSource(), localisationDistance - 1);
});
}
};
LocalisedXGMMLWriter.prototype.calcOutVertexVisibility = function (vertex, localisationDistance) {
var _this = this;
if (this.noSpills && vertex.isSpill()) {
localisationDistance++;
}
this.m_visibleVertices[vertex.__hpcc_id] = vertex;
if (localisationDistance > 0) {
vertex.getOutEdges().forEach(function (edge) {
_this.calcOutVertexVisibility(edge.getTarget(), localisationDistance - 1);
});
}
};
LocalisedXGMMLWriter.prototype.calcSubgraphVisibility = function (subgraph, localisationDepth) {
var _this = this;
if (localisationDepth < 0) {
return;
}
if (localisationDepth > 0) {
subgraph.__hpcc_subgraphs.forEach(function (subgraph, idx) {
_this.calcSubgraphVisibility(subgraph, localisationDepth - 1);
});
}
subgraph.__hpcc_subgraphs.forEach(function (subgraph, idx) {
_this.m_visibleSubgraphs[subgraph.__hpcc_id] = subgraph;
});
subgraph.__hpcc_vertices.forEach(function (vertex, idx) {
_this.m_visibleVertices[vertex.__hpcc_id] = vertex;
});
// Calculate edges that pass through the subgraph ---
var dedupEdges = {};
this.graph.edges.forEach(function (edge, idx) {
if (edge.getSource().__hpcc_parent !== edge.getTarget().__hpcc_parent && subgraph === _this.getCommonAncestor(edge)) {
// Only include one unique edge between subgraphs ---
if (!dedupEdges[edge.getSource().__hpcc_parent.__hpcc_id + "::" + edge.getTarget().__hpcc_parent.__hpcc_id]) {
dedupEdges[edge.getSource().__hpcc_parent.__hpcc_id + "::" + edge.getTarget().__hpcc_parent.__hpcc_id] = true;
_this.m_visibleEdges[edge.__hpcc_id] = edge;
}
}
});
};
LocalisedXGMMLWriter.prototype.buildVertexString = function (vertex, isPoint) {
var attrStr = "";
var propsStr = "";
var props = vertex.getProperties();
for (var key in props) {
if (isPoint && key.indexOf("_kind") >= 0) {
propsStr += "<att name=\"_kind\" value=\"point\"/>";
}
else if (key === "id" || key === "label") {
attrStr += " " + key + "=\"" + xmlEncode(props[key]) + "\"";
}
else {
propsStr += "<att name=\"" + key + "\" value=\"" + xmlEncode(props[key]) + "\"/>";
}
}
return "<node" + attrStr + ">" + propsStr + "</node>";
};
LocalisedXGMMLWriter.prototype.buildEdgeString = function (edge) {
var attrStr = "";
var propsStr = "";
var props = edge.getProperties();
for (var key in props) {
if (key.toLowerCase() === "id" ||
key.toLowerCase() === "label" ||
key.toLowerCase() === "source" ||
key.toLowerCase() === "target") {
attrStr += " " + key + "=\"" + xmlEncode(props[key]) + "\"";
}
else {
propsStr += "<att name=\"" + key + "\" value=\"" + xmlEncode(props[key]) + "\"/>";
}
}
return "<edge" + attrStr + ">" + propsStr + "</edge>";
};
LocalisedXGMMLWriter.prototype.getAncestors = function (v, ancestors) {
var parent = v.__hpcc_parent;
while (parent) {
ancestors.push(parent);
parent = parent.__hpcc_parent;
}
};
LocalisedXGMMLWriter.prototype.getCommonAncestorV = function (v1, v2) {
var v1_ancestors = [];
var v2_ancestors = [];
this.getAncestors(v1, v1_ancestors);
this.getAncestors(v2, v2_ancestors);
var finger1 = v1_ancestors.length - 1;
var finger2 = v2_ancestors.length - 1;
var retVal = null;
while (finger1 >= 0 && finger2 >= 0 && v1_ancestors[finger1] === v2_ancestors[finger2]) {
retVal = v1_ancestors[finger1];
--finger1;
--finger2;
}
return retVal;
};
LocalisedXGMMLWriter.prototype.getCommonAncestor = function (e) {
return this.getCommonAncestorV(e.getSource(), e.getTarget());
};
LocalisedXGMMLWriter.prototype.calcAncestorVisibility = function (vertex) {
var _this = this;
var ancestors = [];
this.getAncestors(vertex, ancestors);
ancestors.forEach(function (item, idx) {
_this.m_visibleSubgraphs[item.__hpcc_id] = item;
});
};
LocalisedXGMMLWriter.prototype.calcVisibility2 = function () {
var _this = this;
for (var key in this.m_visibleVertices) {
var vertex = this.m_visibleVertices[key];
vertex.getInEdges().forEach(function (edge, idx) {
_this.m_visibleEdges[edge.__hpcc_id] = edge;
});
vertex.getOutEdges().forEach(function (edge, idx) {
_this.m_visibleEdges[edge.__hpcc_id] = edge;
});
this.calcAncestorVisibility(vertex);
}
this.calcSemiVisibleVertices();
};
LocalisedXGMMLWriter.prototype.addSemiVisibleEdge = function (edge) {
if (edge && !this.m_visibleEdges[edge.__hpcc_id]) {
this.m_visibleEdges[edge.__hpcc_id] = edge;
}
};
LocalisedXGMMLWriter.prototype.addSemiVisibleVertex = function (vertex) {
if (!this.m_visibleVertices[vertex.__hpcc_id]) {
this.m_semiVisibleVertices[vertex.__hpcc_id] = vertex;
this.calcAncestorVisibility(vertex);
}
};
LocalisedXGMMLWriter.prototype.calcSemiVisibleVertices = function () {
for (var key in this.m_visibleEdges) {
var edge = this.m_visibleEdges[key];
var source = edge.getSource();
this.addSemiVisibleVertex(source);
while (this.noSpills && source.isSpill()) {
var inEdges = source.getInEdges();
if (inEdges.length) {
this.addSemiVisibleEdge(inEdges[0]);
source = inEdges[0].getSource();
this.addSemiVisibleVertex(source);
}
else {
break;
}
}
var target = edge.getTarget();
this.addSemiVisibleVertex(target);
while (this.noSpills && target.isSpill()) {
var outEdges = target.getOutEdges();
if (outEdges.length) {
this.addSemiVisibleEdge(outEdges[0]);
target = outEdges[0].getTarget();
this.addSemiVisibleVertex(target);
}
else {
break;
}
}
}
};
LocalisedXGMMLWriter.prototype.writeXgmml = function () {
var _this = this;
this.subgraphVisited(this.graph.subgraphs[0], true);
this.graph.edges.forEach(function (edge, idx) {
_this.edgeVisited(edge);
});
};
LocalisedXGMMLWriter.prototype.subgraphVisited = function (subgraph, root) {
if (root === void 0) { root = false; }
if (this.m_visibleSubgraphs[subgraph.__hpcc_id]) {
var propsStr = "";
this.m_xgmml += root ? "" : "<node id=\"" + subgraph.__hpcc_id + "\"><att><graph>";
var xgmmlLen = this.m_xgmml.length;
subgraph.walkSubgraphs(this);
subgraph.walkVertices(this);
if (xgmmlLen === this.m_xgmml.length) {
// Add at least one child otherwise subgraphs will render as a vertex ---
var vertex = subgraph.__hpcc_vertices[0];
if (vertex) {
this.m_xgmml += this.buildVertexString(vertex, true);
}
}
var props = subgraph.getProperties();
for (var key in props) {
propsStr += "<att name=\"" + key + "\" value=\"" + xmlEncode(props[key]) + "\"/>";
}
this.m_xgmml += root ? "" : "</graph></att>" + propsStr + "</node>";
}
return false;
};
LocalisedXGMMLWriter.prototype.vertexVisited = function (vertex) {
if (this.m_visibleVertices[vertex.__hpcc_id]) {
this.m_xgmml += this.buildVertexString(vertex, false);
}
else if (this.m_semiVisibleVertices[vertex.__hpcc_id]) {
this.m_xgmml += this.buildVertexString(vertex, true);
}
};
LocalisedXGMMLWriter.prototype.edgeVisited = function (edge) {
if (this.m_visibleEdges[edge.__hpcc_id]) {
this.m_xgmml += this.buildEdgeString(edge);
}
};
return LocalisedXGMMLWriter;
}());
var GraphItem = /** @class */ (function () {
function GraphItem(graph, id) {
this.__hpcc_graph = graph;
this.__hpcc_id = id;
this._globalID = id;
}
GraphItem.prototype.getProperties = function () {
var retVal = {};
for (var key in this) {
if (key.indexOf("__") !== 0 && this.hasOwnProperty(key)) {
retVal[key] = this[key];
}
}
return retVal;
};
return GraphItem;
}());
var Subgraph = /** @class */ (function (_super) {
__extends(Subgraph, _super);
function Subgraph(graph, id) {
var _this = _super.call(this, graph, id) || this;
_this._globalType = id === "0" ? "Graph" : "Cluster";
_this.__hpcc_subgraphs = [];
_this.__hpcc_vertices = [];
_this.__hpcc_edges = [];
_this.id = id;
return _this;
}
Subgraph.prototype.addSubgraph = function (subgraph) {
subgraph.__hpcc_parent = this;
if (!this.__hpcc_subgraphs.some(function (subgraph2) { return subgraph === subgraph2; })) {
this.__hpcc_subgraphs.push(subgraph);
}
};
Subgraph.prototype.addVertex = function (vertex) {
vertex.__hpcc_parent = this;
if (!this.__hpcc_vertices.some(function (vertex2) { return vertex === vertex2; })) {
this.__hpcc_vertices.push(vertex);
}
};
Subgraph.prototype.removeVertex = function (vertex) {
this.__hpcc_vertices = this.__hpcc_vertices.filter(function (vertex2) { return vertex !== vertex2; });
};
Subgraph.prototype.addEdge = function (edge) {
edge.__hpcc_parent = this;
if (!this.__hpcc_edges.some(function (edge2) { return edge === edge2; })) {
this.__hpcc_edges.push(edge);
}
};
Subgraph.prototype.removeEdge = function (edge) {
this.__hpcc_edges = this.__hpcc_edges.filter(function (edge2) { return edge !== edge2; });
};
Subgraph.prototype.remove = function () {
var _this = this;
this.__hpcc_subgraphs.forEach(function (subgraph) { return subgraph.__hpcc_parent = _this.__hpcc_parent; });
this.__hpcc_vertices.forEach(function (vertex) { return vertex.__hpcc_parent = _this.__hpcc_parent; });
this.__hpcc_edges.forEach(function (edge) { return edge.__hpcc_parent = _this.__hpcc_parent; });
delete this.__hpcc_parent;
this.__hpcc_graph.removeItem(this);
};
Subgraph.prototype.walkSubgraphs = function (visitor) {
this.__hpcc_subgraphs.forEach(function (subgraph, idx) {
if (visitor.subgraphVisited(subgraph)) {
subgraph.walkSubgraphs(visitor);
}
});
};
Subgraph.prototype.walkVertices = function (visitor) {
this.__hpcc_vertices.forEach(function (vertex, idx) {
visitor.vertexVisited(vertex);
});
};
return Subgraph;
}(GraphItem));
var Vertex = /** @class */ (function (_super) {
__extends(Vertex, _super);
function Vertex(graph, id) {
var _this = _super.call(this, graph, id) || this;
_this._globalType = "Vertex";
return _this;
}
Vertex.prototype.isSpill = function () {
return this._isSpill;
};
Vertex.prototype.remove = function () {
var _a;
var inVertices = this.getInVertices();
if (inVertices.length <= 1) {
console.warn(this.__hpcc_id + ": remove only supports single or zero inputs activities...");
}
this.getInEdges().forEach(function (edge) {
edge.remove();
});
this.getOutEdges().forEach(function (edge) {
edge.setSource(inVertices[0]);
});
(_a = this.__hpcc_parent) === null || _a === void 0 ? void 0 : _a.removeVertex(this);
this.__hpcc_graph.removeItem(this);
};
Vertex.prototype.getInVertices = function () {
return this.getInEdges().map(function (edge) {
return edge.getSource();
});
};
Vertex.prototype.getInEdges = function () {
var _this = this;
return this.__hpcc_graph.edges.filter(function (edge) {
return edge.getTarget() === _this;
});
};
Vertex.prototype.getOutVertices = function () {
return this.getOutEdges().map(function (edge) {
return edge.getTarget();
});
};
Vertex.prototype.getOutEdges = function () {
var _this = this;
return this.__hpcc_graph.edges.filter(function (edge) {
return edge.getSource() === _this;
});
};
return Vertex;
}(GraphItem));
var Edge = /** @class */ (function (_super) {
__extends(Edge, _super);
function Edge(graph, id) {
var _this = _super.call(this, graph, id) || this;
_this._globalType = "Edge";
_this._globalType = "Edge";
return _this;
}
Edge.prototype.remove = function () {
var _this = this;
this.__hpcc_graph.subgraphs.forEach(function (subgraph) {
subgraph.removeEdge(_this);
});
this.__hpcc_graph.removeItem(this);
};
Edge.prototype.getSource = function () {
return this.__hpcc_graph.idx[this._sourceActivity || this.source];
};
Edge.prototype.setSource = function (source) {
if (this._sourceActivity) {
this._sourceActivity = source.__hpcc_id;
}
else if (this.source) {
this.source = source.__hpcc_id;
}
if (this.__widget) {
this.__widget.setSource(this.getSource().__widget);
}
};
Edge.prototype.getTarget = function () {
return this.__hpcc_graph.idx[this._targetActivity || this.target];
};
return Edge;
}(GraphItem));
var QueryGraph = /** @class */ (function () {
function QueryGraph() {
this.idx = {};
this.subgraphs = [];
this.vertices = [];
this.edges = [];
this.xgmml = "";
this.clear();
}
QueryGraph.prototype.clear = function () {
this.xgmml = "";
this.idx = {};
this.subgraphs = [];
this.vertices = [];
this.edges = [];
};
QueryGraph.prototype.load = function (xgmml) {
this.clear();
this.merge(xgmml);
};
QueryGraph.prototype.merge = function (xgmml) {
this.xgmml = xgmml;
var parser = new DOMParser();
var dom = parser.parseFromString(xgmml, "text/xml");
this.walkDocument(dom.documentElement, "0");
};
QueryGraph.prototype.isSubgraph = function (item) {
return item instanceof Subgraph;
};
QueryGraph.prototype.isVertex = function (item) {
return item instanceof Vertex;
};
QueryGraph.prototype.isEdge = function (item) {
return item instanceof Edge;
};
QueryGraph.prototype.getGlobalType = function (item) {
if (item instanceof Vertex) {
return GRAPH_TYPE.VERTEX;
}
else if (item instanceof Edge) {
return GRAPH_TYPE.EDGE;
}
else if (item instanceof Subgraph) {
return GRAPH_TYPE.SUBGRAPH;
}
else if (item instanceof QueryGraph) {
return GRAPH_TYPE.GRAPH;
}
return GRAPH_TYPE.UNKNOWN;
};
QueryGraph.prototype.getGlobalTypeString = function (item) {
if (item instanceof Vertex) {
return GRAPH_TYPE_STRING.VERTEX;
}
else if (item instanceof Edge) {
return GRAPH_TYPE_STRING.EDGE;
}
else if (item instanceof Subgraph) {
return GRAPH_TYPE_STRING.SUBGRAPH;
}
else if (item instanceof QueryGraph) {
return GRAPH_TYPE_STRING.GRAPH;
}
return GRAPH_TYPE_STRING.UNKNOWN;
};
QueryGraph.prototype.getItem = function (docNode, id) {
if (!this.idx[id]) {
switch (docNode.tagName) {
case "graph":
var subgraph = new Subgraph(this, id);
this.subgraphs.push(subgraph);
this.idx[id] = subgraph;
break;
case "node":
var vertex = new Vertex(this, id);
this.vertices.push(vertex);
this.idx[id] = vertex;
break;
case "edge":
var edge = new Edge(this, id);
this.edges.push(edge);
this.idx[id] = edge;
break;
default:
console.warn("Graph.getItem - Unknown Node Type!");
break;
}
}
var retVal = this.idx[id];
Array.from(docNode.attributes).forEach(function (attr) {
safeAssign(retVal, attr.name, attr.value);
});
return retVal;
};
QueryGraph.prototype.removeItem = function (item) {
delete this.idx[item.__hpcc_id];
if (item instanceof Subgraph) {
this.subgraphs = this.subgraphs.filter(function (subgraph) {
return item !== subgraph;
});
}
else if (item instanceof Vertex) {
this.vertices = this.vertices.filter(function (vertex) {
return item !== vertex;
});
}
else if (item instanceof Edge) {
this.edges = this.edges.filter(function (edge) {
return item !== edge;
});
}
};
QueryGraph.prototype.getChildByTagName = function (docNode, tagName) {
var retVal = null;
Array.from(docNode.childNodes).some(function (childNode, idx) {
if (childNode.tagName === tagName) {
retVal = childNode;
return true;
}
});
return retVal;
};
QueryGraph.prototype.walkDocument = function (docNode, id) {
var _this = this;
var retVal = this.getItem(docNode, id);
docNode.childNodes.forEach(function (childNode, idx) {
switch (childNode.nodeType) {
case 1: // ELEMENT_NODE
switch (childNode.tagName) {
case "graph":
break;
case "node":
var isSubgraph = false;
var attNode = _this.getChildByTagName(childNode, "att");
if (attNode) {
var graphNode = _this.getChildByTagName(attNode, "graph");
if (graphNode) {
isSubgraph = true;
var subgraph = _this.walkDocument(graphNode, childNode.getAttribute("id"));
retVal.addSubgraph(subgraph);
}
}
if (!isSubgraph) {
var vertex = _this.walkDocument(childNode, childNode.getAttribute("id"));
retVal.addVertex(vertex);
}
break;
case "att":
var name_1 = childNode.getAttribute("name");
var uname = "_" + name_1;
var value = childNode.getAttribute("value");
if (name_1.indexOf("Time") === 0) {
safeAssign(retVal, uname, value);
safeAssign(retVal, name_1, "" + espTime2Seconds(value));
}
else if (name_1.indexOf("Size") === 0) {
safeAssign(retVal, uname, value);
safeAssign(retVal, name_1, "" + espSize2Bytes(value));
}
else if (name_1.indexOf("Skew") === 0) {
safeAssign(retVal, uname, value);
safeAssign(retVal, name_1, "" + espSkew2Number(value));
}
else {
safeAssign(retVal, name_1, value);
}
break;
case "edge":
var edge = _this.walkDocument(childNode, childNode.getAttribute("id"));
if (edge.NumRowsProcessed !== undefined) {
edge._eclwatchCount = edge.NumRowsProcessed.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
else if (edge.Count !== undefined) {
edge._eclwatchCount = edge.Count.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
else if (edge.count !== undefined) {
edge._eclwatchCount = edge.count.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
if (edge.inputProgress) {
edge._eclwatchInputProgress = "[" + edge.inputProgress.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "]";
}
if (edge.SkewMaxRowsProcessed && edge.SkewMinRowsProcessed) {
edge._eclwatchSkew = "+" + edge.SkewMaxRowsProcessed + ", " + edge.SkewMinRowsProcessed;
}
if (edge._dependsOn) {
}
else if (edge._childGraph) {
}
else if (edge._sourceActivity || edge._targetActivity) {
edge._isSpill = true;
var source = edge.getSource();
source._isSpill = true;
var target = edge.getTarget();
target._isSpill = true;
}
retVal.addEdge(edge);
break;
default:
break;
}
break;
case 2: // ATTRIBUTE_NODE
case 3: // TEXT_NODE
case 4: // CDATA_SECTION_NODE
case 5: // ENTITY_REFERENCE_NODE
case 6: // ENTITY_NODE
case 7: // PROCESSING_INSTRUCTION_NODE
case 8: // COMMENT_NODE
case 9: // DOCUMENT_NODE
case 10: // DOCUMENT_TYPE_NODE
case 11: // DOCUMENT_FRAGMENT_NODE
case 12: // NOTATION_NODE
break;
default:
break;
}
});
return retVal;
};
QueryGraph.prototype.removeSubgraphs = function () {
var subgraphs = __spreadArray([], this.subgraphs, true);
subgraphs.forEach(function (subgraph) {
if (subgraph.__hpcc_parent instanceof Subgraph) {
subgraph.remove();
}
});
};
QueryGraph.prototype.removeSpillVertices = function () {
var vertices = __spreadArray([], this.vertices, true);
vertices.forEach(function (vertex) {
if (vertex.isSpill()) {
vertex.remove();
}
});
};
QueryGraph.prototype.getLocalisedXGMML = function (items, localisationDepth, localisationDistance, noSpills) {
var xgmmlWriter = new LocalisedXGMMLWriter(this);
xgmmlWriter.calcVisibility(items, localisationDepth, localisationDistance, noSpills);
xgmmlWriter.writeXgmml();
return "<graph>" + xgmmlWriter.m_xgmml + "</graph>";
};
return QueryGraph;
}());
export { QueryGraph };
//# sourceMappingURL=queryGraph.js.map