public class CodeCompiler extends Object
Modifier and Type | Class and Description |
---|---|
static class |
CodeCompiler.CodeGenCompiler
Abstracts out the details of compiling code using the two available
mechanisms.
|
Modifier and Type | Field and Description |
---|---|
static String |
COMPILE_BASE |
static String |
DISABLE_CACHE_CONFIG
Disables the code cache.
|
static String |
ENABLE_SAVE_CODE_FOR_DEBUG_TOPN
Enables saving generated code for debugging
|
static String |
MAX_LOADING_CACHE_SIZE_CONFIG
Maximum size of the compiled class cache.
|
static String |
PREFER_POJ_CONFIG
Prefer to generate code as plain Java when the code generator
supports that mechanism.
|
Constructor and Description |
---|
CodeCompiler(DrillConfig config,
OptionSet optionManager) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Upon close, report the effectiveness of the code cache to the log.
|
<T> T |
createInstance(CodeGenerator<?> cg)
Create a single instance of the generated class.
|
<T> List<T> |
createInstances(CodeGenerator<?> cg,
int count)
Create multiple instances of the generated class.
|
void |
flushCache()
Flush the compiled classes from the cache.
|
public static final String COMPILE_BASE
public static final String MAX_LOADING_CACHE_SIZE_CONFIG
public static final String DISABLE_CACHE_CONFIG
public static final String ENABLE_SAVE_CODE_FOR_DEBUG_TOPN
public static final String PREFER_POJ_CONFIG
public CodeCompiler(DrillConfig config, OptionSet optionManager)
public <T> T createInstance(CodeGenerator<?> cg) throws ClassTransformationException
cg
- code generator for the class to be instantiated.ClassTransformationException
- general "something is wrong" exception
for the Drill compilation chain.public <T> List<T> createInstances(CodeGenerator<?> cg, int count) throws ClassTransformationException
cg
- code generator for the class to be instantiated.count
- the number of instances desired.ClassTransformationException
- general "something is wrong" exception
for the Drill compilation chain.public void flushCache()
The cache has DrillbitContext lifetime, so the only way items go out of it now is by being aged out because of the maximum cache size.
The intent of flushCache() is to make it possible to flush the cache for testing purposes, although this could be used by users in case issues arise. If that happens, remove the visible for testing annotation.
public void close()
Copyright © 2018 The Apache Software Foundation. All rights reserved.