(data, ctx)
| 249 | } |
| 250 | |
| 251 | function parsePlan(data, ctx) { |
| 252 | let idx = 1, |
| 253 | lvl = data.level = data.level || [idx], |
| 254 | plans = [], |
| 255 | nodeType = data['Node Type'], |
| 256 | // Calculating relative xpos of current node from top node |
| 257 | xpos = data.xpos = data.xpos - pWIDTH, |
| 258 | // Calculating relative ypos of current node from top node |
| 259 | ypos = data.ypos, |
| 260 | maxChildWidth = 0; |
| 261 | |
| 262 | ctx.totalNodes++; |
| 263 | ctx.explainTable.total_time = data['total_time'] || data['Actual Total Time']; |
| 264 | |
| 265 | data['_serial'] = ctx.totalNodes; |
| 266 | data['width'] = pWIDTH; |
| 267 | data['height'] = pHEIGHT; |
| 268 | |
| 269 | // Calculate arrow width according to cost of a particular plan |
| 270 | let arrowSize = DEFAULT_ARROW_SIZE; |
| 271 | let startCost = data['Startup Cost'], |
| 272 | totalCost = data['Total Cost']; |
| 273 | if (startCost != undefined && totalCost != undefined) { |
| 274 | arrowSize = Math.round(Math.log((startCost + totalCost) / 2 + startCost)); |
| 275 | if (arrowSize < 1) { |
| 276 | arrowSize = 1; |
| 277 | } else if (arrowSize > 10) { |
| 278 | arrowSize = 10; |
| 279 | } |
| 280 | } |
| 281 | data['arr_id'] = _.uniqueId('arr'); |
| 282 | ctx.arrows[data['arr_id']] = arrowSize; |
| 283 | /* |
| 284 | * calculating xpos, ypos, width and height if current node is a subplan |
| 285 | */ |
| 286 | if (data['Parent Relationship'] === 'SubPlan') { |
| 287 | data['width'] += (xMargin * 2) + (xMargin / 2); |
| 288 | data['height'] += (yMargin * 2); |
| 289 | data['ypos'] += yMargin; |
| 290 | xpos -= xMargin; |
| 291 | ypos += yMargin; |
| 292 | } |
| 293 | |
| 294 | if (nodeType.startsWith('(slice')) |
| 295 | nodeType = nodeType.substring(0, 7); |
| 296 | |
| 297 | // Get the image information for current node |
| 298 | let mappedImage = (_.isFunction(ImageMapper[nodeType]) && |
| 299 | ImageMapper[nodeType].apply(undefined, [data])) || |
| 300 | ImageMapper[nodeType] || { |
| 301 | 'image': 'ex_unknown.svg', |
| 302 | 'image_text': nodeType, |
| 303 | }; |
| 304 | |
| 305 | data['image'] = mappedImage['image']; |
| 306 | data['image_text'] = mappedImage['image_text']; |
| 307 | |
| 308 | if ('Actual Total Time' in data && 'Actual Loops' in data) { |
no test coverage detected