public interface QueryService
QueryService queryService = cache.getQueryService();
queryService.createIndex ("SampleIndex", // indexName
"e.age", // indexedExpression
"/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()
.Modifier and Type | Field and Description |
---|---|
static Object |
UNDEFINED
The undefined constant
|
Modifier and Type | Method and Description |
---|---|
boolean |
clearDefinedIndexes()
Clears all the indexes that were defined using
defineIndex(String, String, String) |
void |
closeCqs()
Unregister all Continuous Queries.
|
List<Index> |
createDefinedIndexes()
Creates all the indexes that were defined using
defineIndex(String, String, String) |
Index |
createHashIndex(String indexName,
String indexedExpression,
String regionPath)
Deprecated.
Due to the overhead caused by rehashing while expanding the backing array, hash
index has been deprecated since Apache Geode 1.4.0. Use method
createIndex(String, String, String) instead. |
Index |
createHashIndex(String indexName,
String indexedExpression,
String regionPath,
String imports)
Deprecated.
Due to the overhead caused by rehashing while expanding the backing array, hash
index has been deprecated since Apache Geode 1.4.0. Use method
createIndex(String, String, String, String) instead |
Index |
createIndex(String indexName,
IndexType indexType,
String indexedExpression,
String fromClause)
Deprecated.
As of 6.6.2, use
createIndex(String, String, String) and
createKeyIndex(String, String, String) instead.
Create an index that can be used when executing queries. |
Index |
createIndex(String indexName,
IndexType indexType,
String indexedExpression,
String fromClause,
String imports)
Deprecated.
As of 6.6.2, use
createIndex(String, String, String, String) and
createKeyIndex(String, String, String) instead.
Create an index that can be used when executing queries. |
Index |
createIndex(String indexName,
String indexedExpression,
String regionPath)
Create an index that can be used when executing queries.
|
Index |
createIndex(String indexName,
String indexedExpression,
String regionPath,
String imports)
Create an index that can be used when executing queries.
|
Index |
createKeyIndex(String indexName,
String indexedExpression,
String regionPath)
Create a key index that can be used when executing queries.
|
void |
defineHashIndex(String indexName,
String indexedExpression,
String regionPath)
Deprecated.
Due to the overhead caused by rehashing while expanding the backing array, hash
index has been deprecated since Apache Geode 1.4.0. Use method
defineIndex(String, String, String) instead. |
void |
defineHashIndex(String indexName,
String indexedExpression,
String regionPath,
String imports)
Deprecated.
Due to the overhead caused by rehashing while expanding the backing array, hash
index has been deprecated since Apache Geode 1.4.0. Use method
defineIndex(String, String, String, String) instead. |
void |
defineIndex(String indexName,
String indexedExpression,
String regionPath)
Defines an index that can be used when executing queries.
|
void |
defineIndex(String indexName,
String indexedExpression,
String regionPath,
String imports)
Defines an index that can be used when executing queries.
|
void |
defineKeyIndex(String indexName,
String indexedExpression,
String regionPath)
Defines a key index that can be used when executing queries.
|
void |
executeCqs()
Starts execution of all the registered continuous queries for this client.
|
void |
executeCqs(String regionName)
Starts execution of all the continuous queries registered on the specified region for this
client.
|
List<String> |
getAllDurableCqsFromServer()
Retrieves all the durable CQs registered by the client calling this method.
|
CqQuery |
getCq(String cqName)
Retrieves the Continuous Query specified by the name.
|
CqQuery[] |
getCqs()
Retrieve all registered Continuous Queries.
|
CqQuery[] |
getCqs(String regionName)
Retrieves all the registered Continuous Queries for a given region.
|
CqServiceStatistics |
getCqStatistics()
Returns CqServiceStatistics object, which provides helper methods to get CQ service related
statistics for this client.
|
Index |
getIndex(Region<?,?> region,
String indexName)
Get the Index from the specified Region with the specified name.
|
Collection<Index> |
getIndexes()
Get a collection of all the indexes in the Cache.
|
Collection<Index> |
getIndexes(Region<?,?> region)
Get a collection of all the indexes on the specified Region
|
Collection<Index> |
getIndexes(Region<?,?> region,
IndexType indexType)
Deprecated.
As of 6.6.2, use
getIndexes(Region) only.
Get a collection of all the indexes on the specified Region of the specified index
type. |
CqQuery |
newCq(String queryString,
CqAttributes cqAttr)
Constructs a new continuous query, represented by an instance of CqQuery.
|
CqQuery |
newCq(String queryString,
CqAttributes cqAttr,
boolean isDurable)
Constructs a new continuous query, represented by an instance of CqQuery.
|
CqQuery |
newCq(String name,
String queryString,
CqAttributes cqAttr)
Constructs a new named continuous query, represented by an instance of CqQuery.
|
CqQuery |
newCq(String name,
String queryString,
CqAttributes cqAttr,
boolean isDurable)
Constructs a new named continuous query, represented by an instance of CqQuery.
|
Query |
newQuery(String queryString)
Constructs a new
Query object. |
void |
removeIndex(Index index)
Remove the specified index.
|
void |
removeIndexes()
Remove all the indexes from this cache.
|
void |
removeIndexes(Region<?,?> region)
Remove all the indexes on the specified Region
|
void |
stopCqs()
Stops execution of all the continuous queries for this client to become inactive.
|
void |
stopCqs(String regionName)
Stops execution of all the continuous queries registered on the specified region for this
client.
|
static final Object UNDEFINED
Query newQuery(String queryString)
Query
object.queryString
- the String that is the query programQuery
object.QueryInvalidException
- if the syntax of the queryString is invalid.Query
@Deprecated Index createHashIndex(String indexName, String indexedExpression, String regionPath) throws IndexInvalidException, IndexNameConflictException, IndexExistsException, RegionNotFoundException, UnsupportedOperationException
createIndex(String, String, String)
instead.indexName
- the name of this index.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
is restricted to only one expression
Example: Query1: "Select * from /portfolio p where p.mktValue = 25.00" For index on
mktValue field: indexExpression: "p.mktValue" regionPath: "/portfolio p"QueryInvalidException
- if the argument query language strings have invalid syntaxIndexInvalidException
- if the arguments do not correctly specify an indexIndexNameConflictException
- if an index with this name already existsIndexExistsException
- if an index with these parameters already exists with a different
nameRegionNotFoundException
- if the region referred to in the fromClause doesn't existUnsupportedOperationException
- If Index is being created on a region which does not
support indexes.void defineKeyIndex(String indexName, String indexedExpression, String regionPath) throws RegionNotFoundException
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"RegionNotFoundException
- if the region referred to in the fromClause doesn't exist@Deprecated void defineHashIndex(String indexName, String indexedExpression, String regionPath) throws RegionNotFoundException
defineIndex(String, String, String)
instead.createDefinedIndexes()
indexName
- the name of this index.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
is restricted to only one expression
Example: Query1: "Select * from /portfolio p where p.mktValue = 25.00" For index on
mktValue field: indexExpression: "p.mktValue" regionPath: "/portfolio p"RegionNotFoundException
- if the region referred to in the fromClause doesn't exist@Deprecated void defineHashIndex(String indexName, String indexedExpression, String regionPath, String imports) throws RegionNotFoundException
defineIndex(String, String, String, String)
instead.createDefinedIndexes()
indexName
- the name of this index.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 The regionPath is restricted to only one expressionimports
- 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"RegionNotFoundException
- if the region referred to in the fromClause doesn't existvoid defineIndex(String indexName, String indexedExpression, String regionPath) throws RegionNotFoundException
createDefinedIndexes()
indexName
- the name of this index.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"RegionNotFoundException
- if the region referred to in the fromClause doesn't existvoid defineIndex(String indexName, String indexedExpression, String regionPath, String imports) throws RegionNotFoundException
createDefinedIndexes()
indexName
- the name of this index.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"QueryInvalidException
- if the argument query language strings have invalid syntaxIndexInvalidException
- if the arguments do not correctly specify an indexRegionNotFoundException
- if the region referred to in the fromClause doesn't existUnsupportedOperationException
- If Index is being created on a region which overflows to
disk@Deprecated Index createHashIndex(String indexName, String indexedExpression, String regionPath, String imports) throws IndexInvalidException, IndexNameConflictException, IndexExistsException, RegionNotFoundException, UnsupportedOperationException
createIndex(String, String, String, String)
insteadindexName
- the name of this index.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 The regionPath is restricted to only one expressionimports
- 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"QueryInvalidException
- if the argument query language strings have invalid syntaxIndexInvalidException
- if the arguments do not correctly specify an indexIndexNameConflictException
- if an index with this name already existsIndexExistsException
- if an index with these parameters already exists with a different
nameRegionNotFoundException
- if the region referred to in the fromClause doesn't existUnsupportedOperationException
- If Index is being created on a region which overflows to
disk@Deprecated Index createIndex(String indexName, IndexType indexType, String indexedExpression, String fromClause) throws IndexInvalidException, IndexNameConflictException, IndexExistsException, RegionNotFoundException, UnsupportedOperationException
createIndex(String, String, String)
and
createKeyIndex(String, String, String)
instead.
Create an index that can be used when executing queries.indexName
- the name of this index, used for statistics collection and to identify this
index for later accessindexType
- 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.QueryInvalidException
- if the argument query language strings have invalid syntaxIndexInvalidException
- if the arguments do not correctly specify an indexIndexNameConflictException
- if an index with this name already existsIndexExistsException
- if an index with these parameters already exists with a different
nameRegionNotFoundException
- if the region referred to in the fromClause doesn't existUnsupportedOperationException
- If Index is being created on a region which overflows to
disk@Deprecated Index createIndex(String indexName, IndexType indexType, String indexedExpression, String fromClause, String imports) throws IndexInvalidException, IndexNameConflictException, IndexExistsException, RegionNotFoundException, UnsupportedOperationException
createIndex(String, String, String, String)
and
createKeyIndex(String, String, String)
instead.
Create an index that can be used when executing queries.indexName
- the name of this index, used for statistics collection and to identify this
index for later accessindexType
- 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.QueryInvalidException
- if the argument query language strings have invalid syntaxIndexInvalidException
- if the arguments do not correctly specify an indexIndexNameConflictException
- if an index with this name already existsIndexExistsException
- if an index with these parameters already exists with a different
nameRegionNotFoundException
- if the region referred to in the fromClause doesn't existUnsupportedOperationException
- If Index is being created on a region which overflows to
diskIndex createIndex(String indexName, String indexedExpression, String regionPath) throws IndexInvalidException, IndexNameConflictException, IndexExistsException, RegionNotFoundException, UnsupportedOperationException
indexName
- the name of this index.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"QueryInvalidException
- if the argument query language strings have invalid syntaxIndexInvalidException
- if the arguments do not correctly specify an indexIndexNameConflictException
- if an index with this name already existsIndexExistsException
- if an index with these parameters already exists with a different
nameRegionNotFoundException
- if the region referred to in the fromClause doesn't existUnsupportedOperationException
- If Index is being created on a region which does not
support indexes.Index createIndex(String indexName, String indexedExpression, String regionPath, String imports) throws IndexInvalidException, IndexNameConflictException, IndexExistsException, RegionNotFoundException, UnsupportedOperationException
indexName
- the name of this index.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"QueryInvalidException
- if the argument query language strings have invalid syntaxIndexInvalidException
- if the arguments do not correctly specify an indexIndexNameConflictException
- if an index with this name already existsIndexExistsException
- if an index with these parameters already exists with a different
nameRegionNotFoundException
- if the region referred to in the fromClause doesn't existUnsupportedOperationException
- If Index is being created on a region which overflows to
diskIndex createKeyIndex(String indexName, String indexedExpression, String regionPath) throws IndexInvalidException, IndexNameConflictException, IndexExistsException, RegionNotFoundException, UnsupportedOperationException
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"QueryInvalidException
- if the argument query language strings have invalid syntaxIndexInvalidException
- if the arguments do not correctly specify an indexIndexNameConflictException
- if an index with this name already existsIndexExistsException
- if an index with these parameters already exists with a different
nameRegionNotFoundException
- if the region referred to in the fromClause doesn't existUnsupportedOperationException
- If Index is being created on a region which overflows to
diskList<Index> createDefinedIndexes() throws MultiIndexCreationException
defineIndex(String, String, String)
MultiIndexCreationException
- which consists a map of failed indexNames and the
Exceptions.boolean clearDefinedIndexes()
defineIndex(String, String, String)
Index getIndex(Region<?,?> region, String indexName)
region
- the Region for the requested indexindexName
- the name of the index to retrieveCollection<Index> getIndexes()
Collection<Index> getIndexes(Region<?,?> region)
region
- the region for the requested indexes@Deprecated Collection<Index> getIndexes(Region<?,?> region, IndexType indexType)
getIndexes(Region)
only.
Get a collection of all the indexes on the specified Region of the specified index
type.region
- the region for the requested indexesindexType
- the type of indexes to get. Currently must be Indexable.FUNCTIONALvoid removeIndex(Index index)
index
- the Index to removevoid removeIndexes()
void removeIndexes(Region<?,?> region)
region
- the Region to remove all indexes fromCqQuery newCq(String queryString, CqAttributes cqAttr) throws QueryInvalidException, CqException
queryString
- the OQL querycqAttr
- the CqAttributesIllegalArgumentException
- if queryString or cqAttr is null.IllegalStateException
- if this method is called from a cache server.QueryInvalidException
- if there is a syntax error in the query.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.CqQuery newCq(String queryString, CqAttributes cqAttr, boolean isDurable) throws QueryInvalidException, CqException
queryString
- the OQL querycqAttr
- the CqAttributesisDurable
- true if the CQ is durableIllegalArgumentException
- if queryString or cqAttr is null.IllegalStateException
- if this method is called from a cache server.QueryInvalidException
- if there is a syntax error in the query.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.CqQuery newCq(String name, String queryString, CqAttributes cqAttr) throws QueryInvalidException, CqExistsException, CqException
name
- the String name for this queryqueryString
- the OQL querycqAttr
- the CqAttributesCqExistsException
- if a CQ by this name already exists on this clientIllegalArgumentException
- if queryString or cqAttr is null.IllegalStateException
- if this method is called from a cache server.QueryInvalidException
- if there is a syntax error in the query.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.CqQuery newCq(String name, String queryString, CqAttributes cqAttr, boolean isDurable) throws QueryInvalidException, CqExistsException, CqException
name
- the String name for this queryqueryString
- the OQL querycqAttr
- the CqAttributesisDurable
- true if the CQ is durableCqExistsException
- if a CQ by this name already exists on this clientIllegalArgumentException
- if queryString or cqAttr is null.IllegalStateException
- if this method is called from a cache server.QueryInvalidException
- if there is a syntax error in the query.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.void closeCqs()
CqQuery[] getCqs()
CqQuery[] getCqs(String regionName) throws CqException
regionName
- the name of the region on which registered CQs will be retrievedCqException
- if the region does not exist.CqQuery getCq(String cqName)
cqName
- - String, name of the CQvoid executeCqs() throws CqException
CqException
- if failure to execute CQ.stopCqs()
void stopCqs() throws CqException
CqException
- if failure to stop CQ.executeCqs()
void executeCqs(String regionName) throws CqException
regionName
- the name of the region on which registered CQs will be executedCqException
- if failure to execute CQs.stopCqs()
void stopCqs(String regionName) throws CqException
regionName
- the name of the region on which registered CQs will be stoppedCqException
- if failure to stop CQs.executeCqs()
List<String> getAllDurableCqsFromServer() throws CqException
CqException
- if an exception is encountered when retrieving CQsCqServiceStatistics getCqStatistics()
CqServiceStatistics