Skip to content
Paul Rogers edited this page Nov 18, 2016 · 2 revisions

Code Generation Components

Global

  • CodeCompiler: Mechanism to generate and compile code. Holds the global code cache (with a limit of 1000 entries.)
  • ClassTransformer: Compiles, merges and transforms classes created from generated code. Works with the ASM byte code manipulation library to perform the byte code transforms.

Code Generation

  • CodeGenerator<T>: generate the Java source code required to complete the implementation of an abstract template. T is the interface that results from compiling and merging the runtime code that is generated.
  • TemplateClassDefinition<T>: Identifies the interface which the code will implement, along with the template code used to (what?). Also provides a serial number for classes generated from this template. The template is created from the interface that the generated code is to implement.
  • SignatureHolder: (Seems to hold information about the class to be generated: methods and so on.)
  • CodeGeneratorMethod: (Describes one method in the generated code: name, return value, arguments, etc.)
  • FunctionImplementationRegistry:
  • MappingSet:
  • GeneratorMapping: Maps the four standard "conceptual" methods (setup, eval, reset, cleanup) to the names of the actual method (if any) in the generated code. Many method use a standard set of mappings defined in ClassGenerator<T>: DEFAULT_SCALAR_MAP and DEFAULT_CONSTANT_MAP.
  • JCodeModel: "CodeModel is a Java library for code generators; it provides a way to generate Java programs."
  • FragmentContext: Provides the getImplementationClass( ) method which uses the DrillbitContext to find the compiler module that generates and compiles the code.
  • ClassGenerator: Generates an a query-specific class from a template.

Managing the Generated Class Files

  • QueryClassLoader: Class loader for generated code. This loader not only provides access to the code, it is the gateway to compiling the code via the associated ClassCompilerSelector class.
  • AbstractClassCompiler: Base class for the supported Java compilers.
  • JaninoClassCompiler: Class compiler based on [Janino[(http://janino-compiler.github.io/janino/).
  • JDKClassCompiler: Class compiler based on the standard Java compiler. (Actually, the JRE compiler since, in modern Java, the JDK is not required for programmatic compilation.)

Supporting Components

  • OptionManager: A Javascript-like, prototype-based "stack" of options set from various sources (system, query, etc.) The options influence code generation and compilation.
Clone this wiki locally