Class IgniteH2Indexing
- java.lang.Object
-
- org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing
-
- All Implemented Interfaces:
GridQueryIndexing
public class IgniteH2Indexing extends Object implements GridQueryIndexing
Indexing implementation based on H2 database engine. In this implementation main query language is SQL, fulltext indexing can be performed using Lucene.For each registered
GridQueryTypeDescriptorthis SPI will create respective SQL table with'_key'and'_val'fields for key and value, and fields fromGridQueryTypeDescriptor.fields(). For each table it will create indexes declared inGridQueryTypeDescriptor.indexes().
-
-
Field Summary
Fields Modifier and Type Field Description protected GridKernalContextctx
-
Constructor Summary
Constructors Constructor Description IgniteH2Indexing()
-
Method Summary
-
-
-
Field Detail
-
ctx
protected volatile GridKernalContext ctx
-
-
Method Detail
-
kernalContext
public GridKernalContext kernalContext()
- Returns:
- Kernal context.
-
parameterMetaData
public List<JdbcParameterMeta> parameterMetaData(String schemaName, SqlFieldsQuery qry) throws IgniteSQLException
- Specified by:
parameterMetaDatain interfaceGridQueryIndexing- Throws:
IgniteSQLException
-
resultMetaData
public List<GridQueryFieldMetadata> resultMetaData(String schemaName, SqlFieldsQuery qry) throws IgniteSQLException
- Specified by:
resultMetaDatain interfaceGridQueryIndexing- Throws:
IgniteSQLException
-
store
public void store(GridCacheContext cctx, GridQueryTypeDescriptor type, CacheDataRow row, @Nullable @Nullable CacheDataRow prevRow, boolean prevRowAvailable) throws IgniteCheckedException
- Specified by:
storein interfaceGridQueryIndexing- Throws:
IgniteCheckedException
-
remove
public void remove(GridCacheContext cctx, GridQueryTypeDescriptor type, CacheDataRow row) throws IgniteCheckedException
- Specified by:
removein interfaceGridQueryIndexing- Throws:
IgniteCheckedException
-
queryLocalText
public <K,V> GridCloseableIterator<IgniteBiTuple<K,V>> queryLocalText(String schemaName, String cacheName, String qry, String typeName, IndexingQueryFilter filters, int limit) throws IgniteCheckedException
- Specified by:
queryLocalTextin interfaceGridQueryIndexing- Throws:
IgniteCheckedException
-
streamUpdateQuery
public long streamUpdateQuery(String schemaName, String qry, @Nullable @Nullable Object[] params, IgniteDataStreamer<?,?> streamer, String qryInitiatorId) throws IgniteCheckedException
- Specified by:
streamUpdateQueryin interfaceGridQueryIndexing- Throws:
IgniteCheckedException
-
streamBatchedUpdateQuery
public List<Long> streamBatchedUpdateQuery(String schemaName, String qry, List<Object[]> params, SqlClientContext cliCtx, String qryInitiatorId) throws IgniteCheckedException
- Specified by:
streamBatchedUpdateQueryin interfaceGridQueryIndexing- Throws:
IgniteCheckedException
-
executeSqlQueryWithTimer
public ResultSet executeSqlQueryWithTimer(H2PooledConnection conn, String sql, @Nullable @Nullable Collection<Object> params, int timeoutMillis, @Nullable @Nullable GridQueryCancel cancel, Boolean dataPageScanEnabled, H2QueryInfo qryInfo) throws IgniteCheckedException
Executes sql query and prints warning if query is too slow..- Parameters:
conn- Connection,sql- Sql query.params- Parameters.timeoutMillis- Query timeout.cancel- Query cancel.dataPageScanEnabled- If data page scan is enabled.- Returns:
- Result.
- Throws:
IgniteCheckedException- If failed.
-
enableDataPageScan
public void enableDataPageScan(Boolean dataPageScanEnabled)
- Parameters:
dataPageScanEnabled- If data page scan is enabled.
-
executeSqlQueryWithTimer
public ResultSet executeSqlQueryWithTimer(PreparedStatement stmt, H2PooledConnection conn, String sql, int timeoutMillis, @Nullable @Nullable GridQueryCancel cancel, Boolean dataPageScanEnabled, H2QueryInfo qryInfo) throws IgniteCheckedException
Executes sql query and prints warning if query is too slow.- Parameters:
stmt- Prepared statement for query.conn- Connection.sql- Sql query.timeoutMillis- Query timeout.cancel- Query cancel.dataPageScanEnabled- If data page scan is enabled.- Returns:
- Result.
- Throws:
IgniteCheckedException- If failed.
-
generateFieldsQuery
public SqlFieldsQuery generateFieldsQuery(String cacheName, SqlQuery qry)
- Specified by:
generateFieldsQueryin interfaceGridQueryIndexing
-
querySqlFields
public List<FieldsQueryCursor<List<?>>> querySqlFields(String schemaName, SqlFieldsQuery qry, @Nullable @Nullable SqlClientContext cliCtx, boolean keepBinary, boolean failOnMultipleStmts, GridQueryCancel cancel)
- Specified by:
querySqlFieldsin interfaceGridQueryIndexing
-
registerQueryStartedListener
public void registerQueryStartedListener(Consumer<GridQueryStartedInfo> lsnr)
- Parameters:
lsnr- Listener.
-
unregisterQueryStartedListener
public boolean unregisterQueryStartedListener(Object lsnr)
- Parameters:
lsnr- Listener.
-
registerQueryFinishedListener
public void registerQueryFinishedListener(Consumer<GridQueryFinishedInfo> lsnr)
- Parameters:
lsnr- Listener.
-
unregisterQueryFinishedListener
public boolean unregisterQueryFinishedListener(Object lsnr)
- Parameters:
lsnr- Listener.
-
executeUpdateOnDataNode
public UpdateResult executeUpdateOnDataNode(String schemaName, SqlFieldsQuery qry, IndexingQueryFilter filter, GridQueryCancel cancel, boolean loc) throws IgniteCheckedException
Executes DML request on map node. Happens only for "skip reducer" mode.- Parameters:
schemaName- Schema name.qry- Query.filter- Filter.cancel- Cancel state.loc- Locality flag.- Returns:
- Update result.
- Throws:
IgniteCheckedException- if failed.
-
isStreamableInsertStatement
public boolean isStreamableInsertStatement(String schemaName, SqlFieldsQuery qry) throws SQLException
- Specified by:
isStreamableInsertStatementin interfaceGridQueryIndexing- Throws:
SQLException
-
busyLock
public GridSpinBusyLock busyLock()
- Returns:
- Busy lock.
-
mapQueryExecutor
public GridMapQueryExecutor mapQueryExecutor()
- Returns:
- Map query executor.
-
reduceQueryExecutor
public GridReduceQueryExecutor reduceQueryExecutor()
- Returns:
- Reduce query executor.
-
runningQueryManager
public RunningQueryManager runningQueryManager()
- Specified by:
runningQueryManagerin interfaceGridQueryIndexing
-
start
public void start(GridKernalContext ctx, GridSpinBusyLock busyLock) throws IgniteCheckedException
- Specified by:
startin interfaceGridQueryIndexing- Throws:
IgniteCheckedException
-
onMessage
public void onMessage(UUID nodeId, Object msg)
- Parameters:
nodeId- Node ID.msg- Message.
-
objectContext
public CacheObjectValueContext objectContext()
- Returns:
- Value object context.
-
send
public boolean send(Object topic, int topicOrd, Collection<ClusterNode> nodes, Message msg, @Nullable @Nullable IgniteBiClosure<ClusterNode,Message,Message> specialize, @Nullable @Nullable IgniteInClosure2X<ClusterNode,Message> locNodeHnd, byte plc, boolean runLocParallel)
- Parameters:
topic- Topic.topicOrd- Topic ordinal forGridTopic.nodes- Nodes.msg- Message.specialize- Optional closure to specialize message for each node.locNodeHnd- Handler for local node.plc- Policy identifying the executor service which will process message.runLocParallel- Run local handler in parallel thread.- Returns:
trueIf all messages sent successfully.
-
stop
public void stop()
- Specified by:
stopin interfaceGridQueryIndexing
-
onClientDisconnect
public void onClientDisconnect()
- Specified by:
onClientDisconnectin interfaceGridQueryIndexing
-
registerCache
public void registerCache(String cacheName, String schemaName, GridCacheContextInfo<?,?> cacheInfo)
- Specified by:
registerCachein interfaceGridQueryIndexing
-
unregisterCache
public void unregisterCache(GridCacheContextInfo<?,?> cacheInfo)
- Specified by:
unregisterCachein interfaceGridQueryIndexing
-
backupFilter
public IndexingQueryFilter backupFilter(@Nullable @Nullable AffinityTopologyVersion topVer, @Nullable @org.jetbrains.annotations.Nullable int[] parts)
- Specified by:
backupFilterin interfaceGridQueryIndexing
-
backupFilter
public IndexingQueryFilter backupFilter(@Nullable @Nullable AffinityTopologyVersion topVer, @Nullable @org.jetbrains.annotations.Nullable int[] parts, boolean treatReplicatedAsPartitioned)
Returns backup filter.- Parameters:
topVer- Topology version.parts- Partitions.treatReplicatedAsPartitioned- true if need to treat replicated as partitioned (for outer joins).- Returns:
- Backup filter.
-
readyTopologyVersion
public AffinityTopologyVersion readyTopologyVersion()
- Returns:
- Ready topology version.
-
serverTopologyChanged
public boolean serverTopologyChanged(AffinityTopologyVersion readyVer)
- Parameters:
readyVer- Ready topology version.- Returns:
trueIf pending distributed exchange exists because server topology is changed.
-
awaitForReadyTopologyVersion
public void awaitForReadyTopologyVersion(AffinityTopologyVersion topVer) throws IgniteCheckedException
- Parameters:
topVer- Topology version.- Throws:
IgniteCheckedException- If failed.
-
onDisconnected
public void onDisconnected(IgniteFuture<?> reconnectFut)
- Specified by:
onDisconnectedin interfaceGridQueryIndexing
-
onKernalStop
public void onKernalStop()
- Specified by:
onKernalStopin interfaceGridQueryIndexing
-
queryContextRegistry
public QueryContextRegistry queryContextRegistry()
- Returns:
- Query context registry.
-
connections
public ConnectionManager connections()
- Returns:
- Connection manager.
-
parser
public QueryParser parser()
- Returns:
- Parser.
-
schemaManager
public H2SchemaManager schemaManager()
- Returns:
- Schema manager.
-
partitionExtractor
public PartitionExtractor partitionExtractor()
- Returns:
- Partition extractor.
-
partitionReservationManager
public PartitionReservationManager partitionReservationManager()
- Returns:
- Partition reservation manager.
-
heavyQueriesTracker
public HeavyQueriesTracker heavyQueriesTracker()
- Returns:
- Heavy queries tracker.
-
distributedConfiguration
public DistributedIndexingConfiguration distributedConfiguration()
- Returns:
- Distributed SQL configuration.
-
executeWithResumableTimeTracking
public <T> T executeWithResumableTimeTracking(IgniteThrowableSupplier<T> task, H2QueryInfo qryInfo) throws IgniteCheckedException
Resumes time tracking before the task (if needed) and suspends time tracking after the task is finished.- Parameters:
task- Query/fetch to execute.qryInfo- Query info.- Throws:
IgniteCheckedException- If failed.
-
-