Skip to content

Commit

Permalink
IGNITE-21558 Sql. Remove ExecutionContext dependency from ExpressionF…
Browse files Browse the repository at this point in the history
…actory
  • Loading branch information
korlov42 committed Dec 24, 2024
1 parent 24dd154 commit 7f0ec91
Show file tree
Hide file tree
Showing 53 changed files with 2,493 additions and 1,535 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.apache.ignite.internal.sql.engine.exec.SqlRowHandler;
import org.apache.ignite.internal.sql.engine.exec.TransactionTracker;
import org.apache.ignite.internal.sql.engine.exec.ddl.DdlCommandHandler;
import org.apache.ignite.internal.sql.engine.exec.exp.ExpressionFactoryImpl;
import org.apache.ignite.internal.sql.engine.exec.exp.func.TableFunctionRegistryImpl;
import org.apache.ignite.internal.sql.engine.exec.fsm.ExecutionPhase;
import org.apache.ignite.internal.sql.engine.exec.fsm.QueryExecutor;
Expand All @@ -93,6 +94,7 @@
import org.apache.ignite.internal.sql.engine.statistic.SqlStatisticManagerImpl;
import org.apache.ignite.internal.sql.engine.tx.QueryTransactionContext;
import org.apache.ignite.internal.sql.engine.tx.QueryTransactionContextImpl;
import org.apache.ignite.internal.sql.engine.util.Commons;
import org.apache.ignite.internal.sql.engine.util.cache.CacheFactory;
import org.apache.ignite.internal.sql.engine.util.cache.CaffeineCacheFactory;
import org.apache.ignite.internal.sql.metrics.SqlClientMetricSource;
Expand Down Expand Up @@ -124,6 +126,9 @@ public class SqlQueryProcessor implements QueryProcessor, SystemViewProvider {
/** Size of the table access cache. */
private static final int TABLE_CACHE_SIZE = 1024;

/** Size of the compiled expressions cache. */
private static final int COMPILED_EXPRESSIONS_CACHE_SIZE = 1024;

/** Number of the schemas in cache. */
private static final int SCHEMA_CACHE_SIZE = 128;

Expand Down Expand Up @@ -340,6 +345,9 @@ public synchronized CompletableFuture<Void> startAsync(ComponentContext componen
tableFunctionRegistry,
clockService,
killCommandHandler,
new ExpressionFactoryImpl<>(
Commons.typeFactory(), COMPILED_EXPRESSIONS_CACHE_SIZE, CACHE_FACTORY
),
EXECUTION_SERVICE_SHUTDOWN_TIMEOUT
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ public DynamicPartitionProvider(
public List<PartitionWithConsistencyToken> getPartitions(ExecutionContext<RowT> ctx) {
ExpressionFactory<RowT> expressionFactory = ctx.expressionFactory();

return PartitionPruningPredicate.prunePartitions(columns, table, expressionFactory, assignments, nodeName);
return PartitionPruningPredicate.prunePartitions(ctx, columns, table, expressionFactory, assignments, nodeName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.ignite.internal.sql.engine.exec;

import static org.apache.ignite.internal.sql.engine.util.Commons.FRAMEWORK_CONFIG;
import static org.apache.ignite.lang.ErrorGroups.Common.INTERNAL_ERR;

import java.lang.reflect.Type;
Expand All @@ -43,7 +42,6 @@
import org.apache.ignite.internal.sql.engine.QueryCancel;
import org.apache.ignite.internal.sql.engine.QueryCancelledException;
import org.apache.ignite.internal.sql.engine.exec.exp.ExpressionFactory;
import org.apache.ignite.internal.sql.engine.exec.exp.ExpressionFactoryImpl;
import org.apache.ignite.internal.sql.engine.exec.mapping.ColocationGroup;
import org.apache.ignite.internal.sql.engine.exec.mapping.FragmentDescription;
import org.apache.ignite.internal.sql.engine.prepare.pruning.PartitionPruningColumns;
Expand Down Expand Up @@ -103,6 +101,7 @@ public class ExecutionContext<RowT> implements DataContext {
/**
* Constructor.
*
* @param expressionFactory Expression factory.
* @param executor Task executor.
* @param executionId Execution ID.
* @param localNode Local node.
Expand All @@ -116,6 +115,7 @@ public class ExecutionContext<RowT> implements DataContext {
*/
@SuppressWarnings("AssignmentOrReturnOfFieldWithMutableType")
public ExecutionContext(
ExpressionFactory<RowT> expressionFactory,
QueryTaskExecutor executor,
ExecutionId executionId,
ClusterNode localNode,
Expand All @@ -127,6 +127,7 @@ public ExecutionContext(
ZoneId timeZoneId,
@Nullable QueryCancel cancel
) {
this.expressionFactory = expressionFactory;
this.executor = executor;
this.executionId = executionId;
this.description = description;
Expand All @@ -138,11 +139,6 @@ public ExecutionContext(
this.timeZoneId = timeZoneId;
this.cancel = cancel;

expressionFactory = new ExpressionFactoryImpl<>(
this,
FRAMEWORK_CONFIG.getParserConfig().conformance()
);

Instant nowUtc = Instant.now();
startTs = nowUtc.plusSeconds(this.timeZoneId.getRules().getOffset(nowUtc).getTotalSeconds()).toEpochMilli();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
import org.apache.ignite.internal.sql.engine.SqlQueryType;
import org.apache.ignite.internal.sql.engine.exec.AsyncDataCursorExt.CancellationReason;
import org.apache.ignite.internal.sql.engine.exec.ddl.DdlCommandHandler;
import org.apache.ignite.internal.sql.engine.exec.exp.ExpressionFactory;
import org.apache.ignite.internal.sql.engine.exec.exp.func.TableFunctionRegistry;
import org.apache.ignite.internal.sql.engine.exec.kill.KillCommand;
import org.apache.ignite.internal.sql.engine.exec.kill.KillCommandHandler;
Expand Down Expand Up @@ -178,6 +179,8 @@ public class ExecutionServiceImpl<RowT> implements ExecutionService, TopologyEve

private final KillCommandHandler killCommandHandler;

private final ExpressionFactory<RowT> expressionFactory;

/**
* Constructor.
*
Expand Down Expand Up @@ -206,6 +209,7 @@ public ExecutionServiceImpl(
ImplementorFactory<RowT> implementorFactory,
ClockService clockService,
KillCommandHandler killCommandHandler,
ExpressionFactory<RowT> expressionFactory,
long shutdownTimeout
) {
this.localNode = topSrvc.localMember();
Expand All @@ -221,6 +225,7 @@ public ExecutionServiceImpl(
this.implementorFactory = implementorFactory;
this.clockService = clockService;
this.killCommandHandler = killCommandHandler;
this.expressionFactory = expressionFactory;
this.shutdownTimeout = shutdownTimeout;
}

Expand Down Expand Up @@ -260,6 +265,7 @@ public static <RowT> ExecutionServiceImpl<RowT> create(
TableFunctionRegistry tableFunctionRegistry,
ClockService clockService,
KillCommandHandler killCommandHandler,
ExpressionFactory<RowT> expressionFactory,
long shutdownTimeout
) {
return new ExecutionServiceImpl<>(
Expand All @@ -281,6 +287,7 @@ public static <RowT> ExecutionServiceImpl<RowT> create(
),
clockService,
killCommandHandler,
expressionFactory,
shutdownTimeout
);
}
Expand Down Expand Up @@ -423,6 +430,7 @@ private AsyncDataCursor<InternalSqlRow> executeExecutablePlan(

ExecutionId executionId = nextExecutionId(operationContext.queryId());
ExecutionContext<RowT> ectx = new ExecutionContext<>(
expressionFactory,
taskExecutor,
executionId,
localNode,
Expand Down Expand Up @@ -943,6 +951,7 @@ private CompletableFuture<Void> executeFragment(IgniteRel treeRoot, ResolvedDepe

private ExecutionContext<RowT> createContext(String initiatorNodeName, FragmentDescription desc, TxAttributes txAttributes) {
return new ExecutionContext<>(
expressionFactory,
taskExecutor,
executionId,
localNode,
Expand Down
Loading

0 comments on commit 7f0ec91

Please sign in to comment.