Interface GridQueryIndexing
-
public interface GridQueryIndexingAbstraction for internal indexing implementation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IndexingQueryFilterbackupFilter(AffinityTopologyVersion topVer, int[] parts)Returns backup filter.SqlFieldsQuerygenerateFieldsQuery(String cacheName, SqlQuery qry)Generate SqlFieldsQuery from SqlQuery.booleanisStreamableInsertStatement(String schemaName, SqlFieldsQuery sql)Whether passed sql statement is single insert statement eligible for streaming.voidonClientDisconnect()Performs necessary actions on disconnect of a stateful client (say, one associated with a transaction).voidonDisconnected(IgniteFuture<?> reconnectFut)Client disconnected callback.voidonKernalStop()Cancels all executing queries.List<JdbcParameterMeta>parameterMetaData(String schemaName, SqlFieldsQuery sql)Jdbc parameters metadata of the specified query.<K,V>
GridCloseableIterator<IgniteBiTuple<K,V>>queryLocalText(String schemaName, String cacheName, String qry, String typeName, IndexingQueryFilter filter, int limit)Executes text query.List<FieldsQueryCursor<List<?>>>querySqlFields(String schemaName, SqlFieldsQuery qry, SqlClientContext cliCtx, boolean keepBinary, boolean failOnMultipleStmts, GridQueryCancel cancel)Detect whether SQL query should be executed in distributed or local manner and execute it.voidregisterCache(String cacheName, String schemaName, GridCacheContextInfo<?,?> cacheInfo)Registers cache.voidremove(GridCacheContext cctx, GridQueryTypeDescriptor type, CacheDataRow row)Removes index entry by key.@Nullable List<GridQueryFieldMetadata>resultMetaData(String schemaName, SqlFieldsQuery sql)Metadata of the result set that is returned if specified query gets executed.RunningQueryManagerrunningQueryManager()voidstart(GridKernalContext ctx, GridSpinBusyLock busyLock)Starts indexing.voidstop()Stops indexing.voidstore(GridCacheContext cctx, GridQueryTypeDescriptor type, CacheDataRow row, CacheDataRow prevRow, boolean prevRowAvailable)Updates index.List<Long>streamBatchedUpdateQuery(String schemaName, String qry, List<Object[]> params, SqlClientContext cliCtx, String qryInitiatorId)Execute a batched INSERT statement using data streamer as receiver.longstreamUpdateQuery(String schemaName, String qry, @Nullable Object[] params, IgniteDataStreamer<?,?> streamer, String qryInitiatorId)Execute an INSERT statement using data streamer as receiver.voidunregisterCache(GridCacheContextInfo<?,?> cacheInfo)Unregisters cache.
-
-
-
Method Detail
-
start
void start(GridKernalContext ctx, GridSpinBusyLock busyLock) throws IgniteCheckedException
Starts indexing.- Parameters:
ctx- Context.busyLock- Busy lock.- Throws:
IgniteCheckedException- If failed.
-
stop
void stop() throws IgniteCheckedException
Stops indexing.- Throws:
IgniteCheckedException- If failed.
-
onClientDisconnect
void onClientDisconnect() throws IgniteCheckedExceptionPerforms necessary actions on disconnect of a stateful client (say, one associated with a transaction).- Throws:
IgniteCheckedException- If failed.
-
generateFieldsQuery
SqlFieldsQuery generateFieldsQuery(String cacheName, SqlQuery qry)
Generate SqlFieldsQuery from SqlQuery.- Parameters:
cacheName- Cache name.qry- Query.- Returns:
- Fields query.
-
querySqlFields
List<FieldsQueryCursor<List<?>>> querySqlFields(String schemaName, SqlFieldsQuery qry, SqlClientContext cliCtx, boolean keepBinary, boolean failOnMultipleStmts, GridQueryCancel cancel)
Detect whether SQL query should be executed in distributed or local manner and execute it.- Parameters:
schemaName- Schema name.qry- Query.cliCtx- Client context.keepBinary- Keep binary flag.failOnMultipleStmts- Whether an exception should be thrown for multiple statements query.- Returns:
- Cursor.
-
streamUpdateQuery
long streamUpdateQuery(String schemaName, String qry, @Nullable @Nullable Object[] params, IgniteDataStreamer<?,?> streamer, String qryInitiatorId) throws IgniteCheckedException
Execute an INSERT statement using data streamer as receiver.- Parameters:
schemaName- Schema name.qry- Query.params- Query parameters.streamer- Data streamer to feed data to.qryInitiatorId- Query initiator ID.- Returns:
- Update counter.
- Throws:
IgniteCheckedException- If failed.
-
streamBatchedUpdateQuery
List<Long> streamBatchedUpdateQuery(String schemaName, String qry, List<Object[]> params, SqlClientContext cliCtx, String qryInitiatorId) throws IgniteCheckedException
Execute a batched INSERT statement using data streamer as receiver.- Parameters:
schemaName- Schema name.qry- Query.params- Query parameters.cliCtx- Client connection context.qryInitiatorId- Query initiator ID.- Returns:
- Update counters.
- Throws:
IgniteCheckedException- If failed.
-
queryLocalText
<K,V> GridCloseableIterator<IgniteBiTuple<K,V>> queryLocalText(String schemaName, String cacheName, String qry, String typeName, IndexingQueryFilter filter, int limit) throws IgniteCheckedException
Executes text query.- Parameters:
schemaName- Schema name.cacheName- Cache name.qry- Text query.typeName- Type name.filter- Cache name and key filter. @return Queried rows.limit- Limits response records count. If 0 or less, the limit considered to be Integer.MAX_VALUE, that is virtually no limit.- Throws:
IgniteCheckedException- If failed.
-
registerCache
void registerCache(String cacheName, String schemaName, GridCacheContextInfo<?,?> cacheInfo) throws IgniteCheckedException
Registers cache.- Parameters:
cacheName- Cache name.schemaName- Schema name.cacheInfo- Cache context info.- Throws:
IgniteCheckedException- If failed.
-
unregisterCache
void unregisterCache(GridCacheContextInfo<?,?> cacheInfo)
Unregisters cache.- Parameters:
cacheInfo- Cache context info.
-
parameterMetaData
List<JdbcParameterMeta> parameterMetaData(String schemaName, SqlFieldsQuery sql) throws IgniteSQLException
Jdbc parameters metadata of the specified query.- Parameters:
schemaName- the default schema name for query.sql- Sql query.- Returns:
- metadata describing all the parameters, even in case of multi-statement.
- Throws:
SQLException- if failed to get meta.IgniteSQLException
-
resultMetaData
@Nullable @Nullable List<GridQueryFieldMetadata> resultMetaData(String schemaName, SqlFieldsQuery sql) throws IgniteSQLException
Metadata of the result set that is returned if specified query gets executed.- Parameters:
schemaName- the default schema name for query.sql- Sql query.- Returns:
- metadata or
nullif provided query is multi-statement or id it's not a SELECT statement. - Throws:
SQLException- if failed to get meta.IgniteSQLException
-
store
void store(GridCacheContext cctx, GridQueryTypeDescriptor type, CacheDataRow row, CacheDataRow prevRow, boolean prevRowAvailable) throws IgniteCheckedException
Updates index. Note that key is unique for cache, so if cache contains multiple indexes the key should be removed from indexes other than one being updated.- Parameters:
cctx- Cache context.type- Type descriptor.row- New row.prevRow- Previous row.prevRowAvailable- Whether previous row is available.- Throws:
IgniteCheckedException- If failed.
-
remove
void remove(GridCacheContext cctx, GridQueryTypeDescriptor type, CacheDataRow row) throws IgniteCheckedException
Removes index entry by key.- Parameters:
cctx- Cache context.type- Type descriptor.row- Row.- Throws:
IgniteCheckedException- If failed.
-
backupFilter
IndexingQueryFilter backupFilter(AffinityTopologyVersion topVer, int[] parts)
Returns backup filter.- Parameters:
topVer- Topology version.parts- Partitions.- Returns:
- Backup filter.
-
onDisconnected
void onDisconnected(IgniteFuture<?> reconnectFut)
Client disconnected callback.- Parameters:
reconnectFut- Reconnect future.
-
runningQueryManager
RunningQueryManager runningQueryManager()
- Returns:
- Running query manager.
-
onKernalStop
void onKernalStop()
Cancels all executing queries.
-
isStreamableInsertStatement
boolean isStreamableInsertStatement(String schemaName, SqlFieldsQuery sql) throws SQLException
Whether passed sql statement is single insert statement eligible for streaming.- Parameters:
schemaName- name of the schema.sql- sql statement.- Throws:
SQLException
-
-