|
1 | 1 | /* |
| 2 | + * Elemental |
| 3 | + * Copyright (C) 2024, Evolved Binary Ltd |
| 4 | + * |
| 5 | + |
| 6 | + * https://www.evolvedbinary.com | https://www.elemental.xyz |
| 7 | + * |
| 8 | + * This library is free software; you can redistribute it and/or |
| 9 | + * modify it under the terms of the GNU Lesser General Public |
| 10 | + * License as published by the Free Software Foundation; version 2.1. |
| 11 | + * |
| 12 | + * This library is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | + * Lesser General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU Lesser General Public |
| 18 | + * License along with this library; if not, write to the Free Software |
| 19 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | + * |
| 21 | + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. |
| 22 | + * The original license header is included below. |
| 23 | + * |
| 24 | + * ===================================================================== |
| 25 | + * |
2 | 26 | * eXist-db Open Source Native XML Database |
3 | 27 | * Copyright (C) 2001 The eXist-db Authors |
4 | 28 | * |
|
19 | 43 | * License along with this library; if not, write to the Free Software |
20 | 44 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 | 45 | */ |
22 | | - |
23 | 46 | package org.exist.xquery; |
24 | 47 |
|
25 | 48 | import net.jcip.annotations.NotThreadSafe; |
@@ -365,48 +388,47 @@ private FunctionStats[] sort() { |
365 | 388 |
|
366 | 389 | @Override |
367 | 390 | public void serialize(final MemTreeBuilder builder) { |
368 | | - builder.startElement(new QName(XML_ELEMENT_CALLS, XML_NAMESPACE, XML_PREFIX), null); |
369 | | - if (isEnabled()) { |
370 | | - final AttributesImpl attrs = new AttributesImpl(); |
371 | | - for (final QueryStats stats : queries.values()) { |
372 | | - attrs.clear(); |
| 391 | + final AttributesImpl attrs = new AttributesImpl(); |
| 392 | + attrs.addAttribute("", "tracing-enabled", "tracing-enabled", "CDATA", Boolean.toString(isEnabled())); |
| 393 | + builder.startElement(new QName(XML_ELEMENT_CALLS, XML_NAMESPACE, XML_PREFIX), attrs); |
| 394 | + for (final QueryStats stats : queries.values()) { |
| 395 | + attrs.clear(); |
| 396 | + attrs.addAttribute("", "source", "source", "CDATA", stats.source); |
| 397 | + attrs.addAttribute("", "elapsed", "elapsed", "CDATA", Double.toString(stats.executionTime / 1000.0)); |
| 398 | + attrs.addAttribute("", "calls", "calls", "CDATA", Integer.toString(stats.callCount)); |
| 399 | + builder.startElement(new QName("query", XML_NAMESPACE, XML_PREFIX), attrs); |
| 400 | + builder.endElement(); |
| 401 | + } |
| 402 | + for (final FunctionStats stats : functions.values()) { |
| 403 | + attrs.clear(); |
| 404 | + attrs.addAttribute("", "name", "name", "CDATA", stats.qname.getStringValue()); |
| 405 | + attrs.addAttribute("", "elapsed", "elapsed", "CDATA", Double.toString(stats.executionTime / 1000.0)); |
| 406 | + attrs.addAttribute("", "calls", "calls", "CDATA", Integer.toString(stats.callCount)); |
| 407 | + if (stats.source != null) { |
373 | 408 | attrs.addAttribute("", "source", "source", "CDATA", stats.source); |
374 | | - attrs.addAttribute("", "elapsed", "elapsed", "CDATA", Double.toString(stats.executionTime / 1000.0)); |
375 | | - attrs.addAttribute("", "calls", "calls", "CDATA", Integer.toString(stats.callCount)); |
376 | | - builder.startElement(new QName("query", XML_NAMESPACE, XML_PREFIX), attrs); |
377 | | - builder.endElement(); |
378 | | - } |
379 | | - for (final FunctionStats stats : functions.values()) { |
380 | | - attrs.clear(); |
381 | | - attrs.addAttribute("", "name", "name", "CDATA", stats.qname.getStringValue()); |
382 | | - attrs.addAttribute("", "elapsed", "elapsed", "CDATA", Double.toString(stats.executionTime / 1000.0)); |
383 | | - attrs.addAttribute("", "calls", "calls", "CDATA", Integer.toString(stats.callCount)); |
384 | | - if (stats.source != null) { |
385 | | - attrs.addAttribute("", "source", "source", "CDATA", stats.source); |
386 | | - } |
387 | | - builder.startElement(new QName("function", XML_NAMESPACE, XML_PREFIX), attrs); |
388 | | - builder.endElement(); |
389 | | - } |
390 | | - for (final IndexStats stats : indexStats.values()) { |
391 | | - attrs.clear(); |
392 | | - attrs.addAttribute("", "type", "type", "CDATA", stats.indexType); |
393 | | - attrs.addAttribute("", "source", "source", "CDATA", stats.source + " [" + stats.line + ":" + |
394 | | - stats.column + "]"); |
395 | | - attrs.addAttribute("", "elapsed", "elapsed", "CDATA", Double.toString(stats.executionTime / 1000.0)); |
396 | | - attrs.addAttribute("", "calls", "calls", "CDATA", Integer.toString(stats.usageCount)); |
397 | | - attrs.addAttribute("", "optimization-level", "optimization", "CDATA", stats.indexOptimizationLevel.name()); |
398 | | - builder.startElement(new QName("index", XML_NAMESPACE, XML_PREFIX), attrs); |
399 | | - builder.endElement(); |
400 | 409 | } |
401 | | - for (final OptimizationStats stats : optimizations) { |
402 | | - attrs.clear(); |
403 | | - attrs.addAttribute("", "type", "type", "CDATA", stats.type.toString()); |
404 | | - if (stats.source != null) { |
405 | | - attrs.addAttribute("", "source", "source", "CDATA", stats.source + " [" + stats.line + ":" + stats.column + "]"); |
406 | | - } |
407 | | - builder.startElement(new QName("optimization", XML_NAMESPACE, XML_PREFIX), attrs); |
408 | | - builder.endElement(); |
| 410 | + builder.startElement(new QName("function", XML_NAMESPACE, XML_PREFIX), attrs); |
| 411 | + builder.endElement(); |
| 412 | + } |
| 413 | + for (final IndexStats stats : indexStats.values()) { |
| 414 | + attrs.clear(); |
| 415 | + attrs.addAttribute("", "type", "type", "CDATA", stats.indexType); |
| 416 | + attrs.addAttribute("", "source", "source", "CDATA", stats.source + " [" + stats.line + ":" + |
| 417 | + stats.column + "]"); |
| 418 | + attrs.addAttribute("", "elapsed", "elapsed", "CDATA", Double.toString(stats.executionTime / 1000.0)); |
| 419 | + attrs.addAttribute("", "calls", "calls", "CDATA", Integer.toString(stats.usageCount)); |
| 420 | + attrs.addAttribute("", "optimization-level", "optimization", "CDATA", stats.indexOptimizationLevel.name()); |
| 421 | + builder.startElement(new QName("index", XML_NAMESPACE, XML_PREFIX), attrs); |
| 422 | + builder.endElement(); |
| 423 | + } |
| 424 | + for (final OptimizationStats stats : optimizations) { |
| 425 | + attrs.clear(); |
| 426 | + attrs.addAttribute("", "type", "type", "CDATA", stats.type.toString()); |
| 427 | + if (stats.source != null) { |
| 428 | + attrs.addAttribute("", "source", "source", "CDATA", stats.source + " [" + stats.line + ":" + stats.column + "]"); |
409 | 429 | } |
| 430 | + builder.startElement(new QName("optimization", XML_NAMESPACE, XML_PREFIX), attrs); |
| 431 | + builder.endElement(); |
410 | 432 | } |
411 | 433 | builder.endElement(); |
412 | 434 | } |
|
0 commit comments