diff --git a/Util/src/main/java/io/deephaven/util/CompletionStageFuture.java b/Util/src/main/java/io/deephaven/util/CompletionStageFuture.java index 87eeaf57151..0564f9dbf01 100644 --- a/Util/src/main/java/io/deephaven/util/CompletionStageFuture.java +++ b/Util/src/main/java/io/deephaven/util/CompletionStageFuture.java @@ -5,8 +5,8 @@ import org.jetbrains.annotations.NotNull; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.Future; import java.util.function.BiConsumer; @@ -21,31 +21,40 @@ */ public interface CompletionStageFuture extends Future, CompletionStage { + /** + * Create a new incomplete future. + * + * @param The result type returned by this future's {@code join} + * @return a resolver for the future + */ + static Resolver make() { + return new CompletionStageFutureImpl().new ResolverImpl(); + } + /** * Returns a new CompletionStageFuture that is already completed with the given value. * * @param value the value * @param the type of the value * @return the completed CompletionStageFuture - * @see CompletableFuture#completedFuture(Object) + * @see java.util.concurrent.CompletableFuture#completedFuture(Object) */ static CompletionStageFuture completedFuture(U value) { - final CompletionStageFutureImpl.Resolver resolver = CompletionStageFutureImpl.make(); + final CompletionStageFutureImpl.Resolver resolver = CompletionStageFuture.make(); resolver.complete(value); return resolver.getFuture(); } /** - * Returns a new CompletableFuture that is already completed exceptionally with the given exception. + * Returns a new CompletionStageFuture that is already completed exceptionally with the given exception. * * @param ex the exception * @param the type of the value - * @return the exceptionally completed CompletableFuture - * @since 9 - * @see CompletableFuture#failedFuture(Throwable) + * @return the exceptionally completed CompletionStageFuture + * @see java.util.concurrent.CompletableFuture#failedFuture(Throwable) */ static CompletionStageFuture failedFuture(Throwable ex) { - final CompletionStageFutureImpl.Resolver resolver = CompletionStageFutureImpl.make(); + final CompletionStageFutureImpl.Resolver resolver = CompletionStageFuture.make(); resolver.completeExceptionally(ex); return resolver.getFuture(); } @@ -56,7 +65,7 @@ interface Resolver { * If not already completed, sets the value returned by {@link #get()} and related methods to the given value. * * @param value the result value - * @return {@code true} if this invocation caused this SafeCompletableFuture to transition to a completed state, + * @return {@code true} if this invocation caused this CompletionStageFuture to transition to a completed state, * else {@code false} * @see java.util.concurrent.CompletableFuture#complete(Object) */ @@ -64,17 +73,18 @@ interface Resolver { /** * If not already completed, causes invocations of {@link #get()} and related methods to throw the given - * exception. + * exception wrapped in an {@link ExecutionException}. * * @param ex the exception - * @return {@code true} if this invocation caused this SafeCompletableFuture to transition to a completed state, + * @return {@code true} if this invocation caused this CompletionStageFuture to transition to a completed state, * else {@code false} * @see java.util.concurrent.CompletableFuture#completeExceptionally(Throwable) */ boolean completeExceptionally(@NotNull Throwable ex); /** - * @return the underlying future to provide to the recipient + * @return the underlying future to provide to the recipient; implementations must ensure that this method + * always returns an identical result for a given Resolver instance */ CompletionStageFuture getFuture(); } diff --git a/Util/src/main/java/io/deephaven/util/CompletionStageFutureImpl.java b/Util/src/main/java/io/deephaven/util/CompletionStageFutureImpl.java index 59884161404..df86fb942b0 100644 --- a/Util/src/main/java/io/deephaven/util/CompletionStageFutureImpl.java +++ b/Util/src/main/java/io/deephaven/util/CompletionStageFutureImpl.java @@ -20,20 +20,10 @@ @SuppressWarnings("unchecked") public class CompletionStageFutureImpl extends CompletableFuture implements CompletionStageFuture { - /** - * Create a new incomplete future. - * - * @param The result type returned by this future's {@code join} - * @return a resolver for the future - */ - public static Resolver make() { - return new CompletionStageFutureImpl().new ResolverImpl(); - } - /** * A resolver for this future implementation. */ - private class ResolverImpl implements CompletionStageFuture.Resolver { + class ResolverImpl implements CompletionStageFuture.Resolver { public boolean complete(final T value) { return safelyComplete(value); } diff --git a/Util/src/main/java/io/deephaven/util/MultiException.java b/Util/src/main/java/io/deephaven/util/MultiException.java index d8f275e5aaa..f2dcc13a90c 100644 --- a/Util/src/main/java/io/deephaven/util/MultiException.java +++ b/Util/src/main/java/io/deephaven/util/MultiException.java @@ -8,7 +8,7 @@ import java.util.List; /** - * An exception to use when a series of operations mus all be executed, but may all throw exceptions themselves. This + * An exception to use when a series of operations must all be executed, but may all throw exceptions themselves. This * allows for retention of all exception data. */ public class MultiException extends Exception { diff --git a/Util/src/main/java/io/deephaven/util/datastructures/LazyCachingFunction.java b/Util/src/main/java/io/deephaven/util/datastructures/SoftCachingFunction.java similarity index 89% rename from Util/src/main/java/io/deephaven/util/datastructures/LazyCachingFunction.java rename to Util/src/main/java/io/deephaven/util/datastructures/SoftCachingFunction.java index 05b654fc1bc..e3521335875 100644 --- a/Util/src/main/java/io/deephaven/util/datastructures/LazyCachingFunction.java +++ b/Util/src/main/java/io/deephaven/util/datastructures/SoftCachingFunction.java @@ -2,7 +2,7 @@ // Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending // // ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY -// ****** Edit LazyCachingSupplier and run "./gradlew replicateCachingSupplier" to regenerate +// ****** Edit SoftCachingSupplier and run "./gradlew replicateCachingSupplier" to regenerate // // @formatter:off package io.deephaven.util.datastructures; @@ -18,7 +18,7 @@ * * @param the type of results supplied by this function */ -public final class LazyCachingFunction implements Function { +public final class SoftCachingFunction implements Function { private final Function internalFunction; @@ -29,7 +29,7 @@ public final class LazyCachingFunction implements Funct * * @param internalFunction The {@link Function} to wrap. Must be safely repeatable and must not return {@code null}. */ - public LazyCachingFunction(@NotNull final Function internalFunction) { + public SoftCachingFunction(@NotNull final Function internalFunction) { this.internalFunction = internalFunction; } diff --git a/Util/src/main/java/io/deephaven/util/datastructures/LazyCachingSupplier.java b/Util/src/main/java/io/deephaven/util/datastructures/SoftCachingSupplier.java similarity index 91% rename from Util/src/main/java/io/deephaven/util/datastructures/LazyCachingSupplier.java rename to Util/src/main/java/io/deephaven/util/datastructures/SoftCachingSupplier.java index 478d33c0901..788a61c954e 100644 --- a/Util/src/main/java/io/deephaven/util/datastructures/LazyCachingSupplier.java +++ b/Util/src/main/java/io/deephaven/util/datastructures/SoftCachingSupplier.java @@ -14,7 +14,7 @@ * * @param the type of results supplied by this supplier */ -public final class LazyCachingSupplier implements Supplier { +public final class SoftCachingSupplier implements Supplier { private final Supplier internalSupplier; @@ -25,7 +25,7 @@ public final class LazyCachingSupplier implements Supplier internalSupplier) { + public SoftCachingSupplier(@NotNull final Supplier internalSupplier) { this.internalSupplier = internalSupplier; } diff --git a/engine/context/src/main/java/io/deephaven/engine/context/QueryCompiler.java b/engine/context/src/main/java/io/deephaven/engine/context/QueryCompiler.java index 0302ea55d9a..1152569987c 100644 --- a/engine/context/src/main/java/io/deephaven/engine/context/QueryCompiler.java +++ b/engine/context/src/main/java/io/deephaven/engine/context/QueryCompiler.java @@ -14,7 +14,6 @@ import io.deephaven.io.logger.Logger; import io.deephaven.util.ByteUtils; import io.deephaven.util.CompletionStageFuture; -import io.deephaven.util.CompletionStageFutureImpl; import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.text.StringEscapeUtils; import org.jetbrains.annotations.NotNull; @@ -216,7 +215,7 @@ public void setParentClassLoader(final ClassLoader parentClassLoader) { * @param request The compilation request */ public Class compile(@NotNull final QueryCompilerRequest request) { - final CompletionStageFuture.Resolver> resolver = CompletionStageFutureImpl.make(); + final CompletionStageFuture.Resolver> resolver = CompletionStageFuture.make(); compile(request, resolver); try { return resolver.getFuture().get(); @@ -227,7 +226,7 @@ public Class compile(@NotNull final QueryCompilerRequest request) { } throw new UncheckedDeephavenException("Error while compiling class", cause); } catch (InterruptedException e) { - throw new UncheckedDeephavenException("Interrupted while compile class", e); + throw new UncheckedDeephavenException("Interrupted while compiling class", e); } } @@ -235,6 +234,7 @@ public Class compile(@NotNull final QueryCompilerRequest request) { * Compile a class. * * @param request The compilation request + * @param resolver The resolver to use for delivering compilation results */ public void compile( @NotNull final QueryCompilerRequest request, @@ -247,6 +247,7 @@ public void compile( * Compiles all requests. * * @param requests The compilation requests + * @param resolvers The resolvers to use for delivering compilation results */ public void compile( @NotNull final QueryCompilerRequest[] requests, @@ -459,8 +460,8 @@ private String getClassPath() { } private static class CompilationState { - int next_pi; - boolean compiled; + int nextProbeIndex; + boolean complete; String packageName; String fqClassName; } @@ -481,7 +482,7 @@ private void compileHelper( requests.get(ii).classBody().getBytes(StandardCharsets.UTF_8))); } - int numCompiled = 0; + int numComplete = 0; final CompilationState[] states = new CompilationState[requests.size()]; for (int ii = 0; ii < requests.size(); ++ii) { states[ii] = new CompilationState(); @@ -489,21 +490,21 @@ private void compileHelper( /* * @formatter:off - * 1. try to resolve CFs without compiling; retain next hash to try + * 1. try to resolve without compiling; retain next hash to try * 2. compile all remaining with a single compilation task * 3. goto step 1 if any are unresolved * @formatter:on */ - while (numCompiled < requests.size()) { + while (numComplete < requests.size()) { for (int ii = 0; ii < requests.size(); ++ii) { final CompilationState state = states[ii]; - if (state.compiled) { + if (state.complete) { continue; } while (true) { - final int pi = state.next_pi++; + final int pi = state.nextProbeIndex++; final String packageNameSuffix = "c_" + basicHashText[ii] + (pi == 0 ? "" : ("p" + pi)) + "v" + JAVA_CLASS_VERSION; @@ -514,8 +515,8 @@ private void compileHelper( + request.packageNameRoot() + ", class name=" + request.className() + ", class body " + "hash=" + basicHashText[ii] + " - contact Deephaven support!"); resolvers.get(ii).completeExceptionally(err); - state.compiled = true; - ++numCompiled; + state.complete = true; + ++numComplete; break; } @@ -533,14 +534,14 @@ private void compileHelper( if (completeIfResultMatchesQueryCompilerRequest(state.packageName, request, resolvers.get(ii), result)) { - state.compiled = true; - ++numCompiled; + state.complete = true; + ++numComplete; break; } } } - if (numCompiled == requests.size()) { + if (numComplete == requests.size()) { return; } @@ -548,7 +549,7 @@ private void compileHelper( final List compilationRequestAttempts = new ArrayList<>(); for (int ii = 0; ii < requests.size(); ++ii) { final CompilationState state = states[ii]; - if (!state.compiled) { + if (!state.complete) { final QueryCompilerRequest request = requests.get(ii); compilationRequestAttempts.add(new CompilationRequestAttempt( request, @@ -558,22 +559,22 @@ private void compileHelper( } } - maybeCreateClass(compilationRequestAttempts); + maybeCreateClasses(compilationRequestAttempts); // We could be running on a screwy filesystem that is slow (e.g. NFS). If we wrote a file and can't load it // ... then give the filesystem some time. All requests should use the same deadline. final long deadline = System.currentTimeMillis() + CODEGEN_TIMEOUT_MS - CODEGEN_LOOP_DELAY_MS; for (int ii = 0; ii < requests.size(); ++ii) { final CompilationState state = states[ii]; - if (state.compiled) { + if (state.complete) { continue; } final QueryCompilerRequest request = requests.get(ii); final CompletionStageFuture.Resolver> resolver = resolvers.get(ii); if (resolver.getFuture().isDone()) { - state.compiled = true; - ++numCompiled; + state.complete = true; + ++numComplete; continue; } @@ -599,8 +600,8 @@ private void compileHelper( } if (completeIfResultMatchesQueryCompilerRequest(state.packageName, request, resolver, clazz)) { - state.compiled = true; - ++numCompiled; + state.complete = true; + ++numComplete; } } } @@ -796,7 +797,7 @@ public JavaSourceFromString makeSource() { } } - private void maybeCreateClass( + private void maybeCreateClasses( @NotNull final List requests) { // Get the destination root directory (e.g. /tmp/workspace/cache/classes) and populate it with the package // directories (e.g. io/deephaven/test) if they are not already there. This will be useful later. @@ -841,8 +842,6 @@ private void maybeCreateClass( int parallelismFactor = operationInitializer.parallelismFactor(); int requestsPerTask = Math.max(32, (requests.size() + parallelismFactor - 1) / parallelismFactor); - log.info().append("Compiling with parallelismFactor = ").append(parallelismFactor) - .append(" requestsPerTask = ").append(requestsPerTask).endl(); if (parallelismFactor == 1 || requestsPerTask >= requests.size()) { maybeCreateClassHelper(compiler, fileManager, requests, rootPathAsString, tempDirAsString, 0, requests.size()); @@ -895,6 +894,9 @@ private void maybeCreateClassHelper( final int startInclusive, final int endExclusive) { final List toRetry = new ArrayList<>(); + // If any of our requests fail to compile then the JavaCompiler will not write any class files at all. The + // non-failing requests will be retried in a second pass that is expected to succeed. This enables us to + // fulfill futures independent of each other; otherwise a single failure would taint all requests in a batch. final boolean wantRetry = maybeCreateClassHelper2(compiler, fileManager, requests, rootPathAsString, tempDirAsString, startInclusive, endExclusive, toRetry); if (!wantRetry) { diff --git a/engine/context/src/test/java/io/deephaven/engine/context/TestQueryCompiler.java b/engine/context/src/test/java/io/deephaven/engine/context/TestQueryCompiler.java index aa19e47dc45..3a42aabfa9c 100644 --- a/engine/context/src/test/java/io/deephaven/engine/context/TestQueryCompiler.java +++ b/engine/context/src/test/java/io/deephaven/engine/context/TestQueryCompiler.java @@ -9,7 +9,6 @@ import io.deephaven.engine.testutil.junit4.EngineCleanup; import io.deephaven.time.DateTimeUtils; import io.deephaven.util.CompletionStageFuture; -import io.deephaven.util.CompletionStageFutureImpl; import io.deephaven.util.SafeCloseable; import org.junit.After; import org.junit.Before; @@ -295,8 +294,8 @@ public void testMultiCompileWithFailure() throws ExecutionException, Interrupted // noinspection unchecked CompletionStageFuture.Resolver>[] resolvers = (CompletionStageFuture.Resolver>[]) new CompletionStageFuture.Resolver[] { - CompletionStageFutureImpl.make(), - CompletionStageFutureImpl.make(), + CompletionStageFuture.make(), + CompletionStageFuture.make(), }; try { diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/DeferredViewTable.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/DeferredViewTable.java index c87b539058a..b2328798e78 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/DeferredViewTable.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/DeferredViewTable.java @@ -20,7 +20,6 @@ import java.util.*; import java.util.function.Function; -import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -47,14 +46,12 @@ public DeferredViewTable(@NotNull final TableDefinition definition, this.deferredViewColumns = deferredViewColumns == null ? SelectColumn.ZERO_LENGTH_SELECT_COLUMN_ARRAY : deferredViewColumns; final TableDefinition parentDefinition = tableReference.getDefinition(); - final Supplier> variableSupplier = SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); - final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); SelectAndViewAnalyzer.initializeSelectColumns( - parentDefinition.getColumnNameMap(), variableSupplier, this.deferredViewColumns, compilationProcessor); + parentDefinition.getColumnNameMap(), this.deferredViewColumns, compilationProcessor); this.deferredFilters = deferredFilters == null ? WhereFilter.ZERO_LENGTH_SELECT_FILTER_ARRAY : deferredFilters; for (final WhereFilter sf : this.deferredFilters) { - sf.init(parentDefinition, variableSupplier, compilationProcessor); + sf.init(parentDefinition, compilationProcessor); if (sf instanceof LivenessReferent && sf.isRefreshing()) { manage((LivenessReferent) sf); setRefreshing(true); @@ -83,11 +80,9 @@ public DeferredViewTable(@NotNull final TableDefinition definition, @Override public Table where(Filter filter) { final WhereFilter[] whereFilters = WhereFilter.fromInternal(filter); - final Supplier> variableSupplier = SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); - final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); for (WhereFilter f : whereFilters) { - f.init(definition, variableSupplier, compilationProcessor); + f.init(definition, compilationProcessor); } compilationProcessor.compile(); return getResultTableWithWhere(whereFilters); @@ -198,11 +193,9 @@ private PreAndPostFilters applyFilterRenamings(WhereFilter[] filters) { } } - final Supplier> variableSupplier = SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); - final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); for (final WhereFilter filter : filters) { - filter.init(definition, variableSupplier, compilationProcessor); + filter.init(definition, compilationProcessor); final boolean isPostView = Stream.of(filter.getColumns(), filter.getColumnArrays()) .flatMap(Collection::stream) diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/PartitionAwareSourceTable.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/PartitionAwareSourceTable.java index f219651845a..4adde99c515 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/PartitionAwareSourceTable.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/PartitionAwareSourceTable.java @@ -3,7 +3,6 @@ // package io.deephaven.engine.table.impl; -import io.deephaven.api.ColumnName; import io.deephaven.api.Selectable; import io.deephaven.api.filter.Filter; import io.deephaven.base.verify.Assert; @@ -25,7 +24,6 @@ import java.util.*; import java.util.function.Function; -import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -286,11 +284,9 @@ private Table whereImpl(final WhereFilter[] whereFilters) { Set groupingColumnNames = groupingColumns.stream().map(ColumnDefinition::getName).collect(Collectors.toSet()); - final Supplier> variableSupplier = SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); - final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); for (WhereFilter whereFilter : whereFilters) { - whereFilter.init(definition, variableSupplier, compilationProcessor); + whereFilter.init(definition, compilationProcessor); List columns = whereFilter.getColumns(); if (whereFilter instanceof ReindexingFilter) { otherFilters.add(whereFilter); diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/QueryCompilerRequestProcessor.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/QueryCompilerRequestProcessor.java index 08f3cac184d..4244d076df7 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/QueryCompilerRequestProcessor.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/QueryCompilerRequestProcessor.java @@ -4,21 +4,56 @@ package io.deephaven.engine.table.impl; import io.deephaven.UncheckedDeephavenException; +import io.deephaven.api.util.NameValidator; import io.deephaven.engine.context.ExecutionContext; import io.deephaven.engine.context.QueryCompiler; import io.deephaven.engine.context.QueryCompilerRequest; +import io.deephaven.engine.context.QueryScope; import io.deephaven.engine.table.impl.perf.QueryPerformanceRecorder; import io.deephaven.util.MultiException; import io.deephaven.util.SafeCloseable; import io.deephaven.util.CompletionStageFuture; -import io.deephaven.util.CompletionStageFutureImpl; +import io.deephaven.util.datastructures.CachingSupplier; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public interface QueryCompilerRequestProcessor { + + /** + * @return An immediate QueryCompilerRequestProcessor + */ + static QueryCompilerRequestProcessor.ImmediateProcessor immediate() { + return new ImmediateProcessor(); + } + + /** + * @return A batch QueryCompilerRequestProcessor + */ + static QueryCompilerRequestProcessor.BatchProcessor batch() { + return new BatchProcessor(); + } + + /** + * @return a CachingSupplier that supplies a snapshot of the current query scope variables + */ + static CachingSupplier> newQueryScopeVariableSupplier() { + final QueryScope queryScope = ExecutionContext.getContext().getQueryScope(); + return new CachingSupplier<>(() -> Collections.unmodifiableMap( + queryScope.toMap((name, value) -> NameValidator.isValidQueryParameterName(name)))); + } + + /** + * @return a lazily cached snapshot of the current query scope variables + */ + Map getQueryScopeVariables(); + /** * Submit a request for compilation. The QueryCompilerRequestProcessor is not required to immediately compile this * request. @@ -31,16 +66,38 @@ public interface QueryCompilerRequestProcessor { * A QueryCompilerRequestProcessor that immediately compiles requests. */ class ImmediateProcessor implements QueryCompilerRequestProcessor { - public static final ImmediateProcessor INSTANCE = new ImmediateProcessor(); + + private final CachingSupplier> queryScopeVariableSupplier = newQueryScopeVariableSupplier(); + + private ImmediateProcessor() { + // force use of static factory method + } + + @Override + public Map getQueryScopeVariables() { + return queryScopeVariableSupplier.get(); + } @Override public CompletionStageFuture> submit(@NotNull final QueryCompilerRequest request) { - final String desc = "Compile " + request.description(); - final CompletionStageFuture.Resolver> resolver = CompletionStageFutureImpl.make(); + final String desc = "Compile: " + request.description(); + final CompletionStageFuture.Resolver> resolver = CompletionStageFuture.make(); try (final SafeCloseable ignored = QueryPerformanceRecorder.getInstance().getCompilationNugget(desc)) { ExecutionContext.getContext().getQueryCompiler().compile(request, resolver); } - return resolver.getFuture(); + + // The earlier we validate the future, the better. + final CompletionStageFuture> future = resolver.getFuture(); + try { + future.get(0, TimeUnit.SECONDS); + } catch (ExecutionException err) { + throw new UncheckedDeephavenException("Compilation failed", err.getCause()); + } catch (InterruptedException | TimeoutException err) { + // This should never happen since the future is already completed. + throw new UncheckedDeephavenException("Caught unexpected exception", err); + } + + return future; } } @@ -52,10 +109,20 @@ public CompletionStageFuture> submit(@NotNull final QueryCompilerReques class BatchProcessor implements QueryCompilerRequestProcessor { private final List requests = new ArrayList<>(); private final List>> resolvers = new ArrayList<>(); + private final CachingSupplier> queryScopeVariableSupplier = newQueryScopeVariableSupplier(); + + private BatchProcessor() { + // force use of static factory method + } + + @Override + public Map getQueryScopeVariables() { + return queryScopeVariableSupplier.get(); + } @Override public CompletionStageFuture> submit(@NotNull final QueryCompilerRequest request) { - final CompletionStageFuture.Resolver> resolver = CompletionStageFutureImpl.make(); + final CompletionStageFuture.Resolver> resolver = CompletionStageFuture.make(); requests.add(request); resolvers.add(resolver); return resolver.getFuture(); diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/QueryTable.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/QueryTable.java index 7acd8e9187a..1a6be0e420a 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/QueryTable.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/QueryTable.java @@ -1187,11 +1187,9 @@ private QueryTable whereInternal(final WhereFilter... filters) { List selectFilters = new LinkedList<>(); List>>> shiftColPairs = new LinkedList<>(); final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); - final Supplier> variableSupplier = - SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); + QueryCompilerRequestProcessor.batch(); for (final WhereFilter filter : filters) { - filter.init(getDefinition(), variableSupplier, compilationProcessor); + filter.init(getDefinition(), compilationProcessor); if (filter instanceof AbstractConditionFilter && ((AbstractConditionFilter) filter).hasConstantArrayAccess()) { shiftColPairs.add(((AbstractConditionFilter) filter).getFormulaShiftColPair()); diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/RedefinableTable.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/RedefinableTable.java index 684cb4e8a2d..819e1d196be 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/RedefinableTable.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/RedefinableTable.java @@ -9,7 +9,6 @@ import io.deephaven.engine.table.Table; import io.deephaven.engine.table.TableDefinition; import io.deephaven.engine.table.impl.select.*; -import io.deephaven.engine.table.impl.select.analyzers.SelectAndViewAnalyzer; import org.jetbrains.annotations.NotNull; import java.util.*; @@ -51,11 +50,9 @@ private Table viewInternal(Collection selectables, boolean final Map> allColumns = new HashMap<>(definition.getColumnNameMap()); boolean simpleRetain = true; - final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); for (final SelectColumn selectColumn : columns) { - List usedColumnNames = selectColumn.initDef( - allColumns, SelectAndViewAnalyzer.newQueryScopeVariableSupplier(), compilationProcessor); + List usedColumnNames = selectColumn.initDef(allColumns, compilationProcessor); usedColumnNames.addAll(selectColumn.getColumnArrays()); resultColumnsInternal.addAll(usedColumnNames.stream() .filter(usedColumnName -> !resultColumnsExternal.containsKey(usedColumnName)) diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/WouldMatchOperation.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/WouldMatchOperation.java index 97ee9353f62..b153f5822f0 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/WouldMatchOperation.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/WouldMatchOperation.java @@ -10,7 +10,6 @@ import io.deephaven.engine.rowset.*; import io.deephaven.engine.rowset.RowSetFactory; import io.deephaven.engine.table.*; -import io.deephaven.engine.table.impl.select.analyzers.SelectAndViewAnalyzer; import io.deephaven.engine.updategraph.NotificationQueue; import io.deephaven.engine.liveness.LivenessArtifact; import io.deephaven.engine.table.impl.select.WhereFilter; @@ -22,7 +21,6 @@ import org.jetbrains.annotations.Nullable; import java.util.*; -import java.util.function.Supplier; import java.util.stream.Collectors; /** @@ -40,7 +38,7 @@ public class WouldMatchOperation implements QueryTable.MemoizableOperation initialize(boolean usePrev, long beforeClock) { final List dependencies = new ArrayList<>(); final Map> newColumns = new LinkedHashMap<>(parent.getColumnSourceMap()); - final Supplier> variableSupplier = - SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + QueryCompilerRequestProcessor.batch(); final WhereFilter[] filters = matchColumns.stream().map(ColumnHolder::getFilter) - .peek(holder -> holder.init(parent.getDefinition(), variableSupplier, compilationProcessor)) + .peek(holder -> holder.init(parent.getDefinition(), compilationProcessor)) .toArray(WhereFilter[]::new); compilationProcessor.compile(); @@ -332,7 +328,6 @@ public WritableRowSet match( final Object... keys) { boolean hasFalse = false; boolean hasTrue = false; - boolean hasOther = false; for (Object key : keys) { if (key instanceof Boolean) { @@ -341,8 +336,6 @@ public WritableRowSet match( } else { hasFalse = true; } - } else { - hasOther = true; } } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/by/AggregationProcessor.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/by/AggregationProcessor.java index 505955435d6..2b751681071 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/by/AggregationProcessor.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/by/AggregationProcessor.java @@ -93,7 +93,6 @@ import io.deephaven.engine.table.impl.by.ssmcountdistinct.unique.ShortRollupUniqueOperator; import io.deephaven.engine.table.impl.by.ssmminmax.SsmChunkedMinMaxOperator; import io.deephaven.engine.table.impl.by.ssmpercentile.SsmChunkedPercentileOperator; -import io.deephaven.engine.table.impl.select.analyzers.SelectAndViewAnalyzer; import io.deephaven.engine.table.impl.sources.ReinterpretUtils; import io.deephaven.engine.table.impl.ssms.SegmentedSortedMultiSet; import io.deephaven.engine.table.impl.util.freezeby.FreezeByCountOperator; @@ -281,10 +280,9 @@ public AggregationContext makeAggregationContext( switch (type) { case NORMAL: final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + QueryCompilerRequestProcessor.batch(); final AggregationContext aggContext = new NormalConverter( - table, requireStateChangeRecorder, SelectAndViewAnalyzer.newQueryScopeVariableSupplier(), - compilationProcessor, groupByColumnNames).build(); + table, requireStateChangeRecorder, compilationProcessor, groupByColumnNames).build(); compilationProcessor.compile(); return aggContext; case ROLLUP_BASE: @@ -668,17 +666,14 @@ final void addWeightedAvgOrSumOperator( * {@link AggregationContext} for standard aggregations. Accumulates state by visiting each aggregation. */ private final class NormalConverter extends Converter { - private final Supplier> queryScopeVariables; private final QueryCompilerRequestProcessor compilationProcessor; private NormalConverter( @NotNull final Table table, final boolean requireStateChangeRecorder, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor, @NotNull final String... groupByColumnNames) { super(table, requireStateChangeRecorder, groupByColumnNames); - this.queryScopeVariables = queryScopeVariables; this.compilationProcessor = compilationProcessor; } @@ -754,7 +749,7 @@ public void visit(@NotNull final AggSpecFormula formula) { final GroupByChunkedOperator groupByChunkedOperator = new GroupByChunkedOperator(table, false, null, resultPairs.stream().map(pair -> MatchPair.of((Pair) pair.input())).toArray(MatchPair[]::new)); final FormulaChunkedOperator formulaChunkedOperator = new FormulaChunkedOperator(groupByChunkedOperator, - true, formula.formula(), formula.paramToken(), queryScopeVariables, compilationProcessor, + true, formula.formula(), formula.paramToken(), compilationProcessor, MatchPair.fromPairs(resultPairs)); addNoInputOperator(formulaChunkedOperator); } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/by/FormulaChunkedOperator.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/by/FormulaChunkedOperator.java index d076711b5b9..bdf69ed3a97 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/by/FormulaChunkedOperator.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/by/FormulaChunkedOperator.java @@ -30,7 +30,6 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import java.util.function.Supplier; import java.util.function.UnaryOperator; import static io.deephaven.engine.table.impl.sources.ArrayBackedColumnSource.BLOCK_SIZE; @@ -76,7 +75,6 @@ class FormulaChunkedOperator implements IterativeChunkedAggregationOperator { final boolean delegateToBy, @NotNull final String formula, @NotNull final String columnParamName, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor, @NotNull final MatchPair... resultColumnPairs) { this.groupBy = groupBy; @@ -101,7 +99,7 @@ class FormulaChunkedOperator implements IterativeChunkedAggregationOperator { .fromGenericType(inputColumnName, inputColumnSource.getType(), inputColumnSource.getComponentType()); formulaColumn.initDef(Collections.singletonMap(inputColumnName, inputColumnDefinition), - queryScopeVariables, compilationProcessor); + compilationProcessor); resultColumns[ci] = ArrayBackedColumnSource.getMemoryColumnSource( 0, formulaColumn.getReturnedType(), formulaColumn.getReturnedComponentType()); } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/BaseNodeOperationsRecorder.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/BaseNodeOperationsRecorder.java index 61a0b855cfc..8602715b72c 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/BaseNodeOperationsRecorder.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/BaseNodeOperationsRecorder.java @@ -283,7 +283,7 @@ private Stream absoluteSelectColumns() { // have no need to drop them post-sort. final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + QueryCompilerRequestProcessor.batch(); final SelectColumn[] columns = sortColumns.stream() .map(sc -> sc.column().name()) @@ -293,7 +293,7 @@ private Stream absoluteSelectColumns() { final Selectable selectable = AbsoluteSortColumnConventions.makeSelectable(cn, baseColumnName); final SelectColumn selectColumn = SelectColumn.of(selectable); selectColumn.initDef(Map.of(baseColumnName, getDefinition().getColumn(baseColumnName)), - SelectAndViewAnalyzer.newQueryScopeVariableSupplier(), compilationProcessor); + compilationProcessor); return selectColumn; }).toArray(SelectColumn[]::new); diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/RollupTableImpl.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/RollupTableImpl.java index ea0814d525d..26a77957a08 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/RollupTableImpl.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/RollupTableImpl.java @@ -26,7 +26,6 @@ import io.deephaven.engine.table.impl.by.AggregationRowLookup; import io.deephaven.engine.table.impl.select.SelectColumn; import io.deephaven.engine.table.impl.select.WhereFilter; -import io.deephaven.engine.table.impl.select.analyzers.SelectAndViewAnalyzer; import io.deephaven.engine.table.impl.sources.NullValueColumnSource; import io.deephaven.engine.table.impl.util.RowRedirection; import io.deephaven.util.type.TypeUtils; @@ -37,7 +36,6 @@ import java.util.*; import java.util.function.Function; import java.util.function.LongUnaryOperator; -import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -278,11 +276,9 @@ public static WhereFilter[] initializeAndValidateFilters( @NotNull final Collection filters, @NotNull final Function exceptionFactory) { final WhereFilter[] whereFilters = WhereFilter.from(filters); - final Supplier> variableSupplier = SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); - final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); for (final WhereFilter whereFilter : whereFilters) { - whereFilter.init(source.getDefinition(), variableSupplier, compilationProcessor); + whereFilter.init(source.getDefinition(), compilationProcessor); final List invalidColumnsUsed = whereFilter.getColumns().stream().map(ColumnName::of) .filter(cn -> !groupByColumns.contains(cn)).map(ColumnName::name).collect(Collectors.toList()); if (!invalidColumnsUsed.isEmpty()) { diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/TreeNodeOperationsRecorder.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/TreeNodeOperationsRecorder.java index d28a469286b..a40d60d69c5 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/TreeNodeOperationsRecorder.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/TreeNodeOperationsRecorder.java @@ -12,14 +12,11 @@ import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.select.SelectColumn; import io.deephaven.engine.table.impl.select.WhereFilter; -import io.deephaven.engine.table.impl.select.analyzers.SelectAndViewAnalyzer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.List; -import java.util.Map; -import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -140,13 +137,11 @@ public Table where(Filter filter) { } private Stream whereFilters() { - final Supplier> variableSupplier = - SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + QueryCompilerRequestProcessor.batch(); final WhereFilter[] filters = WhereFilter.fromInternal(filter); for (final WhereFilter filter : filters) { - filter.init(getDefinition(), variableSupplier, compilationProcessor); + filter.init(getDefinition(), compilationProcessor); } compilationProcessor.compile(); return Stream.of(filters); diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/TreeTableFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/TreeTableFilter.java index 779765c5c8e..53f5eaadb85 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/TreeTableFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/TreeTableFilter.java @@ -19,7 +19,6 @@ import io.deephaven.engine.table.impl.*; import io.deephaven.engine.table.impl.chunkboxer.ChunkBoxer; import io.deephaven.engine.table.impl.select.WhereFilter; -import io.deephaven.engine.table.impl.select.analyzers.SelectAndViewAnalyzer; import io.deephaven.engine.table.impl.sources.ArrayBackedColumnSource; import io.deephaven.engine.table.impl.remote.ConstructSnapshot; import io.deephaven.util.SafeCloseable; @@ -32,7 +31,6 @@ import java.util.*; import java.util.function.Function; -import java.util.function.Supplier; import java.util.stream.Stream; /** @@ -153,11 +151,9 @@ private TreeTableFilter(@NotNull final TreeTableImpl tree, @NotNull final WhereF parentIdColumnName = tree.getParentIdentifierColumn(); sourceRowLookup = tree.getSourceRowLookup(); this.filters = filters; - final Supplier> variableSupplier = SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); - final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); - Arrays.stream(filters).forEach((final WhereFilter filter) -> filter.init(source.getDefinition(), - variableSupplier, compilationProcessor)); + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); + Arrays.stream(filters) + .forEach((final WhereFilter filter) -> filter.init(source.getDefinition(), compilationProcessor)); compilationProcessor.compile(); idSource = source.getColumnSource(tree.getIdentifierColumn().name()); diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/TreeTableImpl.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/TreeTableImpl.java index ce5d62cb06f..680b20c07a6 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/TreeTableImpl.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/hierarchical/TreeTableImpl.java @@ -16,7 +16,6 @@ import io.deephaven.engine.table.impl.by.AggregationProcessor; import io.deephaven.engine.table.impl.by.AggregationRowLookup; import io.deephaven.engine.table.impl.select.WhereFilter; -import io.deephaven.engine.table.impl.select.analyzers.SelectAndViewAnalyzer; import io.deephaven.engine.table.impl.sources.NullValueColumnSource; import org.apache.commons.lang3.mutable.MutableObject; import org.jetbrains.annotations.NotNull; @@ -24,7 +23,6 @@ import java.util.*; import java.util.function.LongUnaryOperator; -import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -108,7 +106,7 @@ private static Table makeNullSingleColumnTable( @NotNull final Table source, @NotNull final ColumnName column, final long size) { - final ColumnDefinition columnDefinition = source.getDefinition().getColumn(column.name()); + final ColumnDefinition columnDefinition = source.getDefinition().getColumn(column.name()); final TableDefinition columnOnlyTableDefinition = TableDefinition.of(columnDefinition); // noinspection resource return new QueryTable(columnOnlyTableDefinition, RowSetFactory.flat(size).toTracking(), @@ -156,11 +154,9 @@ public TreeTable withFilter(@NotNull Filter filter) { if (whereFilters.length == 0) { return noopResult(); } - final Supplier> variableSupplier = SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); - final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); final Map> nodeSuitabilityToFilters = Stream.of(whereFilters) - .peek(wf -> wf.init(source.getDefinition(), variableSupplier, compilationProcessor)) + .peek(wf -> wf.init(source.getDefinition(), compilationProcessor)) .collect(Collectors.partitioningBy(wf -> { // Node-level filters have only node-filter columns and use no column arrays return wf.getColumns().stream().map(ColumnName::of).allMatch(nodeFilterColumns::contains) diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/BaseTableTransformationColumn.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/BaseTableTransformationColumn.java index 6d854abef0b..22c1fc2e8d5 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/BaseTableTransformationColumn.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/BaseTableTransformationColumn.java @@ -30,7 +30,6 @@ public final Class getReturnedType() { @Override public Class getReturnedComponentType() { - // Table does not have a component type return null; } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/BiTableTransformationColumn.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/BiTableTransformationColumn.java index 6111dbf6cea..2dfe17bd3eb 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/BiTableTransformationColumn.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/BiTableTransformationColumn.java @@ -11,7 +11,6 @@ import io.deephaven.engine.rowset.RowSequence; import io.deephaven.engine.rowset.TrackingRowSet; import io.deephaven.engine.table.*; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.select.Formula; import io.deephaven.engine.table.impl.select.SelectColumn; import io.deephaven.engine.table.impl.sources.ViewColumnSource; @@ -22,7 +21,6 @@ import java.util.List; import java.util.Map; import java.util.function.BinaryOperator; -import java.util.function.Supplier; /** * {@link SelectColumn} implementation to wrap transformer functions for {@link PartitionedTable#partitionedTransform @@ -59,10 +57,7 @@ public List initInputs( } @Override - public List initDef( - @NotNull final Map> columnDefinitionMap, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationRequestProcessor) { + public List initDef(@NotNull final Map> columnDefinitionMap) { validateInputColumnDefinition(inputOutputColumnName, columnDefinitionMap); validateInputColumnDefinition(secondInputColumnName, columnDefinitionMap); return getColumns(); diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/LongConstantColumn.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/LongConstantColumn.java index a12dd7ace2f..449488af308 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/LongConstantColumn.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/LongConstantColumn.java @@ -10,7 +10,6 @@ import io.deephaven.engine.rowset.TrackingRowSet; import io.deephaven.engine.table.*; import io.deephaven.engine.table.impl.MatchPair; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.select.Formula; import io.deephaven.engine.table.impl.select.SelectColumn; import io.deephaven.engine.table.impl.sources.LongSingleValueSource; @@ -21,7 +20,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.function.Supplier; /** * {@link SelectColumn} implementation to assign a constant {@code long} value. @@ -46,10 +44,7 @@ public List initInputs( } @Override - public List initDef( - @NotNull final Map> columnDefinitionMap, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationRequestProcessor) { + public List initDef(@NotNull final Map> columnDefinitionMap) { return getColumns(); } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/PartitionedTableImpl.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/PartitionedTableImpl.java index 591447a0cd6..e93342b475a 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/PartitionedTableImpl.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/PartitionedTableImpl.java @@ -23,7 +23,6 @@ import io.deephaven.engine.table.impl.remote.ConstructSnapshot; import io.deephaven.engine.table.impl.select.MatchFilter; import io.deephaven.engine.table.impl.select.WhereFilter; -import io.deephaven.engine.table.impl.select.analyzers.SelectAndViewAnalyzer; import io.deephaven.engine.table.impl.sources.NullValueColumnSource; import io.deephaven.engine.table.impl.sources.UnionSourceManager; import io.deephaven.engine.table.iterators.ChunkedObjectColumnIterator; @@ -40,7 +39,6 @@ import java.lang.ref.WeakReference; import java.util.*; import java.util.function.BinaryOperator; -import java.util.function.Supplier; import java.util.function.UnaryOperator; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -234,11 +232,9 @@ private Map computeSharedAttributes(@NotNull final Iterator filters) { final WhereFilter[] whereFilters = WhereFilter.from(filters); - final Supplier> variableSupplier = SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); - final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); final boolean invalidFilter = Arrays.stream(whereFilters).flatMap((final WhereFilter filter) -> { - filter.init(table.getDefinition(), variableSupplier, compilationProcessor); + filter.init(table.getDefinition(), compilationProcessor); return Stream.concat(filter.getColumns().stream(), filter.getColumnArrays().stream()); }).anyMatch((final String columnName) -> columnName.equals(constituentColumnName)); compilationProcessor.compile(); diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/PartitionedTableProxyImpl.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/PartitionedTableProxyImpl.java index dbf38fa2359..848c0e179b4 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/PartitionedTableProxyImpl.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/PartitionedTableProxyImpl.java @@ -32,7 +32,6 @@ import java.util.*; import java.util.concurrent.atomic.AtomicLong; import java.util.function.BinaryOperator; -import java.util.function.Supplier; import java.util.function.UnaryOperator; import java.util.stream.Collectors; @@ -465,11 +464,9 @@ public PartitionedTable.Proxy sort(Collection columnsToSortBy) { public PartitionedTable.Proxy where(Filter filter) { final WhereFilter[] whereFilters = WhereFilter.fromInternal(filter); final TableDefinition definition = target.constituentDefinition(); - final Supplier> variableSupplier = SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); - final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); for (WhereFilter whereFilter : whereFilters) { - whereFilter.init(definition, variableSupplier, compilationProcessor); + whereFilter.init(definition, compilationProcessor); } compilationProcessor.compile(); return basicTransform(ct -> ct.where(Filter.and(WhereFilter.copyFrom(whereFilters)))); diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/TableTransformationColumn.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/TableTransformationColumn.java index fa3c7c24c32..cf796fe5852 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/TableTransformationColumn.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/partitioned/TableTransformationColumn.java @@ -12,7 +12,6 @@ import io.deephaven.engine.rowset.RowSequence; import io.deephaven.engine.rowset.TrackingRowSet; import io.deephaven.engine.table.*; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.select.Formula; import io.deephaven.engine.table.impl.select.SelectColumn; import io.deephaven.engine.table.impl.sources.ViewColumnSource; @@ -22,7 +21,6 @@ import java.util.List; import java.util.Map; import java.util.function.Function; -import java.util.function.Supplier; /** * {@link SelectColumn} implementation to wrap transformer functions for {@link PartitionedTable#transform @@ -54,10 +52,7 @@ public List initInputs( } @Override - public List initDef( - @NotNull final Map> columnDefinitionMap, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationRequestProcessor) { + public List initDef(@NotNull final Map> columnDefinitionMap) { validateInputColumnDefinition(inputOutputColumnName, columnDefinitionMap); return getColumns(); } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/rangejoin/ValidFloatingPointFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/rangejoin/ValidFloatingPointFilter.java index f73f3e21c68..686e4ab7130 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/rangejoin/ValidFloatingPointFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/rangejoin/ValidFloatingPointFilter.java @@ -17,16 +17,13 @@ import io.deephaven.engine.table.ColumnSource; import io.deephaven.engine.table.Table; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.chunkfilter.ChunkFilter; import io.deephaven.engine.table.impl.select.WhereFilter; import io.deephaven.engine.table.impl.select.WhereFilterImpl; import org.jetbrains.annotations.NotNull; import java.util.List; -import java.util.Map; import java.util.Objects; -import java.util.function.Supplier; import static io.deephaven.util.QueryConstants.NULL_DOUBLE; import static io.deephaven.util.QueryConstants.NULL_FLOAT; @@ -53,10 +50,7 @@ public List getColumnArrays() { } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeSupplier, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + public void init(@NotNull final TableDefinition tableDefinition) { final ColumnDefinition columnDefinition = tableDefinition.getColumn(columnName.name()); if (columnDefinition == null) { throw new IllegalArgumentException(String.format("Missing expected input column %s", diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/AbstractConditionFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/AbstractConditionFilter.java index 0cd05704618..bdd46c1fb29 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/AbstractConditionFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/AbstractConditionFilter.java @@ -26,7 +26,6 @@ import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.util.*; -import java.util.function.Supplier; import java.util.stream.Collectors; import static io.deephaven.engine.table.impl.select.DhFormulaColumn.COLUMN_SUFFIX; @@ -74,10 +73,14 @@ public List getColumnArrays() { .collect(Collectors.toList()); } + @Override + public void init(@NotNull TableDefinition tableDefinition) { + init(tableDefinition, QueryCompilerRequestProcessor.immediate()); + } + @Override public synchronized void init( @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor) { if (initialized) { return; @@ -89,7 +92,7 @@ public synchronized void init( final QueryLanguageParser.Result result = FormulaAnalyzer.parseFormula( timeConversionResult, tableDefinition.getColumnNameMap(), outerToInnerNames, - queryScopeVariables.get(), unboxArguments); + compilationProcessor.getQueryScopeVariables(), unboxArguments); formulaShiftColPair = result.getFormulaShiftColPair(); if (formulaShiftColPair != null) { diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/AbstractFormulaColumn.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/AbstractFormulaColumn.java index 318e99ef80b..03fd59fdd77 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/AbstractFormulaColumn.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/AbstractFormulaColumn.java @@ -10,6 +10,7 @@ import io.deephaven.engine.context.QueryScopeParam; import io.deephaven.engine.table.impl.BaseTable; import io.deephaven.engine.table.impl.MatchPair; +import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.util.CompletionStageFuture; import io.deephaven.vector.Vector; import io.deephaven.engine.table.impl.vector.*; @@ -46,7 +47,7 @@ public abstract class AbstractFormulaColumn implements FormulaColumn { @NotNull protected final String columnName; - protected Future formulaFactory; + protected Future formulaFactoryFuture; private Formula formula; protected QueryScopeParam[] params; protected Map> columnSources; @@ -94,9 +95,7 @@ public List initInputs( return usedColumns; } - // we'll have to assume that initDef has already been invoked if we could have grouped compilation requests - // otherwise this call will compile immediately if necessary - return initDef(extractDefinitions(columnsOfInterest)); + return initDef(extractDefinitions(columnsOfInterest), QueryCompilerRequestProcessor.immediate()); } @Override @@ -153,7 +152,7 @@ protected void applyUsedVariables( } protected void onCopy(final AbstractFormulaColumn copy) { - copy.formulaFactory = formulaFactory; + copy.formulaFactoryFuture = formulaFactoryFuture; copy.columnDefinitions = columnDefinitions; copy.params = params; copy.usedColumns = usedColumns; @@ -239,12 +238,12 @@ private Formula getFormula(boolean initLazyMap, QueryScopeParam... params) { try { // the future must already be completed or else it is an error - formula = formulaFactory.get(0, TimeUnit.SECONDS).createFormula( + formula = formulaFactoryFuture.get(0, TimeUnit.SECONDS).createFormula( StringEscapeUtils.escapeJava(columnName), rowSet, initLazyMap, columnsToData, params); - } catch (TimeoutException e) { + } catch (InterruptedException | TimeoutException e) { throw new IllegalStateException("Formula factory not already compiled!"); - } catch (InterruptedException | ExecutionException e) { - throw new UncheckedDeephavenException("Error creating formula for " + columnName, e); + } catch (ExecutionException e) { + throw new UncheckedDeephavenException("Error creating formula for " + columnName, e.getCause()); } return formula; } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/BaseIncrementalReleaseFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/BaseIncrementalReleaseFilter.java index 2e38b00e0d2..887f5a221fa 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/BaseIncrementalReleaseFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/BaseIncrementalReleaseFilter.java @@ -8,7 +8,6 @@ import io.deephaven.engine.table.Table; import io.deephaven.engine.table.TableDefinition; import io.deephaven.engine.rowset.RowSet; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.updategraph.NotificationQueue; import io.deephaven.engine.updategraph.UpdateGraph; import io.deephaven.util.QueryConstants; @@ -17,8 +16,6 @@ import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.function.Supplier; /** * Base class for filters that will release more rows of a table on each UGP cycle. @@ -70,10 +67,7 @@ public List getColumnArrays() { } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + public void init(@NotNull final TableDefinition tableDefinition) { initialized = true; if (!started) { return; diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ByteRangeFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ByteRangeFilter.java index 7ad699fe1f1..d506eee8bc5 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ByteRangeFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ByteRangeFilter.java @@ -12,7 +12,6 @@ import io.deephaven.engine.table.ColumnDefinition; import io.deephaven.engine.table.ColumnSource; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.chunkfilter.ByteRangeComparator; import io.deephaven.engine.table.impl.chunkfilter.ChunkFilter; import io.deephaven.gui.table.filters.Condition; @@ -21,9 +20,6 @@ import io.deephaven.util.type.TypeUtils; import org.jetbrains.annotations.NotNull; -import java.util.Map; -import java.util.function.Supplier; - public class ByteRangeFilter extends AbstractRangeFilter { public static ByteRangeFilter lt(String columnName, byte x) { return new ByteRangeFilter(columnName, QueryConstants.NULL_BYTE, x, true, false); @@ -71,10 +67,7 @@ static WhereFilter makeByteRangeFilter(String columnName, Condition condition, S } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + public void init(@NotNull final TableDefinition tableDefinition) { if (chunkFilter != null) { return; } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/CharRangeFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/CharRangeFilter.java index 06df9a3bc66..f5d640d13f5 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/CharRangeFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/CharRangeFilter.java @@ -8,7 +8,6 @@ import io.deephaven.engine.table.ColumnDefinition; import io.deephaven.engine.table.ColumnSource; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.chunkfilter.CharRangeComparator; import io.deephaven.engine.table.impl.chunkfilter.ChunkFilter; import io.deephaven.gui.table.filters.Condition; @@ -17,9 +16,6 @@ import io.deephaven.util.type.TypeUtils; import org.jetbrains.annotations.NotNull; -import java.util.Map; -import java.util.function.Supplier; - public class CharRangeFilter extends AbstractRangeFilter { public static CharRangeFilter lt(String columnName, char x) { return new CharRangeFilter(columnName, QueryConstants.NULL_CHAR, x, true, false); @@ -67,10 +63,7 @@ static WhereFilter makeCharRangeFilter(String columnName, Condition condition, S } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + public void init(@NotNull final TableDefinition tableDefinition) { if (chunkFilter != null) { return; } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ClockFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ClockFilter.java index f1751d83be7..71a38223370 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ClockFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ClockFilter.java @@ -11,7 +11,6 @@ import io.deephaven.engine.rowset.RowSetFactory; import io.deephaven.engine.table.Table; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.lang.QueryLanguageFunctionUtils; import io.deephaven.engine.table.impl.sources.ReinterpretUtils; import io.deephaven.engine.updategraph.DynamicNode; @@ -25,8 +24,6 @@ import java.time.Instant; import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.function.Supplier; /** * Boilerplate super-class for various clock-oriented filters. @@ -49,10 +46,7 @@ public ClockFilter(@NotNull final String columnName, @NotNull final Clock clock, } @Override - public final void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) {} + public final void init(@NotNull final TableDefinition tableDefinition) {} @Override public final List getColumns() { diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ComparableRangeFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ComparableRangeFilter.java index 1f76242f348..3050b8d13a3 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ComparableRangeFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ComparableRangeFilter.java @@ -6,7 +6,6 @@ import io.deephaven.base.verify.Assert; import io.deephaven.engine.table.ColumnDefinition; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.chunkfilter.ChunkFilter; import io.deephaven.util.compare.ObjectComparisons; import io.deephaven.engine.table.ColumnSource; @@ -18,9 +17,6 @@ import io.deephaven.util.annotations.TestUseOnly; import org.jetbrains.annotations.NotNull; -import java.util.Map; -import java.util.function.Supplier; - public class ComparableRangeFilter extends AbstractRangeFilter { private final Comparable upper; private final Comparable lower; @@ -45,10 +41,7 @@ public static ComparableRangeFilter makeForTest(String columnName, Comparable } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + public void init(@NotNull final TableDefinition tableDefinition) { if (chunkFilter != null) { return; } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ComposedFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ComposedFilter.java index cde86f837a6..b5a21c52357 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ComposedFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ComposedFilter.java @@ -12,7 +12,6 @@ import org.jetbrains.annotations.NotNull; import java.util.*; -import java.util.function.Supplier; import java.util.stream.Stream; public abstract class ComposedFilter extends WhereFilterLivenessArtifactImpl implements DependencyStreamProvider { @@ -58,13 +57,19 @@ public List getColumnArrays() { return new ArrayList<>(result); } + @Override + public void init(@NotNull TableDefinition tableDefinition) { + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); + init(tableDefinition, compilationProcessor); + compilationProcessor.compile(); + } + @Override public void init( @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor) { for (WhereFilter filter : componentFilters) { - filter.init(tableDefinition, queryScopeVariables, compilationProcessor); + filter.init(tableDefinition, compilationProcessor); } } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ConditionFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ConditionFilter.java index 6bad2b7a70d..fc065f6b052 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ConditionFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ConditionFilter.java @@ -49,7 +49,7 @@ public class ConditionFilter extends AbstractConditionFilter { public static final int CHUNK_SIZE = 4096; - private Future> filterKernelClass = null; + private Future> filterKernelClassFuture = null; private List>> usedInputs; // that is columns and special variables private String classBody; private Filter filter = null; @@ -70,7 +70,7 @@ public static WhereFilter createConditionFilter(@NotNull String formula, Formula case Numba: throw new UnsupportedOperationException("Python condition filter should be created from python"); default: - throw new UnsupportedOperationException("Unknow parser type " + parser); + throw new UnsupportedOperationException("Unknown parser type " + parser); } } @@ -416,7 +416,7 @@ protected void generateFilterCode( this.classBody = classBody.toString(); - filterKernelClass = compilationProcessor.submit(QueryCompilerRequest.builder() + filterKernelClassFuture = compilationProcessor.submit(QueryCompilerRequest.builder() .description("Filter Expression: " + formula) .className("GeneratedFilterKernel") .classBody(this.classBody) @@ -430,7 +430,7 @@ private StringBuilder getClassBody( @NotNull final TableDefinition tableDefinition, @NotNull final TimeLiteralReplacedExpression timeConversionResult, @NotNull final QueryLanguageParser.Result result) { - if (filterKernelClass != null) { + if (filterKernelClassFuture != null) { return null; } usedInputs = new ArrayList<>(); @@ -590,7 +590,7 @@ protected Filter getFilter(Table table, RowSet fullSet) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { if (filter == null) { try { - final FilterKernel filterKernel = (FilterKernel) filterKernelClass + final FilterKernel filterKernel = (FilterKernel) filterKernelClassFuture .get(0, TimeUnit.SECONDS) .getConstructor(Table.class, RowSet.class, QueryScopeParam[].class) .newInstance(table, fullSet, (Object) params); @@ -601,10 +601,10 @@ protected Filter getFilter(Table table, RowSet fullSet) // note this filter is not valid for use in other contexts, as it captures references from the source // table filterValidForCopy = false; - } catch (TimeoutException e) { + } catch (InterruptedException | TimeoutException e) { throw new IllegalStateException("Formula factory not already compiled!"); - } catch (InterruptedException | ExecutionException e) { - throw new FormulaCompilationException("Formula compilation error for: " + formula, e); + } catch (ExecutionException e) { + throw new FormulaCompilationException("Formula compilation error for: " + formula, e.getCause()); } } return filter; @@ -620,7 +620,7 @@ public ConditionFilter copy() { final ConditionFilter copy = new ConditionFilter(formula, outerToInnerNames); onCopy(copy); if (initialized) { - copy.filterKernelClass = filterKernelClass; + copy.filterKernelClassFuture = filterKernelClassFuture; copy.usedInputs = usedInputs; copy.classBody = classBody; if (filterValidForCopy) { diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DhFormulaColumn.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DhFormulaColumn.java index ec5200ab9dc..9326466fe90 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DhFormulaColumn.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DhFormulaColumn.java @@ -48,7 +48,6 @@ import java.util.concurrent.ExecutionException; import java.util.function.Consumer; import java.util.function.Function; -import java.util.function.Supplier; import static io.deephaven.engine.util.IterableUtils.makeCommaSeparatedList; @@ -180,12 +179,16 @@ public static Class getVectorType(Class declaredType) { } } + @Override + public List initDef(@NotNull final Map> columnDefinitionMap) { + return initDef(columnDefinitionMap, QueryCompilerRequestProcessor.immediate()); + } + @Override public List initDef( @NotNull final Map> columnDefinitionMap, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationRequestProcessor) { - if (formulaFactory != null) { + if (formulaFactoryFuture != null) { validateColumnDefinition(columnDefinitionMap); return formulaColumnPython != null ? formulaColumnPython.usedColumns : usedColumns; } @@ -194,7 +197,8 @@ public List initDef( final TimeLiteralReplacedExpression timeConversionResult = TimeLiteralReplacedExpression.convertExpression(formulaString); final QueryLanguageParser.Result result = FormulaAnalyzer.parseFormula( - timeConversionResult, columnDefinitionMap, Collections.emptyMap(), queryScopeVariables.get(), true); + timeConversionResult, columnDefinitionMap, Collections.emptyMap(), + compilationRequestProcessor.getQueryScopeVariables(), true); analyzedFormula = FormulaAnalyzer.analyze(formulaString, columnDefinitionMap, timeConversionResult, result); hasConstantValue = result.isConstantValueExpression(); @@ -211,13 +215,13 @@ public List initDef( formulaString = result.getConvertedExpression(); // check if this is a column to be created with a Python vectorizable function - checkAndInitializeVectorization(columnDefinitionMap, queryScopeVariables, compilationRequestProcessor); + checkAndInitializeVectorization(columnDefinitionMap, compilationRequestProcessor); } catch (Exception e) { throw new FormulaCompilationException("Formula compilation error for: " + originalFormulaString, e); } if (useKernelFormulasProperty) { - formulaFactory = createKernelFormulaFactory(getFormulaKernelFactory(compilationRequestProcessor)); + formulaFactoryFuture = createKernelFormulaFactory(getFormulaKernelFactory(compilationRequestProcessor)); } else { compileFormula(compilationRequestProcessor); } @@ -226,7 +230,6 @@ public List initDef( private void checkAndInitializeVectorization( @NotNull final Map> columnDefinitionMap, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationRequestProcessor) { // noinspection SuspiciousToArrayCall final PyCallableWrapperJpyImpl[] cws = Arrays.stream(params) @@ -248,7 +251,7 @@ private void checkAndInitializeVectorization( pyCallableWrapper.getReturnType(), this.analyzedFormula.sourceDescriptor.sources, argumentsChunked, true)); - formulaColumnPython.initDef(columnDefinitionMap, queryScopeVariables, compilationRequestProcessor); + formulaColumnPython.initDef(columnDefinitionMap, compilationRequestProcessor); } } @@ -750,7 +753,7 @@ private CompletionStageFuture invokeKernelBuilder( @NotNull String generateKernelClassBody() { try { - return invokeKernelBuilder(QueryCompilerRequestProcessor.ImmediateProcessor.INSTANCE).get().classBody; + return invokeKernelBuilder(QueryCompilerRequestProcessor.immediate()).get().classBody; } catch (InterruptedException | ExecutionException e) { throw new UncheckedDeephavenException("Failed to compile formula: ", e); } @@ -759,7 +762,7 @@ String generateKernelClassBody() { @Override public SelectColumn copy() { final DhFormulaColumn copy = new DhFormulaColumn(columnName, formulaString); - if (formulaFactory != null) { + if (formulaFactoryFuture != null) { copy.analyzedFormula = analyzedFormula; copy.hasConstantValue = hasConstantValue; copy.returnedType = returnedType; @@ -807,7 +810,7 @@ private void compileFormula(@NotNull final QueryCompilerRequestProcessor compila return null; }); - formulaFactory = compilationRequestProcessor.submit(QueryCompilerRequest.builder() + formulaFactoryFuture = compilationRequestProcessor.submit(QueryCompilerRequest.builder() .description("Formula Expression: " + formulaString) .className(className) .classBody(classBody) diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DoubleRangeFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DoubleRangeFilter.java index c69b7100947..1b195e01b0b 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DoubleRangeFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DoubleRangeFilter.java @@ -10,7 +10,6 @@ import io.deephaven.engine.rowset.WritableRowSet; import io.deephaven.engine.table.ColumnDefinition; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.util.compare.DoubleComparisons; import io.deephaven.engine.table.impl.chunkfilter.DoubleRangeComparator; import io.deephaven.engine.table.ColumnSource; @@ -19,9 +18,6 @@ import io.deephaven.util.QueryConstants; import org.jetbrains.annotations.NotNull; -import java.util.Map; -import java.util.function.Supplier; - public class DoubleRangeFilter extends AbstractRangeFilter { public static DoubleRangeFilter lt(String columnName, double x) { @@ -83,10 +79,7 @@ static WhereFilter makeDoubleRangeFilter(String columnName, Condition condition, } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + public void init(@NotNull final TableDefinition tableDefinition) { if (chunkFilter != null) { return; } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DownsampledWhereFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DownsampledWhereFilter.java index 2a1ed5bc5b6..d917756a289 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DownsampledWhereFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DownsampledWhereFilter.java @@ -9,7 +9,6 @@ import io.deephaven.engine.rowset.RowSetFactory; import io.deephaven.engine.table.Table; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.time.DateTimeUtils; import io.deephaven.engine.updategraph.DynamicNode; import io.deephaven.engine.table.ColumnSource; @@ -18,8 +17,6 @@ import java.time.Instant; import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.function.Supplier; /** * Utilities for downsampling non-ticking time series data within a query. The input table must be sorted by the @@ -88,10 +85,7 @@ public List getColumnArrays() { } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) {} + public void init(@NotNull final TableDefinition tableDefinition) {} @NotNull @Override diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DynamicWhereFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DynamicWhereFilter.java index 7ea956c163b..affa6bb2afd 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DynamicWhereFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/DynamicWhereFilter.java @@ -26,7 +26,6 @@ import org.jetbrains.annotations.NotNull; import java.util.*; -import java.util.function.Supplier; /** * A where filter that extracts a set of inclusion or exclusion keys from a set table. @@ -222,10 +221,7 @@ public List getColumnArrays() { } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) {} + public void init(@NotNull final TableDefinition tableDefinition) {} @NotNull @Override diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/FloatRangeFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/FloatRangeFilter.java index def411b61c8..2cdebf0bde7 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/FloatRangeFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/FloatRangeFilter.java @@ -6,7 +6,6 @@ import io.deephaven.engine.rowset.WritableRowSet; import io.deephaven.engine.table.ColumnDefinition; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.util.compare.FloatComparisons; import io.deephaven.engine.table.impl.chunkfilter.FloatRangeComparator; import io.deephaven.engine.table.ColumnSource; @@ -15,9 +14,6 @@ import io.deephaven.util.QueryConstants; import org.jetbrains.annotations.NotNull; -import java.util.Map; -import java.util.function.Supplier; - public class FloatRangeFilter extends AbstractRangeFilter { public static FloatRangeFilter lt(String columnName, float x) { @@ -79,10 +75,7 @@ static WhereFilter makeFloatRangeFilter(String columnName, Condition condition, } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + public void init(@NotNull final TableDefinition tableDefinition) { if (chunkFilter != null) { return; } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/FunctionalColumn.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/FunctionalColumn.java index 0ddbb47682b..5854fa12440 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/FunctionalColumn.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/FunctionalColumn.java @@ -8,7 +8,6 @@ import io.deephaven.api.util.NameValidator; import io.deephaven.engine.table.impl.MatchPair; import io.deephaven.engine.table.impl.NoSuchColumnException; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.sources.InMemoryColumnSource; import io.deephaven.engine.table.impl.sources.SparseArrayColumnSource; import io.deephaven.engine.table.impl.sources.ViewColumnSource; @@ -26,7 +25,6 @@ import java.util.Map; import java.util.function.BiFunction; import java.util.function.Function; -import java.util.function.Supplier; public class FunctionalColumn implements SelectColumn { @@ -108,10 +106,7 @@ public List initInputs(TrackingRowSet rowSet, Map initDef( - @NotNull final Map> columnDefinitionMap, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationRequestProcessor) { + public List initDef(@NotNull final Map> columnDefinitionMap) { // noinspection unchecked final ColumnDefinition sourceColumnDefinition = (ColumnDefinition) columnDefinitionMap.get(sourceName); if (sourceColumnDefinition == null) { diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/InstantRangeFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/InstantRangeFilter.java index 3328ccab9b6..7d45254db75 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/InstantRangeFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/InstantRangeFilter.java @@ -6,7 +6,6 @@ import io.deephaven.base.verify.Assert; import io.deephaven.engine.table.ColumnDefinition; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.chunkfilter.ChunkFilter; import io.deephaven.engine.rowset.chunkattributes.OrderedRowKeys; import io.deephaven.engine.table.ColumnSource; @@ -19,8 +18,6 @@ import org.jetbrains.annotations.NotNull; import java.time.Instant; -import java.util.Map; -import java.util.function.Supplier; public class InstantRangeFilter extends LongRangeFilter { @@ -40,10 +37,7 @@ public InstantRangeFilter( } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + public void init(@NotNull final TableDefinition tableDefinition) { if (chunkFilter != null) { return; } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/IntRangeFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/IntRangeFilter.java index 3e787851bb0..ee4a345e2a2 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/IntRangeFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/IntRangeFilter.java @@ -12,7 +12,6 @@ import io.deephaven.engine.table.ColumnDefinition; import io.deephaven.engine.table.ColumnSource; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.chunkfilter.IntRangeComparator; import io.deephaven.engine.table.impl.chunkfilter.ChunkFilter; import io.deephaven.gui.table.filters.Condition; @@ -21,9 +20,6 @@ import io.deephaven.util.type.TypeUtils; import org.jetbrains.annotations.NotNull; -import java.util.Map; -import java.util.function.Supplier; - public class IntRangeFilter extends AbstractRangeFilter { public static IntRangeFilter lt(String columnName, int x) { return new IntRangeFilter(columnName, QueryConstants.NULL_INT, x, true, false); @@ -71,10 +67,7 @@ static WhereFilter makeIntRangeFilter(String columnName, Condition condition, St } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + public void init(@NotNull final TableDefinition tableDefinition) { if (chunkFilter != null) { return; } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/LongRangeFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/LongRangeFilter.java index 9d4fad06cbe..d0718eab953 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/LongRangeFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/LongRangeFilter.java @@ -12,7 +12,6 @@ import io.deephaven.engine.table.ColumnDefinition; import io.deephaven.engine.table.ColumnSource; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.chunkfilter.LongRangeComparator; import io.deephaven.engine.table.impl.chunkfilter.ChunkFilter; import io.deephaven.gui.table.filters.Condition; @@ -21,9 +20,6 @@ import io.deephaven.util.type.TypeUtils; import org.jetbrains.annotations.NotNull; -import java.util.Map; -import java.util.function.Supplier; - public class LongRangeFilter extends AbstractRangeFilter { public static LongRangeFilter lt(String columnName, long x) { return new LongRangeFilter(columnName, QueryConstants.NULL_LONG, x, true, false); @@ -71,10 +67,7 @@ static WhereFilter makeLongRangeFilter(String columnName, Condition condition, S } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + public void init(@NotNull final TableDefinition tableDefinition) { if (chunkFilter != null) { return; } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/MatchFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/MatchFilter.java index 3ee5b9ee254..aed73c2752f 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/MatchFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/MatchFilter.java @@ -5,14 +5,12 @@ import io.deephaven.api.literal.Literal; import io.deephaven.base.string.cache.CompressedString; -import io.deephaven.engine.context.ExecutionContext; import io.deephaven.engine.rowset.WritableRowSet; import io.deephaven.engine.table.ColumnDefinition; import io.deephaven.engine.table.Table; import io.deephaven.engine.table.TableDefinition; import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.preview.DisplayWrapper; -import io.deephaven.engine.context.QueryScope; import io.deephaven.time.DateTimeUtils; import io.deephaven.util.type.ArrayTypeUtils; import io.deephaven.engine.table.ColumnSource; @@ -24,7 +22,6 @@ import java.math.BigInteger; import java.time.Instant; import java.util.*; -import java.util.function.Supplier; public class MatchFilter extends WhereFilterImpl { @@ -117,10 +114,14 @@ public List getColumnArrays() { return Collections.emptyList(); } + @Override + public void init(@NotNull TableDefinition tableDefinition) { + init(tableDefinition, QueryCompilerRequestProcessor.immediate()); + } + @Override public synchronized void init( @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariablesSupplier, @NotNull final QueryCompilerRequestProcessor compilationProcessor) { if (initialized) { return; @@ -135,7 +136,7 @@ public synchronized void init( return; } final List valueList = new ArrayList<>(); - final Map queryScopeVariables = queryScopeVariablesSupplier.get(); + final Map queryScopeVariables = compilationProcessor.getQueryScopeVariables(); final ColumnTypeConvertor convertor = ColumnTypeConvertorFactory.getConvertor(column.getDataType(), column.getName()); for (String strValue : strValues) { diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/MultiSourceFunctionalColumn.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/MultiSourceFunctionalColumn.java index 8e5c1342a40..9898430313b 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/MultiSourceFunctionalColumn.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/MultiSourceFunctionalColumn.java @@ -9,7 +9,6 @@ import io.deephaven.engine.table.impl.MatchPair; import io.deephaven.engine.table.impl.NoSuchColumnException; import io.deephaven.engine.table.impl.PrevColumnSource; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.sources.InMemoryColumnSource; import io.deephaven.engine.table.impl.sources.SparseArrayColumnSource; import io.deephaven.engine.table.impl.sources.ViewColumnSource; @@ -24,7 +23,6 @@ import java.util.*; import java.util.function.BiFunction; -import java.util.function.Supplier; import java.util.stream.Collectors; // TODO: Comment the heck out of this... @@ -95,10 +93,7 @@ public List initInputs(TrackingRowSet rowSet, Map initDef( - @NotNull final Map> columnDefinitionMap, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationRequestProcessor) { + public List initDef(@NotNull final Map> columnDefinitionMap) { NoSuchColumnException.throwIf(columnDefinitionMap.keySet(), sourceNames); return getColumns(); } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/NullSelectColumn.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/NullSelectColumn.java index 7ed11fe9d1f..c897dcb7daf 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/NullSelectColumn.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/NullSelectColumn.java @@ -5,7 +5,6 @@ import io.deephaven.engine.table.*; import io.deephaven.engine.table.impl.MatchPair; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.sources.*; import io.deephaven.engine.rowset.TrackingRowSet; import org.jetbrains.annotations.NotNull; @@ -13,7 +12,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.function.Supplier; /** * A SelectColumn implementation that can be used to replace columns with {@link NullValueColumnSource}s @@ -34,10 +32,7 @@ public List initInputs(final TrackingRowSet rowSet, } @Override - public List initDef( - @NotNull final Map> columnDefinitionMap, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationRequestProcessor) { + public List initDef(@NotNull final Map> columnDefinitionMap) { return Collections.emptyList(); } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/RangeConditionFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/RangeConditionFilter.java index b6c37e32dbb..f7cdfaa570a 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/RangeConditionFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/RangeConditionFilter.java @@ -19,8 +19,6 @@ import java.math.BigInteger; import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.function.Supplier; /** * A filter for comparable types (including Instant) for {@link Condition} values:
@@ -131,22 +129,26 @@ public List getColumnArrays() { return Collections.emptyList(); } + @Override + public void init(@NotNull TableDefinition tableDefinition) { + init(tableDefinition, QueryCompilerRequestProcessor.immediate()); + } + @Override public void init( @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor) { if (filter != null) { return; } - final ColumnDefinition def = tableDefinition.getColumn(columnName); + final ColumnDefinition def = tableDefinition.getColumn(columnName); if (def == null) { throw new RuntimeException("Column \"" + columnName + "\" doesn't exist in this table, available columns: " + tableDefinition.getColumnNames()); } - final Class colClass = def.getDataType(); + final Class colClass = def.getDataType(); if (colClass == double.class || colClass == Double.class) { filter = DoubleRangeFilter.makeDoubleRangeFilter(columnName, condition, value); @@ -185,7 +187,7 @@ public void init( } } - filter.init(tableDefinition, queryScopeVariables, compilationProcessor); + filter.init(tableDefinition, compilationProcessor); } public static char parseCharFilter(String value) { diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ReinterpretedColumn.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ReinterpretedColumn.java index 968e0287c9d..3e04c8ee0bb 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ReinterpretedColumn.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ReinterpretedColumn.java @@ -13,7 +13,6 @@ import io.deephaven.engine.table.ColumnSource; import io.deephaven.engine.table.WritableColumnSource; import io.deephaven.engine.rowset.TrackingRowSet; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.sources.ConvertibleTimeSource; import io.deephaven.engine.table.impl.sources.LocalDateWrapperSource; import io.deephaven.engine.table.impl.sources.LocalTimeWrapperSource; @@ -35,7 +34,6 @@ import java.util.List; import java.util.Map; import java.util.function.Function; -import java.util.function.Supplier; /** * Allows {@link ColumnSource} reinterpretation via view-type ({@link Table#view} and {@link Table#updateView}) @@ -153,10 +151,7 @@ public List initInputs(TrackingRowSet rowSet, Map initDef( - @NotNull final Map> columnDefinitionMap, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationRequestProcessor) { + public List initDef(@NotNull final Map> columnDefinitionMap) { // noinspection unchecked final ColumnDefinition sourceColumnDefinition = (ColumnDefinition) columnDefinitionMap.get(sourceName); if (sourceColumnDefinition == null) { diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/RollingReleaseFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/RollingReleaseFilter.java index 66975516e66..6459c65c704 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/RollingReleaseFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/RollingReleaseFilter.java @@ -9,15 +9,12 @@ import io.deephaven.engine.table.Table; import io.deephaven.engine.table.TableDefinition; import io.deephaven.engine.rowset.RowSet; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.updategraph.NotificationQueue; import io.deephaven.engine.updategraph.UpdateGraph; import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.function.Supplier; /** * This will filter a table starting off with the first N rows, and then adding new rows to the table on each run. @@ -48,10 +45,7 @@ public List getColumnArrays() { } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) {} + public void init(@NotNull final TableDefinition tableDefinition) {} @NotNull @Override diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SelectColumn.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SelectColumn.java index 9728f556c1d..a725ebdcc5b 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SelectColumn.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SelectColumn.java @@ -21,8 +21,6 @@ import io.deephaven.engine.table.WritableColumnSource; import io.deephaven.engine.table.impl.BaseTable; import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; -import io.deephaven.engine.table.impl.select.analyzers.SelectAndViewAnalyzer; -import io.deephaven.util.annotations.FinalDefault; import org.jetbrains.annotations.NotNull; import java.util.Arrays; @@ -30,7 +28,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.function.Supplier; import java.util.stream.Collectors; /** @@ -86,18 +83,13 @@ static Collection copyFrom(Collection selectColumns) * {@link QueryCompiler} usage needs to be resolved within initDef. Implementations must be idempotent. * Implementations that want to hold on to the {@code columnDefinitionMap} must make a defensive copy. */ - @FinalDefault - default List initDef(@NotNull Map> columnDefinitionMap) { - return initDef(columnDefinitionMap, SelectAndViewAnalyzer.newQueryScopeVariableSupplier(), - QueryCompilerRequestProcessor.ImmediateProcessor.INSTANCE); - } + List initDef(@NotNull Map> columnDefinitionMap); /** * Initialize any internal column definitions from the provided initial. A compilation request consumer is provided * to allow for deferred compilation of expressions that belong to the same query. * * @param columnDefinitionMap the starting set of column definitions; valid for this call only - * @param queryScopeVariables a caching supplier of the set of query scope variables; valid for this call only * @param compilationRequestProcessor a consumer to submit compilation requests; valid for this call only * * @return a list of columns on which the result of this is dependent @@ -105,10 +97,12 @@ default List initDef(@NotNull Map> columnDef * {@link QueryCompiler} usage needs to be resolved within initDef. Implementations must be idempotent. * Implementations that want to hold on to the {@code columnDefinitionMap} must make a defensive copy. */ - List initDef( - @NotNull Map> columnDefinitionMap, - @NotNull Supplier> queryScopeVariables, - @NotNull QueryCompilerRequestProcessor compilationRequestProcessor); + @SuppressWarnings("unused") + default List initDef( + @NotNull final Map> columnDefinitionMap, + @NotNull final QueryCompilerRequestProcessor compilationRequestProcessor) { + return initDef(columnDefinitionMap); + } /** * Get the data type stored in the resultant column. diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ShortRangeFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ShortRangeFilter.java index cedccd871c1..461707e7b7f 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ShortRangeFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/ShortRangeFilter.java @@ -12,7 +12,6 @@ import io.deephaven.engine.table.ColumnDefinition; import io.deephaven.engine.table.ColumnSource; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.chunkfilter.ShortRangeComparator; import io.deephaven.engine.table.impl.chunkfilter.ChunkFilter; import io.deephaven.gui.table.filters.Condition; @@ -21,9 +20,6 @@ import io.deephaven.util.type.TypeUtils; import org.jetbrains.annotations.NotNull; -import java.util.Map; -import java.util.function.Supplier; - public class ShortRangeFilter extends AbstractRangeFilter { public static ShortRangeFilter lt(String columnName, short x) { return new ShortRangeFilter(columnName, QueryConstants.NULL_SHORT, x, true, false); @@ -71,10 +67,7 @@ static WhereFilter makeShortRangeFilter(String columnName, Condition condition, } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + public void init(@NotNull final TableDefinition tableDefinition) { if (chunkFilter != null) { return; } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SingleSidedComparableRangeFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SingleSidedComparableRangeFilter.java index 6801ff9de4d..d9a54a7758b 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SingleSidedComparableRangeFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SingleSidedComparableRangeFilter.java @@ -6,7 +6,6 @@ import io.deephaven.base.verify.Assert; import io.deephaven.engine.table.ColumnDefinition; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.chunkfilter.ChunkFilter; import io.deephaven.util.compare.ObjectComparisons; import io.deephaven.engine.table.ColumnSource; @@ -18,9 +17,6 @@ import io.deephaven.util.annotations.TestUseOnly; import org.jetbrains.annotations.NotNull; -import java.util.Map; -import java.util.function.Supplier; - public class SingleSidedComparableRangeFilter extends AbstractRangeFilter { private final Comparable pivot; private final boolean isGreaterThan; @@ -38,10 +34,7 @@ public static SingleSidedComparableRangeFilter makeForTest(String columnName, Co } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + public void init(@NotNull final TableDefinition tableDefinition) { if (chunkFilter != null) { return; } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SourceColumn.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SourceColumn.java index 0a0449c7fca..fcaa5d30bd2 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SourceColumn.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SourceColumn.java @@ -7,7 +7,6 @@ import io.deephaven.base.verify.Assert; import io.deephaven.engine.table.*; import io.deephaven.engine.table.impl.MatchPair; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.sources.InMemoryColumnSource; import io.deephaven.api.util.NameValidator; import io.deephaven.engine.table.impl.NoSuchColumnException; @@ -20,7 +19,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.function.Supplier; public class SourceColumn implements SelectColumn { @@ -63,10 +61,7 @@ public List initInputs(TrackingRowSet rowSet, Map initDef( - @NotNull final Map> columnDefinitionMap, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationRequestProcessor) { + public List initDef(@NotNull final Map> columnDefinitionMap) { sourceDefinition = columnDefinitionMap.get(sourceName); if (sourceDefinition == null) { throw new NoSuchColumnException(columnDefinitionMap.keySet(), sourceName); diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SwitchColumn.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SwitchColumn.java index 48caddc72a8..d380d98ed36 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SwitchColumn.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/SwitchColumn.java @@ -16,7 +16,6 @@ import java.util.List; import java.util.Map; -import java.util.function.Supplier; public class SwitchColumn implements SelectColumn { @@ -46,10 +45,14 @@ public List initInputs(TrackingRowSet rowSet, Map initDef(@NotNull Map> columnDefinitionMap) { + return initDef(columnDefinitionMap, QueryCompilerRequestProcessor.immediate()); + } + @Override public List initDef( @NotNull final Map> columnDefinitionMap, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationRequestProcessor) { if (realColumn == null) { if (columnDefinitionMap.get(expression) != null) { @@ -58,8 +61,7 @@ public List initDef( realColumn = FormulaColumn.createFormulaColumn(columnName, expression, parser); } } - final List usedColumns = realColumn.initDef( - columnDefinitionMap, queryScopeVariables, compilationRequestProcessor); + final List usedColumns = realColumn.initDef(columnDefinitionMap, compilationRequestProcessor); if (realColumn instanceof DhFormulaColumn) { FormulaColumnPython formulaColumnPython = ((DhFormulaColumn) realColumn).getFormulaColumnPython(); realColumn = formulaColumnPython != null ? formulaColumnPython : realColumn; diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/TimeSeriesFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/TimeSeriesFilter.java index 2b6bf85eb8f..497957f4e45 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/TimeSeriesFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/TimeSeriesFilter.java @@ -12,7 +12,6 @@ import io.deephaven.engine.rowset.RowSetFactory; import io.deephaven.engine.table.Table; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.updategraph.NotificationQueue; import io.deephaven.engine.updategraph.UpdateGraph; import io.deephaven.time.DateTimeUtils; @@ -22,8 +21,6 @@ import java.time.Instant; import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.function.Supplier; /** * This will filter a table for the most recent N nanoseconds (must be on an {@link Instant} column). @@ -62,10 +59,7 @@ public List getColumnArrays() { } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) {} + public void init(@NotNull final TableDefinition tableDefinition) {} @NotNull @Override diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereFilter.java index c493d194d50..80cbcf295f2 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereFilter.java @@ -14,7 +14,6 @@ import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.QueryTable; import io.deephaven.engine.table.impl.remote.ConstructSnapshot; -import io.deephaven.engine.table.impl.select.analyzers.SelectAndViewAnalyzer; import io.deephaven.util.annotations.FinalDefault; import io.deephaven.util.annotations.InternalUseOnly; import org.jetbrains.annotations.NotNull; @@ -22,8 +21,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.Map; -import java.util.function.Supplier; /** * Interface for individual filters within a where clause. @@ -107,25 +104,22 @@ interface RecomputeListener { * @apiNote Any {@link io.deephaven.engine.context.QueryLibrary}, {@link io.deephaven.engine.context.QueryScope}, or * {@link QueryCompiler} usage needs to be resolved within init. Implementations must be idempotent. */ - @FinalDefault - default void init(@NotNull TableDefinition tableDefinition) { - init(tableDefinition, SelectAndViewAnalyzer.newQueryScopeVariableSupplier(), - QueryCompilerRequestProcessor.ImmediateProcessor.INSTANCE); - } + void init(@NotNull TableDefinition tableDefinition); /** * Initialize this select filter given the table definition * * @param tableDefinition the definition of the table that will be filtered - * @param queryScopeVariables a caching supplier of the set of query scope variables; valid for this call only * @param compilationProcessor the processor to use for compilation * @apiNote Any {@link io.deephaven.engine.context.QueryLibrary}, {@link io.deephaven.engine.context.QueryScope}, or * {@link QueryCompiler} usage needs to be resolved within init. Implementations must be idempotent. */ - void init( - @NotNull TableDefinition tableDefinition, - @NotNull Supplier> queryScopeVariables, - @NotNull QueryCompilerRequestProcessor compilationProcessor); + @SuppressWarnings("unused") + default void init( + @NotNull final TableDefinition tableDefinition, + @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + init(tableDefinition); + } /** * Validate that this {@code WhereFilter} is safe to use in the context of the provided sourceTable. diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereFilterInvertedImpl.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereFilterInvertedImpl.java index e051f16e299..9792774fac1 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereFilterInvertedImpl.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereFilterInvertedImpl.java @@ -4,7 +4,6 @@ package io.deephaven.engine.table.impl.select; import io.deephaven.engine.liveness.LivenessArtifact; -import io.deephaven.engine.liveness.LivenessReferent; import io.deephaven.engine.rowset.RowSet; import io.deephaven.engine.rowset.WritableRowSet; import io.deephaven.engine.table.Table; @@ -17,9 +16,7 @@ import org.jetbrains.annotations.NotNull; import java.util.List; -import java.util.Map; import java.util.Objects; -import java.util.function.Supplier; import java.util.stream.Stream; class WhereFilterInvertedImpl @@ -59,12 +56,16 @@ public List getColumnArrays() { return filter.getColumnArrays(); } + @Override + public void init(@NotNull TableDefinition tableDefinition) { + init(tableDefinition, QueryCompilerRequestProcessor.immediate()); + } + @Override public void init( @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor) { - filter.init(tableDefinition, queryScopeVariables, compilationProcessor); + filter.init(tableDefinition, compilationProcessor); } @Override diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereFilterPatternImpl.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereFilterPatternImpl.java index f66094e9083..de19278857d 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereFilterPatternImpl.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereFilterPatternImpl.java @@ -16,15 +16,12 @@ import io.deephaven.engine.table.ColumnSource; import io.deephaven.engine.table.Table; import io.deephaven.engine.table.TableDefinition; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.chunkfilter.ChunkFilter; import io.deephaven.engine.table.impl.chunkfilter.ChunkFilter.ObjectChunkFilter; import org.jetbrains.annotations.NotNull; import java.util.List; -import java.util.Map; import java.util.Objects; -import java.util.function.Supplier; final class WhereFilterPatternImpl extends WhereFilterImpl { @@ -46,10 +43,7 @@ private WhereFilterPatternImpl(FilterPattern filterPattern) { } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) { + public void init(@NotNull final TableDefinition tableDefinition) { final String columnName = columnName(); final ColumnDefinition column = tableDefinition.getColumn(columnName); if (column == null) { diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereNoneFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereNoneFilter.java index 9b1317ee747..7a8a686ba9e 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereNoneFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereNoneFilter.java @@ -8,13 +8,10 @@ import io.deephaven.engine.table.TableDefinition; import io.deephaven.engine.rowset.RowSet; import io.deephaven.engine.rowset.RowSetFactory; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.function.Supplier; /** * A Select filter that always returns an empty RowSet. @@ -36,10 +33,7 @@ public List getColumnArrays() { } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) {} + public void init(@NotNull final TableDefinition tableDefinition) {} @NotNull @Override diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/analyzers/SelectAndViewAnalyzer.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/analyzers/SelectAndViewAnalyzer.java index dc997685e2b..783a92fe62b 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/analyzers/SelectAndViewAnalyzer.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/analyzers/SelectAndViewAnalyzer.java @@ -3,12 +3,9 @@ // package io.deephaven.engine.table.impl.select.analyzers; -import io.deephaven.api.util.NameValidator; import io.deephaven.base.Pair; import io.deephaven.base.log.LogOutputAppendable; import io.deephaven.datastructures.util.CollectionUtil; -import io.deephaven.engine.context.ExecutionContext; -import io.deephaven.engine.context.QueryScope; import io.deephaven.engine.liveness.LivenessNode; import io.deephaven.engine.rowset.RowSet; import io.deephaven.engine.rowset.RowSetFactory; @@ -32,14 +29,12 @@ import io.deephaven.io.log.impl.LogOutputStringImpl; import io.deephaven.util.SafeCloseable; import io.deephaven.util.SafeCloseablePair; -import io.deephaven.util.datastructures.CachingSupplier; import io.deephaven.vector.Vector; import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; -import java.util.function.Supplier; import java.util.stream.Stream; public abstract class SelectAndViewAnalyzer implements LogOutputAppendable { @@ -50,29 +45,21 @@ public enum Mode { VIEW_LAZY, VIEW_EAGER, SELECT_STATIC, SELECT_REFRESHING, SELECT_REDIRECTED_REFRESHING, SELECT_REDIRECTED_STATIC } - public static Supplier> newQueryScopeVariableSupplier() { - final QueryScope queryScope = ExecutionContext.getContext().getQueryScope(); - return new CachingSupplier<>(() -> Collections.unmodifiableMap( - queryScope.toMap((name, value) -> NameValidator.isValidQueryParameterName(name)))); - } - public static void initializeSelectColumns( final Map> parentColumnMap, final SelectColumn[] selectColumns) { - final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); - initializeSelectColumns(parentColumnMap, newQueryScopeVariableSupplier(), selectColumns, compilationProcessor); + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); + initializeSelectColumns(parentColumnMap, selectColumns, QueryCompilerRequestProcessor.batch()); compilationProcessor.compile(); } public static void initializeSelectColumns( final Map> parentColumnMap, - final Supplier> queryScopeVariables, final SelectColumn[] selectColumns, final QueryCompilerRequestProcessor compilationProcessor) { final Map> targetColumnMap = new HashMap<>(parentColumnMap); for (SelectColumn column : selectColumns) { - column.initDef(targetColumnMap, queryScopeVariables, compilationProcessor); + column.initDef(targetColumnMap, compilationProcessor); final ColumnDefinition columnDefinition = ColumnDefinition.fromGenericType( column.getName(), column.getReturnedType(), column.getReturnedComponentType()); targetColumnMap.put(column.getName(), columnDefinition); @@ -120,9 +107,7 @@ public static SelectAndViewAnalyzerWrapper create( final HashSet resultColumns = new HashSet<>(); // First pass to initialize all columns and to compile formulas in one batch. - final Supplier> variableSupplier = SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); - final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); for (Map.Entry> entry : columnSources.entrySet()) { final String name = entry.getKey(); final ColumnSource cs = entry.getValue(); @@ -136,7 +121,7 @@ public static SelectAndViewAnalyzerWrapper create( continue; } - sc.initDef(columnDefinitions, variableSupplier, compilationProcessor); + sc.initDef(columnDefinitions, compilationProcessor); final ColumnDefinition cd = ColumnDefinition.fromGenericType( sc.getName(), sc.getReturnedType(), sc.getReturnedComponentType()); columnDefinitions.put(sc.getName(), cd); diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/python/FormulaColumnPython.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/python/FormulaColumnPython.java index e60d7db35db..298abcf1702 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/python/FormulaColumnPython.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/python/FormulaColumnPython.java @@ -5,7 +5,6 @@ import io.deephaven.engine.table.ColumnDefinition; import io.deephaven.engine.context.QueryScopeParam; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.util.CompletionStageFuture; import io.deephaven.vector.Vector; import io.deephaven.engine.table.impl.select.AbstractFormulaColumn; @@ -19,7 +18,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.function.Supplier; import static io.deephaven.datastructures.util.CollectionUtil.ZERO_LENGTH_STRING_ARRAY; @@ -42,16 +40,13 @@ private FormulaColumnPython(String columnName, } @Override - public final List initDef( - @NotNull final Map> columnDefinitionMap, - @NotNull final Supplier> queryScopeVariables, - @NotNull final QueryCompilerRequestProcessor compilationRequestProcessor) { - if (formulaFactory != null) { + public final List initDef(@NotNull final Map> columnDefinitionMap) { + if (formulaFactoryFuture != null) { validateColumnDefinition(columnDefinitionMap); } else { returnedType = dcf.getReturnedType(); applyUsedVariables(columnDefinitionMap, new LinkedHashSet<>(dcf.getColumnNames()), Map.of()); - formulaFactory = createKernelFormulaFactory(CompletionStageFuture.completedFuture(this)); + formulaFactoryFuture = createKernelFormulaFactory(CompletionStageFuture.completedFuture(this)); } return usedColumns; @@ -75,7 +70,7 @@ protected final FormulaSourceDescriptor getSourceDescriptor() { @Override public final SelectColumn copy() { final FormulaColumnPython copy = new FormulaColumnPython(columnName, dcf); - if (formulaFactory != null) { + if (formulaFactoryFuture != null) { // copy all initDef state copy.returnedType = returnedType; onCopy(copy); @@ -85,7 +80,7 @@ public final SelectColumn copy() { @Override public final FormulaKernel createInstance(Vector[] arrays, QueryScopeParam[] params) { - if (formulaFactory == null) { + if (formulaFactoryFuture == null) { throw new IllegalStateException("Must be initialized first"); } return dcf.toFormulaKernel(); diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/UpdateByOperatorFactory.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/UpdateByOperatorFactory.java index 8a4ecb8bf35..6e551476520 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/UpdateByOperatorFactory.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/UpdateByOperatorFactory.java @@ -14,7 +14,6 @@ import io.deephaven.engine.table.impl.MatchPair; import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.select.FormulaColumn; -import io.deephaven.engine.table.impl.select.analyzers.SelectAndViewAnalyzer; import io.deephaven.engine.table.impl.updateby.delta.*; import io.deephaven.engine.table.impl.updateby.em.*; import io.deephaven.engine.table.impl.updateby.emstd.*; @@ -40,7 +39,6 @@ import java.math.MathContext; import java.time.Instant; import java.util.*; -import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -88,8 +86,7 @@ final Collection getOutputColumns(@NotNull final Collection getOperators(@NotNull final Collection specs) { - final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = - new QueryCompilerRequestProcessor.BatchProcessor(); + final QueryCompilerRequestProcessor.BatchProcessor compilationProcessor = QueryCompilerRequestProcessor.batch(); final OperationVisitor v = new OperationVisitor(compilationProcessor); specs.forEach(s -> s.walk(v)); @@ -290,7 +287,6 @@ public Void visit(@NotNull final ColumnUpdateOperation clause) { } private class OperationVisitor implements UpdateBySpec.Visitor, UpdateByOperation.Visitor { - private final Supplier> queryScopeVariables; private final QueryCompilerRequestProcessor compilationProcessor; private final List ops = new ArrayList<>(); private MatchPair[] pairs; @@ -301,7 +297,6 @@ private class OperationVisitor implements UpdateBySpec.Visitor, UpdateByOp OperationVisitor( @NotNull final QueryCompilerRequestProcessor compilationProcessor) { - this.queryScopeVariables = SelectAndViewAnalyzer.newQueryScopeVariableSupplier(); this.compilationProcessor = compilationProcessor; } @@ -1380,47 +1375,47 @@ private UpdateByOperator makeRollingFormulaOperator(@NotNull final MatchPair pai return new BooleanRollingFormulaOperator(pair, affectingColumns, rs.revWindowScale().timestampCol(), prevWindowScaleUnits, fwdWindowScaleUnits, rs.formula(), rs.paramToken(), - formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + formulaColumnMap, tableDef, compilationProcessor); } else if (csType == byte.class || csType == Byte.class) { return new ByteRollingFormulaOperator(pair, affectingColumns, rs.revWindowScale().timestampCol(), prevWindowScaleUnits, fwdWindowScaleUnits, rs.formula(), rs.paramToken(), - formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + formulaColumnMap, tableDef, compilationProcessor); } else if (csType == char.class || csType == Character.class) { return new CharRollingFormulaOperator(pair, affectingColumns, rs.revWindowScale().timestampCol(), prevWindowScaleUnits, fwdWindowScaleUnits, rs.formula(), rs.paramToken(), - formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + formulaColumnMap, tableDef, compilationProcessor); } else if (csType == short.class || csType == Short.class) { return new ShortRollingFormulaOperator(pair, affectingColumns, rs.revWindowScale().timestampCol(), prevWindowScaleUnits, fwdWindowScaleUnits, rs.formula(), rs.paramToken(), - formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + formulaColumnMap, tableDef, compilationProcessor); } else if (csType == int.class || csType == Integer.class) { return new IntRollingFormulaOperator(pair, affectingColumns, rs.revWindowScale().timestampCol(), prevWindowScaleUnits, fwdWindowScaleUnits, rs.formula(), rs.paramToken(), - formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + formulaColumnMap, tableDef, compilationProcessor); } else if (csType == long.class || csType == Long.class) { return new LongRollingFormulaOperator(pair, affectingColumns, rs.revWindowScale().timestampCol(), prevWindowScaleUnits, fwdWindowScaleUnits, rs.formula(), rs.paramToken(), - formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + formulaColumnMap, tableDef, compilationProcessor); } else if (csType == float.class || csType == Float.class) { return new FloatRollingFormulaOperator(pair, affectingColumns, rs.revWindowScale().timestampCol(), prevWindowScaleUnits, fwdWindowScaleUnits, rs.formula(), rs.paramToken(), - formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + formulaColumnMap, tableDef, compilationProcessor); } else if (csType == double.class || csType == Double.class) { return new DoubleRollingFormulaOperator(pair, affectingColumns, rs.revWindowScale().timestampCol(), prevWindowScaleUnits, fwdWindowScaleUnits, rs.formula(), rs.paramToken(), - formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + formulaColumnMap, tableDef, compilationProcessor); } return new ObjectRollingFormulaOperator<>(pair, affectingColumns, rs.revWindowScale().timestampCol(), prevWindowScaleUnits, fwdWindowScaleUnits, rs.formula(), rs.paramToken(), - formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + formulaColumnMap, tableDef, compilationProcessor); } } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/BaseRollingFormulaOperator.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/BaseRollingFormulaOperator.java index 9f04380105a..b5e0a9560a9 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/BaseRollingFormulaOperator.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/BaseRollingFormulaOperator.java @@ -28,7 +28,6 @@ import java.util.Collections; import java.util.Map; import java.util.function.IntConsumer; -import java.util.function.Supplier; abstract class BaseRollingFormulaOperator extends UpdateByOperator { protected final String PARAM_COLUMN_NAME = "__PARAM_COLUMN__"; @@ -98,7 +97,6 @@ public BaseRollingFormulaOperator( @NotNull final String paramToken, @NotNull final Map, FormulaColumn> formulaColumnMap, @NotNull final TableDefinition tableDef, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor) { super(pair, affectingColumns, timestampColumnName, reverseWindowScaleUnits, forwardWindowScaleUnits, true); this.formulaColumnMap = formulaColumnMap; @@ -117,8 +115,7 @@ public BaseRollingFormulaOperator( final ColumnDefinition inputColumnDefinition = ColumnDefinition .fromGenericType(PARAM_COLUMN_NAME, inputVectorType, inputColumnType); - tmp.initDef(Collections.singletonMap(PARAM_COLUMN_NAME, inputColumnDefinition), queryScopeVariables, - compilationProcessor); + tmp.initDef(Collections.singletonMap(PARAM_COLUMN_NAME, inputColumnDefinition), compilationProcessor); return tmp; }); } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/BooleanRollingFormulaOperator.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/BooleanRollingFormulaOperator.java index 4dbe63b8ae2..b54d4dcc02d 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/BooleanRollingFormulaOperator.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/BooleanRollingFormulaOperator.java @@ -29,7 +29,6 @@ import java.util.Collections; import java.util.Map; import java.util.function.IntConsumer; -import java.util.function.Supplier; import static io.deephaven.util.QueryConstants.NULL_INT; @@ -163,10 +162,9 @@ public BooleanRollingFormulaOperator( @NotNull final String paramToken, @NotNull final Map, FormulaColumn> formulaColumnMap, @NotNull final TableDefinition tableDef, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor) { super(pair, affectingColumns, timestampColumnName, reverseWindowScaleUnits, forwardWindowScaleUnits, formula, - paramToken, formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + paramToken, formulaColumnMap, tableDef, compilationProcessor); } protected BooleanRollingFormulaOperator( diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/ByteRollingFormulaOperator.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/ByteRollingFormulaOperator.java index bcb5da64243..4cb47097afa 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/ByteRollingFormulaOperator.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/ByteRollingFormulaOperator.java @@ -33,7 +33,6 @@ import java.util.Collections; import java.util.Map; import java.util.function.IntConsumer; -import java.util.function.Supplier; import static io.deephaven.util.QueryConstants.NULL_INT; @@ -166,13 +165,12 @@ public ByteRollingFormulaOperator( @NotNull final String paramToken, @NotNull final Map, FormulaColumn> formulaColumnMap, @NotNull final TableDefinition tableDef, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor - // region extra-constructor-args - // endregion extra-constructor-args + // region extra-constructor-args + // endregion extra-constructor-args ) { super(pair, affectingColumns, timestampColumnName, reverseWindowScaleUnits, forwardWindowScaleUnits, formula, - paramToken, formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + paramToken, formulaColumnMap, tableDef, compilationProcessor); // region constructor // endregion constructor } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/CharRollingFormulaOperator.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/CharRollingFormulaOperator.java index 86a490caf42..7018c431482 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/CharRollingFormulaOperator.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/CharRollingFormulaOperator.java @@ -29,7 +29,6 @@ import java.util.Collections; import java.util.Map; import java.util.function.IntConsumer; -import java.util.function.Supplier; import static io.deephaven.util.QueryConstants.NULL_INT; @@ -162,13 +161,12 @@ public CharRollingFormulaOperator( @NotNull final String paramToken, @NotNull final Map, FormulaColumn> formulaColumnMap, @NotNull final TableDefinition tableDef, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor // region extra-constructor-args // endregion extra-constructor-args ) { super(pair, affectingColumns, timestampColumnName, reverseWindowScaleUnits, forwardWindowScaleUnits, formula, - paramToken, formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + paramToken, formulaColumnMap, tableDef, compilationProcessor); // region constructor // endregion constructor } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/DoubleRollingFormulaOperator.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/DoubleRollingFormulaOperator.java index 161b9842cff..bb0c449e394 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/DoubleRollingFormulaOperator.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/DoubleRollingFormulaOperator.java @@ -33,7 +33,6 @@ import java.util.Collections; import java.util.Map; import java.util.function.IntConsumer; -import java.util.function.Supplier; import static io.deephaven.util.QueryConstants.NULL_INT; @@ -166,13 +165,12 @@ public DoubleRollingFormulaOperator( @NotNull final String paramToken, @NotNull final Map, FormulaColumn> formulaColumnMap, @NotNull final TableDefinition tableDef, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor - // region extra-constructor-args - // endregion extra-constructor-args + // region extra-constructor-args + // endregion extra-constructor-args ) { super(pair, affectingColumns, timestampColumnName, reverseWindowScaleUnits, forwardWindowScaleUnits, formula, - paramToken, formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + paramToken, formulaColumnMap, tableDef, compilationProcessor); // region constructor // endregion constructor } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/FloatRollingFormulaOperator.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/FloatRollingFormulaOperator.java index f994066ec0d..66a65898978 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/FloatRollingFormulaOperator.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/FloatRollingFormulaOperator.java @@ -33,7 +33,6 @@ import java.util.Collections; import java.util.Map; import java.util.function.IntConsumer; -import java.util.function.Supplier; import static io.deephaven.util.QueryConstants.NULL_INT; @@ -166,13 +165,12 @@ public FloatRollingFormulaOperator( @NotNull final String paramToken, @NotNull final Map, FormulaColumn> formulaColumnMap, @NotNull final TableDefinition tableDef, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor - // region extra-constructor-args - // endregion extra-constructor-args + // region extra-constructor-args + // endregion extra-constructor-args ) { super(pair, affectingColumns, timestampColumnName, reverseWindowScaleUnits, forwardWindowScaleUnits, formula, - paramToken, formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + paramToken, formulaColumnMap, tableDef, compilationProcessor); // region constructor // endregion constructor } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/IntRollingFormulaOperator.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/IntRollingFormulaOperator.java index 2e160f87ef4..c0b07b52af9 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/IntRollingFormulaOperator.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/IntRollingFormulaOperator.java @@ -33,7 +33,6 @@ import java.util.Collections; import java.util.Map; import java.util.function.IntConsumer; -import java.util.function.Supplier; import static io.deephaven.util.QueryConstants.NULL_INT; @@ -166,13 +165,12 @@ public IntRollingFormulaOperator( @NotNull final String paramToken, @NotNull final Map, FormulaColumn> formulaColumnMap, @NotNull final TableDefinition tableDef, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor - // region extra-constructor-args - // endregion extra-constructor-args + // region extra-constructor-args + // endregion extra-constructor-args ) { super(pair, affectingColumns, timestampColumnName, reverseWindowScaleUnits, forwardWindowScaleUnits, formula, - paramToken, formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + paramToken, formulaColumnMap, tableDef, compilationProcessor); // region constructor // endregion constructor } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/LongRollingFormulaOperator.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/LongRollingFormulaOperator.java index 15f0f13aac8..9b3eb63de7b 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/LongRollingFormulaOperator.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/LongRollingFormulaOperator.java @@ -33,7 +33,6 @@ import java.util.Collections; import java.util.Map; import java.util.function.IntConsumer; -import java.util.function.Supplier; import static io.deephaven.util.QueryConstants.NULL_INT; @@ -166,13 +165,12 @@ public LongRollingFormulaOperator( @NotNull final String paramToken, @NotNull final Map, FormulaColumn> formulaColumnMap, @NotNull final TableDefinition tableDef, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor - // region extra-constructor-args - // endregion extra-constructor-args + // region extra-constructor-args + // endregion extra-constructor-args ) { super(pair, affectingColumns, timestampColumnName, reverseWindowScaleUnits, forwardWindowScaleUnits, formula, - paramToken, formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + paramToken, formulaColumnMap, tableDef, compilationProcessor); // region constructor // endregion constructor } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/ObjectRollingFormulaOperator.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/ObjectRollingFormulaOperator.java index 932f1eba0b8..8b062025e52 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/ObjectRollingFormulaOperator.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/ObjectRollingFormulaOperator.java @@ -28,7 +28,6 @@ import java.util.Collections; import java.util.Map; import java.util.function.IntConsumer; -import java.util.function.Supplier; import static io.deephaven.util.QueryConstants.NULL_INT; @@ -162,10 +161,9 @@ public ObjectRollingFormulaOperator( @NotNull final String paramToken, @NotNull final Map, FormulaColumn> formulaColumnMap, @NotNull final TableDefinition tableDef, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor) { super(pair, affectingColumns, timestampColumnName, reverseWindowScaleUnits, forwardWindowScaleUnits, formula, - paramToken, formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + paramToken, formulaColumnMap, tableDef, compilationProcessor); } protected ObjectRollingFormulaOperator( diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/ShortRollingFormulaOperator.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/ShortRollingFormulaOperator.java index 7fcb68ed3d1..7cce65c7cb5 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/ShortRollingFormulaOperator.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/updateby/rollingformula/ShortRollingFormulaOperator.java @@ -33,7 +33,6 @@ import java.util.Collections; import java.util.Map; import java.util.function.IntConsumer; -import java.util.function.Supplier; import static io.deephaven.util.QueryConstants.NULL_INT; @@ -166,13 +165,12 @@ public ShortRollingFormulaOperator( @NotNull final String paramToken, @NotNull final Map, FormulaColumn> formulaColumnMap, @NotNull final TableDefinition tableDef, - @NotNull final Supplier> queryScopeVariables, @NotNull final QueryCompilerRequestProcessor compilationProcessor - // region extra-constructor-args - // endregion extra-constructor-args + // region extra-constructor-args + // endregion extra-constructor-args ) { super(pair, affectingColumns, timestampColumnName, reverseWindowScaleUnits, forwardWindowScaleUnits, formula, - paramToken, formulaColumnMap, tableDef, queryScopeVariables, compilationProcessor); + paramToken, formulaColumnMap, tableDef, compilationProcessor); // region constructor // endregion constructor } diff --git a/engine/table/src/main/java/io/deephaven/engine/util/DynamicCompileUtils.java b/engine/table/src/main/java/io/deephaven/engine/util/DynamicCompileUtils.java index da14d6b0499..8a615214e71 100644 --- a/engine/table/src/main/java/io/deephaven/engine/util/DynamicCompileUtils.java +++ b/engine/table/src/main/java/io/deephaven/engine/util/DynamicCompileUtils.java @@ -6,7 +6,6 @@ import io.deephaven.engine.context.ExecutionContext; import io.deephaven.engine.context.QueryCompiler; import io.deephaven.engine.context.QueryCompilerRequest; -import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import java.util.*; import java.util.function.Supplier; diff --git a/engine/table/src/test/java/io/deephaven/engine/table/impl/QueryTableWhereParallelTest.java b/engine/table/src/test/java/io/deephaven/engine/table/impl/QueryTableWhereParallelTest.java index cc927144403..65b27a6b380 100644 --- a/engine/table/src/test/java/io/deephaven/engine/table/impl/QueryTableWhereParallelTest.java +++ b/engine/table/src/test/java/io/deephaven/engine/table/impl/QueryTableWhereParallelTest.java @@ -21,8 +21,6 @@ import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.function.Supplier; import static org.junit.Assert.assertEquals; @@ -59,10 +57,7 @@ public List getColumnArrays() { } @Override - public void init( - @NotNull final TableDefinition tableDefinition, - @NotNull final Supplier> queryScopeSupplier, - @NotNull final QueryCompilerRequestProcessor compilationProcessor) {} + public void init(@NotNull final TableDefinition tableDefinition) {} @NotNull @Override diff --git a/engine/table/src/test/java/io/deephaven/engine/table/impl/lang/TestQueryLanguageParser.java b/engine/table/src/test/java/io/deephaven/engine/table/impl/lang/TestQueryLanguageParser.java index 4f7597807fe..34d2db264b3 100644 --- a/engine/table/src/test/java/io/deephaven/engine/table/impl/lang/TestQueryLanguageParser.java +++ b/engine/table/src/test/java/io/deephaven/engine/table/impl/lang/TestQueryLanguageParser.java @@ -4,15 +4,14 @@ package io.deephaven.engine.table.impl.lang; import groovy.lang.Closure; -import io.deephaven.api.util.NameValidator; import io.deephaven.base.Pair; import io.deephaven.base.testing.BaseArrayTestCase; import io.deephaven.base.verify.Assert; import io.deephaven.base.verify.Require; import io.deephaven.engine.context.*; import io.deephaven.engine.table.Table; +import io.deephaven.engine.table.impl.QueryCompilerRequestProcessor; import io.deephaven.engine.table.impl.lang.QueryLanguageParser.QueryLanguageParseException; -import io.deephaven.engine.table.impl.select.analyzers.SelectAndViewAnalyzer; import io.deephaven.engine.testutil.ControlledUpdateGraph; import io.deephaven.engine.util.PyCallableWrapper; import io.deephaven.util.QueryConstants; @@ -3179,7 +3178,7 @@ private void check(String expression, String resultExpression, Class resultTy final Map possibleParams; final QueryScope queryScope = ExecutionContext.getContext().getQueryScope(); if (!(queryScope instanceof PoisonedQueryScope)) { - possibleParams = SelectAndViewAnalyzer.newQueryScopeVariableSupplier().get(); + possibleParams = QueryCompilerRequestProcessor.newQueryScopeVariableSupplier().get(); } else { possibleParams = null; } diff --git a/extensions/parquet/base/src/main/java/io/deephaven/parquet/base/ColumnChunkReaderImpl.java b/extensions/parquet/base/src/main/java/io/deephaven/parquet/base/ColumnChunkReaderImpl.java index e553331daa7..d32a0ea4883 100644 --- a/extensions/parquet/base/src/main/java/io/deephaven/parquet/base/ColumnChunkReaderImpl.java +++ b/extensions/parquet/base/src/main/java/io/deephaven/parquet/base/ColumnChunkReaderImpl.java @@ -9,7 +9,7 @@ import io.deephaven.parquet.compress.CompressorAdapter; import io.deephaven.parquet.compress.DeephavenCompressorAdapterFactory; import io.deephaven.util.channel.SeekableChannelContext.ContextHolder; -import io.deephaven.util.datastructures.LazyCachingFunction; +import io.deephaven.util.datastructures.SoftCachingFunction; import org.apache.parquet.bytes.BytesInput; import org.apache.parquet.column.ColumnDescriptor; import org.apache.parquet.column.Dictionary; @@ -77,7 +77,7 @@ final class ColumnChunkReaderImpl implements ColumnChunkReader { } this.offsetIndex = offsetIndex; this.fieldTypes = fieldTypes; - this.dictionarySupplier = new LazyCachingFunction<>(this::getDictionary); + this.dictionarySupplier = new SoftCachingFunction<>(this::getDictionary); this.nullMaterializerFactory = PageMaterializer.factoryForType(path.getPrimitiveType().getPrimitiveTypeName()); this.numRows = numRows; this.version = version; diff --git a/extensions/parquet/table/src/main/java/io/deephaven/parquet/table/pagestore/topage/ChunkDictionary.java b/extensions/parquet/table/src/main/java/io/deephaven/parquet/table/pagestore/topage/ChunkDictionary.java index 56bccb4e4a0..17e83139c31 100644 --- a/extensions/parquet/table/src/main/java/io/deephaven/parquet/table/pagestore/topage/ChunkDictionary.java +++ b/extensions/parquet/table/src/main/java/io/deephaven/parquet/table/pagestore/topage/ChunkDictionary.java @@ -9,7 +9,7 @@ import io.deephaven.util.channel.SeekableChannelContext; import io.deephaven.stringset.LongBitmapStringSet; import io.deephaven.chunk.ObjectChunk; -import io.deephaven.util.datastructures.LazyCachingSupplier; +import io.deephaven.util.datastructures.SoftCachingSupplier; import org.apache.parquet.column.Dictionary; import org.jetbrains.annotations.NotNull; @@ -47,7 +47,7 @@ public interface Lookup { ChunkDictionary( @NotNull final Lookup lookup, @NotNull final Function dictionarySupplier) { - this.valuesSupplier = new LazyCachingSupplier<>(() -> { + this.valuesSupplier = new SoftCachingSupplier<>(() -> { // We use NULL channel context here and rely on materialization logic to provide the correct context final Dictionary dictionary = dictionarySupplier.apply(SeekableChannelContext.NULL); final T[] values = ObjectChunk.makeArray(dictionary.getMaxId() + 1); @@ -56,7 +56,7 @@ public interface Lookup { } return ObjectChunk.chunkWrap(values); }); - this.reverseMapSupplier = new LazyCachingSupplier<>(() -> { + this.reverseMapSupplier = new SoftCachingSupplier<>(() -> { final ObjectChunk values = getChunk(); final TObjectIntMap reverseMap = new TObjectIntHashMap<>(values.size()); for (int vi = 0; vi < values.size(); ++vi) { diff --git a/replication/static/src/main/java/io/deephaven/replicators/ReplicateCachingSupplier.java b/replication/static/src/main/java/io/deephaven/replicators/ReplicateCachingSupplier.java index ae28bf10bc5..a102cb09e85 100644 --- a/replication/static/src/main/java/io/deephaven/replicators/ReplicateCachingSupplier.java +++ b/replication/static/src/main/java/io/deephaven/replicators/ReplicateCachingSupplier.java @@ -8,9 +8,9 @@ import static io.deephaven.replication.ReplicatePrimitiveCode.replaceAll; public class ReplicateCachingSupplier { - private static final String LAZY_CACHING_SUPPLIER_DIR = "Util/src/main/java/io/deephaven/util/datastructures/"; - private static final String LAZY_CACHING_SUPPLIER_PATH = LAZY_CACHING_SUPPLIER_DIR + "LazyCachingSupplier.java"; - private static final String LAZY_CACHING_FUNCTION_PATH = LAZY_CACHING_SUPPLIER_DIR + "LazyCachingFunction.java"; + private static final String SOFT_CACHING_SUPPLIER_DIR = "Util/src/main/java/io/deephaven/util/datastructures/"; + private static final String SOFT_CACHING_SUPPLIER_PATH = SOFT_CACHING_SUPPLIER_DIR + "SoftCachingSupplier.java"; + private static final String SOFT_CACHING_FUNCTION_PATH = SOFT_CACHING_SUPPLIER_DIR + "SoftCachingFunction.java"; private static final String[] NO_EXCEPTIONS = new String[0]; @@ -22,7 +22,7 @@ public static void main(final String[] args) throws IOException { {"Supplier", "Function"}, {"supplier", "function"}, }; - replaceAll("replicateCachingSupplier", LAZY_CACHING_SUPPLIER_PATH, LAZY_CACHING_FUNCTION_PATH, null, + replaceAll("replicateCachingSupplier", SOFT_CACHING_SUPPLIER_PATH, SOFT_CACHING_FUNCTION_PATH, null, NO_EXCEPTIONS, pairs); } }