Skip to content

Commit e788af1

Browse files
committed
[bugfix] Allow previously collected Performance Stats to be serialized
1 parent 39df32e commit e788af1

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

exist-core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@
914914
<include>src/test/java/org/exist/xquery/ForwardReferenceTest.java</include>
915915
<include>src/main/java/org/exist/xquery/FunctionFactory.java</include>
916916
<include>src/main/java/org/exist/xquery/Optimizer.java</include>
917-
<include>src/main/java/org/exist/xquery/PerformanceStatsImpl.java</include>
917+
<include>src/main/java/org/exist/xquery/PerformanceStats.java</include>
918918
<include>src/main/java/org/exist/xquery/TryCatchExpression.java</include>
919919
<include>src/main/java/org/exist/xquery/UserDefinedFunction.java</include>
920920
<include>src/main/java/org/exist/xquery/XPathUtil.java</include>
@@ -1256,7 +1256,7 @@
12561256
<exclude>src/main/java/org/exist/xquery/Materializable.java</exclude>
12571257
<exclude>src/main/java/org/exist/xquery/NameTest.java</exclude>
12581258
<exclude>src/main/java/org/exist/xquery/Optimizer.java</exclude>
1259-
<exclude>src/main/java/org/exist/xquery/PerformanceStatsImpl.java</exclude>
1259+
<exclude>src/main/java/org/exist/xquery/PerformanceStats.java</exclude>
12601260
<exclude>src/main/java/org/exist/xquery/TryCatchExpression.java</exclude>
12611261
<exclude>src/main/java/org/exist/xquery/UserDefinedFunction.java</exclude>
12621262
<exclude>src/test/java/org/exist/xquery/WatchdogTest.java</exclude>

exist-core/src/main/java/org/exist/xquery/PerformanceStats.java

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
/*
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+
*
226
* eXist-db Open Source Native XML Database
327
* Copyright (C) 2001 The eXist-db Authors
428
*
@@ -19,7 +43,6 @@
1943
* License along with this library; if not, write to the Free Software
2044
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2145
*/
22-
2346
package org.exist.xquery;
2447

2548
import org.apache.commons.io.output.StringBuilderWriter;
@@ -317,9 +340,10 @@ private FunctionStats[] sort() {
317340
return stats;
318341
}
319342

320-
public synchronized void toXML(MemTreeBuilder builder) {
343+
public synchronized void toXML(final MemTreeBuilder builder) {
321344
final AttributesImpl attrs = new AttributesImpl();
322-
builder.startElement(new QName("calls", XML_NAMESPACE, XML_PREFIX), null);
345+
attrs.addAttribute("", "tracing-enabled", "tracing-enabled", "CDATA", Boolean.toString(isEnabled()));
346+
builder.startElement(new QName("calls", XML_NAMESPACE, XML_PREFIX), attrs);
323347
for (final QueryStats stats : queries.values()) {
324348
attrs.clear();
325349
attrs.addAttribute("", "source", "source", "CDATA", stats.source);
@@ -333,20 +357,19 @@ public synchronized void toXML(MemTreeBuilder builder) {
333357
attrs.addAttribute("", "name", "name", "CDATA", stats.qname.getStringValue());
334358
attrs.addAttribute("", "elapsed", "elapsed", "CDATA", Double.toString(stats.executionTime / 1000.0));
335359
attrs.addAttribute("", "calls", "calls", "CDATA", Integer.toString(stats.callCount));
336-
if (stats.source != null)
337-
{attrs.addAttribute("", "source", "source", "CDATA", stats.source);}
360+
if (stats.source != null) {
361+
attrs.addAttribute("", "source", "source", "CDATA", stats.source);
362+
}
338363
builder.startElement(new QName("function", XML_NAMESPACE, XML_PREFIX), attrs);
339364
builder.endElement();
340365
}
341366
for (final IndexStats stats: indexStats.values()) {
342367
attrs.clear();
343368
attrs.addAttribute("", "type", "type", "CDATA", stats.indexType);
344-
attrs.addAttribute("", "source", "source", "CDATA", stats.source + " [" + stats.line + ":" +
345-
stats.column + "]");
369+
attrs.addAttribute("", "source", "source", "CDATA", stats.source + " [" + stats.line + ":" + stats.column + "]");
346370
attrs.addAttribute("", "elapsed", "elapsed", "CDATA", Double.toString(stats.executionTime / 1000.0));
347371
attrs.addAttribute("", "calls", "calls", "CDATA", Integer.toString(stats.usageCount));
348-
attrs.addAttribute("", "optimization", "optimization", "CDATA",
349-
Integer.toString(stats.mode));
372+
attrs.addAttribute("", "optimization", "optimization", "CDATA", Integer.toString(stats.mode));
350373
builder.startElement(new QName("index", XML_NAMESPACE, XML_PREFIX), attrs);
351374
builder.endElement();
352375
}

0 commit comments

Comments
 (0)