The query engine resolves names and path expressions according to the name space that is currently in scope in the query.
The initial name space for any query is composed of:
- Regions. In the context of a query, the name of a region is specified by its full path starting with a forward slash ( / ) and delimited by the forward slash between region names. For example, /exampleRegion or /root/exampleRegion.
- Region querying attributes. From a region path, you can access the Region object’s public fields and methods, referred to in querying as the region’s attributes. For example, /exampleRegion.size.
- Top-level region data. You can access entry keys and entry data through the region path.
/exampleRegion.keySetreturns the Set of entry keys in the region
/exampleRegion.entrysetreturns the Set of Region.Entry objects
/exampleRegion.valuesreturns the Collection of entry values
/exampleRegionreturns the Collection of entry values
New name spaces are brought into scope based on the FROM clause in the SELECT statement.
Query a region for all distinct values. Return a collection of unique entry values from the region:
SELECT DISTINCT * FROM /exampleRegion
Query the top level region data using entrySet. Return the keys and positions of Region.Entry objects whose mktValue attribute is greater than 25.00:
SELECT key, positions FROM /exampleRegion.entrySet, value.positions.values positions WHERE positions.mktValue >= 25.00
Query the region for its entry values. Return a set of unique values from Region.Entry objects that have the key equal to 1:
SELECT DISTINCT entry.value FROM /exampleRegion.entries entry WHERE entry.key = '1'
Query the region for its entry values. Return the set of all entry values in which the
ID field is greater than 1000:
SELECT * FROM /exampleRegion.entries entry WHERE entry.value.ID > 1000
Query entry keys in the region. Return a set of entry keys in the region that have the key equal to ‘1’:
SELECT * FROM /exampleRegion.keySet key WHERE key = '1'
Query values in the region. Return a collection of entry values in the region that have the status attribute value of 'active’:
SELECT * FROM /exampleRegion.values portfolio WHERE portfolio.status = 'active'
In query strings, you can use aliases in path expressions (region and its objects) so that you can refer to the region or objects in other places in the query.
You can also use the AS keyword to provide a label for joined path expressions.
SELECT DISTINCT * FROM /exampleRegion p WHERE p.status = 'active'
SELECT * FROM /exampleRegion p, p.positions.values AS pos WHERE pos.secId != '1'
Specifying object type in the FROM clause helps the query engine to process the query at optimal speed. Apart from specifying the object types during configuration (using key-constraint and value-constraint), type can be explicitly specified in the query string.
SELECT DISTINCT * FROM /exampleRegion, positions.values positions TYPE Position WHERE positions.mktValue >= 25.00