Search in sources :

Example 1 with TableInformation

use of org.apache.ignite.internal.processors.query.TableInformation in project ignite by apache.

the class IgniteH2Indexing method tablesInformation.

/**
 * {@inheritDoc}
 */
@Override
public Collection<TableInformation> tablesInformation(String schemaNamePtrn, String tblNamePtrn, String... tblTypes) {
    Set<String> types = F.isEmpty(tblTypes) ? Collections.emptySet() : new HashSet<>(Arrays.asList(tblTypes));
    Collection<TableInformation> infos = new ArrayList<>();
    boolean allTypes = F.isEmpty(tblTypes);
    if (allTypes || types.contains(TableType.TABLE.name())) {
        schemaMgr.dataTables().stream().filter(t -> matches(t.getSchema().getName(), schemaNamePtrn)).filter(t -> matches(t.getName(), tblNamePtrn)).map(t -> {
            int cacheGrpId = t.cacheInfo().groupId();
            CacheGroupDescriptor cacheGrpDesc = ctx.cache().cacheGroupDescriptors().get(cacheGrpId);
            // We should skip table in case regarding cache group has been removed.
            if (cacheGrpDesc == null)
                return null;
            GridQueryTypeDescriptor type = t.rowDescriptor().type();
            IndexColumn affCol = t.getExplicitAffinityKeyColumn();
            String affinityKeyCol = affCol != null ? affCol.columnName : null;
            return new TableInformation(t.getSchema().getName(), t.getName(), TableType.TABLE.name(), cacheGrpId, cacheGrpDesc.cacheOrGroupName(), t.cacheId(), t.cacheName(), affinityKeyCol, type.keyFieldAlias(), type.valueFieldAlias(), type.keyTypeName(), type.valueTypeName());
        }).filter(Objects::nonNull).forEach(infos::add);
    }
    if ((allTypes || types.contains(TableType.VIEW.name())) && matches(QueryUtils.SCHEMA_SYS, schemaNamePtrn)) {
        schemaMgr.systemViews().stream().filter(t -> matches(t.getTableName(), tblNamePtrn)).map(v -> new TableInformation(QueryUtils.SCHEMA_SYS, v.getTableName(), TableType.VIEW.name())).forEach(infos::add);
    }
    return infos;
}
Also used : QueryCancelledException(org.apache.ignite.cache.query.QueryCancelledException) SQL_CMD_QRY_EXECUTE(org.apache.ignite.internal.processors.tracing.SpanType.SQL_CMD_QRY_EXECUTE) InlineIndexFactory(org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexFactory) Collections.singletonList(java.util.Collections.singletonList) BinaryUtils(org.apache.ignite.internal.binary.BinaryUtils) SysProperties(org.h2.engine.SysProperties) Map(java.util.Map) SqlQuery(org.apache.ignite.cache.query.SqlQuery) JdbcParameterMeta(org.apache.ignite.internal.processors.odbc.jdbc.JdbcParameterMeta) TimestampIndexKey(org.apache.ignite.internal.processors.query.h2.index.keys.TimestampIndexKey) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) QueryField(org.apache.ignite.internal.processors.query.QueryField) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) PreparedStatement(java.sql.PreparedStatement) CacheDataRow(org.apache.ignite.internal.processors.cache.persistence.CacheDataRow) GridMapQueryExecutor(org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor) Stream(java.util.stream.Stream) GridQueryCacheObjectsIterator(org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator) InlineIndexImpl(org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexImpl) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) GridQueryNextPageRequest(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest) SchemaIndexCacheVisitor(org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitor) BatchUpdateException(java.sql.BatchUpdateException) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteLogger(org.apache.ignite.IgniteLogger) GridQueryIndexing(org.apache.ignite.internal.processors.query.GridQueryIndexing) SecurityPermission(org.apache.ignite.plugin.security.SecurityPermission) LinkedHashMap(java.util.LinkedHashMap) SqlQueryExecutionEvent(org.apache.ignite.events.SqlQueryExecutionEvent) GridCacheQueryMarshallable(org.apache.ignite.internal.processors.cache.query.GridCacheQueryMarshallable) DmlUtils(org.apache.ignite.internal.processors.query.h2.dml.DmlUtils) ClusterTopologyServerNotFoundException(org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException) IgniteStatisticsManagerImpl(org.apache.ignite.internal.processors.query.stat.IgniteStatisticsManagerImpl) IgniteMBeansManager(org.apache.ignite.internal.managers.IgniteMBeansManager) GridQueryProperty(org.apache.ignite.internal.processors.query.GridQueryProperty) DmlDistributedPlanInfo(org.apache.ignite.internal.processors.query.h2.dml.DmlDistributedPlanInfo) SQL_QRY(org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY) MvccSnapshot(org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot) SqlClientContext(org.apache.ignite.internal.processors.query.SqlClientContext) H2Utils.generateFieldsQueryString(org.apache.ignite.internal.processors.query.h2.H2Utils.generateFieldsQueryString) SQL_QRY_EXECUTE(org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY_EXECUTE) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) SqlRollbackTransactionCommand(org.apache.ignite.internal.sql.command.SqlRollbackTransactionCommand) IndexingQueryFilter(org.apache.ignite.spi.indexing.IndexingQueryFilter) JdbcUtils(org.h2.util.JdbcUtils) GridQueryFieldMetadata(org.apache.ignite.internal.processors.query.GridQueryFieldMetadata) IgniteStatisticsManager(org.apache.ignite.internal.processors.query.stat.IgniteStatisticsManager) PartitionResult(org.apache.ignite.internal.sql.optimizer.affinity.PartitionResult) RegisteredQueryCursor(org.apache.ignite.internal.processors.cache.query.RegisteredQueryCursor) LoggerResource(org.apache.ignite.resources.LoggerResource) GridCacheTwoStepQuery(org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery) SqlCommand(org.apache.ignite.internal.sql.command.SqlCommand) Collection(java.util.Collection) GridSqlStatement(org.apache.ignite.internal.processors.query.h2.sql.GridSqlStatement) UUID(java.util.UUID) GridQueryFieldsResultAdapter(org.apache.ignite.internal.processors.query.GridQueryFieldsResultAdapter) Math.min(java.lang.Math.min) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) H2TreeIndex(org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex) IndexColumn(org.h2.table.IndexColumn) CU(org.apache.ignite.internal.util.typedef.internal.CU) TX_SIZE_THRESHOLD(org.apache.ignite.internal.processors.cache.mvcc.MvccCachingManager.TX_SIZE_THRESHOLD) SQL_CURSOR_OPEN(org.apache.ignite.internal.processors.tracing.SpanType.SQL_CURSOR_OPEN) FieldsQueryCursor(org.apache.ignite.cache.query.FieldsQueryCursor) SqlCommitTransactionCommand(org.apache.ignite.internal.sql.command.SqlCommitTransactionCommand) Span(org.apache.ignite.internal.processors.tracing.Span) H2TreeClientIndex(org.apache.ignite.internal.processors.query.h2.database.H2TreeClientIndex) QueryUtils.matches(org.apache.ignite.internal.processors.query.QueryUtils.matches) HashSet(java.util.HashSet) QueryIndexDescriptorImpl(org.apache.ignite.internal.processors.query.QueryIndexDescriptorImpl) IndexType(org.h2.index.IndexType) UpdateSourceIterator(org.apache.ignite.internal.processors.query.UpdateSourceIterator) CacheDataTree(org.apache.ignite.internal.processors.cache.tree.CacheDataTree) GridMessageListener(org.apache.ignite.internal.managers.communication.GridMessageListener) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) GridCacheContextInfo(org.apache.ignite.internal.processors.cache.GridCacheContextInfo) GridReduceQueryExecutor(org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor) GridCloseableIterator(org.apache.ignite.internal.util.lang.GridCloseableIterator) GridQueryNextPageResponse(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) GridCacheQueryType(org.apache.ignite.internal.processors.cache.query.GridCacheQueryType) UPDATE_RESULT_META(org.apache.ignite.internal.processors.query.h2.H2Utils.UPDATE_RESULT_META) EnlistOperation(org.apache.ignite.internal.processors.query.EnlistOperation) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) GridLocalEventListener(org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener) IndexKeyTypes(org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypes) Arrays(java.util.Arrays) GridQueryCancel(org.apache.ignite.internal.processors.query.GridQueryCancel) QueryUtils(org.apache.ignite.internal.processors.query.QueryUtils) UpdateMode(org.apache.ignite.internal.processors.query.h2.dml.UpdateMode) MvccUtils.txStart(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.txStart) DateIndexKey(org.apache.ignite.internal.processors.query.h2.index.keys.DateIndexKey) GridH2Table(org.apache.ignite.internal.processors.query.h2.opt.GridH2Table) ResultSet(java.sql.ResultSet) QueryIndexDefinition(org.apache.ignite.internal.processors.query.h2.index.QueryIndexDefinition) GridEmptyCloseableIterator(org.apache.ignite.internal.util.GridEmptyCloseableIterator) QueryContextRegistry(org.apache.ignite.internal.processors.query.h2.opt.QueryContextRegistry) StaticMvccQueryTracker(org.apache.ignite.internal.processors.cache.mvcc.StaticMvccQueryTracker) GridQueryTypeDescriptor(org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Set(java.util.Set) SqlQueryMXBean(org.apache.ignite.internal.mxbean.SqlQueryMXBean) IgniteClusterReadOnlyException(org.apache.ignite.internal.processors.cache.distributed.dht.IgniteClusterReadOnlyException) ERROR(org.apache.ignite.internal.processors.tracing.SpanTags.ERROR) DataType(org.h2.value.DataType) MTC(org.apache.ignite.internal.processors.tracing.MTC) IGNITE_MVCC_TX_SIZE_CACHING_THRESHOLD(org.apache.ignite.IgniteSystemProperties.IGNITE_MVCC_TX_SIZE_CACHING_THRESHOLD) ClientIndexDefinition(org.apache.ignite.internal.processors.query.h2.index.client.ClientIndexDefinition) Message(org.apache.ignite.plugin.extensions.communication.Message) H2Utils.zeroCursor(org.apache.ignite.internal.processors.query.h2.H2Utils.zeroCursor) ColumnInformation(org.apache.ignite.internal.processors.query.ColumnInformation) GridQueryFieldsResult(org.apache.ignite.internal.processors.query.GridQueryFieldsResult) SQL_SCHEMA(org.apache.ignite.internal.processors.tracing.SpanTags.SQL_SCHEMA) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) Column(org.h2.table.Column) MvccUtils.requestSnapshot(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.requestSnapshot) CacheServerNotFoundException(org.apache.ignite.cache.CacheServerNotFoundException) SQLException(java.sql.SQLException) Session(org.h2.engine.Session) ClusterNode(org.apache.ignite.cluster.ClusterNode) SQL_QRY_TEXT(org.apache.ignite.internal.processors.tracing.SpanTags.SQL_QRY_TEXT) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) MvccUtils(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils) IndexName(org.apache.ignite.internal.cache.query.index.IndexName) IgniteTxAdapter(org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter) SQL_ITER_OPEN(org.apache.ignite.internal.processors.tracing.SpanType.SQL_ITER_OPEN) ErrorCode(org.h2.api.ErrorCode) DmlUpdateSingleEntryIterator(org.apache.ignite.internal.processors.query.h2.dml.DmlUpdateSingleEntryIterator) GridRunningQueryInfo(org.apache.ignite.internal.processors.query.GridRunningQueryInfo) Marshaller(org.apache.ignite.marshaller.Marshaller) TableType(org.h2.table.TableType) GridH2IndexBase(org.apache.ignite.internal.processors.query.h2.opt.GridH2IndexBase) TimeIndexKey(org.apache.ignite.internal.processors.query.h2.index.keys.TimeIndexKey) GridTopic(org.apache.ignite.internal.GridTopic) PartitionReservationManager(org.apache.ignite.internal.processors.query.h2.twostep.PartitionReservationManager) Statement(java.sql.Statement) IgniteDataStreamer(org.apache.ignite.IgniteDataStreamer) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) H2Utils.session(org.apache.ignite.internal.processors.query.h2.H2Utils.session) SqlQueryMXBeanImpl(org.apache.ignite.internal.mxbean.SqlQueryMXBeanImpl) Index(org.h2.index.Index) CacheObjectValueContext(org.apache.ignite.internal.processors.cache.CacheObjectValueContext) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) TableInformation(org.apache.ignite.internal.processors.query.TableInformation) ClientIndexFactory(org.apache.ignite.internal.processors.query.h2.index.client.ClientIndexFactory) SqlStateCode(org.apache.ignite.internal.processors.odbc.SqlStateCode) RunningQueryManager(org.apache.ignite.internal.processors.query.RunningQueryManager) H2Utils.validateTypeDescriptor(org.apache.ignite.internal.processors.query.h2.H2Utils.validateTypeDescriptor) InlineIndex(org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndex) X(org.apache.ignite.internal.util.typedef.X) GridQueryFailResponse(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryFailResponse) GridH2DmlResponse(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2DmlResponse) UpdatePlan(org.apache.ignite.internal.processors.query.h2.dml.UpdatePlan) TEXT(org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.TEXT) IgniteFuture(org.apache.ignite.lang.IgniteFuture) DmlUpdateResultsIterator(org.apache.ignite.internal.processors.query.h2.dml.DmlUpdateResultsIterator) EventType(org.apache.ignite.events.EventType) IndexingQueryFilterImpl(org.apache.ignite.spi.indexing.IndexingQueryFilterImpl) IgniteException(org.apache.ignite.IgniteException) GridSpinBusyLock(org.apache.ignite.internal.util.GridSpinBusyLock) List(java.util.List) JavaObjectSerializer(org.h2.api.JavaObjectSerializer) Math.max(java.lang.Math.max) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) IgniteSingletonIterator(org.apache.ignite.internal.util.lang.IgniteSingletonIterator) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) QueryCursorImpl(org.apache.ignite.internal.processors.cache.QueryCursorImpl) GridH2QueryRequest(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest) MvccUtils.tx(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.tx) GridQueryCancelRequest(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest) HashMap(java.util.HashMap) IgniteBiClosure(org.apache.ignite.lang.IgniteBiClosure) SQL_DML_QRY_EXECUTE(org.apache.ignite.internal.processors.tracing.SpanType.SQL_DML_QRY_EXECUTE) PartitionExtractor(org.apache.ignite.internal.processors.query.h2.affinity.PartitionExtractor) IndexKeyFactory(org.apache.ignite.internal.cache.query.index.sorted.keys.IndexKeyFactory) IgniteUtils(org.apache.ignite.internal.util.IgniteUtils) CacheException(javax.cache.CacheException) EVT_SQL_QUERY_EXECUTION(org.apache.ignite.events.EventType.EVT_SQL_QUERY_EXECUTION) IgniteInClosure2X(org.apache.ignite.internal.util.lang.IgniteInClosure2X) F(org.apache.ignite.internal.util.typedef.F) Iterator(java.util.Iterator) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) H2TreeIndexBase(org.apache.ignite.internal.processors.query.h2.database.H2TreeIndexBase) GridH2DmlRequest(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2DmlRequest) MvccUtils.mvccEnabled(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.mvccEnabled) IgniteQueryErrorCode(org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode) TimeUnit(java.util.concurrent.TimeUnit) H2PartitionResolver(org.apache.ignite.internal.processors.query.h2.affinity.H2PartitionResolver) GridSqlConst(org.apache.ignite.internal.processors.query.h2.sql.GridSqlConst) CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext) MvccUtils.checkActive(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.checkActive) Collections(java.util.Collections) MvccQueryTracker(org.apache.ignite.internal.processors.cache.mvcc.MvccQueryTracker) QueryContext(org.apache.ignite.internal.processors.query.h2.opt.QueryContext) TraceSurroundings(org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings) ArrayList(java.util.ArrayList) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) H2Utils.generateFieldsQueryString(org.apache.ignite.internal.processors.query.h2.H2Utils.generateFieldsQueryString) GridQueryTypeDescriptor(org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor) IndexColumn(org.h2.table.IndexColumn) TableInformation(org.apache.ignite.internal.processors.query.TableInformation)

Aggregations

Math.max (java.lang.Math.max)1 Math.min (java.lang.Math.min)1 BatchUpdateException (java.sql.BatchUpdateException)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Collections.singletonList (java.util.Collections.singletonList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1