Search in sources :

Example 6 with StatisticsTarget

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

the class SqlParserRefreshStatisticsSelfTest method testRefresh.

/**
 * Tests for REFRESH STATISTICS command.
 */
@Test
public void testRefresh() {
    parseValidate(null, "REFRESH STATISTICS tbl", new StatisticsTarget((String) null, "TBL"));
    parseValidate(null, "REFRESH STATISTICS tbl;", new StatisticsTarget((String) null, "TBL"));
    parseValidate(null, "REFRESH STATISTICS schema.tbl", new StatisticsTarget("SCHEMA", "TBL"));
    parseValidate(null, "REFRESH STATISTICS schema.tbl;", new StatisticsTarget("SCHEMA", "TBL"));
    parseValidate(null, "REFRESH STATISTICS schema.tbl(a)", new StatisticsTarget("SCHEMA", "TBL", "A"));
    parseValidate(null, "REFRESH STATISTICS schema.tbl(a);", new StatisticsTarget("SCHEMA", "TBL", "A"));
    parseValidate(null, "REFRESH STATISTICS tbl(a)", new StatisticsTarget((String) null, "TBL", "A"));
    parseValidate(null, "REFRESH STATISTICS tbl(a);", new StatisticsTarget((String) null, "TBL", "A"));
    parseValidate(null, "REFRESH STATISTICS tbl(a, b, c)", new StatisticsTarget((String) null, "TBL", "A", "B", "C"));
    parseValidate(null, "REFRESH STATISTICS tbl(a), schema.tbl2(a,B)", new StatisticsTarget((String) null, "TBL", "A"), new StatisticsTarget("SCHEMA", "TBL2", "A", "B"));
    assertParseError(null, "REFRESH STATISTICS p,", "Unexpected end of command");
    assertParseError(null, "REFRESH STATISTICS p()", "Unexpected token: \")\"");
}
Also used : StatisticsTarget(org.apache.ignite.internal.processors.query.stat.StatisticsTarget) Test(org.junit.Test)

Example 7 with StatisticsTarget

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

the class SqlAnalyzeCommand method parse.

/**
 * {@inheritDoc}
 */
@Override
public SqlCommand parse(SqlLexer lex) {
    while (true) {
        SqlQualifiedName tblQName = parseQualifiedIdentifier(lex);
        String[] cols = parseColumnList(lex, true);
        Map<String, String> params = parseParams(lex);
        StatisticsTarget target = new StatisticsTarget(tblQName.schemaName(), tblQName.name(), cols);
        configs.add(buildConfig(target, params));
        if (tryEnd(lex))
            return this;
    }
}
Also used : StatisticsTarget(org.apache.ignite.internal.processors.query.stat.StatisticsTarget)

Example 8 with StatisticsTarget

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

the class CommandProcessor method processDropStatisticsCommand.

/**
 * Process drop statistics command.
 *
 * @param cmd Drop statistics command.
 */
private void processDropStatisticsCommand(SqlDropStatisticsCommand cmd) throws IgniteCheckedException {
    ctx.security().authorize(SecurityPermission.CHANGE_STATISTICS);
    IgniteH2Indexing indexing = (IgniteH2Indexing) ctx.query().getIndexing();
    StatisticsTarget[] targets = cmd.targets().stream().map(t -> (t.schema() == null) ? new StatisticsTarget(cmd.schemaName(), t.obj(), t.columns()) : t).toArray(StatisticsTarget[]::new);
    indexing.statsManager().dropStatistics(targets);
}
Also used : GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) QueryUtils(org.apache.ignite.internal.processors.query.QueryUtils) GridQueryKillResponse(org.apache.ignite.internal.processors.query.messages.GridQueryKillResponse) SqlCreateUserCommand(org.apache.ignite.internal.sql.command.SqlCreateUserCommand) MvccUtils.txStart(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.txStart) GridH2Table(org.apache.ignite.internal.processors.query.h2.opt.GridH2Table) Map(java.util.Map) NoOperation(org.h2.command.dml.NoOperation) SqlSetStreamingCommand(org.apache.ignite.internal.sql.command.SqlSetStreamingCommand) GridIoPolicy(org.apache.ignite.internal.managers.communication.GridIoPolicy) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) SqlCreateIndexCommand(org.apache.ignite.internal.sql.command.SqlCreateIndexCommand) GridQueryTypeDescriptor(org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor) QueryField(org.apache.ignite.internal.processors.query.QueryField) CIX2(org.apache.ignite.internal.util.typedef.CIX2) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Event(org.apache.ignite.events.Event) Set(java.util.Set) QueryEntityEx(org.apache.ignite.internal.processors.query.QueryEntityEx) AlterTableAlterColumn(org.h2.command.ddl.AlterTableAlterColumn) SqlAnalyzeCommand(org.apache.ignite.internal.sql.command.SqlAnalyzeCommand) DataType(org.h2.value.DataType) SqlRefreshStatitsicsCommand(org.apache.ignite.internal.sql.command.SqlRefreshStatitsicsCommand) PARAM_WRAP_VALUE(org.apache.ignite.internal.processors.query.h2.sql.GridSqlQueryParser.PARAM_WRAP_VALUE) Message(org.apache.ignite.plugin.extensions.communication.Message) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) BulkLoadStreamerWriter(org.apache.ignite.internal.processors.bulkload.BulkLoadStreamerWriter) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteLogger(org.apache.ignite.IgniteLogger) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) SecurityPermission(org.apache.ignite.plugin.security.SecurityPermission) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) LinkedHashMap(java.util.LinkedHashMap) Column(org.h2.table.Column) ClusterNode(org.apache.ignite.cluster.ClusterNode) GridSqlAlterTableAddColumn(org.apache.ignite.internal.processors.query.h2.sql.GridSqlAlterTableAddColumn) SqlBeginTransactionCommand(org.apache.ignite.internal.sql.command.SqlBeginTransactionCommand) SqlIndexColumn(org.apache.ignite.internal.sql.command.SqlIndexColumn) MvccUtils(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils) SqlKillQueryCommand(org.apache.ignite.internal.sql.command.SqlKillQueryCommand) NestedTxMode(org.apache.ignite.internal.processors.query.NestedTxMode) SqlDropUserCommand(org.apache.ignite.internal.sql.command.SqlDropUserCommand) Value(org.h2.value.Value) ServiceMXBeanImpl(org.apache.ignite.internal.ServiceMXBeanImpl) GridQueryProperty(org.apache.ignite.internal.processors.query.GridQueryProperty) GridSqlCreateIndex(org.apache.ignite.internal.processors.query.h2.sql.GridSqlCreateIndex) GridSqlAlterTableDropColumn(org.apache.ignite.internal.processors.query.h2.sql.GridSqlAlterTableDropColumn) BulkLoadParser(org.apache.ignite.internal.processors.bulkload.BulkLoadParser) SqlBulkLoadCommand(org.apache.ignite.internal.sql.command.SqlBulkLoadCommand) GridRunningQueryInfo(org.apache.ignite.internal.processors.query.GridRunningQueryInfo) DropIndex(org.h2.command.ddl.DropIndex) GridSqlDropTable(org.apache.ignite.internal.processors.query.h2.sql.GridSqlDropTable) AtomicLong(java.util.concurrent.atomic.AtomicLong) GridTopic(org.apache.ignite.internal.GridTopic) SqlClientContext(org.apache.ignite.internal.processors.query.SqlClientContext) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException) TransactionsMXBeanImpl(org.apache.ignite.internal.TransactionsMXBeanImpl) IgniteDataStreamer(org.apache.ignite.IgniteDataStreamer) CacheMode(org.apache.ignite.cache.CacheMode) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) SqlRollbackTransactionCommand(org.apache.ignite.internal.sql.command.SqlRollbackTransactionCommand) SqlAlterUserCommand(org.apache.ignite.internal.sql.command.SqlAlterUserCommand) DmlBulkLoadDataConverter(org.apache.ignite.internal.processors.query.h2.dml.DmlBulkLoadDataConverter) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) SqlAlterTableCommand(org.apache.ignite.internal.sql.command.SqlAlterTableCommand) IgniteCluster(org.apache.ignite.IgniteCluster) StatisticsTarget(org.apache.ignite.internal.processors.query.stat.StatisticsTarget) CreateTable(org.h2.command.ddl.CreateTable) QueryEntity(org.apache.ignite.cache.QueryEntity) UpdatePlan(org.apache.ignite.internal.processors.query.h2.dml.UpdatePlan) SqlCommand(org.apache.ignite.internal.sql.command.SqlCommand) EventType(org.apache.ignite.events.EventType) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) GridSqlStatement(org.apache.ignite.internal.processors.query.h2.sql.GridSqlStatement) UUID(java.util.UUID) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) Objects(java.util.Objects) SqlKillContinuousQueryCommand(org.apache.ignite.internal.sql.command.SqlKillContinuousQueryCommand) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) SqlKillScanQueryCommand(org.apache.ignite.internal.sql.command.SqlKillScanQueryCommand) BulkLoadAckClientParameters(org.apache.ignite.internal.processors.bulkload.BulkLoadAckClientParameters) IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) NotNull(org.jetbrains.annotations.NotNull) FieldsQueryCursor(org.apache.ignite.cache.query.FieldsQueryCursor) GridSqlColumn(org.apache.ignite.internal.processors.query.h2.sql.GridSqlColumn) GridQueryKillRequest(org.apache.ignite.internal.processors.query.messages.GridQueryKillRequest) UpdatePlanBuilder(org.apache.ignite.internal.processors.query.h2.dml.UpdatePlanBuilder) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) QueryMXBeanImpl(org.apache.ignite.internal.QueryMXBeanImpl) SqlCommitTransactionCommand(org.apache.ignite.internal.sql.command.SqlCommitTransactionCommand) MvccUtils.tx(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.tx) HashMap(java.util.HashMap) GridSqlCreateTable(org.apache.ignite.internal.processors.query.h2.sql.GridSqlCreateTable) SqlKillServiceCommand(org.apache.ignite.internal.sql.command.SqlKillServiceCommand) IgniteClosureX(org.apache.ignite.internal.util.lang.IgniteClosureX) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) BulkLoadCacheWriter(org.apache.ignite.internal.processors.bulkload.BulkLoadCacheWriter) StatisticsObjectConfiguration(org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration) BulkLoadContextCursor(org.apache.ignite.cache.query.BulkLoadContextCursor) StatisticsKey(org.apache.ignite.internal.processors.query.stat.StatisticsKey) QueryIndexType(org.apache.ignite.cache.QueryIndexType) F(org.apache.ignite.internal.util.typedef.F) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) Iterator(java.util.Iterator) SqlKillComputeTaskCommand(org.apache.ignite.internal.sql.command.SqlKillComputeTaskCommand) GridSqlDropIndex(org.apache.ignite.internal.processors.query.h2.sql.GridSqlDropIndex) SqlDropStatisticsCommand(org.apache.ignite.internal.sql.command.SqlDropStatisticsCommand) SqlKillTransactionCommand(org.apache.ignite.internal.sql.command.SqlKillTransactionCommand) MvccUtils.mvccEnabled(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.mvccEnabled) IgniteQueryErrorCode(org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode) SqlDropIndexCommand(org.apache.ignite.internal.sql.command.SqlDropIndexCommand) Prepared(org.h2.command.Prepared) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) BulkLoadProcessor(org.apache.ignite.internal.processors.bulkload.BulkLoadProcessor) CreateIndex(org.h2.command.ddl.CreateIndex) ComputeMXBeanImpl(org.apache.ignite.internal.ComputeMXBeanImpl) Collections(java.util.Collections) QueryIndex(org.apache.ignite.cache.QueryIndex) DropTable(org.h2.command.ddl.DropTable) GridLocalEventListener(org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener) StatisticsTarget(org.apache.ignite.internal.processors.query.stat.StatisticsTarget)

Aggregations

StatisticsTarget (org.apache.ignite.internal.processors.query.stat.StatisticsTarget)8 Test (org.junit.Test)4 Set (java.util.Set)3 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 UUID (java.util.UUID)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)2 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IgniteCluster (org.apache.ignite.IgniteCluster)2