Package io.deephaven.engine.context
Class QueryCompilerImpl
java.lang.Object
io.deephaven.engine.context.QueryCompilerImpl
- All Implemented Interfaces:
LogOutputAppendable,QueryCompiler
A
QueryCompiler implementation that compiles Java source to bytecode in memory and defines the resulting
classes via ClassLoader.defineClass(byte[], int, int), avoiding filesystem writes for compilation output.
The compiler resolves dependencies from java.class.path and an optional additional classpath directory
(typically where Groovy writes its bytecode). Compiled classes are loaded in per-batch child classloaders of the
provided parent classloader, enabling GC of both classes and classloaders when neither the compiled Classes nor this
compiler instance are reachable.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidcompile(@NotNull QueryCompilerRequest[] requests, CompletionStageFuture.Resolver<Class<?>>[] resolvers) Compiles all requests.static QueryCompilerImplcreate()Creates a new compiler that has no extra directory to read from, suitable for unit tests or cases where the existing classpath is sufficient.static QueryCompilerImplCreates a new QueryCompilerImpl.static QueryCompilerImplcreate(@Nullable File additionalClassPathDir, @Nullable ClassLoader classLoader) Creates a new QueryCompilerImpl.static StringcreateEscapedJoinedString(String originalString) Transform a string into the corresponding Java source code that compiles into that string.static StringcreateEscapedJoinedString(String originalString, int maxStringLength) voidsetClassNamesForAnnotationProcessing(List<String> classNames) Currently only intended for testing, this method allows specifying annotation processors to run during this compile.static booleansetLogEnabled(boolean logEnabled) Enables or disables compilation logging.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.deephaven.engine.context.QueryCompiler
compile, compile
-
Field Details
-
FORMULA_CLASS_PREFIX
- See Also:
-
DYNAMIC_CLASS_PREFIX
- See Also:
-
-
Method Details
-
create
Creates a new QueryCompilerImpl. Uses the current thread's context classloader as the parent for per-batch classloaders (as required byQueryCompiler's contract).- Parameters:
additionalClassPathDir- optional directory to add to the compiler's classpath (e.g., groovy bytecode dir)
-
create
public static QueryCompilerImpl create(@Nullable @Nullable File additionalClassPathDir, @Nullable @Nullable ClassLoader classLoader) Creates a new QueryCompilerImpl. UsesclassLoaderas the parent for per-batch classloaders. IfclassLoaderis null, uses the current thread's context classloader at compile time instead (as required byQueryCompiler's contract).- Parameters:
additionalClassPathDir- optional directory to add to the compiler's classpath (e.g., groovy bytecode dir)classLoader- optional parent classloader for per-batch classloaders; if null, the current thread's context classloader is used
-
create
Creates a new compiler that has no extra directory to read from, suitable for unit tests or cases where the existing classpath is sufficient. -
setClassNamesForAnnotationProcessing
Currently only intended for testing, this method allows specifying annotation processors to run during this compile.- Parameters:
classNames- the annotation processor classes to allow to run
-
append
- Specified by:
appendin interfaceLogOutputAppendable
-
toString
-
setLogEnabled
public static boolean setLogEnabled(boolean logEnabled) Enables or disables compilation logging.- Parameters:
logEnabled- Whether logging should be enabled- Returns:
- The value of
logEnabledbefore calling this method.
-
compile
public void compile(@NotNull @NotNull QueryCompilerRequest[] requests, @NotNull CompletionStageFuture.Resolver<Class<?>>[] resolvers) Description copied from interface:QueryCompilerCompiles all requests.- Specified by:
compilein interfaceQueryCompiler- Parameters:
requests- The compilation requests; these must be independent of each otherresolvers- The resolvers to use for delivering compilation results
-
createEscapedJoinedString
Transform a string into the corresponding Java source code that compiles into that string. -
createEscapedJoinedString
-