Skip to content

Commit

Permalink
[refactor] Renamed 'exist:timer' pragma to 'exist:time' to better ref…
Browse files Browse the repository at this point in the history
…lect its purpose. Leaves 'exist:timer' as an intact legacy supported name for now too
  • Loading branch information
adamretter committed Oct 4, 2023
1 parent 5f862a5 commit 8896c5c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3000,7 +3000,7 @@ public Pragma getPragma(final String name, final String contents) throws XPathEx

return switch(qname.getLocalPart()) {
case Optimize.OPTIMIZE_PRAGMA_LOCAL_NAME -> new Optimize(rootExpression, this, qname, sanitizedContents, true);
case TimerPragma.TIMER_PRAGMA_LOCAL_NAME -> new TimerPragma(rootExpression, qname, sanitizedContents);
case TimePragma.TIME_PRAGMA_LOCAL_NAME, TimePragma.DEPRECATED_TIMER_PRAGMA_LOCAL_NAME -> new TimePragma(rootExpression, qname, sanitizedContents);
case ProfilePragma.PROFILING_PRAGMA_LOCAL_NAME -> new ProfilePragma(rootExpression, qname, sanitizedContents);
case ForceIndexUse.FORCE_INDEX_USE_PRAGMA_LOCAL_NAME -> new ForceIndexUse(rootExpression, qname, sanitizedContents);
case NoIndexPragma.NO_INDEX_PRAGMA_LOCAL_NAME -> new NoIndexPragma(rootExpression, qname, sanitizedContents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,30 @@
import org.exist.xquery.util.ExpressionDumper;
import org.exist.xquery.value.Sequence;

public class TimerPragma extends AbstractPragma {
public static final String TIMER_PRAGMA_LOCAL_NAME = "timer";
public static final QName TIMER_PRAGMA = new QName(TIMER_PRAGMA_LOCAL_NAME, Namespaces.EXIST_NS, "exist");
/**
* An XQuery Pragma that will record the execution
* time of the associated expression.
*/
public class TimePragma extends AbstractPragma {

public static final String TIME_PRAGMA_LOCAL_NAME = "time";
public static final QName TIME_PRAGMA = new QName(TIME_PRAGMA_LOCAL_NAME, Namespaces.EXIST_NS, "exist");
public static final String DEPRECATED_TIMER_PRAGMA_LOCAL_NAME = "timer";

private Logger log = null;

private long start;
private boolean verbose = true;

public TimerPragma(final Expression expression, final QName qname, final String contents) throws XPathException {
public TimePragma(final Expression expression, final QName qname, final String contents) throws XPathException {
super(expression, qname, contents);
if (contents != null && !contents.isEmpty()) {

final String[] options = Option.tokenize(contents);
for (final String option : options) {
final String[] param = Option.parseKeyValuePair(option);
if (param == null) {
throw new XPathException((Expression) null, "Invalid content found for pragma " + TIMER_PRAGMA.getStringValue() + ": " + contents);
throw new XPathException((Expression) null, "Invalid content found for pragma " + TIME_PRAGMA.getStringValue() + ": " + contents);
}

if ("verbose".equals(param[0])) {
Expand All @@ -57,7 +63,7 @@ public TimerPragma(final Expression expression, final QName qname, final String
}
}
if (log == null) {
log = LogManager.getLogger(TimerPragma.class);
log = LogManager.getLogger(TimePragma.class);
}
}

Expand Down

0 comments on commit 8896c5c

Please sign in to comment.