Search in sources :

Example 61 with IndexColumn

use of org.h2.table.IndexColumn 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)

Example 62 with IndexColumn

use of org.h2.table.IndexColumn in project ignite by apache.

the class IgniteH2Indexing method columnsInformation.

/**
 * {@inheritDoc}
 */
@Override
public Collection<ColumnInformation> columnsInformation(String schemaNamePtrn, String tblNamePtrn, String colNamePtrn) {
    Collection<ColumnInformation> infos = new ArrayList<>();
    // Gather information about tables.
    schemaMgr.dataTables().stream().filter(t -> matches(t.getSchema().getName(), schemaNamePtrn)).filter(t -> matches(t.getName(), tblNamePtrn)).flatMap(tbl -> {
        IndexColumn affCol = tbl.getAffinityKeyColumn();
        return Stream.of(tbl.getColumns()).filter(Column::getVisible).filter(c -> matches(c.getName(), colNamePtrn)).map(c -> {
            GridQueryProperty prop = tbl.rowDescriptor().type().property(c.getName());
            boolean isAff = affCol != null && c.getColumnId() == affCol.column.getColumnId();
            return new ColumnInformation(c.getColumnId() - QueryUtils.DEFAULT_COLUMNS_COUNT + 1, tbl.getSchema().getName(), tbl.getName(), c.getName(), prop.type(), c.isNullable(), prop.defaultValue(), prop.precision(), prop.scale(), isAff);
        });
    }).forEach(infos::add);
    // Gather information about system views.
    if (matches(QueryUtils.SCHEMA_SYS, schemaNamePtrn)) {
        schemaMgr.systemViews().stream().filter(v -> matches(v.getTableName(), tblNamePtrn)).flatMap(view -> Stream.of(view.getColumns()).filter(c -> matches(c.getName(), colNamePtrn)).map(c -> new ColumnInformation(c.getColumnId() + 1, QueryUtils.SCHEMA_SYS, view.getTableName(), c.getName(), IgniteUtils.classForName(DataType.getTypeClassName(c.getType()), Object.class), c.isNullable(), null, (int) c.getPrecision(), c.getScale(), false))).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) GridQueryProperty(org.apache.ignite.internal.processors.query.GridQueryProperty) ColumnInformation(org.apache.ignite.internal.processors.query.ColumnInformation) ArrayList(java.util.ArrayList) IndexColumn(org.h2.table.IndexColumn)

Example 63 with IndexColumn

use of org.h2.table.IndexColumn in project ignite by apache.

the class H2TreeIndex method toSearchRowMessage.

/**
 * @param row Search row.
 * @return Row message.
 */
public GridH2RowMessage toSearchRowMessage(SearchRow row) {
    if (row == null)
        return null;
    List<GridH2ValueMessage> vals = new ArrayList<>(indexColumns.length);
    for (IndexColumn idxCol : indexColumns) {
        Value val = row.getValue(idxCol.column.getColumnId());
        if (val == null)
            break;
        try {
            vals.add(GridH2ValueMessageFactory.toMessage(val));
        } catch (IgniteCheckedException e) {
            throw new CacheException(e);
        }
    }
    GridH2RowMessage res = new GridH2RowMessage();
    res.values(vals);
    return res;
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CacheException(javax.cache.CacheException) GridH2ValueMessage(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2ValueMessage) ArrayList(java.util.ArrayList) Value(org.h2.value.Value) GridH2RowMessage(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2RowMessage) IndexColumn(org.h2.table.IndexColumn)

Example 64 with IndexColumn

use of org.h2.table.IndexColumn in project ignite by apache.

the class H2TreeIndex method createLookupBatch.

/**
 * {@inheritDoc}
 */
@Override
public IndexLookupBatch createLookupBatch(TableFilter[] filters, int filter) {
    QueryContext qctx = H2Utils.context(filters[filter].getSession());
    if (qctx == null || qctx.distributedJoinContext() == null || !getTable().isPartitioned())
        return null;
    IndexColumn affCol = getTable().getAffinityKeyColumn();
    GridH2RowDescriptor desc = getTable().rowDescriptor();
    int affColId = -1;
    boolean ucast = false;
    if (affCol != null) {
        affColId = affCol.column.getColumnId();
        int[] masks = filters[filter].getMasks();
        if (masks != null) {
            ucast = (masks[affColId] & IndexCondition.EQUALITY) != 0 || desc.checkKeyIndexCondition(masks, IndexCondition.EQUALITY);
        }
    }
    return new DistributedLookupBatch(this, cctx, ucast, affColId);
}
Also used : DistributedLookupBatch(org.apache.ignite.internal.processors.query.h2.opt.join.DistributedLookupBatch) GridH2RowDescriptor(org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor) IndexQueryContext(org.apache.ignite.internal.cache.query.index.sorted.inline.IndexQueryContext) QueryContext(org.apache.ignite.internal.processors.query.h2.opt.QueryContext) IndexColumn(org.h2.table.IndexColumn)

Example 65 with IndexColumn

use of org.h2.table.IndexColumn in project ignite by apache.

the class GridSqlQueryParser method parseCreateIndex.

/**
 * Parse {@code CREATE INDEX} statement.
 *
 * @param createIdx {@code CREATE INDEX} statement.
 * @see <a href="http://h2database.com/html/grammar.html#create_index">H2 {@code CREATE INDEX} spec.</a>
 */
private GridSqlCreateIndex parseCreateIndex(CreateIndex createIdx) {
    if (CREATE_INDEX_HASH.get(createIdx) || CREATE_INDEX_PRIMARY_KEY.get(createIdx) || CREATE_INDEX_UNIQUE.get(createIdx)) {
        throw new IgniteSQLException("Only SPATIAL modifier is supported for CREATE INDEX", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
    }
    GridSqlCreateIndex res = new GridSqlCreateIndex();
    Schema schema = SCHEMA_COMMAND_SCHEMA.get(createIdx);
    String tblName = CREATE_INDEX_TABLE_NAME.get(createIdx);
    res.schemaName(schema.getName());
    res.tableName(tblName);
    res.ifNotExists(CREATE_INDEX_IF_NOT_EXISTS.get(createIdx));
    QueryIndex idx = new QueryIndex();
    idx.setName(CREATE_INDEX_NAME.get(createIdx));
    idx.setIndexType(CREATE_INDEX_SPATIAL.get(createIdx) ? QueryIndexType.GEOSPATIAL : QueryIndexType.SORTED);
    IndexColumn[] cols = CREATE_INDEX_COLUMNS.get(createIdx);
    LinkedHashMap<String, Boolean> flds = new LinkedHashMap<>(cols.length);
    for (IndexColumn col : CREATE_INDEX_COLUMNS.get(createIdx)) {
        int sortType = INDEX_COLUMN_SORT_TYPE.get(col);
        if ((sortType & SortOrder.NULLS_FIRST) != 0 || (sortType & SortOrder.NULLS_LAST) != 0) {
            throw new IgniteSQLException("NULLS FIRST and NULLS LAST modifiers are not supported for index columns", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
        }
        Boolean prev = flds.put(INDEX_COLUMN_NAME.get(col), (sortType & SortOrder.DESCENDING) == 0);
        if (prev != null) {
            String prevCol = INDEX_COLUMN_NAME.get(col) + " " + (prev ? "ASC" : "DESC");
            throw new IgniteSQLException("Already defined column in index: " + prevCol, IgniteQueryErrorCode.COLUMN_ALREADY_EXISTS);
        }
    }
    idx.setFields(flds);
    res.index(idx);
    return res;
}
Also used : Schema(org.h2.schema.Schema) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) QueryIndex(org.apache.ignite.cache.QueryIndex) AlterTableAddConstraint(org.h2.command.ddl.AlterTableAddConstraint) IndexColumn(org.h2.table.IndexColumn) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

IndexColumn (org.h2.table.IndexColumn)53 Column (org.h2.table.Column)23 ArrayList (java.util.ArrayList)14 Index (org.h2.index.Index)12 Value (org.h2.value.Value)12 IndexType (org.h2.index.IndexType)9 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 Constraint (org.h2.constraint.Constraint)6 ExpressionColumn (org.h2.expression.ExpressionColumn)6 LinkedHashMap (java.util.LinkedHashMap)5 CacheException (javax.cache.CacheException)5 TableFilter (org.h2.table.TableFilter)5 StatementBuilder (org.h2.util.StatementBuilder)5 ValueString (org.h2.value.ValueString)5 HashMap (java.util.HashMap)4 H2TreeIndex (org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex)4 H2TreeIndexBase (org.apache.ignite.internal.processors.query.h2.database.H2TreeIndexBase)4 GridH2Table (org.apache.ignite.internal.processors.query.h2.opt.GridH2Table)4 Row (org.h2.result.Row)4 ResultSet (java.sql.ResultSet)3