Home | Products | Issue Tracker | FAQ | Download | |
Date: | 2013/04/04 |
---|---|
Author: | Thomas Bonfort |
Contact: | thomas.bonfort@gmail.com |
Status: | Adopted |
Version: | MapServer 6.4 |
We have a relatively low hanging performance speedup related to expressions when doing class filtering. The context relates to when there’s the need to apply a given CLASS to multiple attribute values.
Currently, to apply a single class to multiple values of an attribute, you can either use regular expressions, or use the IN operator, like this:
LAYER
...
CLASSITEM "type"
CLASS
EXPRESSION /primary|secondary|tertiary/ #regular expression on CLASSITEM
EXPRESSION ("[type]" IN "primary,secondary,tertiary") #"complex" parser expression
...
END
END
Both methods require quite a bit of overhead, either in the regex system calls, or by using quite a few mallocs when going through the IN parser operation.
We can cut down on this overhead by adding a “list” expression type, denoted by the { } delimiters, where the previous layer definition becomes:
LAYER
...
CLASSITEM "type"
CLASS
EXPRESSION {primary,secondary,tertiary}
...
END
END
In that case, the expression parsing is a simple string lookup inside msEvalExpression() instead of having to go down into the system regex or the parser.
The modifications to the code are fairly straightforward:
None, new functionality
The expression parser had already been sped up in 6.0 with the use of precompiled expressions, this goes one step further for the specific case where a given CLASS should match multiple attribute values
+1: MikeS, TomK, DanielM, SteveW, ThomasB