Skip to content

Commit 8c169cf

Browse files
authored
Merge pull request #85 from evolvedbinary/6.x.x/hotfix/profiling-fots-prefix
[6.x.x] Show prefix of XPath standard library functions in the profiling output
2 parents 13f4408 + 16d8b4f commit 8c169cf

File tree

103 files changed

+2603
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+2603
-203
lines changed

exist-core/pom.xml

Lines changed: 187 additions & 1 deletion
Large diffs are not rendered by default.

exist-core/src/main/java/org/exist/Namespaces.java

Lines changed: 26 additions & 1 deletion
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
*
@@ -40,7 +64,8 @@ public interface Namespaces {
4064
String SCHEMA_INSTANCE_NS = XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
4165

4266
// Move this here from Function.BUILTIN_FUNCTION_NS? /ljo
43-
String XPATH_FUNCTIONS_NS = "http://www.w3.org/2005/xpath-functions";
67+
String XPATH_FUNCTIONS_NS = "http://www.w3.org/2005/xpath-functions";
68+
String XPATH_FUNCTIONS_PREFIX = "fn";
4469
String XQUERY_LOCAL_NS = "http://www.w3.org/2005/xquery-local-functions";
4570
String XPATH_DATATYPES_NS = "http://www.w3.org/2003/05/xpath-datatypes";
4671

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

Lines changed: 24 additions & 4 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
*
@@ -55,10 +79,6 @@
5579
*/
5680
public abstract class Function extends PathExpr {
5781

58-
// Declare it in Namespaces instead? /ljo
59-
public final static String BUILTIN_FUNCTION_NS =
60-
"http://www.w3.org/2005/xpath-functions";
61-
6282
/**
6383
* The module that declared the function.
6484
*/

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

Lines changed: 26 additions & 1 deletion
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
*
@@ -25,6 +49,7 @@
2549
import java.util.List;
2650

2751
import org.exist.dom.QName;
52+
import org.exist.xquery.functions.fn.FnModule;
2853
import org.exist.xquery.parser.XQueryAST;
2954
import org.exist.xquery.util.ExpressionDumper;
3055
import org.exist.xquery.value.FunctionReference;
@@ -53,7 +78,7 @@ public void analyze(AnalyzeContextInfo contextInfo) throws XPathException {
5378
}
5479

5580
public static FunctionCall lookupFunction(Expression self, XQueryContext context, QName funcName, int arity) throws XPathException {
56-
if (Function.BUILTIN_FUNCTION_NS.equals(funcName.getNamespaceURI())
81+
if (FnModule.NAMESPACE_URI.equals(funcName.getNamespaceURI())
5782
&& "concat".equals(funcName.getLocalPart())
5883
&& arity < 2) {
5984
throw new XPathException(self, ErrorCodes.XPST0017, "No such function; fn:concat requires at least two arguments");

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
import java.io.PrintWriter;
5959
import java.util.HashSet;
6060

61+
import static org.exist.Namespaces.XPATH_FUNCTIONS_NS;
62+
import static org.exist.Namespaces.XPATH_FUNCTIONS_PREFIX;
63+
6164
public class PerformanceStats implements BrokerPoolService {
6265

6366
public final static String RANGE_IDX_TYPE = "range";
@@ -250,7 +253,12 @@ public void recordQuery(String source, long elapsed) {
250253
}
251254
}
252255

253-
public void recordFunctionCall(QName qname, String source, long elapsed) {
256+
public void recordFunctionCall(QName qname, final String source, final long elapsed) {
257+
if (XPATH_FUNCTIONS_NS.equals(qname.getNamespaceURI()) && qname.getPrefix() == null) {
258+
// make sure that functions from the XPath/XQuery standard library are shown correctly in the output
259+
qname = new QName(qname.getLocalPart(), qname.getNamespaceURI(), XPATH_FUNCTIONS_PREFIX, qname.getNameType());
260+
}
261+
254262
final FunctionStats newStats = new FunctionStats(source, qname);
255263
final FunctionStats stats = functions.get(newStats);
256264
if (stats == null) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public class XQueryContext implements BinaryValueManager, Context {
310310

311311
protected String moduleLoadPath = ".";
312312

313-
private String defaultFunctionNamespace = Function.BUILTIN_FUNCTION_NS;
313+
private String defaultFunctionNamespace = Namespaces.XPATH_FUNCTIONS_NS;
314314
private AnyURIValue defaultElementNamespace = AnyURIValue.EMPTY_URI;
315315
private AnyURIValue defaultElementNamespaceSchema = AnyURIValue.EMPTY_URI;
316316

@@ -444,7 +444,7 @@ public class XQueryContext implements BinaryValueManager, Context {
444444
*/
445445
@Nullable
446446
private HttpContext httpContext = null;
447-
private static final QName UNNAMED_DECIMAL_FORMAT = new QName("__UNNAMED__", Function.BUILTIN_FUNCTION_NS);
447+
private static final QName UNNAMED_DECIMAL_FORMAT = new QName("__UNNAMED__", Namespaces.XPATH_FUNCTIONS_NS);
448448

449449
private final Map<QName, DecimalFormat> staticDecimalFormats = HashMap(Tuple(UNNAMED_DECIMAL_FORMAT, DecimalFormat.UNNAMED));
450450

@@ -1063,7 +1063,7 @@ public String getDefaultFunctionNamespace() {
10631063
@Override
10641064
public void setDefaultFunctionNamespace(final String uri) throws XPathException {
10651065
//Not sure for the 2nd clause : eXist-db forces the function NS as default.
1066-
if ((defaultFunctionNamespace != null) && !defaultFunctionNamespace.equals(Function.BUILTIN_FUNCTION_NS) && !defaultFunctionNamespace.equals(uri)) {
1066+
if ((defaultFunctionNamespace != null) && !defaultFunctionNamespace.equals(Namespaces.XPATH_FUNCTIONS_NS) && !defaultFunctionNamespace.equals(uri)) {
10671067
throw new XPathException(rootExpression, ErrorCodes.XQST0066, "Default function namespace is already set to: '" + defaultFunctionNamespace + "'");
10681068
}
10691069
defaultFunctionNamespace = uri;

exist-core/src/main/java/org/exist/xquery/functions/fn/ExtCollection.java

Lines changed: 25 additions & 1 deletion
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
*
@@ -54,7 +78,7 @@ public class ExtCollection extends Function {
5478

5579
public final static FunctionSignature signature =
5680
new FunctionSignature(
57-
new QName("collection", Function.BUILTIN_FUNCTION_NS),
81+
new QName("collection", FnModule.NAMESPACE_URI),
5882
"Returns the documents contained in the collections specified in " +
5983
"the input sequence. " + XMLDBModule.COLLECTION_URI +
6084
" Documents contained in sub-collections are also included. If no value is supplied, the statically know documents are used, for the REST Server this could be the addressed collection.",

exist-core/src/main/java/org/exist/xquery/functions/fn/FnDefaultLanguage.java

Lines changed: 25 additions & 1 deletion
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
*
@@ -32,7 +56,7 @@
3256
public class FnDefaultLanguage extends BasicFunction {
3357

3458
public static final FunctionSignature FS_DEFAULT_LANGUAGE = FunctionDSL.functionSignature(
35-
new QName("default-language", Function.BUILTIN_FUNCTION_NS),
59+
new QName("default-language", FnModule.NAMESPACE_URI),
3660
"Returns the xs:language that is " +
3761
"the value of the default language property from the dynamic context " +
3862
"during the evaluation of a query or transformation in which " +

exist-core/src/main/java/org/exist/xquery/functions/fn/FnFormatDates.java

Lines changed: 30 additions & 6 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
*
@@ -69,7 +93,7 @@ public class FnFormatDates extends BasicFunction {
6993

7094

7195
public final static FunctionSignature FNS_FORMAT_DATETIME_2 = new FunctionSignature(
72-
new QName("format-dateTime", Function.BUILTIN_FUNCTION_NS),
96+
new QName("format-dateTime", FnModule.NAMESPACE_URI),
7397
"Returns a string containing an xs:date value formatted for display.",
7498
new SequenceType[] {
7599
DATETIME,
@@ -79,7 +103,7 @@ public class FnFormatDates extends BasicFunction {
79103
);
80104

81105
public final static FunctionSignature FNS_FORMAT_DATETIME_5 = new FunctionSignature(
82-
new QName("format-dateTime", Function.BUILTIN_FUNCTION_NS),
106+
new QName("format-dateTime", FnModule.NAMESPACE_URI),
83107
"Returns a string containing an xs:date value formatted for display.",
84108
new SequenceType[] {
85109
DATETIME,
@@ -92,7 +116,7 @@ public class FnFormatDates extends BasicFunction {
92116
);
93117

94118
public final static FunctionSignature FNS_FORMAT_DATE_2 = new FunctionSignature(
95-
new QName("format-date", Function.BUILTIN_FUNCTION_NS),
119+
new QName("format-date", FnModule.NAMESPACE_URI),
96120
"Returns a string containing an xs:date value formatted for display.",
97121
new SequenceType[] {
98122
DATE,
@@ -102,7 +126,7 @@ public class FnFormatDates extends BasicFunction {
102126
);
103127

104128
public final static FunctionSignature FNS_FORMAT_DATE_5 = new FunctionSignature(
105-
new QName("format-date", Function.BUILTIN_FUNCTION_NS),
129+
new QName("format-date", FnModule.NAMESPACE_URI),
106130
"Returns a string containing an xs:date value formatted for display.",
107131
new SequenceType[] {
108132
DATE,
@@ -115,7 +139,7 @@ public class FnFormatDates extends BasicFunction {
115139
);
116140

117141
public final static FunctionSignature FNS_FORMAT_TIME_2 = new FunctionSignature(
118-
new QName("format-time", Function.BUILTIN_FUNCTION_NS),
142+
new QName("format-time", FnModule.NAMESPACE_URI),
119143
"Returns a string containing an xs:time value formatted for display.",
120144
new SequenceType[] {
121145
TIME,
@@ -125,7 +149,7 @@ public class FnFormatDates extends BasicFunction {
125149
);
126150

127151
public final static FunctionSignature FNS_FORMAT_TIME_5 = new FunctionSignature(
128-
new QName("format-time", Function.BUILTIN_FUNCTION_NS),
152+
new QName("format-time", FnModule.NAMESPACE_URI),
129153
"Returns a string containing an xs:time value formatted for display.",
130154
new SequenceType[] {
131155
TIME,

exist-core/src/main/java/org/exist/xquery/functions/fn/FnHasChildren.java

Lines changed: 25 additions & 1 deletion
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
*
@@ -29,7 +53,7 @@
2953

3054
public class FnHasChildren extends Function {
3155

32-
private final static QName QN_HAS_CHILDREN = new QName("has-children", Function.BUILTIN_FUNCTION_NS);
56+
private final static QName QN_HAS_CHILDREN = new QName("has-children", FnModule.NAMESPACE_URI);
3357

3458
public final static FunctionSignature FNS_HAS_CHILDREN_0 = new FunctionSignature(
3559
QN_HAS_CHILDREN,

0 commit comments

Comments
 (0)