You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Paul Rogers (JIRA)" <ji...@apache.org> on 2017/03/07 17:41:38 UTC

[jira] [Commented] (DRILL-5321) Refactor FragmentContext for unit testing

    [ https://issues.apache.org/jira/browse/DRILL-5321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15899824#comment-15899824 ] 

Paul Rogers commented on DRILL-5321:
------------------------------------

Proposed new interface (comments omitted):

{code}
public interface CodeGenContext {
  FunctionImplementationRegistry getFunctionRegistry();
  OptionSet getOptionSet();
  <T> T getImplementationClass(final ClassGenerator<T> cg)
      throws ClassTransformationException, IOException;
  <T> T getImplementationClass(final CodeGenerator<T> cg)
      throws ClassTransformationException, IOException;
  <T> List<T> getImplementationClass(final ClassGenerator<T> cg, final int instanceCount)
      throws ClassTransformationException, IOException;
  <T> List<T> getImplementationClass(final CodeGenerator<T> cg, final int instanceCount)
      throws ClassTransformationException, IOException;
}
{code}


> Refactor FragmentContext for unit testing
> -----------------------------------------
>
>                 Key: DRILL-5321
>                 URL: https://issues.apache.org/jira/browse/DRILL-5321
>             Project: Apache Drill
>          Issue Type: Sub-task
>          Components: Tools, Build & Test
>    Affects Versions: 1.10.0
>            Reporter: Paul Rogers
>            Assignee: Paul Rogers
>             Fix For: Future
>
>
> Each operator has visibility to the {{FragmentContext}} class. {{FragmentContext}} provides access to all of Drill internals: the Drillbit context, the network interfaces, RPC messages and so on.
> Further, all the code generation mechanisms require a {{FragmentContext}} object.
> This structure creates a large barrier to unit testing. To test, say, a particular bit of generated code, we must have the entire Drillbit running so we can obtain a {{FragmentContext}}. Clearly, this is less than ideal.
> Upon inspection, it turns out that the {{FragmentContext}} is mostly needed, by many operators, to generate code. Of the many methods in {{FragmentContext}}, code generation uses only six.
> The solution is to create a new super-interface, {{CodeGenContext}}, which holds those six methods. The {{CodeGenContext}} can be easily re-implemented for unit testing.
> Then, modify all the code-generation classes that currently take {{FragmentContext}} to take {{CodeGenContext}} instead.
> Since {{FragmentContext}} derives from {{CodeGenContext}}, existing operator code "just works."



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)