com.gemstone.gemfire.cache.query
Interface QueryService

public interface QueryService

Interface for the query service, which is used for instantiating queries,
creating and destroying indexes, creating CQs and operating on CQs.
Creating an index on an employee's age using QueryService in region "employeeRegion",
QueryService queryService = cache.getQueryService();
queryService.createIndex ("SampleIndex", //IndexName
"e.age" //indexExpression
"/employeeRegion e", //regionPath
);
The CQs work on the server regions, the client can use the CQ methods supported
in this class to create/operate CQs on the server. The CQ obtains the Server
connection from the corresponding local region on the client.
The implementation of this interface is obtained from the Cache
using RegionService.getQueryService().

indexName - the name of this index, used for statistics collection and
to identify this index for later access

indexType - the type of index. The indexType must be either
IndexType.FUNCTIONAL or IndexType.PRIMARY_KEY.

indexedExpression - refers to the elements of the collection (or
collection of structs) that are referenced in the fromClause.
This expression is used to optimize the comparison of the same
path found in a query's WHERE clause when used to compare against
a constant expression.
For example, an index with indexedExpression "mktValue" might
be used for a query with a WHERE clause of "mktValue > 25.00".
The exact use and specification of the indexedExpression varies
depending on the indexType.
Query parameters and region paths are not allowed in the
indexedExpression (e.g. $1).

fromClause - expression, that resolves to a collection or list of
collections which will correspond to the FROM clause or part of a
FROM clause in a SELECT statement. The FROM clause must include
exactly one region, but may include multiple FROM expressions as
required to drill down into nested region contents.
The collections that the FROM expressions evaluate to must be
dependent on one and only one entry in the referenced region
(otherwise the index could not be maintained on single entry
updates). References to query parameters are not allowed.
For primary key indexes, the fromClause must be just one collection
which must be a region path only.

indexName - the name of this index, used for statistics collection and
to identify this index for later access

indexType - the type of index. The indexType must be either
IndexType.FUNCTIONAL or IndexType.PRIMARY_KEY.

indexedExpression - refers to the elements of the collection (or
collection of structs) that are referenced in the fromClause.
This expression is used to optimize the comparison of the same
path found in a query's WHERE clause when used to compare against
a constant expression.
For example, an index with indexedExpression "mktValue" might
be used for a query with a WHERE clause of "mktValue > 25.00".
The exact use and specification of the indexedExpression varies
depending on the indexType.
Query parameters and region paths are not allowed in the
indexedExpression (e.g. $1).

fromClause - expression, that resolves to a collection or list of
collections which will correspond to the FROM clause or part of a
FROM clause in a SELECT statement. The FROM clause must include
exactly one region, but may include multiple FROM expressions as
required to drill down into nested region contents.
The collections that the FROM expressions evaluate to must be
dependent on one and only one entry in the referenced region
(otherwise the index could not be maintained on single entry
updates). References to query parameters are not allowed.
For primary key indexes, the fromClause must be just one collection
which must be a region path only.

imports - string containing imports (in the query language syntax,
each import statement separated by a semicolon), provides packages
and classes used in variable typing in the Indexed and FROM
expressions.
The use is the same as for the FROM clause in querying.

indexedExpression - refers to the field of the region values that
are referenced by the regionPath.

regionPath - that resolves to region values or nested
collections of region values which will correspond to the
FROM clause in a query. Check following examples.
The regionPath must include exactly one region, but may include
multiple expressions as required to drill down into nested
region contents.
Example:
Query1: "Select * from /portfolio p where p.mktValue > 25.00"
For index on mktValue field:
indexExpression: "p.mktValue"
regionPath: "/portfolio p"
Query2: "Select * from /portfolio p, p.positions.values pos where pos.secId ='VMWARE'"
For index on secId field:
indexExpression: "pos.secId"
regionPath: "/portfolio p, p.positions.values pos"

indexedExpression - refers to the field of the region values that
are referenced by the regionPath.

regionPath - that resolves to region values or nested
collections of region values which will correspond to the
FROM clause in a query.
The regionPath must include exactly one region, but may include
multiple expressions as required to drill down into nested
region contents. Check following examples.

imports - string containing imports (in the query language syntax,
each import statement separated by a semicolon), provides packages
and classes used in variable typing in the Indexed and FROM
expressions. The use is the same as for the FROM clause in
querying.
Example:
Query1: "Select * from /portfolio p where p.mktValue > 25.00"
For index on mktValue field:
indexExpression: "p.mktValue"
regionPath: "/portfolio p"
Query2: "Select * from /portfolio p, p.positions.values pos where pos.secId ='VMWARE'"
For index on secId field:
indexExpression: "pos.secId"
regionPath: "/portfolio p, p.positions.values pos TYPE Position"
imports: "package.Position"

Create a key index that can be used when executing queries. The key index
expression indicates query engine to use region key as index for query
evaluation. They are used to make use of the implicit hash index
supported with GemFire regions.

Parameters:

indexName - the name of this index.

indexedExpression - refers to the keys of the region that
is referenced by the regionPath.
For example, an index with indexedExpression "ID" might
be used for a query with a WHERE clause of "ID > 10", In this case
the ID value is evaluated using region keys.

regionPath - that resolves to the region which will
correspond to the FROM clause in a query.
The regionPath must include exactly one region.
Example:
Query1: "Select * from /portfolio p where p.ID > 10"
indexExpression: "p.ID"
regionPath: "/portfolio p"

CqException - if failed to create CQ.
E.g.: Query string should refer to only one region.
Joins are not supported.
The query must be a SELECT statement.
DISTINCT queries are not supported.
Projections are not supported.
Only one iterator in the FROM clause is supported, and it must be a region path.
Bind parameters in the query are not yet supported.

CqException - if failed to create CQ.
E.g.: Query string should refer to only one region.
Joins are not supported.
The query must be a SELECT statement.
DISTINCT queries are not supported.
Projections are not supported.
Only one iterator in the FROM clause is supported, and it must be a region path.
Bind parameters in the query are not yet supported.

Since:

5.5

newCq

Constructs a new named continuous query, represented by an instance of
CqQuery. The CqQuery is not executed until the execute method
is invoked on the CqQuery. The name of the query will be used
to identify this query in statistics archival.

CqException - if failed to create cq.
E.g.: Query string should refer to only one region.
Joins are not supported.
The query must be a SELECT statement.
DISTINCT queries are not supported.
Projections are not supported.
Only one iterator in the FROM clause is supported, and it must be a region path.
Bind parameters in the query are not yet supported.

Since:

5.5

newCq

Constructs a new named continuous query, represented by an instance of
CqQuery. The CqQuery is not executed until the execute method
is invoked on the CqQuery. The name of the query will be used
to identify this query in statistics archival.

CqException - if failed to create cq.
E.g.: Query string should refer to only one region.
Joins are not supported.
The query must be a SELECT statement.
DISTINCT queries are not supported.
Projections are not supported.
Only one iterator in the FROM clause is supported, and it must be a region path.
Bind parameters in the query are not yet supported.

Since:

5.5

closeCqs

void closeCqs()

Unregister all Continuous Queries.
All artifacts and resources associated with the CQs are released.
Any attempt to access closed CqQuery objects will result in the
CqClosedException being thrown to the caller.

getCqStatistics

Returns CqServiceStatistics object, which provides helper methods to
get CQ service related statistics for this client.
Specifically the following aggregate information on the client's CQs is collected:
Number of CQs created (cumulative)
Number of CQs active currently
Number of CQs stopped or suspended currently
Number of CQs closed (cumulative)
Number of CQs active on a specified region currently