Filters
ActiveSpaces supports the application of filters to both listeners and browsers, as well as the ability to evaluate a tuple against a filter. Filters allow your application to further refine the set of tuples it wants to work with using a space browser or event listener.
A filter string can be seen as what would follow the where clause in a select * from Space where… statement.
Examples
field1 < (field2+field3)
state = "CA"
name LIKE ".*John.*" //any name with John
Filters can make reference to any of the fields contained in the tuples. s do not provide any ordering or sorting of the entries stored in the space.
Operators Supported in Filters
Table 3 shows the operators that are supported in the ActiveSpaces filters:
Operator | Meaning |
---|---|
>, >= | greater than |
NOT or ! or <> | not |
* | multiply |
= | equal |
!= | not equal |
ABS | absolute value |
MOD | modulo |
NOT BETWEEN | not between. For example, "age not between 1 and 18". |
BETWEEN | between For example, "age between 18 and 60". |
|| | string concatenation |
NOT LIKE | not like (regex) |
LIKE | like (regex) |
<, <= | less than |
+ | addition |
OR | or |
- | subtraction |
AND | and |
IN | range. For example, "age in (1,3,5,7,11)" |
NULL | does not exist |
NOT NULL | exists |
IS | only used with NULL or NOT NULL, as in “x IS NULL“ or “x IS NOT NULL" |
NOR | nor. For example, "age NOT 30 NOR 40" |
/* .... | comments |
// .... | comments |
Specifying a String Value in a Filter
If you specify a string value in a filter, then the filter value must be enclosed in double quotes; for example:
value = "Jones"
See ASQuery (Java Only) for examples of filter queries that utilize strings enclosed within double quotes.
Regex Syntax for Filter Values
Table 3 indicates several filter formats for regular expressions (regex values). For regular expressions, ActiveSpaces uses the syntax for Perl Compatible Regular Expressions (PCRE).
For general information on PCRE, see the PCRE website at the following URL:
http://www.pcre.org/
For detailed documentation on PCRE, see the text version of the man pages for PCRE at the following URL:
http://www.pcre.org/pcre.txt
Filter to Return a Subset of Fields
In order to return a subset of the fields in the space, use the SELECT clause. For example select field1, field2, select field1, field2 where <condition>
Formats for Filter Values
Table 4 shows the formats for values used in filters.